Merge pull request #427 from mempool/simon/cpfp-ancestors-fee-bug

Bugfix: Ancestors are not able to increase fee of descendants
This commit is contained in:
wiz 2021-04-06 15:52:46 +09:00 committed by GitHub
commit bc8e3109fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 8 deletions

View File

@ -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) => {

View File

@ -177,10 +177,7 @@
</td>
<td class="d-none d-lg-table-cell">{{ cpfpTx.weight / 4 | vbytes: 2 }}</td>
<td>{{ roundToOneDecimal(cpfpTx) | number : '1.1-1' }} <span i18n="shared.sat-vbyte|sat/vB">sat/vB</span></td>
<td class="d-none d-lg-table-cell"><fa-icon *ngIf="roundToOneDecimal(cpfpTx) > tx.feePerVsize; else arrowDown" class="arrow-green" [icon]="['fas', 'angle-double-up']" [fixedWidth]="true"></fa-icon></td>
<ng-template #arrowDown>
<fa-icon *ngIf="roundToOneDecimal(cpfpTx) !== tx.feePerVsize" class="arrow-red" [icon]="['fas', 'angle-double-down']" [fixedWidth]="true"></fa-icon>
</ng-template>
<td class="d-none d-lg-table-cell"><fa-icon *ngIf="roundToOneDecimal(cpfpTx) < tx.feePerVsize" class="arrow-red" [icon]="['fas', 'angle-double-down']" [fixedWidth]="true"></fa-icon></td>
</tr>
</ng-template>
</tbody>

View File

@ -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;