utxo-lib 1.1.2 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. package/README.md +16 -19
  2. package/dist/src/bitgo/PsbtUtil.d.ts +0 -5
  3. package/dist/src/bitgo/PsbtUtil.d.ts.map +1 -1
  4. package/dist/src/bitgo/PsbtUtil.js +2 -15
  5. package/dist/src/bitgo/UtxoPsbt.d.ts +0 -9
  6. package/dist/src/bitgo/UtxoPsbt.d.ts.map +1 -1
  7. package/dist/src/bitgo/UtxoPsbt.js +12 -42
  8. package/dist/src/bitgo/index.d.ts +0 -1
  9. package/dist/src/bitgo/index.d.ts.map +1 -1
  10. package/dist/src/bitgo/index.js +2 -3
  11. package/dist/src/bitgo/parseInput.js +2 -2
  12. package/dist/src/bitgo/wallet/Psbt.d.ts +0 -14
  13. package/dist/src/bitgo/wallet/Psbt.d.ts.map +1 -1
  14. package/dist/src/bitgo/wallet/Psbt.js +3 -71
  15. package/dist/src/bitgo/wallet/WalletOutput.d.ts +1 -17
  16. package/dist/src/bitgo/wallet/WalletOutput.d.ts.map +1 -1
  17. package/dist/src/bitgo/wallet/WalletOutput.js +23 -64
  18. package/dist/src/bitgo/wallet/chains.d.ts +1 -1
  19. package/dist/src/bitgo/zcash/ZcashPsbt.d.ts +1 -0
  20. package/dist/src/bitgo/zcash/ZcashPsbt.d.ts.map +1 -1
  21. package/dist/src/bitgo/zcash/ZcashPsbt.js +12 -3
  22. package/dist/src/testutil/keys.d.ts +0 -3
  23. package/dist/src/testutil/keys.d.ts.map +1 -1
  24. package/dist/src/testutil/keys.js +2 -17
  25. package/dist/src/testutil/psbt.d.ts +5 -23
  26. package/dist/src/testutil/psbt.d.ts.map +1 -1
  27. package/dist/src/testutil/psbt.js +13 -16
  28. package/dist/src/testutil/transaction.d.ts +5 -14
  29. package/dist/src/testutil/transaction.d.ts.map +1 -1
  30. package/dist/src/testutil/transaction.js +9 -9
  31. package/package.json +5 -5
  32. package/dist/src/base_crypto.d.ts +0 -14
  33. package/dist/src/base_crypto.d.ts.map +0 -1
  34. package/dist/src/base_crypto.js +0 -215
  35. package/dist/src/bitgo/legacysafe/index.d.ts +0 -15
  36. package/dist/src/bitgo/legacysafe/index.d.ts.map +0 -1
  37. package/dist/src/bitgo/legacysafe/index.js +0 -61
  38. package/dist/src/musig.d.ts +0 -390
  39. package/dist/src/musig.d.ts.map +0 -1
  40. package/dist/src/musig.js +0 -447
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deleteWitnessUtxoForNonSegwitInputs = exports.clonePsbtWithoutNonWitnessUtxo = exports.extractP2msOnlyHalfSignedTx = exports.getSignatureValidationArrayPsbt = exports.addXpubsToPsbt = exports.isTransactionWithKeyPathSpendInput = exports.isTxInputArray = exports.isPsbtInputArray = exports.getStrictSignatureCounts = exports.getStrictSignatureCount = exports.parsePsbtInput = exports.getPsbtInputScriptType = exports.signWalletPsbt = exports.toWalletPsbt = void 0;
3
+ exports.getSignatureValidationArrayPsbt = exports.addXpubsToPsbt = exports.isTransactionWithKeyPathSpendInput = exports.isTxInputArray = exports.isPsbtInputArray = exports.getStrictSignatureCounts = exports.getStrictSignatureCount = exports.parsePsbtInput = exports.getPsbtInputScriptType = exports.signWalletPsbt = exports.toWalletPsbt = void 0;
4
4
  const assert = require("assert");
