Pizza tracker rbf tree traversal to find mined tx

This commit is contained in:
Mononaut 2024-06-04 22:58:39 +00:00
parent 976e505445
commit f77582250f
No known key found for this signature in database
GPG Key ID: A3F058E41374C04E

View File

@ -220,7 +220,23 @@ export class TrackerComponent implements OnInit, OnDestroy {
this.rbfInfo = rbfResponse?.replacements;
this.rbfReplaces = rbfResponse?.replaces || null;
if (this.rbfInfo) {
// link to the latest pending version
this.latestReplacement = this.rbfInfo.tx.txid;
// or traverse the rbf tree to find a confirmed version
if (this.rbfInfo.mined) {
const stack = [this.rbfInfo];
let found = false;
while (stack.length && !found) {
const top = stack.pop();
if (top?.tx.mined) {
found = true;
this.latestReplacement = top.tx.txid;
break;
} else {
stack.push(...top.replaces);
}
}
}
}
});