Skip to content

Commit 4628408

Browse files
chore(utxo-lib): remove unsafe non-segwit signing for zcash
Remove the unsafe non-segwit signing workaround from ZcashPsbt as it's unnecessary. We now do this by default everywhere. Issue: BTC-2286
1 parent a60bf73 commit 4628408

File tree

2 files changed

+2
-17
lines changed

2 files changed

+2
-17
lines changed

modules/utxo-lib/src/bitgo/zcash/ZcashPsbt.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ import {
44
getDefaultVersionGroupIdForVersion,
55
ZcashTransaction,
66
} from './ZcashTransaction';
7-
import { Network, PsbtTransaction, Signer } from '../../';
7+
import { Network, PsbtTransaction } from '../../';
88
import { Psbt as PsbtBase } from 'bip174';
99
import * as types from 'bitcoinjs-lib/src/types';
10-
import { ValidateSigFunction } from 'bitcoinjs-lib/src/psbt';
11-
import { ProprietaryKeySubtype, PSBT_PROPRIETARY_IDENTIFIER, withUnsafeNonSegwit } from '../PsbtUtil';
10+
import { ProprietaryKeySubtype, PSBT_PROPRIETARY_IDENTIFIER } from '../PsbtUtil';
1211
const typeforce = require('typeforce');
1312

1413
const CONSENSUS_BRANCH_ID_KEY = Buffer.concat([
@@ -124,17 +123,6 @@ export class ZcashPsbt extends UtxoPsbt<ZcashTransaction<bigint>> {
124123
this.tx.consensusBranchId = getDefaultConsensusBranchIdForVersion(network, version);
125124
}
126125

127-
// For Zcash transactions, we do not have to have non-witness UTXO data for non-segwit
128-
// transactions because zcash hashes the value directly. Thus, it is unnecessary to have
129-
// the previous transaction hash on the unspent.
130-
signInput(inputIndex: number, keyPair: Signer, sighashTypes?: number[]): this {
131-
return withUnsafeNonSegwit(this, super.signInput.bind(this, inputIndex, keyPair, sighashTypes));
132-
}
133-
134-
validateSignaturesOfInput(inputIndex: number, validator: ValidateSigFunction, pubkey?: Buffer): boolean {
135-
return withUnsafeNonSegwit(this, super.validateSignaturesOfInput.bind(this, inputIndex, validator, pubkey));
136-
}
137-
138126
private setPropertyCheckSignatures(propName: keyof ZcashTransaction<bigint>, value: unknown) {
139127
if (this.tx[propName] === value) {
140128
return;

modules/utxo-lib/test/bitgo/psbt/ZcashPsbt.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,11 @@ describe('Zcash PSBT', function () {
4545
describe('should be able to sign the transaction', function () {
4646
it('can sign the inputs', async function () {
4747
psbt.signAllInputsHD(rootWalletKeys.user);
48-
assert(!(psbt as any).__CACHE.__UNSAFE_SIGN_NONSEGWIT);
4948
psbt.signAllInputsHD(rootWalletKeys.bitgo);
50-
assert(!(psbt as any).__CACHE.__UNSAFE_SIGN_NONSEGWIT);
5149
});
5250

5351
it('can validate the signatures on the unspents', async function () {
5452
psbt.validateSignaturesOfAllInputs();
55-
assert(!(psbt as any).__CACHE.__UNSAFE_SIGN_NONSEGWIT);
5653
});
5754

5855
it('can finalize and extract the transaction', async function () {

0 commit comments

Comments
 (0)