5
5
  const utils_1 = require("bip174/src/lib/utils");
6
6
  const bs58check = require("bs58check");
7
7
  const UtxoPsbt_1 = require("../UtxoPsbt");
8
8
  const UtxoTransaction_1 = require("../UtxoTransaction");
9
9
  const outputScripts_1 = require("../outputScripts");
10
- const WalletKeys_1 = require("./WalletKeys");
11
10
  const Unspent_1 = require("../Unspent");
12
11
  const transaction_1 = require("../transaction");
13
12
  const Unspent_2 = require("./Unspent");
@@ -357,8 +356,7 @@ exports.isTransactionWithKeyPathSpendInput = isTransactionWithKeyPathSpendInput;
357
356
  * extendedPubkey.
358
357
  */
359
358
  function addXpubsToPsbt(psbt, rootWalletKeys) {
360
- const safeRootWalletKeys = new WalletKeys_1.RootWalletKeys(rootWalletKeys.triple.map((bip32) => bip32.neutered()), rootWalletKeys.derivationPrefixes);
361
- const xPubs = safeRootWalletKeys.triple.map((bip32) => ({
359
+ const xPubs = rootWalletKeys.triple.map((bip32) => ({
362
360
  extendedPubkey: bs58check.decode(bip32.toBase58()),
363
361
  masterFingerprint: bip32.fingerprint,
364
362
  // TODO: BG-73797 - bip174 currently requires m prefix for this to be a valid globalXpub
@@ -381,70 +379,4 @@ function getSignatureValidationArrayPsbt(psbt, rootWalletKeys) {
381
379
  });
382
380
  }
383
381
  exports.getSignatureValidationArrayPsbt = getSignatureValidationArrayPsbt;
384
- /**
385
- * Extracts the half signed transaction from the psbt for p2ms based script types - p2sh, p2wsh, and p2shP2wsh.
386
- * The purpose is to provide backward compatibility to keyternal (KRS) that only supports network transaction and p2ms script types.
387
- */
388
- function extractP2msOnlyHalfSignedTx(psbt) {
389
- assert(!!(psbt.data.inputs.length && psbt.data.outputs.length), 'empty inputs or outputs');
390
- const tx = psbt.getUnsignedTx();
391
- function isP2msParsedPsbtInput(parsed) {
392
- return ['p2sh', 'p2shP2wsh', 'p2wsh'].includes(parsed.scriptType);
393
- }
394
- psbt.data.inputs.forEach((input, i) => {
395
- var _a, _b;
396
- const parsed = parsePsbtInput(input);
397
- assert(isP2msParsedPsbtInput(parsed), `unsupported script type ${parsed.scriptType}`);
398
- assert(((_a = input.partialSig) === null || _a === void 0 ? void 0 : _a.length) === 1, `unexpected signature count ${(_b = input.partialSig) === null || _b === void 0 ? void 0 : _b.length}`);
399
- const [partialSig] = input.partialSig;
400
- assert(input.sighashType !== undefined && input.sighashType === bitcoinjs_lib_1.script.signature.decode(partialSig.signature).hashType, 'signature sighash does not match input sighash type');
401
- // type casting is to address the invalid type checking in payments.p2ms
402
- const signatures = parsed.publicKeys.map((pk) => partialSig.pubkey.equals(pk) ? partialSig.signature : bitcoinjs_lib_1.opcodes.OP_0);
403
- const isP2SH = !!parsed.redeemScript;
404
- const isP2WSH = !!parsed.witnessScript;
405
- const payment = index_1.payments.p2ms({ output: parsed.pubScript, signatures }, { validate: false, allowIncomplete: true });
406
- const p2wsh = isP2WSH ? index_1.payments.p2wsh({ redeem: payment }) : undefined;
407
- const p2sh = isP2SH ? index_1.payments.p2sh({ redeem: p2wsh || payment }) : undefined;
408
- if (p2sh === null || p2sh === void 0 ? void 0 : p2sh.input) {
409
- tx.setInputScript(i, p2sh.input);
410
- }
411
- if (p2wsh === null || p2wsh === void 0 ? void 0 : p2wsh.witness) {
412
- tx.setWitness(i, p2wsh.witness);
413
- }
414
- });
415
- return tx;
416
- }
417
- exports.extractP2msOnlyHalfSignedTx = extractP2msOnlyHalfSignedTx;
418
- /**
419
- * Clones the psbt without nonWitnessUtxo for non-segwit inputs and witnessUtxo is added instead.
420
- * It is not BIP-174 compliant, so use it carefully.
421
- */
422
- function clonePsbtWithoutNonWitnessUtxo(psbt) {
423
- const newPsbt = psbt.clone();
424
- const txInputs = psbt.txInputs;
425
- psbt.data.inputs.forEach((input, i) => {
426
- if (input.nonWitnessUtxo && !input.witnessUtxo) {
427
- const tx = UtxoTransaction_1.UtxoTransaction.fromBuffer(input.nonWitnessUtxo, false, 'bigint', psbt.network);
428
- if (!txInputs[i].hash.equals(tx.getHash())) {
429
- throw new Error(`Non-witness UTXO hash for input #${i} doesn't match the hash specified in the prevout`);
430
- }
431
- newPsbt.data.inputs[i].witnessUtxo = tx.outs[txInputs[i].index];
432
- }
433
- delete newPsbt.data.inputs[i].nonWitnessUtxo;
434
- });
435
- return newPsbt;
436
- }
437
- exports.clonePsbtWithoutNonWitnessUtxo = clonePsbtWithoutNonWitnessUtxo;
438
- /**
439
- * Deletes witnessUtxo for non-segwit inputs to make the PSBT BIP-174 compliant.
440
- */
441
- function deleteWitnessUtxoForNonSegwitInputs(psbt) {
442
- psbt.data.inputs.forEach((input, i) => {
443
- const scriptType = getPsbtInputScriptType(input);
444
- if (scriptType === 'p2sh' || scriptType === 'p2shP2pk') {
445
- delete input.witnessUtxo;
446
- }
447
- });
448
- }
449
- exports.deleteWitnessUtxoForNonSegwitInputs = deleteWitnessUtxoForNonSegwitInputs;
450
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUHNidC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9iaXRnby93YWxsZXQvUHNidC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxpQ0FBaUM7QUFHakMsZ0RBQXFEO0FBRXJELHVDQUF1QztBQUN2QywwQ0FBdUM7QUFDdkMsd0RBQXFEO0FBQ3JELG9EQUE2RztBQUM3Ryw2Q0FBaUU7QUFDakUsd0NBQW9EO0FBQ3BELGdEQUEyRDtBQUMzRCx1Q0FBMkQ7QUFFM0QsOENBY3VCO0FBQ3ZCLHNDQUF1RDtBQUN2RCxvQ0FBMkM7QUFDM0MsMkNBQTBEO0FBQzFELGlEQUEyRTtBQUMzRSx1Q0FBZ0Q7QUFDaEQsMENBQStFO0FBcUUvRSxTQUFTLGlCQUFpQixDQUFDLE1BQWMsRUFBRSxVQUE2QjtJQUN0RSxNQUFNLGdCQUFnQixHQUFHLCtCQUFrQixDQUFDLE1BQU0sRUFBRSx3QkFBd0IsQ0FBQyxDQUFDLFVBQVUsQ0FBQztJQUN6RixNQUFNLGFBQWEsR0FBRyxnQkFBZ0IsQ0FBQyxHQUFHLENBQUMsQ0FBQyxTQUFTLEVBQUUsRUFBRTtRQUN2RCxNQUFNLEtBQUssR0FBRyxVQUFVLENBQUMsVUFBVSxDQUFDLFNBQVMsQ0FBQyxDQUFDLGVBQWUsRUFBRSxFQUFFLENBQ2hFLGdDQUFnQixDQUFDLGVBQWUsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxTQUFTLENBQUMsQ0FDcEQsQ0FBQztRQUNGLElBQUksS0FBSyxJQUFJLENBQUMsRUFBRTtZQUNkLE9BQU8sRUFB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xuICAgIGNvbnN0IHNpZ1ZhbEFycmF5Rm9ySW5wdXQ6IFRyaXBsZTxib29sZWFuPiA9XG4gICAgICBnZXRQc2J0SW5wdXRTY3JpcHRUeXBlKGlucHV0KSA9PT0gJ3Ayc2hQMnBrJ1xuICAgICAgICA/IFtmYWxzZSwgZmFsc2UsIGZhbHNlXVxuICAgICAgICA6IHBzYnQuZ2V0U2lnbmF0dXJlVmFsaWRhdGlvbkFycmF5KGksIHsgcm9vdE5vZGVzOiByb290V2FsbGV0S2V5cy50cmlwbGUgfSk7XG4gICAgcmV0dXJuIFtpLCBzaWdWYWxBcnJheUZvcklucHV0XTtcbiAgfSk7XG59XG4iXX0=
@@ -4,7 +4,7 @@ import { ChainCode } from './chains';
4
4
  /**
5
5
  * Add a verifiable wallet output to the PSBT. The output and all data
6
6
  * needed to verify it from public keys only are added to the PSBT.
7
- * Typically these are change outputs.
7
+ * Typically these are change outputs
8
8
  *
9
9
  * @param psbt the PSBT to add change output to
10
10
  * @param rootWalletKeys keys that will be able to spend the output
@@ -15,20 +15,4 @@ import { ChainCode } from './chains';
15
15
  * @param value value of the change output
16
16
  */
17
17
  export declare function addWalletOutputToPsbt(psbt: UtxoPsbt, rootWalletKeys: RootWalletKeys, chain: ChainCode, index: number, value: bigint): void;
18
- /**
19
- * Update the wallet output with the required information when necessary. If the
20
- * information is there already, it will skip over it.
21
- *
22
- * This function assumes that the output script and value have already been set.
23
- *
24
- * @param psbt the PSBT to update change output at
25
- * @param rootWalletKeys keys that will be able to spend the output
26
- * @param outputIndex output index where to update the output
27
- * @param chain chain code to use for deriving scripts (and to determine script
28
- * type) chain is an API parameter in the BitGo API, and may be
29
- * any valid ChainCode
30
- * @param index derivation index for the change address
31
- * @param value value of the change output
32
- */
33
- export declare function updateWalletOutputForPsbt(psbt: UtxoPsbt, rootWalletKeys: RootWalletKeys, outputIndex: number, chain: ChainCode, index: number): void;
34
18
  //# sourceMappingURL=WalletOutput.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WalletOutput.d.ts","sourceRoot":"","sources":["../../../../src/bitgo/wallet/WalletOutput.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAsB,MAAM,UAAU,CAAC;AAGzD;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,QAAQ,EACd,cAAc,EAAE,cAAc,EAC9B,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ,IAAI,CAYN;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,QAAQ,EACd,cAAc,EAAE,cAAc,EAC9B,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,MAAM,GACZ,IAAI,CAgEN"}
1
+ {"version":3,"file":"WalletOutput.d.ts","sourceRoot":"","sources":["../../../../src/bitgo/wallet/WalletOutput.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAsB,MAAM,UAAU,CAAC;AAGzD;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,QAAQ,EACd,cAAc,EAAE,cAAc,EAC9B,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ,IAAI,CAgDN"}
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateWalletOutputForPsbt = exports.addWalletOutputToPsbt = void 0;
3
+ exports.addWalletOutputToPsbt = void 0;
4
4
  const bitcoinjs_lib_1 = require("bitcoinjs-lib");
5
5
  const chains_1 = require("./chains");
6
6
  const outputScripts_1 = require("../outputScripts");
7
7
  /**
8
8
  * Add a verifiable wallet output to the PSBT. The output and all data
9
9
  * needed to verify it from public keys only are added to the PSBT.
10
- * Typically these are change outputs.
10
+ * Typically these are change outputs
11
11
  *
12
12
  * @param psbt the PSBT to add change output to
13
13
  * @param rootWalletKeys keys that will be able to spend the output
@@ -22,53 +22,13 @@ function addWalletOutputToPsbt(psbt, rootWalletKeys, chain, index, value) {
22
22
  const scriptType = chains_1.scriptTypeForChain(chain);
23
23
  if (scriptType === 'p2tr' || scriptType === 'p2trMusig2') {
24
24
  const payment = scriptType === 'p2tr' ? outputScripts_1.createPaymentP2tr(walletKeys.publicKeys) : outputScripts_1.createPaymentP2trMusig2(walletKeys.publicKeys);
25
- psbt.addOutput({ script: payment.output, value });
26
- }
27
- else {
28
- const { scriptPubKey: script } = outputScripts_1.createOutputScript2of3(walletKeys.publicKeys, scriptType);
29
- psbt.addOutput({ script, value });
30
- }
31
- updateWalletOutputForPsbt(psbt, rootWalletKeys, psbt.data.outputs.length - 1, chain, index);
32
- }
33
- exports.addWalletOutputToPsbt = addWalletOutputToPsbt;
34
- /**
35
- * Update the wallet output with the required information when necessary. If the
36
- * information is there already, it will skip over it.
37
- *
38
- * This function assumes that the output script and value have already been set.
39
- *
40
- * @param psbt the PSBT to update change output at
41
- * @param rootWalletKeys keys that will be able to spend the output
42
- * @param outputIndex output index where to update the output
43
- * @param chain chain code to use for deriving scripts (and to determine script
44
- * type) chain is an API parameter in the BitGo API, and may be
45
- * any valid ChainCode
46
- * @param index derivation index for the change address
47
- * @param value value of the change output
48
- */
49
- function updateWalletOutputForPsbt(psbt, rootWalletKeys, outputIndex, chain, index) {
50
- if (psbt.data.outputs.length <= outputIndex) {
51
- throw new Error(`outputIndex (${outputIndex}) is too large for the number of outputs (${psbt.data.outputs.length})`);
52
- }
53
- const outputScript = psbt.getOutputScript(outputIndex);
54
- const walletKeys = rootWalletKeys.deriveForChainAndIndex(chain, index);
55
- const scriptType = chains_1.scriptTypeForChain(chain);
56
- const output = psbt.data.outputs[outputIndex];
57
- const update = {};
58
- if (scriptType === 'p2tr' || scriptType === 'p2trMusig2') {
59
- const payment = scriptType === 'p2tr' ? outputScripts_1.createPaymentP2tr(walletKeys.publicKeys) : outputScripts_1.createPaymentP2trMusig2(walletKeys.publicKeys);
60
- if (!payment.output || !payment.output.equals(outputScript)) {
61
- throw new Error(`cannot update a p2tr output where the scripts do not match - Failing.`);
62
- }
63
25
  const allLeafHashes = payment.redeems.map((r) => bitcoinjs_lib_1.taproot.hashTapLeaf(r.output));
64
- if (!output.tapTree) {
65
- update.tapTree = payment.tapTree;
66
- }
67
- if (!output.tapInternalKey) {
68
- update.tapInternalKey = payment.internalPubkey;
69
- }
70
- if (!output.tapBip32Derivation) {
71
- update.tapBip32Derivation = [0, 1, 2].map((idx) => {
26
+ psbt.addOutput({
27
+ script: payment.output,
28
+ value,
29
+ tapTree: payment.tapTree,
30
+ tapInternalKey: payment.internalPubkey,
31
+ tapBip32Derivation: [0, 1, 2].map((idx) => {
72
32
  const pubkey = outputScripts_1.toXOnlyPublicKey(walletKeys.triple[idx].publicKey);
73
33
  const leafHashes = [];
74
34
  payment.redeems.forEach((r, idx) => {
@@ -82,29 +42,28 @@ function updateWalletOutputForPsbt(psbt, rootWalletKeys, outputIndex, chain, ind
82
42
  path: walletKeys.paths[idx],
83
43
  masterFingerprint: rootWalletKeys.triple[idx].fingerprint,
84
44
  };
85
- });
86
- }
45
+ }),
46
+ });
87
47
  }
88
48
  else {
89
49
  const { scriptPubKey, witnessScript, redeemScript } = outputScripts_1.createOutputScript2of3(walletKeys.publicKeys, scriptType);
90
- if (!scriptPubKey.equals(outputScript)) {
91
- throw new Error(`cannot update an output where the scripts do not match - Failing.`);
92
- }
93
- if (!output.bip32Derivation) {
94
- update.bip32Derivation = [0, 1, 2].map((idx) => ({
50
+ psbt.addOutput({
51
+ script: scriptPubKey,
52
+ value,
53
+ bip32Derivation: [0, 1, 2].map((idx) => ({
95
54
  pubkey: walletKeys.triple[idx].publicKey,
96
55
  path: walletKeys.paths[idx],
97
56
  masterFingerprint: rootWalletKeys.triple[idx].fingerprint,
98
- }));
99
- }
100
- if (!output.witnessScript && witnessScript) {
101
- update.witnessScript = witnessScript;
57
+ })),
58
+ });
59
+ const outputIndex = psbt.txOutputs.length - 1;
60
+ if (witnessScript) {
61
+ psbt.updateOutput(outputIndex, { witnessScript });
102
62
  }
103
- if (!output.redeemScript && redeemScript) {
104
- update.redeemScript = redeemScript;
63
+ if (redeemScript) {
64
+ psbt.updateOutput(outputIndex, { redeemScript });
105
65
  }
106
66
  }
107
- psbt.updateOutput(outputIndex, update);
108
67
  }
109
- exports.updateWalletOutputForPsbt = updateWalletOutputForPsbt;
110
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiV2FsbGV0T3V0cHV0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL2JpdGdvL3dhbGxldC9XYWxsZXRPdXRwdXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsaURBQXdDO0FBSXhDLHFDQUF5RDtBQUN6RCxvREFBd0g7QUFFeEg7Ozs7Ozs7Ozs7OztHQVlHO0FBQ0gsU0FBZ0IscUJBQXFCLENBQ25DLElBQWMsRUFDZCxjQUE4QixFQUM5QixLQUFnQixFQUNoQixLQUFhLEVBQ2IsS0FBYTtJQUViLE1BQU0sVUFBVSxHQUFHLGNBQWMsQ0FBQyxzQkFBc0IsQ0FBQyxLQUFLLEVBQUUsS0FBSyxDQUFDLENBQUM7SUFDdkUsTUFBTSxVQUFVLEdBQUcsMkJBQWtCLENBQUMsS0FBSyxDQUFDLENBQUM7SUFDN0MsSUFBSSxVQUFVLEtBQUssTUFBTSxJQUFJLFVBQVUsS0FBSyxZQUFZLEVBQUU7UUFDeEQsTUFBTSxPQUFPLEdBQ1gsVU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ICAgICAgfTtcbiAgICAgIH0pLFxuICAgIH0pO1xuICB9IGVsc2Uge1xuICAgIGNvbnN0IHsgc2NyaXB0UHViS2V5LCB3aXRuZXNzU2NyaXB0LCByZWRlZW1TY3JpcHQgfSA9IGNyZWF0ZU91dHB1dFNjcmlwdDJvZjMod2FsbGV0S2V5cy5wdWJsaWNLZXlzLCBzY3JpcHRUeXBlKTtcbiAgICBwc2J0LmFkZE91dHB1dCh7XG4gICAgICBzY3JpcHQ6IHNjcmlwdFB1YktleSxcbiAgICAgIHZhbHVlLFxuICAgICAgYmlwMzJEZXJpdmF0aW9uOiBbMCwgMSwgMl0ubWFwKChpZHgpID0+ICh7XG4gICAgICAgIHB1YmtleTogd2FsbGV0S2V5cy50cmlwbGVbaWR4XS5wdWJsaWNLZXksXG4gICAgICAgIHBhdGg6IHdhbGxldEtleXMucGF0aHNbaWR4XSxcbiAgICAgICAgbWFzdGVyRmluZ2VycHJpbnQ6IHJvb3RXYWxsZXRLZXlzLnRyaXBsZVtpZHhdLmZpbmdlcnByaW50LFxuICAgICAgfSkpLFxuICAgIH0pO1xuICAgIGNvbnN0IG91dHB1dEluZGV4ID0gcHNidC50eE91dHB1dHMubGVuZ3RoIC0gMTtcbiAgICBpZiAod2l0bmVzc1NjcmlwdCkge1xuICAgICAgcHNidC51cGRhdGVPdXRwdXQob3V0cHV0SW5kZXgsIHsgd2l0bmVzc1NjcmlwdCB9KTtcbiAgICB9XG4gICAgaWYgKHJlZGVlbVNjcmlwdCkge1xuICAgICAgcHNidC51cGRhdGVPdXRwdXQob3V0cHV0SW5kZXgsIHsgcmVkZWVtU2NyaXB0IH0pO1xuICAgIH1cbiAgfVxufVxuIl19
@@ -18,7 +18,7 @@ export declare const chainCodesP2shP2wsh: readonly [10, 11];
18
18
  export declare const chainCodesP2wsh: readonly [20, 21];
19
19
  export declare const chainCodesP2tr: readonly [30, 31];
20
20
  export declare const chainCodesP2trMusig2: readonly [40, 41];
21
- export declare const chainCodes: (0 | 1 | 10 | 11 | 20 | 21 | 30 | 31 | 40 | 41)[];
21
+ export declare const chainCodes: (0 | 30 | 1 | 10 | 11 | 20 | 21 | 31 | 40 | 41)[];
22
22
  export declare type ChainCode = (typeof chainCodes)[number];
23
23
  export declare function isChainCode(n: unknown): n is ChainCode;
24
24
  /**
@@ -27,6 +27,7 @@ export declare class ZcashPsbt extends UtxoPsbt<ZcashTransaction<bigint>> {
27
27
  setDefaultsForVersion(network: Network, version: number): void;
28
28
  signInput(inputIndex: number, keyPair: Signer, sighashTypes?: number[]): this;
29
29
  validateSignaturesOfInput(inputIndex: number, validator: ValidateSigFunction, pubkey?: Buffer): boolean;
30
+ private withUnsafeSignNonSegwitTrue;
30
31
  private setPropertyCheckSignatures;
31
32
  setConsensusBranchId(consensusBranchId: number): void;
32
33
  setVersionGroupId(versionGroupId: number): void;
@@ -1 +1 @@
1
- {"version":3,"file":"ZcashPsbt.d.ts","sourceRoot":"","sources":["../../../../src/bitgo/zcash/ZcashPsbt.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAGL,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAmB,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC1D,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAE1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAW7D,qBAAa,SAAU,SAAQ,QAAQ,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC/D,SAAS,CAAC,MAAM,CAAC,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,gBAAgB,CAAC,MAAM,CAAC;IAIlG,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,QAAQ,GAAG,SAAS;IAO7D;;;;;;;OAO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