From 5914d99283dd82cf3b9b2d5d360992ab7f744210 Mon Sep 17 00:00:00 2001 From: softsimon Date: Mon, 5 Apr 2021 23:45:47 +0400 Subject: [PATCH 1/2] Bugfix: Ancestors are not able to increase fee of descendants fixes #426 --- backend/src/api/common.ts | 5 +++-- .../app/components/transaction/transaction.component.html | 5 +---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/backend/src/api/common.ts b/backend/src/api/common.ts index 130e0205d..dd3d84e48 100644 --- a/backend/src/api/common.ts +++ b/backend/src/api/common.ts @@ -81,9 +81,10 @@ export class Common { static setRelativesAndGetCpfpInfo(tx: TransactionExtended, memPool: { [txid: string]: TransactionExtended }): CpfpInfo { const parents = this.findAllParents(tx, memPool); + const lowerFeeParents = parents.filter((parent) => parent.feePerVsize < tx.feePerVsize); - let totalWeight = tx.weight + parents.reduce((prev, val) => prev + val.weight, 0); - let totalFees = tx.fee + parents.reduce((prev, val) => prev + val.fee, 0); + let totalWeight = tx.weight + lowerFeeParents.reduce((prev, val) => prev + val.weight, 0); + let totalFees = tx.fee + lowerFeeParents.reduce((prev, val) => prev + val.fee, 0); tx.ancestors = parents .map((t) => { diff --git a/frontend/src/app/components/transaction/transaction.component.html b/frontend/src/app/components/transaction/transaction.component.html index bf0f9a3c3..d80c6c1d0 100644 --- a/frontend/src/app/components/transaction/transaction.component.html +++ b/frontend/src/app/components/transaction/transaction.component.html @@ -177,10 +177,7 @@ {{ cpfpTx.weight / 4 | vbytes: 2 }} {{ roundToOneDecimal(cpfpTx) | number : '1.1-1' }} sat/vB - - - - + From 56b0eab9b4cc2719a0e8f04cc44a48f7598f2992 Mon Sep 17 00:00:00 2001 From: softsimon Date: Tue, 6 Apr 2021 10:41:13 +0400 Subject: [PATCH 2/2] Bugfix: Ancestors are not able to increase fee of descendants fixes #426 --- .../src/app/components/transaction/transaction.component.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/components/transaction/transaction.component.ts b/frontend/src/app/components/transaction/transaction.component.ts index e551b71b6..ef765b49f 100644 --- a/frontend/src/app/components/transaction/transaction.component.ts +++ b/frontend/src/app/components/transaction/transaction.component.ts @@ -109,8 +109,9 @@ export class TransactionComponent implements OnInit, OnDestroy { } else { this.apiService.getCpfpinfo$(this.tx.txid) .subscribe((cpfpInfo) => { - let totalWeight = tx.weight + cpfpInfo.ancestors.reduce((prev, val) => prev + val.weight, 0); - let totalFees = tx.fee + cpfpInfo.ancestors.reduce((prev, val) => prev + val.fee, 0); + const lowerFeeParents = cpfpInfo.ancestors.filter((ancestor) => (ancestor.fee / (ancestor.weight / 4)) < tx.feePerVsize); + let totalWeight = tx.weight + lowerFeeParents.reduce((prev, val) => prev + val.weight, 0); + let totalFees = tx.fee + lowerFeeParents.reduce((prev, val) => prev + val.fee, 0); if (cpfpInfo.bestDescendant) { totalWeight += cpfpInfo.bestDescendant.weight;