Merge pull request #797 from SonicWizard/ionic
Updates and bug fixes to TransactionComponent
This commit is contained in:
commit
ec208e93ab
@ -18,7 +18,7 @@
|
||||
</ion-row>
|
||||
|
||||
<ion-row>
|
||||
<ion-col col-5>
|
||||
<ion-col col-12 col-md-5>
|
||||
|
||||
<ion-list [hidden]="!tx.isCoinBase">
|
||||
<ion-item>
|
||||
@ -27,36 +27,50 @@
|
||||
</ion-list>
|
||||
|
||||
<ion-list [hidden]="tx.isCoinBase">
|
||||
<ion-item *ngFor="let vin of tx.vin">
|
||||
<ion-item *ngFor="let vin of aggregateItems(tx.vin)">
|
||||
<div>
|
||||
<p><a (click)="goToAddress(vin.addr)">{{ vin.addr }}</a> <span item-end>{{ currency.getConversion(vin.value) }}</span></p>
|
||||
<div class="ellipsis">
|
||||
<p><a (click)="goToAddress(vin.addr)">{{ vin.addr }}</a></p>
|
||||
</div>
|
||||
<div [hidden]="!expanded">
|
||||
<p *ngIf="vin.confirmations"><b>Confirmations</b> {{vin.confirmations}}</p>
|
||||
<p><b>scriptSig</b></p>
|
||||
<div *ngIf="vin.scriptSig">
|
||||
<div *ngFor="let item of vin.scriptSig.asm | split:' '" class="ellipsis">
|
||||
<p>{{item}}</p>
|
||||
<div *ngFor="let item of vin.items">
|
||||
<div *ngIf="item.scriptSig">
|
||||
<div *ngFor="let scriptSig of item.scriptSig.asm | split:' '">
|
||||
<div class="ellipsis">
|
||||
<p>{{ scriptSig }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div item-end>
|
||||
{{ currency.getConversion(vin.value) }}
|
||||
</div>
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
|
||||
</ion-col>
|
||||
<ion-col col-1 text-center>
|
||||
|
||||
<ion-col col-12 col-md-1 text-center>
|
||||
<ion-icon name="arrow-forward"></ion-icon>
|
||||
</ion-col>
|
||||
<ion-col col-6>
|
||||
|
||||
<ion-col col-12 col-md-6>
|
||||
<ion-list>
|
||||
<ion-item *ngFor="let vout of tx.vout">
|
||||
<div>
|
||||
<p><a (click)="goToAddress(getAddress(vout))">{{ getAddress(vout) }}</a></p>
|
||||
<div class="ellipsis">
|
||||
<p><a (click)="goToAddress(getAddress(vout))">{{ getAddress(vout) }}</a></p>
|
||||
</div>
|
||||
<div [hidden]="!expanded">
|
||||
<p><b>Type</b> {{vout.scriptPubKey.type}}</p>
|
||||
<p><b>scriptPubKey</b></p>
|
||||
<div class="ellipsis">
|
||||
<span>{{vout.scriptPubKey.asm}}</span>
|
||||
<p>{{vout.scriptPubKey.asm}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -72,11 +86,13 @@
|
||||
</ion-row>
|
||||
|
||||
<ion-row>
|
||||
<ion-col col-6>
|
||||
<ion-col col-3>
|
||||
<span [hidden]="tx.isCoinBase">Fee {{ currency.getConversion(tx.fees) }}</span>
|
||||
</ion-col>
|
||||
<ion-col col-6 text-right>
|
||||
<ion-col col-6 text-center>
|
||||
{{ tx.confirmations }} Confirmations
|
||||
</ion-col>
|
||||
<ion-col col-3 text-right>
|
||||
<span class="">{{ currency.getConversion(tx.valueOut) }}</span>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
|
||||
@ -15,6 +15,8 @@ import { CurrencyProvider } from '../../providers/currency/currency';
|
||||
})
|
||||
export class TransactionComponent {
|
||||
|
||||
private COIN: number = 100000000;
|
||||
|
||||
public expanded: boolean = false;
|
||||
@Input() public tx: any = {};
|
||||
|
||||
@ -44,4 +46,70 @@ export class TransactionComponent {
|
||||
public toggleExpanded(): void {
|
||||
this.expanded = !this.expanded;
|
||||
}
|
||||
|
||||
public aggregateItems(items: Array<any>): Array<any> {
|
||||
if (!items) return [];
|
||||
|
||||
let l: number = items.length;
|
||||
|
||||
let ret: Array<any> = [];
|
||||
let tmp: any = {};
|
||||
let u: number = 0;
|
||||
|
||||
for (let i: number = 0; i < l; i++) {
|
||||
|
||||
let notAddr: boolean = false;
|
||||
// non standard input
|
||||
if (items[i].scriptSig && !items[i].addr) {
|
||||
items[i].addr = 'Unparsed address [' + u++ + ']';
|
||||
items[i].notAddr = true;
|
||||
notAddr = true;
|
||||
}
|
||||
|
||||
// non standard output
|
||||
if (items[i].scriptPubKey && !items[i].scriptPubKey.addresses) {
|
||||
items[i].scriptPubKey.addresses = ['Unparsed address [' + u++ + ']'];
|
||||
items[i].notAddr = true;
|
||||
notAddr = true;
|
||||
}
|
||||
|
||||
// multiple addr at output
|
||||
if (items[i].scriptPubKey && items[i].scriptPubKey.addresses.length > 1) {
|
||||
items[i].addr = items[i].scriptPubKey.addresses.join(',');
|
||||
ret.push(items[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
let addr: string = items[i].addr || (items[i].scriptPubKey && items[i].scriptPubKey.addresses[0]);
|
||||
|
||||
if (!tmp[addr]) {
|
||||
tmp[addr] = {};
|
||||
tmp[addr].valueSat = 0;
|
||||
tmp[addr].count = 0;
|
||||
tmp[addr].addr = addr;
|
||||
tmp[addr].items = [];
|
||||
}
|
||||
tmp[addr].isSpent = items[i].spentTxId;
|
||||
|
||||
tmp[addr].doubleSpentTxID = tmp[addr].doubleSpentTxID || items[i].doubleSpentTxID;
|
||||
tmp[addr].doubleSpentIndex = tmp[addr].doubleSpentIndex || items[i].doubleSpentIndex;
|
||||
tmp[addr].dbError = tmp[addr].dbError || items[i].dbError;
|
||||
tmp[addr].valueSat += Math.round(items[i].value * this.COIN);
|
||||
tmp[addr].items.push(items[i]);
|
||||
tmp[addr].notAddr = notAddr;
|
||||
|
||||
if (items[i].unconfirmedInput)
|
||||
tmp[addr].unconfirmedInput = true;
|
||||
|
||||
tmp[addr].count++;
|
||||
}
|
||||
|
||||
for (let v in tmp) {
|
||||
let obj: any = tmp[v];
|
||||
obj.value = obj.value || parseInt(obj.valueSat) / this.COIN;
|
||||
ret.push(obj);
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user