Skip to content

Commit

Permalink
Drop previous transaction that is replaced
Browse files Browse the repository at this point in the history
  • Loading branch information
samholmes committed Oct 25, 2023
1 parent ae4bf88 commit 86b2499
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/common/utxobased/engine/makeUtxoEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,8 @@ export async function makeUtxoEngine(
outputs: tx.outputs
},
edgeSpendInfo,
ourScriptPubkeys
ourScriptPubkeys,
rbfTxid
}

const transaction: EdgeTransaction = {
Expand Down Expand Up @@ -515,6 +516,24 @@ export async function makeUtxoEngine(
},

async saveTx(edgeTx: EdgeTransaction): Promise<void> {
// Update rbfTxid if it exists
const rbfTxid: string | undefined = edgeTx.otherParams?.rbfTxid
if (rbfTxid != null) {
// Get the replaced transaction using the rbfTxid
const [rbfTx] = await processor.fetchTransactions({ txId: rbfTxid })
if (rbfTx != null) {
rbfTx.blockHeight = -1
await transactionChanged({
walletId: walletInfo.id,
tx: rbfTx,
pluginInfo,
emitter,
walletTools,
processor
})
}
}

const tx = fromEdgeTransaction(edgeTx)
await transactionChanged({
walletId: walletInfo.id,
Expand Down
1 change: 1 addition & 0 deletions src/common/utxobased/engine/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface UtxoTxOtherParams {
}
edgeSpendInfo?: EdgeSpendInfo
ourScriptPubkeys: string[]
rbfTxid?: string
}

export type UtxoSignMessageOtherParams = ReturnType<
Expand Down

0 comments on commit 86b2499

Please sign in to comment.