Skip to content

Commit b1b10b3

Browse files
authored
Merge pull request #9683 from BitGo/fix/sc-7552-zec-recovery-height
fix(abstract-utxo): pass Zcash recovery block height
2 parents f7c69cf + 65bf651 commit b1b10b3

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

modules/abstract-utxo/src/recovery/backupKeyRecovery.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ export interface RecoverParams {
100100
recoveryProvider?: RecoveryProvider;
101101
/** Satoshi per byte */
102102
feeRate?: number;
103+
/** Block height used to select the Zcash consensus branch ID. */
104+
blockHeight?: number;
103105
/**
104106
* Transaction lock time (nLockTime). Set before signing — it is part of the sighash.
105107
* Used for ECX replay-protection sweeps (e.g. 499_999_999) and other custom lock-time needs.
@@ -270,6 +272,8 @@ export interface RecoverWithUnspentsParams {
270272
krsFee?: bigint;
271273
/** KRS fee address (required if krsFee > 0) */
272274
krsFeeAddress?: string;
275+
/** Block height used to select the Zcash consensus branch ID. */
276+
blockHeight?: number;
273277
/** Transaction lock time (nLockTime), set on the PSBT before signing */
274278
lockTime?: number;
275279
/** Input sequence number applied to every input */
@@ -313,6 +317,7 @@ export function backupKeyRecoveryWithWalletUnspents(
313317
recoveryDestination: recoveryDestination,
314318
keyRecoveryServiceFee: krsFee ?? BigInt(0),
315319
keyRecoveryServiceFeeAddress: krsFeeAddress,
320+
blockHeight: params.blockHeight,
316321
lockTime: params.lockTime,
317322
sequence: params.sequence,
318323
});
@@ -565,6 +570,7 @@ export async function backupKeyRecovery(
565570
feeRateSatVB,
566571
krsFee,
567572
krsFeeAddress,
573+
blockHeight: params.blockHeight,
568574
lockTime: params.lockTime,
569575
sequence: params.sequence,
570576
},

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,26 @@ function runWithScriptTypes(scriptTypes: ScriptType2Of3[]) {
176176
}
177177

178178
describe('Backup Key Recovery PSBT', function () {
179+
it('uses the supplied post-NU6.2 block height for Zcash', function () {
180+
const { walletKeys: externalWallet } = createWasmWalletKeys('external');
181+
const recoveryDestination = getWalletAddress('zec', externalWallet);
182+
const unspent = toUnspent({ scriptType: 'p2sh', value: BigInt(1e8) }, 0, 'zec', wasmWalletKeys);
183+
184+
const psbt = backupKeyRecoveryWithWalletUnspents(
185+
'zec',
186+
{
187+
walletKeys: wasmWalletKeys,
188+
keys: [userPrivkey, backupPrivkey, wasmWalletKeys.bitgoKey()],
189+
recoveryDestination,
190+
feeRateSatVB: 1,
191+
blockHeight: 3_364_600,
192+
},
193+
[unspent]
194+
);
195+
196+
assert.strictEqual((psbt as fixedScriptWallet.ZcashBitGoPsbt).consensusBranchId, 0x5437f330);
197+
});
198+
179199
// compatible with all coins
180200
runWithScriptTypes(['p2sh']);
181201

0 commit comments

Comments
 (0)