diff --git a/backend/src/api/websocket-handler.ts b/backend/src/api/websocket-handler.ts index cc070528f..ecbc7f6d8 100644 --- a/backend/src/api/websocket-handler.ts +++ b/backend/src/api/websocket-handler.ts @@ -164,7 +164,26 @@ class WebsocketHandler { } } - // Send all new incoming transactions related to tracked asset + if (client['track-address']) { + const foundTransactions: TransactionExtended[] = []; + + newTransactions.forEach((tx) => { + const someVin = tx.vin.some((vin) => !!vin.prevout && vin.prevout.scriptpubkey_address === client['track-address']); + if (someVin) { + foundTransactions.push(tx); + return; + } + const someVout = tx.vout.some((vout) => vout.scriptpubkey_address === client['track-address']); + if (someVout) { + foundTransactions.push(tx); + } + }); + + if (foundTransactions.length) { + response['address-transactions'] = foundTransactions; + } + } + if (client['track-asset']) { const foundTransactions: TransactionExtended[] = []; @@ -190,7 +209,7 @@ class WebsocketHandler { }); if (foundTransactions.length) { - response['asset-transactions'] = foundTransactions; + response['address-transactions'] = foundTransactions; } } @@ -231,7 +250,7 @@ class WebsocketHandler { foundTransactions.push(tx); return; } - if (tx.vout && tx.vout.some((vout) => !!vout.asset && vout.asset === client['track-asset'])) { + if (tx.vout && tx.vout.some((vout) => vout.scriptpubkey_address === client['track-address'])) { foundTransactions.push(tx); } }); @@ -246,7 +265,7 @@ class WebsocketHandler { }; }); - response['asset-block-transactions'] = foundTransactions; + response['block-transactions'] = foundTransactions; } } @@ -283,7 +302,7 @@ class WebsocketHandler { }; }); - response['address-block-transactions'] = foundTransactions; + response['block-transactions'] = foundTransactions; } } diff --git a/frontend/src/app/components/about/about.component.html b/frontend/src/app/components/about/about.component.html index a7abca77e..7caa55ca5 100644 --- a/frontend/src/app/components/about/about.component.html +++ b/frontend/src/app/components/about/about.component.html @@ -67,7 +67,7 @@

Push transactions related to address: {{ '{' }} 'track-address': '3PbJ...bF9B' {{ '}' }} - to receive all new transactions containing that address as input or output. Returns an array of transactions. 'address-transactions' for new mempool transactions and 'address-block-transactions' for new block confirmed transactions. + to receive all new transactions containing that address as input or output. Returns an array of transactions. 'address-transactions' for new mempool transactions and 'block-transactions' for new block confirmed transactions. diff --git a/frontend/src/app/components/asset/asset.component.ts b/frontend/src/app/components/asset/asset.component.ts index 1557e8d17..4cd84540b 100644 --- a/frontend/src/app/components/asset/asset.component.ts +++ b/frontend/src/app/components/asset/asset.component.ts @@ -142,7 +142,7 @@ export class AssetComponent implements OnInit, OnDestroy { this.isLoadingAsset = false; }); - this.stateService.assetTransactions$ + this.stateService.mempoolTransactions$ .subscribe((transaction) => { if (this.transactions.some((t) => t.txid === transaction.txid)) { return; diff --git a/frontend/src/app/components/start/start.component.ts b/frontend/src/app/components/start/start.component.ts index 0b4143a79..b6840e9a5 100644 --- a/frontend/src/app/components/start/start.component.ts +++ b/frontend/src/app/components/start/start.component.ts @@ -7,8 +7,6 @@ import { WebsocketService } from 'src/app/services/websocket.service'; styleUrls: ['./start.component.scss'] }) export class StartComponent implements OnInit { - view: 'blocks' | 'transactions' = 'blocks'; - constructor( private websocketService: WebsocketService, ) { } diff --git a/frontend/src/app/components/transaction/transaction.component.ts b/frontend/src/app/components/transaction/transaction.component.ts index 8b48be2c6..c50d85f65 100644 --- a/frontend/src/app/components/transaction/transaction.component.ts +++ b/frontend/src/app/components/transaction/transaction.component.ts @@ -30,8 +30,6 @@ export class TransactionComponent implements OnInit, OnDestroy { transactionTime = -1; subscription: Subscription; - rightPosition = 0; - constructor( private route: ActivatedRoute, private electrsApiService: ElectrsApiService, diff --git a/frontend/src/app/services/state.service.ts b/frontend/src/app/services/state.service.ts index 96dde4526..f0c32ee98 100644 --- a/frontend/src/app/services/state.service.ts +++ b/frontend/src/app/services/state.service.ts @@ -25,7 +25,6 @@ export class StateService { mempoolBlocks$ = new ReplaySubject(1); txConfirmed$ = new Subject(); mempoolTransactions$ = new Subject(); - assetTransactions$ = new Subject(); blockTransactions$ = new Subject(); live2Chart$ = new Subject(); @@ -33,7 +32,7 @@ export class StateService { viewFiat$ = new BehaviorSubject(false); connectionState$ = new BehaviorSubject<0 | 1 | 2>(2); - markBlock$ = new Subject(); + markBlock$ = new ReplaySubject(); keyNavigation$ = new Subject(); constructor( diff --git a/frontend/src/app/services/websocket.service.ts b/frontend/src/app/services/websocket.service.ts index 9d98888a3..9be503356 100644 --- a/frontend/src/app/services/websocket.service.ts +++ b/frontend/src/app/services/websocket.service.ts @@ -111,20 +111,8 @@ export class WebsocketService { }); } - if (response['address-block-transactions']) { - response['address-block-transactions'].forEach((addressTransaction: Transaction) => { - this.stateService.blockTransactions$.next(addressTransaction); - }); - } - - if (response['asset-transactions']) { - response['asset-transactions'].forEach((assetTransaction: Transaction) => { - this.stateService.assetTransactions$.next(assetTransaction); - }); - } - - if (response['asset-block-transactions']) { - response['asset-block-transactions'].forEach((addressTransaction: Transaction) => { + if (response['block-transactions']) { + response['block-transactions'].forEach((addressTransaction: Transaction) => { this.stateService.blockTransactions$.next(addressTransaction); }); }