fix CPFP handling in transaction preview
This commit is contained in:
parent
c7d61a3be4
commit
38c890626b
@ -63,40 +63,14 @@ export class TransactionPreviewComponent implements OnInit, OnDestroy {
|
|||||||
this.fetchCpfpSubscription = this.fetchCpfp$
|
this.fetchCpfpSubscription = this.fetchCpfp$
|
||||||
.pipe(
|
.pipe(
|
||||||
switchMap((txId) =>
|
switchMap((txId) =>
|
||||||
this.apiService
|
this.apiService.getCpfpinfo$(txId).pipe(
|
||||||
.getCpfpinfo$(txId)
|
catchError((err) => {
|
||||||
.pipe(retryWhen((errors) => errors.pipe(delay(2000))))
|
return of(null);
|
||||||
|
})
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.subscribe((cpfpInfo) => {
|
.subscribe((cpfpInfo) => {
|
||||||
if (!this.tx) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.tx.effectiveFeePerVsize = totalFees / (totalWeight / 4);
|
|
||||||
}
|
|
||||||
if (!this.tx.status.confirmed) {
|
|
||||||
this.stateService.markBlock$.next({
|
|
||||||
txFeePerVSize: this.tx.effectiveFeePerVsize,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.cpfpInfo = cpfpInfo;
|
this.cpfpInfo = cpfpInfo;
|
||||||
this.openGraphService.waitOver('cpfp-data-' + this.txId);
|
this.openGraphService.waitOver('cpfp-data-' + this.txId);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user