utxo-lib 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. package/dist/src/address.d.ts.map +1 -1
  2. package/dist/src/address.js +1 -11
  3. package/dist/src/addressFormat.d.ts +1 -1
  4. package/dist/src/addressFormat.d.ts.map +1 -1
  5. package/dist/src/addressFormat.js +1 -1
  6. package/dist/src/bitgo/Musig2.d.ts +17 -115
  7. package/dist/src/bitgo/Musig2.d.ts.map +1 -1
  8. package/dist/src/bitgo/Musig2.js +101 -283
  9. package/dist/src/bitgo/UtxoPsbt.d.ts +49 -173
  10. package/dist/src/bitgo/UtxoPsbt.d.ts.map +1 -1
  11. package/dist/src/bitgo/UtxoPsbt.js +112 -634
  12. package/dist/src/bitgo/bbc/DashPsbt.d.ts +12 -0
  13. package/dist/src/bitgo/bbc/DashPsbt.d.ts.map +1 -0
  14. package/dist/src/bitgo/bbc/DashPsbt.js +27 -0
  15. package/dist/src/bitgo/bbc/DashTransaction.d.ts +39 -0
  16. package/dist/src/bitgo/bbc/DashTransaction.d.ts.map +1 -0
  17. package/dist/src/bitgo/bbc/DashTransaction.js +109 -0
  18. package/dist/src/bitgo/bbc/DashTransactionBuilder.d.ts +14 -0
  19. package/dist/src/bitgo/bbc/DashTransactionBuilder.d.ts.map +1 -0
  20. package/dist/src/bitgo/bbc/DashTransactionBuilder.js +28 -0
  21. package/dist/src/bitgo/bbc/index.d.ts +4 -0
  22. package/dist/src/bitgo/bbc/index.d.ts.map +1 -0
  23. package/dist/src/bitgo/{litecoin → bbc}/index.js +4 -4
  24. package/dist/src/bitgo/bitcoincash/address.js +2 -2
  25. package/dist/src/bitgo/index.d.ts +0 -10
  26. package/dist/src/bitgo/index.d.ts.map +1 -1
  27. package/dist/src/bitgo/index.js +2 -5
  28. package/dist/src/bitgo/outputScripts.d.ts +1 -3
  29. package/dist/src/bitgo/outputScripts.d.ts.map +1 -1
  30. package/dist/src/bitgo/outputScripts.js +10 -18
  31. package/dist/src/bitgo/parseInput.d.ts +20 -49
  32. package/dist/src/bitgo/parseInput.d.ts.map +1 -1
  33. package/dist/src/bitgo/parseInput.js +24 -108
  34. package/dist/src/bitgo/psbt/fromHalfSigned.d.ts.map +1 -1
  35. package/dist/src/bitgo/psbt/fromHalfSigned.js +6 -9
  36. package/dist/src/bitgo/signature.d.ts +3 -3
  37. package/dist/src/bitgo/signature.d.ts.map +1 -1
  38. package/dist/src/bitgo/signature.js +16 -48
  39. package/dist/src/bitgo/transaction.d.ts +3 -18
  40. package/dist/src/bitgo/transaction.d.ts.map +1 -1
  41. package/dist/src/bitgo/transaction.js +15 -28
  42. package/dist/src/bitgo/types.d.ts +0 -2
  43. package/dist/src/bitgo/types.d.ts.map +1 -1
  44. package/dist/src/bitgo/types.js +1 -1
  45. package/dist/src/bitgo/wallet/Psbt.d.ts +12 -90
  46. package/dist/src/bitgo/wallet/Psbt.d.ts.map +1 -1
  47. package/dist/src/bitgo/wallet/Psbt.js +71 -221
  48. package/dist/src/bitgo/wallet/Unspent.d.ts +0 -28
  49. package/dist/src/bitgo/wallet/Unspent.d.ts.map +1 -1
  50. package/dist/src/bitgo/wallet/Unspent.js +68 -173
  51. package/dist/src/bitgo/wallet/chains.d.ts +2 -2
  52. package/dist/src/bitgo/wallet/chains.d.ts.map +1 -1
  53. package/dist/src/bitgo/wallet/chains.js +1 -1
  54. package/dist/src/bitgo/zcash/ZcashPsbt.d.ts.map +1 -1
  55. package/dist/src/bitgo/zcash/ZcashPsbt.js +3 -4
  56. package/dist/src/networks.d.ts +2 -1
  57. package/dist/src/networks.d.ts.map +1 -1
  58. package/dist/src/networks.js +29 -22
  59. package/dist/src/noble_ecc.d.ts.map +1 -1
  60. package/dist/src/noble_ecc.js +2 -6
  61. package/dist/src/payments/p2tr.d.ts.map +1 -1
  62. package/dist/src/payments/p2tr.js +9 -15
  63. package/dist/src/taproot.d.ts +0 -16
  64. package/dist/src/taproot.d.ts.map +1 -1
  65. package/dist/src/taproot.js +2 -44
  66. package/dist/src/testutil/index.d.ts +0 -2
  67. package/dist/src/testutil/index.d.ts.map +1 -1
  68. package/dist/src/testutil/index.js +1 -3
  69. package/dist/src/testutil/mock.d.ts +1 -1
  70. package/dist/src/testutil/mock.d.ts.map +1 -1
  71. package/dist/src/testutil/mock.js +4 -12
  72. package/package.json +4 -6
  73. package/dist/src/bitgo/PsbtUtil.d.ts +0 -54
  74. package/dist/src/bitgo/PsbtUtil.d.ts.map +0 -1
  75. package/dist/src/bitgo/PsbtUtil.js +0 -79
  76. package/dist/src/bitgo/litecoin/LitecoinPsbt.d.ts +0 -10
  77. package/dist/src/bitgo/litecoin/LitecoinPsbt.d.ts.map +0 -1
  78. package/dist/src/bitgo/litecoin/LitecoinPsbt.js +0 -17
  79. package/dist/src/bitgo/litecoin/LitecoinTransaction.d.ts +0 -16
  80. package/dist/src/bitgo/litecoin/LitecoinTransaction.d.ts.map +0 -1
  81. package/dist/src/bitgo/litecoin/LitecoinTransaction.js +0 -46
  82. package/dist/src/bitgo/litecoin/LitecoinTransactionBuilder.d.ts +0 -10
  83. package/dist/src/bitgo/litecoin/LitecoinTransactionBuilder.d.ts.map +0 -1
  84. package/dist/src/bitgo/litecoin/LitecoinTransactionBuilder.js +0 -15
  85. package/dist/src/bitgo/litecoin/index.d.ts +0 -4
  86. package/dist/src/bitgo/litecoin/index.d.ts.map +0 -1
  87. package/dist/src/testutil/psbt.d.ts +0 -71
  88. package/dist/src/testutil/psbt.d.ts.map +0 -1
  89. package/dist/src/testutil/psbt.js +0 -147
  90. package/dist/src/testutil/transaction.d.ts +0 -61
  91. package/dist/src/testutil/transaction.d.ts.map +0 -1
  92. package/dist/src/testutil/transaction.js +0 -107
