From a7f123c3b98a25907a8be1784ce1afc954650059 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Sat, 4 Mar 2023 03:16:59 -0600 Subject: [PATCH] fixes for non-dual-node rbf feature --- backend/src/api/websocket-handler.ts | 1 - .../rbf-timeline-tooltip.component.html | 2 +- .../rbf-timeline-tooltip.component.ts | 2 +- .../rbf-timeline/rbf-timeline.component.ts | 2 +- .../transaction/transaction.component.html | 2 +- .../transaction/transaction.component.ts | 49 +++++++++++-------- frontend/src/app/services/state.service.ts | 2 + 7 files changed, 35 insertions(+), 25 deletions(-) diff --git a/backend/src/api/websocket-handler.ts b/backend/src/api/websocket-handler.ts index 783954b10..06a2d7652 100644 --- a/backend/src/api/websocket-handler.ts +++ b/backend/src/api/websocket-handler.ts @@ -422,7 +422,6 @@ class WebsocketHandler { } } - console.log(client['track-rbf']); if (client['track-rbf'] === 'all' && rbfReplacements) { response['rbfLatest'] = rbfReplacements; } else if (client['track-rbf'] === 'fullRbf' && fullRbfReplacements) { diff --git a/frontend/src/app/components/rbf-timeline/rbf-timeline-tooltip.component.html b/frontend/src/app/components/rbf-timeline/rbf-timeline-tooltip.component.html index 63a9865ee..29efb272f 100644 --- a/frontend/src/app/components/rbf-timeline/rbf-timeline-tooltip.component.html +++ b/frontend/src/app/components/rbf-timeline/rbf-timeline-tooltip.component.html @@ -1,6 +1,6 @@
; diff --git a/frontend/src/app/components/rbf-timeline/rbf-timeline.component.ts b/frontend/src/app/components/rbf-timeline/rbf-timeline.component.ts index cc138d25f..a0add7499 100644 --- a/frontend/src/app/components/rbf-timeline/rbf-timeline.component.ts +++ b/frontend/src/app/components/rbf-timeline/rbf-timeline.component.ts @@ -23,7 +23,7 @@ export class RbfTimelineComponent implements OnInit, OnChanges { rows: TimelineCell[][] = []; hoverInfo: RbfInfo | void = null; - tooltipPosition = { x: 0, y: 0 }; + tooltipPosition = null; dir: 'rtl' | 'ltr' = 'ltr'; diff --git a/frontend/src/app/components/transaction/transaction.component.html b/frontend/src/app/components/transaction/transaction.component.html index 057bab4e6..d28a5d420 100644 --- a/frontend/src/app/components/transaction/transaction.component.html +++ b/frontend/src/app/components/transaction/transaction.component.html @@ -97,7 +97,7 @@ - + ETA diff --git a/frontend/src/app/components/transaction/transaction.component.ts b/frontend/src/app/components/transaction/transaction.component.ts index 4e2ccf96a..c6d957c7c 100644 --- a/frontend/src/app/components/transaction/transaction.component.ts +++ b/frontend/src/app/components/transaction/transaction.component.ts @@ -59,6 +59,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { fetchCpfp$ = new Subject(); fetchRbfHistory$ = new Subject(); fetchCachedTx$ = new Subject(); + isCached: boolean = false; now = new Date().getTime(); timeAvg$: Observable; liquidUnblinding = new LiquidUnblinding(); @@ -162,7 +163,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { this.tx.effectiveFeePerVsize = totalFees / (totalWeight / 4); - if (!this.tx.status.confirmed) { + if (!this.tx?.status?.confirmed) { this.stateService.markBlock$.next({ txFeePerVSize: this.tx.effectiveFeePerVsize, }); @@ -200,6 +201,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { if (!this.tx) { this.tx = tx; + this.isCached = true; if (tx.fee === undefined) { this.tx.fee = 0; } @@ -208,16 +210,15 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { this.error = undefined; this.waitingForTransaction = false; this.graphExpanded = false; + this.transactionTime = 0; this.setupGraph(); - if (!this.tx?.status?.confirmed) { - this.fetchRbfHistory$.next(this.tx.txid); - this.txRbfInfoSubscription = this.stateService.txRbfInfo$.subscribe((rbfInfo) => { - if (this.tx) { - this.rbfInfo = rbfInfo; - } - }); - } + this.fetchRbfHistory$.next(this.tx.txid); + this.txRbfInfoSubscription = this.stateService.txRbfInfo$.subscribe((rbfInfo) => { + if (this.tx) { + this.rbfInfo = rbfInfo; + } + }); } }); @@ -258,7 +259,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { of(true), this.stateService.connectionState$.pipe( filter( - (state) => state === 2 && this.tx && !this.tx.status.confirmed + (state) => state === 2 && this.tx && !this.tx.status?.confirmed ) ) ); @@ -295,10 +296,12 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { ) .subscribe((tx: Transaction) => { if (!tx) { + this.fetchCachedTx$.next(this.txId); return; } this.tx = tx; + this.isCached = false; if (tx.fee === undefined) { this.tx.fee = 0; } @@ -311,13 +314,17 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { this.graphExpanded = false; this.setupGraph(); - if (!tx.status.confirmed && tx.firstSeen) { - this.transactionTime = tx.firstSeen; + if (!tx.status?.confirmed) { + if (tx.firstSeen) { + this.transactionTime = tx.firstSeen; + } else { + this.transactionTime = 0; + } } else { this.getTransactionTime(); } - if (this.tx.status.confirmed) { + if (this.tx?.status?.confirmed) { this.stateService.markBlock$.next({ blockHeight: tx.status.block_height, }); @@ -334,10 +341,10 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { } else { this.fetchCpfp$.next(this.tx.txid); } - this.fetchRbfHistory$.next(this.tx.txid); } + this.fetchRbfHistory$.next(this.tx.txid); - this.priceService.getBlockPrice$(tx.status.block_time, true).pipe( + this.priceService.getBlockPrice$(tx.status?.block_time, true).pipe( tap((price) => { this.blockConversion = price; }) @@ -371,11 +378,13 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { this.error = new Error(); this.waitingForTransaction = false; } - this.rbfTransaction = rbfTransaction; - this.cacheService.setTxCache([this.rbfTransaction]); - this.replaced = true; - if (rbfTransaction && !this.tx) { - this.fetchCachedTx$.next(this.txId); + if (!this.tx?.status?.confirmed) { + this.rbfTransaction = rbfTransaction; + this.cacheService.setTxCache([this.rbfTransaction]); + this.replaced = true; + if (rbfTransaction && !this.tx) { + this.fetchCachedTx$.next(this.txId); + } } }); diff --git a/frontend/src/app/services/state.service.ts b/frontend/src/app/services/state.service.ts index f7e404baf..814f8e9db 100644 --- a/frontend/src/app/services/state.service.ts +++ b/frontend/src/app/services/state.service.ts @@ -43,6 +43,7 @@ export interface Env { MAINNET_BLOCK_AUDIT_START_HEIGHT: number; TESTNET_BLOCK_AUDIT_START_HEIGHT: number; SIGNET_BLOCK_AUDIT_START_HEIGHT: number; + FULL_RBF_ENABLED: boolean; HISTORICAL_PRICE: boolean; } @@ -73,6 +74,7 @@ const defaultEnv: Env = { 'MAINNET_BLOCK_AUDIT_START_HEIGHT': 0, 'TESTNET_BLOCK_AUDIT_START_HEIGHT': 0, 'SIGNET_BLOCK_AUDIT_START_HEIGHT': 0, + 'FULL_RBF_ENABLED': false, 'HISTORICAL_PRICE': true, };