From a554e43c079801f3469c9cf7f9eb4d5390016d6f Mon Sep 17 00:00:00 2001 From: Darren Nelsen Date: Mon, 14 Aug 2017 17:01:19 -0400 Subject: [PATCH 1/3] Added aggregateItems --- .../components/transaction/transaction.html | 14 ++-- app/src/components/transaction/transaction.ts | 72 +++++++++++++++++++ 2 files changed, 81 insertions(+), 5 deletions(-) diff --git a/app/src/components/transaction/transaction.html b/app/src/components/transaction/transaction.html index 75cc9b4..c5d29a5 100644 --- a/app/src/components/transaction/transaction.html +++ b/app/src/components/transaction/transaction.html @@ -27,19 +27,23 @@ - +
-

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

+

{{ vin.addr }}

Confirmations {{vin.confirmations}}

-

scriptSig

-
-
+
+

scriptSig

+

{{item}}

+ +
+ {{ currency.getConversion(vin.value) }} +
diff --git a/app/src/components/transaction/transaction.ts b/app/src/components/transaction/transaction.ts index b01a7bb..772fed1 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,74 @@ export class TransactionComponent { public toggleExpanded(): void { this.expanded = !this.expanded; } + + public aggregateItems(items: Array): Array { + console.log('aggregateItems called'); + 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++; + } + + console.log('tmp is', tmp); + + for (let v in tmp) { + let obj: any = tmp[v]; + console.log('obj isb', obj); + obj.value = obj.value || parseInt(obj.valueSat) / this.COIN; + ret.push(obj); + } + + return ret; + }; } From 0fe359bd1f92e867d3f9ef391ed6dcc7bf5fc178 Mon Sep 17 00:00:00 2001 From: Darren Nelsen Date: Mon, 14 Aug 2017 18:44:57 -0400 Subject: [PATCH 2/3] get scriptSigs working again in expanded view --- app/src/components/transaction/transaction.html | 14 +++++++++----- app/src/components/transaction/transaction.ts | 4 ---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/src/components/transaction/transaction.html b/app/src/components/transaction/transaction.html index c5d29a5..d46d07c 100644 --- a/app/src/components/transaction/transaction.html +++ b/app/src/components/transaction/transaction.html @@ -32,10 +32,14 @@

{{ vin.addr }}

Confirmations {{vin.confirmations}}

-
-

scriptSig

-
-

{{item}}

+

scriptSig

+
+
+
+
+

{{ scriptSig }}

+
+
@@ -60,7 +64,7 @@

Type {{vout.scriptPubKey.type}}

scriptPubKey

- {{vout.scriptPubKey.asm}} +

{{vout.scriptPubKey.asm}}

diff --git a/app/src/components/transaction/transaction.ts b/app/src/components/transaction/transaction.ts index 772fed1..8d5cc19 100644 --- a/app/src/components/transaction/transaction.ts +++ b/app/src/components/transaction/transaction.ts @@ -48,7 +48,6 @@ export class TransactionComponent { } public aggregateItems(items: Array): Array { - console.log('aggregateItems called'); if (!items) return []; let l: number = items.length; @@ -105,11 +104,8 @@ export class TransactionComponent { tmp[addr].count++; } - console.log('tmp is', tmp); - for (let v in tmp) { let obj: any = tmp[v]; - console.log('obj isb', obj); obj.value = obj.value || parseInt(obj.valueSat) / this.COIN; ret.push(obj); } From cf4d45cf591738dc2acde1b79b4b60d5fa1a93e6 Mon Sep 17 00:00:00 2001 From: Darren Nelsen Date: Tue, 15 Aug 2017 11:15:10 -0400 Subject: [PATCH 3/3] fixed responsiveness in the transaction grid --- .../components/transaction/transaction.html | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/app/src/components/transaction/transaction.html b/app/src/components/transaction/transaction.html index d46d07c..78b2ea6 100644 --- a/app/src/components/transaction/transaction.html +++ b/app/src/components/transaction/transaction.html @@ -18,7 +18,7 @@ - + @@ -29,7 +29,9 @@
-

{{ vin.addr }}

+

Confirmations {{vin.confirmations}}

scriptSig

@@ -52,14 +54,18 @@ - + + - + +
-

{{ getAddress(vout) }}

+

Type {{vout.scriptPubKey.type}}

scriptPubKey

@@ -80,11 +86,13 @@ - + Fee {{ currency.getConversion(tx.fees) }} - + {{ tx.confirmations }} Confirmations + + {{ currency.getConversion(tx.valueOut) }}