diff --git a/app/src/components/transaction/transaction.html b/app/src/components/transaction/transaction.html index 75cc9b4..78b2ea6 100644 --- a/app/src/components/transaction/transaction.html +++ b/app/src/components/transaction/transaction.html @@ -18,7 +18,7 @@ - + @@ -27,36 +27,50 @@ - +
-

{{ vin.addr }} {{ currency.getConversion(vin.value) }}

+

Confirmations {{vin.confirmations}}

scriptSig

-
-
-

{{item}}

+
+
+
+
+

{{ scriptSig }}

+
+
+ +
+ {{ currency.getConversion(vin.value) }} +
- + + - + +
-

{{ getAddress(vout) }}

+

Type {{vout.scriptPubKey.type}}

scriptPubKey

- {{vout.scriptPubKey.asm}} +

{{vout.scriptPubKey.asm}}

@@ -72,11 +86,13 @@ - + Fee {{ currency.getConversion(tx.fees) }} - + {{ tx.confirmations }} Confirmations + + {{ currency.getConversion(tx.valueOut) }} diff --git a/app/src/components/transaction/transaction.ts b/app/src/components/transaction/transaction.ts index b01a7bb..8d5cc19 100644 --- a/app/src/components/transaction/transaction.ts +++ b/app/src/components/transaction/transaction.ts @@ -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): Array { + if (!items) return []; + + let l: number = items.length; + + let ret: Array = []; + 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; + }; }