@@ -1,24 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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
- const assert = require("assert");
5
- const utils_1 = require("bip174/src/lib/utils");
6
- const bs58check = require("bs58check");
7
- const UtxoPsbt_1 = require("../UtxoPsbt");
8
- const UtxoTransaction_1 = require("../UtxoTransaction");
3
+ exports.parsePsbtInput = exports.signWalletPsbt = exports.toWalletPsbt = void 0;
9
4
  const outputScripts_1 = require("../outputScripts");
10
5
  const Unspent_1 = require("../Unspent");
11
6
  const transaction_1 = require("../transaction");
12
7
  const Unspent_2 = require("./Unspent");
8
+ const utils_1 = require("bip174/src/lib/utils");
13
9
  const parseInput_1 = require("../parseInput");
14
- const Musig2_1 = require("../Musig2");
15
- const types_1 = require("../types");
16
- const taproot_1 = require("../../taproot");
17
- const bitcoinjs_lib_1 = require("bitcoinjs-lib");
18
- const index_1 = require("../../index");
19
- const PsbtUtil_1 = require("../PsbtUtil");
20
10
  function getTaprootSigners(script, walletKeys) {
21
- const parsedPublicKeys = parseInput_1.parsePubScript2Of3(script, 'taprootScriptPathSpend').publicKeys;
11
+ const parsedPublicKeys = parseInput_1.parsePubScript(script, 'p2tr').publicKeys;
22
12
  const walletSigners = parsedPublicKeys.map((publicKey) => {
23
13
  const index = walletKeys.publicKeys.findIndex((walletPublicKey) => outputScripts_1.toXOnlyPublicKey(walletPublicKey).equals(publicKey));
24
14
  if (index >= 0) {
@@ -29,14 +19,14 @@ function getTaprootSigners(script, walletKeys) {
29
19
  return [walletSigners[0], walletSigners[1]];
30
20
  }
31
21
  function updatePsbtInput(psbt, inputIndex, unspent, rootWalletKeys) {
32
- const input = utils_1.checkForInput(psbt.data.inputs, inputIndex);
33
- const signatureCount = PsbtUtil_1.getPsbtInputSignatureCount(input);
22
+ const signatureCount = psbt.getSignatureCount(inputIndex);
34
23
  const scriptType = outputScripts_1.scriptTypeForChain(unspent.chain);
35
24
  if (signatureCount === 0 && scriptType === 'p2tr') {
36
25
  return;
37
26
  }
38
27
  const walletKeys = rootWalletKeys.deriveForChainAndIndex(unspent.chain, unspent.index);
39
28
  if (scriptType === 'p2tr') {
29
+ const input = psbt.data.inputs[inputIndex];
40
30
  if (!Array.isArray(input.tapLeafScript) || input.tapLeafScript.length === 0) {
41
31
  throw new Error('Invalid PSBT state. Missing required fields.');
42
32
  }
@@ -85,10 +75,7 @@ function updatePsbtInput(psbt, inputIndex, unspent, rootWalletKeys) {
85
75
  * Signed PSBT for other input with witnessUtxo/nonWitnessUtxo, redeemScript/witnessScript, bip32Derivation, partialSig
86
76
  */
87
77
  function toWalletPsbt(tx, unspents, rootWalletKeys) {
88
- const prevOutputs = unspents.map((u) => {
89
- assert.notStrictEqual(outputScripts_1.scriptTypeForChain(u.chain), 'p2trMusig2');
90
- return Unspent_1.toPrevOutputWithPrevTx(u, tx.network);
91
- });
78
+ const prevOutputs = unspents.map((u) => Unspent_1.toPrevOutputWithPrevTx(u, tx.network));
92
79
  const psbt = transaction_1.createPsbtFromTransaction(tx, prevOutputs);
93
80
  unspents.forEach((u, i) => {
94
81
  if (Unspent_2.isWalletUnspent(u) && u.index !== undefined) {
@@ -106,8 +93,7 @@ exports.toWalletPsbt = toWalletPsbt;
106
93
  * @return signed PSBT with signer's key for unspent
107
94
  */
108
95
  function signWalletPsbt(psbt, inputIndex, signer, unspent) {
109
- const scriptType = outputScripts_1.scriptTypeForChain(unspent.chain);
110
- if (scriptType === 'p2tr' || scriptType === 'p2trMusig2') {
96
+ if (outputScripts_1.scriptTypeForChain(unspent.chain) === 'p2tr') {
111
97
  psbt.signTaprootInputHD(inputIndex, signer);
112
98
  }
113
99
  else {
@@ -115,268 +101,132 @@ function signWalletPsbt(psbt, inputIndex, signer, unspent) {
115
101
  }
116
102
  }
117
103
  exports.signWalletPsbt = signWalletPsbt;
118
- /**
119
- * @returns script type of the input
120
- */
121
- function getPsbtInputScriptType(input) {
122
- const isP2pk = (script) => {
123
- try {
124
- const chunks = bitcoinjs_lib_1.script.decompile(script);
125
- return ((chunks === null || chunks === void 0 ? void 0 : chunks.length) === 2 &&
126
- Buffer.isBuffer(chunks[0]) &&
127
- bitcoinjs_lib_1.script.isCanonicalPubKey(chunks[0]) &&
128
- chunks[1] === index_1.opcodes.OP_CHECKSIG);
129
- }
130
- catch (e) {
131
- return false;
132
- }
133
- };
104
+ function classifyScriptType(input) {
134
105
  let scriptType;
135
106
  if (Buffer.isBuffer(input.redeemScript) && Buffer.isBuffer(input.witnessScript)) {
136
107
  scriptType = 'p2shP2wsh';
137
108
  }
138
109
  else if (Buffer.isBuffer(input.redeemScript)) {
139
- scriptType = isP2pk(input.redeemScript) ? 'p2shP2pk' : 'p2sh';
110
+ scriptType = 'p2sh';
140
111
  }
141
112
  else if (Buffer.isBuffer(input.witnessScript)) {
142
113
  scriptType = 'p2wsh';
143
114
  }
144
115
  if (Array.isArray(input.tapLeafScript) && input.tapLeafScript.length > 0) {
145
116
  if (scriptType) {
146
- throw new Error(`Found both ${scriptType} and taprootScriptPath PSBT metadata.`);
117
+ throw new Error(`Found both ${scriptType} and p2tr PSBT metadata.`);
147
118
  }
148
119
  if (input.tapLeafScript.length > 1) {
149
120
  throw new Error('Bitgo only supports a single tap leaf script per input.');
150
121
  }
151
- scriptType = 'taprootScriptPathSpend';
122
+ scriptType = 'p2tr';
152
123
  }
153
- if (input.tapInternalKey) {
154
- if (scriptType) {
155
- throw new Error(`Found both ${scriptType} and taprootKeyPath PSBT metadata.`);
124
+ return scriptType;
125
+ }
126
+ function parseSignatures(input, scriptType) {
127
+ const validate = (sig) => {
128
+ if (Buffer.isBuffer(sig)) {
129
+ return sig;
156
130
  }
157
- scriptType = 'taprootKeyPathSpend';
158
- }
159
- if (scriptType) {
160
- return scriptType;
131
+ throw new Error('Invalid signature type');
132
+ };
133
+ if (scriptType === 'p2tr') {
134
+ if (input.partialSig && input.partialSig.length > 0) {
135
+ throw new Error('Invalid PSBT signature state');
136
+ }
137
+ if (!input.tapScriptSig || input.tapScriptSig.length === 0) {
138
+ return undefined;
139
+ }
140
+ if (input.tapScriptSig.length > 2) {
141
+ throw new Error('unexpected signature count');
142
+ }
143
+ return input.tapScriptSig.length === 1
144
+ ? [validate(input.tapScriptSig[0].signature)]
145
+ : [validate(input.tapScriptSig[0].signature), validate(input.tapScriptSig[1].signature)];
161
146
  }
162
- throw new Error('could not parse input');
163
- }
164
- exports.getPsbtInputScriptType = getPsbtInputScriptType;
165
- function parseTaprootKeyPathSignatures(input) {
166
- const partialSigs = Musig2_1.parsePsbtMusig2PartialSigs(input);
167
- if (!partialSigs) {
168
- return { signatures: undefined, participantPublicKeys: undefined };
147
+ if (input.tapScriptSig && input.tapScriptSig.length > 0) {
148
+ throw new Error('Invalid PSBT signature state');
169
149
  }
170
- const signatures = partialSigs.map((pSig) => pSig.partialSig);
171
- const participantPublicKeys = partialSigs.map((pSig) => pSig.participantPubKey);
172
- return types_1.isTuple(signatures) && types_1.isTuple(participantPublicKeys)
173
- ? { signatures, participantPublicKeys }
174
- : { signatures: [signatures[0]], participantPublicKeys: [participantPublicKeys[0]] };
175
- }
176
- function parsePartialOrTapScriptSignatures(sig) {
177
- if (!(sig === null || sig === void 0 ? void 0 : sig.length)) {
178
- return { signatures: undefined };
150
+ if (!input.partialSig || input.partialSig.length === 0) {
151
+ return undefined;
179
152
  }
180
- if (sig.length > 2) {
153
+ if (input.partialSig.length > 2) {
181
154
  throw new Error('unexpected signature count');
182
155
  }
183
- const signatures = sig.map((tSig) => tSig.signature);
184
- return types_1.isTuple(signatures) ? { signatures } : { signatures: [signatures[0]] };
185
- }
186
- function parseSignatures(input, scriptType) {
187
- return scriptType === 'taprootKeyPathSpend'
188
- ? parseTaprootKeyPathSignatures(input)
189
- : scriptType === 'taprootScriptPathSpend'
190
- ? parsePartialOrTapScriptSignatures(input.tapScriptSig)
191
- : parsePartialOrTapScriptSignatures(input.partialSig);
156
+ return input.partialSig.length === 1
157
+ ? [validate(input.partialSig[0].signature)]
158
+ : [validate(input.partialSig[0].signature), validate(input.partialSig[1].signature)];
192
159
  }
193
160
  function parseScript(input, scriptType) {
194
- var _a;
195
161
  let pubScript;
196
- if (scriptType === 'p2sh' || scriptType === 'p2shP2pk') {
162
+ if (scriptType === 'p2sh') {
197
163
  pubScript = input.redeemScript;
198
164
  }
199
165
  else if (scriptType === 'p2wsh' || scriptType === 'p2shP2wsh') {
200
166
  pubScript = input.witnessScript;
201
167
  }
202
- else if (scriptType === 'taprootScriptPathSpend') {
168
+ else {
203
169
  pubScript = input.tapLeafScript ? input.tapLeafScript[0].script : undefined;
204
170
  }
205
- else if (scriptType === 'taprootKeyPathSpend') {
206
- if ((_a = input.witnessUtxo) === null || _a === void 0 ? void 0 : _a.script) {
207
- pubScript = input.witnessUtxo.script;
208
- }
209
- else if (input.tapInternalKey && input.tapMerkleRoot) {
210
- pubScript = taproot_1.createTaprootOutputScript({ internalPubKey: input.tapInternalKey, taptreeRoot: input.tapMerkleRoot });
211
- }
212
- }
213
171
  if (!pubScript) {
214
172
  throw new Error(`Invalid PSBT state for ${scriptType}. Missing required fields.`);
215
173
  }
216
174
  return parseInput_1.parsePubScript(pubScript, scriptType);
217
175
  }
218
- /**
219
- * @return psbt metadata are parsed as per below conditions.
220
- * redeemScript/witnessScript/tapLeafScript matches BitGo.
221
- * signature and public key count matches BitGo.
222
- * P2SH-P2PK => scriptType, redeemScript, public key, signature.
223
- * P2SH => scriptType, redeemScript, public keys, signatures.
224
- * PW2SH => scriptType, witnessScript, public keys, signatures.
225
- * P2SH-PW2SH => scriptType, redeemScript, witnessScript, public keys, signatures.
226
- * P2TR and P2TR MUSIG2 script path => scriptType (taprootScriptPathSpend), pubScript (leaf script), controlBlock,
227
- * scriptPathLevel, leafVersion, public keys, signatures.
228
- * P2TR MUSIG2 kep path => scriptType (taprootKeyPathSpend), pubScript (scriptPubKey), participant pub keys (signer),
229
- * public key (tapOutputkey), signatures (partial signer sigs).
230
- */
231
- function parsePsbtInput(input) {
232
- if (PsbtUtil_1.isPsbtInputFinalized(input)) {
233
- throw new Error('Finalized PSBT parsing is not supported');
234
- }
235
- const scriptType = getPsbtInputScriptType(input);
176
+ function parseInputMetadata(input, scriptType) {
236
177
  const parsedPubScript = parseScript(input, scriptType);
237
178
  const signatures = parseSignatures(input, scriptType);
238
- if (parsedPubScript.scriptType === 'taprootKeyPathSpend' && 'participantPublicKeys' in signatures) {
239
- return {
240
- ...parsedPubScript,
241
- ...signatures,
242
- };
243
- }
244
- if (parsedPubScript.scriptType === 'taprootScriptPathSpend') {
179
+ if (parsedPubScript.scriptType === 'p2tr') {
245
180
  if (!input.tapLeafScript) {
246
- throw new Error('Invalid PSBT state for taprootScriptPathSpend. Missing required fields.');
181
+ throw new Error('Invalid PSBT state for p2tr. Missing required fields.');
247
182
  }
248
183
  const controlBlock = input.tapLeafScript[0].controlBlock;
249
184
  if (!parseInput_1.isValidControlBock(controlBlock)) {
250
- throw new Error('Invalid PSBT taprootScriptPathSpend controlBlock.');
185
+ throw new Error('Invalid PSBT p2tr script path controlBlock.');
251
186
  }
252
187
  const scriptPathLevel = parseInput_1.calculateScriptPathLevel(controlBlock);
253
- const leafVersion = parseInput_1.getLeafVersion(controlBlock);
188
+ const leafVersion = parseInput_1.getScriptPathLevel(controlBlock);
254
189
  return {
255
190
  ...parsedPubScript,
256
- ...signatures,
191
+ signatures,
257
192
  controlBlock,
258
193
  scriptPathLevel,
259
194
  leafVersion,
260
195
  };
261
196
  }
262
- if (parsedPubScript.scriptType === 'p2sh' ||
263
- parsedPubScript.scriptType === 'p2wsh' ||
264
- parsedPubScript.scriptType === 'p2shP2wsh') {
197
+ else {
265
198
  if (parsedPubScript.scriptType === 'p2shP2wsh') {
266
199
  parsedPubScript.redeemScript = input.redeemScript;
267
200
  }
268
201
  return {
269
202
  ...parsedPubScript,
270
- ...signatures,
271
- };
272
- }
273
- if (parsedPubScript.scriptType === 'p2shP2pk' && (!signatures.signatures || !types_1.isTuple(signatures.signatures))) {
274
- return {
275
- ...parsedPubScript,
276
- signatures: signatures.signatures,
203
+ signatures,
277
204
  };
278
205
  }
279
- throw new Error('invalid pub script');
280
206
  }
281
- exports.parsePsbtInput = parsePsbtInput;
282
207
  /**
283
- * @returns strictly parse the input and get signature count.
284
- * unsigned(0), half-signed(1) or fully-signed(2)
285
- */
286
- function getStrictSignatureCount(input) {
287
- var _a, _b;
288
- const calculateSignatureCount = (signatures) => {
289
- const count = signatures ? signatures.filter((s) => !parseInput_1.isPlaceholderSignature(s)).length : 0;
290
- if (count === 0 || count === 1 || count === 2) {
291
- return count;
292
- }
293
- throw new Error('invalid signature count');
294
- };
295
- if ('hash' in input) {
296
- if (((_a = input.script) === null || _a === void 0 ? void 0 : _a.length) || ((_b = input.witness) === null || _b === void 0 ? void 0 : _b.length)) {
297
- const parsedInput = parseInput_1.parseSignatureScript(input);
298
- return parsedInput.scriptType === 'taprootKeyPathSpend' ? 2 : calculateSignatureCount(parsedInput.signatures);
299
- }
300
- return 0;
301
- }
302
- else {
303
- return calculateSignatureCount(parsePsbtInput(input).signatures);
304
- }
305
- }
306
- exports.getStrictSignatureCount = getStrictSignatureCount;
307
- /**
308
- * @returns strictly parse input and get signature count for all inputs.
309
- * 0=unsigned, 1=half-signed or 2=fully-signed
310
- */
311
- function getStrictSignatureCounts(tx) {
312
- const inputs = tx instanceof UtxoPsbt_1.UtxoPsbt ? tx.data.inputs : tx instanceof UtxoTransaction_1.UtxoTransaction ? tx.ins : tx;
313
- return inputs.map((input, _) => getStrictSignatureCount(input));
314
- }
315
- exports.getStrictSignatureCounts = getStrictSignatureCounts;
316
- /**
317
- * @return true iff inputs array is of PsbtInputType type
318
- * */
319
- function isPsbtInputArray(inputs) {
320
- return !isTxInputArray(inputs);
321
- }
322
- exports.isPsbtInputArray = isPsbtInputArray;
323
- /**
324
- * @return true iff inputs array is of TxInput type
325
- * */
326
- function isTxInputArray(inputs) {
327
- assert(!!inputs.length, 'empty inputs array');
328
- return 'hash' in inputs[0];
329
- }
330
- exports.isTxInputArray = isTxInputArray;
331
- /**
332
- * @returns true iff given psbt/transaction/tx-input-array/psbt-input-array contains at least one taproot key path spend input
208
+ * @return psbt metadata are parsed as per below conditions.
209
+ * redeemScript/witnessScript/tapLeafScript matches BitGo.
210
+ * signature and public key count matches BitGo.
211
+ * P2SH => scriptType, redeemScript, public keys, signatures.
212
+ * PW2SH => scriptType, witnessScript, public keys, signatures.
213
+ * P2SH-PW2SH => scriptType, redeemScript, witnessScript, public keys, signatures.
214
+ * P2TR => scriptType, pubScript (witnessScript), controlBlock, scriptPathLevel, leafVersion, public keys, signatures.
215
+ * Any unsigned PSBT and without required metadata is returned with undefined.
333
216
  */
334
- function isTransactionWithKeyPathSpendInput(data) {
335
- const inputs = data instanceof UtxoPsbt_1.UtxoPsbt ? data.data.inputs : data instanceof UtxoTransaction_1.UtxoTransaction ? data.ins : data;
336
- if (!inputs.length) {
337
- return false;
338
- }
339
- if (isPsbtInputArray(inputs)) {
340
- return inputs.some((input, _) => getPsbtInputScriptType(input) === 'taprootKeyPathSpend');
217
+ function parsePsbtInput(psbt, inputIndex) {
218
+ const input = utils_1.checkForInput(psbt.data.inputs, inputIndex);
219
+ if (psbt.isInputFinalized(inputIndex)) {
220
+ throw new Error('Finalized PSBT parsing is not supported');
341
221
  }
342
- return inputs.some((input, _) => {
343
- // If the input is not signed, it cannot be a taprootKeyPathSpend input because you can only
344
- // extract a fully signed psbt into a transaction with taprootKeyPathSpend inputs.
345
- if (getStrictSignatureCount(input) === 0) {
346
- return false;
222
+ const scriptType = classifyScriptType(input);
223
+ if (!scriptType) {
224
+ if (psbt.getSignatureCount(inputIndex) > 0) {
225
+ throw new Error('Invalid PSBT state. Signatures found without scripts.');
347
226
  }
348
- return parseInput_1.parseSignatureScript(input).scriptType === 'taprootKeyPathSpend';
349
- });
350
- }
351
- exports.isTransactionWithKeyPathSpendInput = isTransactionWithKeyPathSpendInput;
352
- /**
353
- * Set the RootWalletKeys as the globalXpubs on the psbt
354
- *
355
- * We do all the matching of the (tap)bip32Derivations masterFingerprint to the fingerprint of the
356
- * extendedPubkey.
357
- */
358
- function addXpubsToPsbt(psbt, rootWalletKeys) {
359
- const xPubs = rootWalletKeys.triple.map((bip32) => ({
360
- extendedPubkey: bs58check.decode(bip32.toBase58()),
361
- masterFingerprint: bip32.fingerprint,
362
- // TODO: BG-73797 - bip174 currently requires m prefix for this to be a valid globalXpub
363
- path: 'm',
364
- }));
365
- psbt.updateGlobal({ globalXpub: xPubs });
366
- }
367
- exports.addXpubsToPsbt = addXpubsToPsbt;
368
- /**
369
- * validates signatures for each 2 of 3 input against user, backup, bitgo keys derived from rootWalletKeys.
370
- * @returns array of input index and its [is valid user sig exist, is valid backup sig exist, is valid user bitgo exist]
371
- * For p2shP2pk input, [false, false, false] is returned since it is not a 2 of 3 sig input.
372
- */
373
- function getSignatureValidationArrayPsbt(psbt, rootWalletKeys) {
374
- return psbt.data.inputs.map((input, i) => {
375
- const sigValArrayForInput = getPsbtInputScriptType(input) === 'p2shP2pk'
376
- ? [false, false, false]
377
- : psbt.getSignatureValidationArray(i, { rootNodes: rootWalletKeys.triple });
378
- return [i, sigValArrayForInput];
379
- });
227
+ return undefined;
228
+ }
229
+ return parseInputMetadata(input, scriptType);
380
230
  }
381
- exports.getSignatureValidationArrayPsbt = getSignatureValidationArrayPsbt;
382
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUHNidC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9iaXRnby93YWxsZXQvUHNidC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxpQ0FBaUM7QUFHakMsZ0RBQXFEO0FBRXJELHVDQUF1QztBQUN2QywwQ0FBdUM7QUFDdkMsd0RBQXFEO0FBQ3JELG9EQUE2RztBQUU3Ryx3Q0FBb0Q7QUFDcEQsZ0RBQTJEO0FBQzNELHVDQUEyRDtBQUUzRCw4Q0FjdUI7QUFDdkIsc0NBQXVEO0FBQ3ZEL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xuICB9XG4gIGNvbnN0IHNjcmlwdFR5cGUgPSBjbGFzc2lmeVNjcmlwdFR5cGUoaW5wdXQpO1xuICBpZiAoIXNjcmlwdFR5cGUpIHtcbiAgICBpZiAocHNidC5nZXRTaWduYXR1cmVDb3VudChpbnB1dEluZGV4KSA+IDApIHtcbiAgICAgIHRocm93IG5ldyBFcnJvcignSW52YWxpZCBQU0JUIHN0YXRlLiBTaWduYXR1cmVzIGZvdW5kIHdpdGhvdXQgc2NyaXB0cy4nKTtcbiAgICB9XG4gICAgcmV0dXJuIHVuZGVmaW5lZDtcbiAgfVxuICByZXR1cm4gcGFyc2VJbnB1dE1ldGFkYXRhKGlucHV0LCBzY3JpcHRUeXBlKTtcbn1cbiJdfQ==
@@ -11,8 +11,6 @@ import { UtxoPsbt } from '../UtxoPsbt';
11
11
  export interface WalletUnspent<TNumber extends number | bigint = number> extends Unspent<TNumber> {
12
12
  chain: ChainCode;
13
13
  index: number;
14
- witnessScript?: string;
15
- valueString?: string;
16
14
  }
17
15
  export interface NonWitnessWalletUnspent<TNumber extends number | bigint = number> extends UnspentWithPrevTx<TNumber>, WalletUnspent<TNumber> {
18
16
  }
@@ -36,37 +34,11 @@ export interface WalletUnspentLegacy<TNumber extends number | bigint = number> e
36
34
  /** @deprecated - obviated by verifyWithUnspent */
37
35
  witnessScript?: string;
38
36
  }
39
- /**
40
- * @param psbt
41
- * @param inputIndex
42
- * @param id Unspent ID
43
- * @returns true iff the unspent ID on the unspent and psbt input match
44
- */
45
- export declare function psbtIncludesUnspentAtIndex(psbt: UtxoPsbt, inputIndex: number, id: string): boolean;
46
- /**
47
- * Update the psbt input at the given index
48
- * @param psbt
49
- * @param inputIndex
50
- * @param u
51
- * @param redeemScript Only overrides if there is no redeemScript in the input currently
52
- */
53
- export declare function updateReplayProtectionUnspentToPsbt(psbt: UtxoPsbt, inputIndex: number, u: Unspent<bigint>, redeemScript?: Buffer): void;
54
37
  export declare function addReplayProtectionUnspentToPsbt(psbt: UtxoPsbt, u: Unspent<bigint>, redeemScript: Buffer,
55
38
  /**
56
39
  * @deprecated
57
40
  */
58
41
  network?: Network): void;
59
- /**
60
- * Update the PSBT with the unspent data for the input at the given index if the data is not there already.
61
- *
62
- * @param psbt
63
- * @param inputIndex
64
- * @param u
65
- * @param rootWalletKeys
66
- * @param signer
67
- * @param cosigner
68
- */
69
- export declare function updateWalletUnspentForPsbt(psbt: UtxoPsbt, inputIndex: number, u: WalletUnspent<bigint>, rootWalletKeys: RootWalletKeys, signer: KeyName, cosigner: KeyName): void;
70
42
  export declare function addWalletUnspentToPsbt(psbt: UtxoPsbt, u: WalletUnspent<bigint>, rootWalletKeys: RootWalletKeys, signer: KeyName, cosigner: KeyName,
71
43
  /**
72
44
  * @deprecated
@@ -1 +1 @@
1
- {"version":3,"file":"Unspent.d.ts","sourceRoot":"","sources":["../../../../src/bitgo/wallet/Unspent.ts"],"names":[],"mappings":";AAAA,OAAO,EAAc,OAAO,EAAY,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAgBnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAEL,iBAAiB,EACjB,OAAO,EAKR,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAY,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAOvC,MAAM,WAAW,aAAa,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,CAAE,SAAQ,OAAO,CAAC,OAAO,CAAC;IAC/F,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,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