diff --git a/frontend/src/app/components/transaction/transaction-preview.component.html b/frontend/src/app/components/transaction/transaction-preview.component.html index 40ef94dde..8feb980a3 100644 --- a/frontend/src/app/components/transaction/transaction-preview.component.html +++ b/frontend/src/app/components/transaction/transaction-preview.component.html @@ -8,10 +8,10 @@
- + CPFP - + CPFP
diff --git a/frontend/src/app/components/transaction/transaction-preview.component.ts b/frontend/src/app/components/transaction/transaction-preview.component.ts index 6c04af0ab..bd4260244 100644 --- a/frontend/src/app/components/transaction/transaction-preview.component.ts +++ b/frontend/src/app/components/transaction/transaction-preview.component.ts @@ -72,25 +72,31 @@ export class TransactionPreviewComponent implements OnInit, OnDestroy { if (!this.tx) { return; } - const lowerFeeParents = cpfpInfo.ancestors.filter( - (parent) => parent.fee / (parent.weight / 4) < this.tx.feePerVsize - ); - let totalWeight = - this.tx.weight + - lowerFeeParents.reduce((prev, val) => prev + val.weight, 0); - let totalFees = - this.tx.fee + - lowerFeeParents.reduce((prev, val) => prev + val.fee, 0); + if (cpfpInfo.effectiveFeePerVsize) { + this.tx.effectiveFeePerVsize = cpfpInfo.effectiveFeePerVsize; + } else { + const lowerFeeParents = cpfpInfo.ancestors.filter( + (parent) => parent.fee / (parent.weight / 4) < this.tx.feePerVsize + ); + let totalWeight = + this.tx.weight + + lowerFeeParents.reduce((prev, val) => prev + val.weight, 0); + let totalFees = + this.tx.fee + + lowerFeeParents.reduce((prev, val) => prev + val.fee, 0); - if (cpfpInfo.bestDescendant) { - totalWeight += cpfpInfo.bestDescendant.weight; - totalFees += cpfpInfo.bestDescendant.fee; + if (cpfpInfo?.bestDescendant) { + totalWeight += cpfpInfo?.bestDescendant.weight; + totalFees += cpfpInfo?.bestDescendant.fee; + } + + this.tx.effectiveFeePerVsize = totalFees / (totalWeight / 4); + } + if (!this.tx.status.confirmed) { + this.stateService.markBlock$.next({ + txFeePerVSize: this.tx.effectiveFeePerVsize, + }); } - - this.tx.effectiveFeePerVsize = totalFees / (totalWeight / 4); - this.stateService.markBlock$.next({ - txFeePerVSize: this.tx.effectiveFeePerVsize, - }); this.cpfpInfo = cpfpInfo; this.openGraphService.waitOver('cpfp-data-' + this.txId); }); @@ -176,8 +182,17 @@ export class TransactionPreviewComponent implements OnInit, OnDestroy { this.getTransactionTime(); } - if (!this.tx.status.confirmed) { + if (this.tx.status.confirmed) { + this.stateService.markBlock$.next({ + blockHeight: tx.status.block_height, + }); + this.openGraphService.waitFor('cpfp-data-' + this.txId); + this.fetchCpfp$.next(this.tx.txid); + } else { if (tx.cpfpChecked) { + this.stateService.markBlock$.next({ + txFeePerVSize: tx.effectiveFeePerVsize, + }); this.cpfpInfo = { ancestors: tx.ancestors, bestDescendant: tx.bestDescendant,