Skip to content

Commit 0800cd4

Browse files
OttoAllmendingerllm-git
andcommitted
feat(abstract-utxo): update parseTransactionWithWalletKeys to use nested
replayProtection parameter Updates all calls to parseTransactionWithWalletKeys to use the new parameter structure where replayProtection is nested within an options object. Issue: BTC-0 Co-authored-by: llm-git <llm-git@ttll.de>
1 parent dc593cb commit 0800cd4

8 files changed

Lines changed: 19 additions & 11 deletions

File tree

modules/abstract-utxo/src/abstractUtxoCoin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ function hasKeyPathSpendInput<TNumber extends number | bigint>(
159159
assert(pubs && isTriple(pubs), 'pub triple is required to check for key path spend inputs in wasm-utxo PSBT');
160160
const rootWalletKeys = fixedScriptWallet.RootWalletKeys.fromXpubs(pubs);
161161
const replayProtection = { publicKeys: getReplayProtectionPubkeys(coinName) };
162-
const parsed = tx.parseTransactionWithWalletKeys(rootWalletKeys, replayProtection);
162+
const parsed = tx.parseTransactionWithWalletKeys(rootWalletKeys, { replayProtection });
163163
return parsed.inputs.some((input) => input.scriptType === 'p2trMusig2KeyPath');
164164
}
165165
return false;

modules/abstract-utxo/src/transaction/fixedScript/explainPsbtWasm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function explainPsbtWasm(
4949
customChangeWalletXpubs?: Triple<string>;
5050
}
5151
): TransactionExplanationWasm {
52-
const parsed = psbt.parseTransactionWithWalletKeys(walletXpubs, params.replayProtection);
52+
const parsed = psbt.parseTransactionWithWalletKeys(walletXpubs, { replayProtection: params.replayProtection });
5353

5454
const changeOutputs: FixedScriptWalletOutput[] = [];
5555
const outputs: Output[] = [];

modules/abstract-utxo/src/transaction/fixedScript/signPsbtWasm.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function hasKeyPathSpendInput(
2424
rootWalletKeys: fixedScriptWallet.RootWalletKeys,
2525
replayProtection: ReplayProtectionKeys
2626
): boolean {
27-
const parsed = tx.parseTransactionWithWalletKeys(rootWalletKeys, replayProtection);
27+
const parsed = tx.parseTransactionWithWalletKeys(rootWalletKeys, { replayProtection });
2828
return parsed.inputs.some((input) => input.scriptType === 'p2trMusig2KeyPath');
2929
}
3030

@@ -49,7 +49,7 @@ export function signAndVerifyPsbtWasm(
4949
}
5050

5151
// Verify signatures for all signed inputs (still per-input for granular error reporting)
52-
const parsed = tx.parseTransactionWithWalletKeys(rootWalletKeys, replayProtection);
52+
const parsed = tx.parseTransactionWithWalletKeys(rootWalletKeys, { replayProtection });
5353
const verifyErrors: InputSigningError<bigint>[] = [];
5454

5555
parsed.inputs.forEach((input, inputIndex) => {

modules/abstract-utxo/test/unit/postProcessPrebuild.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('Post Build Validation', function () {
3434
resultPsbt.lockTime.should.equal(0);
3535

3636
// Check sequences via parseTransactionWithWalletKeys
37-
const parsed = resultPsbt.parseTransactionWithWalletKeys(walletKeys, { publicKeys: [] });
37+
const parsed = resultPsbt.parseTransactionWithWalletKeys(walletKeys, { replayProtection: { publicKeys: [] } });
3838
for (const input of parsed.inputs) {
3939
input.sequence.should.equal(0xffffffff);
4040
}

modules/abstract-utxo/test/unit/recovery/backupKeyRecovery.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ function run(
9393
);
9494

9595
// Parse generated PSBT
96-
parsed = psbt.parseTransactionWithWalletKeys(wasmWalletKeys, { publicKeys: replayProtection });
96+
parsed = psbt.parseTransactionWithWalletKeys(wasmWalletKeys, {
97+
replayProtection: { publicKeys: replayProtection },
98+
});
9799

98100
// Load and parse fixture PSBT
99101
const psbtHex = Buffer.from(psbt.serialize()).toString('hex');
@@ -104,7 +106,9 @@ function run(
104106
Buffer.from(storedFixture.psbtHex, 'hex'),
105107
fixtureCoin.name
106108
);
107-
fixtureParsed = fixturePsbt.parseTransactionWithWalletKeys(wasmWalletKeys, { publicKeys: replayProtection });
109+
fixtureParsed = fixturePsbt.parseTransactionWithWalletKeys(wasmWalletKeys, {
110+
replayProtection: { publicKeys: replayProtection },
111+
});
108112
});
109113

110114
it('has expected input count', function () {

modules/abstract-utxo/test/unit/recovery/crossChainRecovery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ function run<TNumber extends number | bigint = number>(sourceCoin: AbstractUtxoC
163163
function checkRecoveryPsbtSignature(psbtHex: string) {
164164
// Parse using wasm-utxo for signature verification
165165
const wasmPsbt = fixedScriptWallet.BitGoPsbt.fromBytes(Buffer.from(psbtHex, 'hex'), sourceCoin.name);
166-
const parsed = wasmPsbt.parseTransactionWithWalletKeys(wasmWalletKeys, { publicKeys: [] });
166+
const parsed = wasmPsbt.parseTransactionWithWalletKeys(wasmWalletKeys, { replayProtection: { publicKeys: [] } });
167167
const unspents = getRecoveryUnspents();
168168
should.equal(parsed.inputs.length, unspents.length);
169169
// Verify user key has signed each input (same pattern as backupKeyRecovery test)

modules/abstract-utxo/test/unit/transaction/fixedScript/signPsbt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function assertSignedWasm(
6666
replayProtection: ReplayProtectionKeys
6767
): void {
6868
const wasmUserKey = BIP32.from(userKey);
69-
const parsed = psbt.parseTransactionWithWalletKeys(rootWalletKeys, replayProtection);
69+
const parsed = psbt.parseTransactionWithWalletKeys(rootWalletKeys, { replayProtection });
7070

7171
// Verify that all wallet inputs have been signed by user key
7272
parsed.inputs.forEach((input, inputIndex) => {

modules/abstract-utxo/test/unit/util/transaction.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,12 @@ export function assertEqualParsedPsbt(
5050
}
5151
const aPsbt = fixedScriptWallet.BitGoPsbt.fromBytes(a, coinName);
5252
const bPsbt = fixedScriptWallet.BitGoPsbt.fromBytes(b, coinName);
53-
const aParsed = aPsbt.parseTransactionWithWalletKeys(walletKeys, { publicKeys: replayProtection });
54-
const bParsed = bPsbt.parseTransactionWithWalletKeys(walletKeys, { publicKeys: replayProtection });
53+
const aParsed = aPsbt.parseTransactionWithWalletKeys(walletKeys, {
54+
replayProtection: { publicKeys: replayProtection },
55+
});
56+
const bParsed = bPsbt.parseTransactionWithWalletKeys(walletKeys, {
57+
replayProtection: { publicKeys: replayProtection },
58+
});
5559
assert.deepStrictEqual(aParsed, bParsed);
5660
}
5761

0 commit comments

Comments
 (0)