From eb576824712d5a44c04037c3719a96f22dc5f12f Mon Sep 17 00:00:00 2001 From: Otto Allmendinger Date: Fri, 14 Nov 2025 11:28:50 +0100 Subject: [PATCH] feat(utxo-lib): refactor replay protection to use wallet keys Refactor the replay protection code to use the user keys consistently instead of hardcoded "signerName". Also add a helper method to get the replay protection output script directly. Issue: BTC-2732 Co-authored-by: llm-git --- modules/utxo-lib/src/testutil/psbt.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/utxo-lib/src/testutil/psbt.ts b/modules/utxo-lib/src/testutil/psbt.ts index 23fe79033f..07e5d128aa 100644 --- a/modules/utxo-lib/src/testutil/psbt.ts +++ b/modules/utxo-lib/src/testutil/psbt.ts @@ -201,7 +201,7 @@ export function constructPsbt( if (isWalletUnspent(u) && cosignerName) { addWalletUnspentToPsbt(psbt, u, rootWalletKeys, signerName, cosignerName, { skipNonWitnessUtxo }); } else { - const { redeemScript } = createOutputScriptP2shP2pk(rootWalletKeys[signerName].publicKey); + const { redeemScript } = createOutputScriptP2shP2pk(rootWalletKeys.user.publicKey); assert(redeemScript); addReplayProtectionUnspentToPsbt(psbt, u, redeemScript, { skipNonWitnessUtxo }); } @@ -328,6 +328,12 @@ export class AcidTest { return `${networkName} ${this.signStage} ${this.txFormat}`; } + getReplayProtectionOutputScript(): Buffer { + const { scriptPubKey } = createOutputScriptP2shP2pk(this.rootWalletKeys.user.publicKey); + assert(scriptPubKey); + return scriptPubKey; + } + createPsbt(): UtxoPsbt { const psbt = constructPsbt(this.inputs, this.outputs, this.network, this.rootWalletKeys, this.signStage, { deterministic: true,