utxo-lib 1.0.9 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. package/README.md +19 -16
  2. package/dist/src/address.d.ts.map +1 -1
  3. package/dist/src/address.js +11 -1
  4. package/dist/src/addressFormat.d.ts +1 -1
  5. package/dist/src/addressFormat.d.ts.map +1 -1
  6. package/dist/src/addressFormat.js +1 -1
  7. package/dist/src/bitgo/Musig2.d.ts +115 -17
  8. package/dist/src/bitgo/Musig2.d.ts.map +1 -1
  9. package/dist/src/bitgo/Musig2.js +283 -100
  10. package/dist/src/bitgo/PsbtUtil.d.ts +59 -0
  11. package/dist/src/bitgo/PsbtUtil.d.ts.map +1 -0
  12. package/dist/src/bitgo/PsbtUtil.js +92 -0
  13. package/dist/src/bitgo/UtxoPsbt.d.ts +180 -47
  14. package/dist/src/bitgo/UtxoPsbt.d.ts.map +1 -1
  15. package/dist/src/bitgo/UtxoPsbt.js +673 -113
  16. package/dist/src/bitgo/UtxoTransaction.js +2 -2
  17. package/dist/src/bitgo/bitcoincash/address.js +2 -2
  18. package/dist/src/bitgo/index.d.ts +11 -0
  19. package/dist/src/bitgo/index.d.ts.map +1 -1
  20. package/dist/src/bitgo/index.js +6 -2
  21. package/dist/src/bitgo/legacysafe/index.d.ts +15 -0
  22. package/dist/src/bitgo/legacysafe/index.d.ts.map +1 -0
  23. package/dist/src/bitgo/legacysafe/index.js +61 -0
  24. package/dist/src/bitgo/litecoin/LitecoinPsbt.d.ts +10 -0
  25. package/dist/src/bitgo/litecoin/LitecoinPsbt.d.ts.map +1 -0
  26. package/dist/src/bitgo/litecoin/LitecoinPsbt.js +17 -0
  27. package/dist/src/bitgo/litecoin/LitecoinTransaction.d.ts +16 -0
  28. package/dist/src/bitgo/litecoin/LitecoinTransaction.d.ts.map +1 -0
  29. package/dist/src/bitgo/litecoin/LitecoinTransaction.js +46 -0
  30. package/dist/src/bitgo/litecoin/LitecoinTransactionBuilder.d.ts +10 -0
  31. package/dist/src/bitgo/litecoin/LitecoinTransactionBuilder.d.ts.map +1 -0
  32. package/dist/src/bitgo/litecoin/LitecoinTransactionBuilder.js +15 -0
  33. package/dist/src/bitgo/litecoin/index.d.ts +4 -0
  34. package/dist/src/bitgo/litecoin/index.d.ts.map +1 -0
  35. package/dist/src/bitgo/litecoin/index.js +16 -0
  36. package/dist/src/bitgo/outputScripts.d.ts +3 -1
  37. package/dist/src/bitgo/outputScripts.d.ts.map +1 -1
  38. package/dist/src/bitgo/outputScripts.js +20 -12
  39. package/dist/src/bitgo/parseInput.d.ts +49 -20
  40. package/dist/src/bitgo/parseInput.d.ts.map +1 -1
  41. package/dist/src/bitgo/parseInput.js +110 -26
  42. package/dist/src/bitgo/psbt/fromHalfSigned.d.ts.map +1 -1
  43. package/dist/src/bitgo/psbt/fromHalfSigned.js +9 -6
  44. package/dist/src/bitgo/psbt/scriptTypes.js +3 -3
  45. package/dist/src/bitgo/signature.d.ts +3 -3
  46. package/dist/src/bitgo/signature.d.ts.map +1 -1
  47. package/dist/src/bitgo/signature.js +48 -16
  48. package/dist/src/bitgo/transaction.d.ts +18 -3
  49. package/dist/src/bitgo/transaction.d.ts.map +1 -1
  50. package/dist/src/bitgo/transaction.js +28 -15
  51. package/dist/src/bitgo/types.d.ts +2 -0
  52. package/dist/src/bitgo/types.d.ts.map +1 -1
  53. package/dist/src/bitgo/types.js +1 -1
  54. package/dist/src/bitgo/wallet/Psbt.d.ts +104 -12
  55. package/dist/src/bitgo/wallet/Psbt.d.ts.map +1 -1
  56. package/dist/src/bitgo/wallet/Psbt.js +288 -70
  57. package/dist/src/bitgo/wallet/Unspent.d.ts +28 -0
  58. package/dist/src/bitgo/wallet/Unspent.d.ts.map +1 -1
  59. package/dist/src/bitgo/wallet/Unspent.js +173 -68
  60. package/dist/src/bitgo/wallet/WalletOutput.d.ts +17 -1
  61. package/dist/src/bitgo/wallet/WalletOutput.d.ts.map +1 -1
  62. package/dist/src/bitgo/wallet/WalletOutput.js +64 -23
  63. package/dist/src/bitgo/wallet/chains.d.ts +2 -2
  64. package/dist/src/bitgo/wallet/chains.d.ts.map +1 -1
  65. package/dist/src/bitgo/wallet/chains.js +1 -1
  66. package/dist/src/bitgo/zcash/ZcashPsbt.d.ts +0 -1
  67. package/dist/src/bitgo/zcash/ZcashPsbt.d.ts.map +1 -1
  68. package/dist/src/bitgo/zcash/ZcashPsbt.js +8 -15
  69. package/dist/src/bitgo/zcash/ZcashTransaction.js +2 -2
  70. package/dist/src/musig.d.ts +0 -1
  71. package/dist/src/musig.d.ts.map +1 -1
  72. package/dist/src/musig.js +15 -29
  73. package/dist/src/networks.d.ts +1 -2
  74. package/dist/src/networks.d.ts.map +1 -1
  75. package/dist/src/networks.js +22 -29
  76. package/dist/src/noble_ecc.d.ts +1 -1
  77. package/dist/src/noble_ecc.d.ts.map +1 -1
  78. package/dist/src/noble_ecc.js +9 -5
  79. package/dist/src/payments/p2tr.d.ts.map +1 -1
  80. package/dist/src/payments/p2tr.js +25 -15
  81. package/dist/src/payments/p2tr_ns.js +3 -2
  82. package/dist/src/taproot.d.ts +16 -0
  83. package/dist/src/taproot.d.ts.map +1 -1
  84. package/dist/src/taproot.js +46 -3
  85. package/dist/src/testutil/index.d.ts +2 -0
  86. package/dist/src/testutil/index.d.ts.map +1 -1
  87. package/dist/src/testutil/index.js +3 -1
  88. package/dist/src/testutil/keys.d.ts +3 -0
  89. package/dist/src/testutil/keys.d.ts.map +1 -1
  90. package/dist/src/testutil/keys.js +17 -2
  91. package/dist/src/testutil/mock.d.ts +1 -1
  92. package/dist/src/testutil/mock.d.ts.map +1 -1
  93. package/dist/src/testutil/mock.js +12 -4
  94. package/dist/src/testutil/psbt.d.ts +89 -0
  95. package/dist/src/testutil/psbt.d.ts.map +1 -0
  96. package/dist/src/testutil/psbt.js +150 -0
  97. package/dist/src/testutil/transaction.d.ts +70 -0
  98. package/dist/src/testutil/transaction.d.ts.map +1 -0
  99. package/dist/src/testutil/transaction.js +107 -0
  100. package/dist/src/transaction_builder.js +2 -2
  101. package/package.json +7 -6
@@ -3,10 +3,11 @@
3
3
  // https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki
4
4
  // https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getTweakedOutputKey = exports.getTaptreeRoot = exports.getTapleafHash = exports.parseControlBlock = exports.parseTaprootWitness = exports.getControlBlock = exports.getHuffmanTaptree = exports.getDepthFirstTaptree = exports.tapTweakPubkey = exports.tapTweakPrivkey = exports.hashTapBranch = exports.hashTapLeaf = exports.serializeScriptSize = exports.aggregateMuSigPubkeys = exports.INITIAL_TAPSCRIPT_VERSION = exports.EVEN_Y_COORD_PREFIX = void 0;
6
+ exports.getTaprootOutputKey = exports.createTaprootOutputScript = exports.getTweakedOutputKey = exports.getTaptreeRoot = exports.getTapleafHash = exports.parseControlBlock = exports.parseTaprootWitness = exports.getControlBlock = exports.getHuffmanTaptree = exports.getDepthFirstTaptree = exports.tapTweakPubkey = exports.tapTweakPrivkey = exports.calculateTapTweak = exports.hashTapBranch = exports.hashTapLeaf = exports.serializeScriptSize = exports.aggregateMuSigPubkeys = exports.INITIAL_TAPSCRIPT_VERSION = exports.EVEN_Y_COORD_PREFIX = void 0;
7
7
  const assert = require("assert");
8
8
  const FastPriorityQueue = require("fastpriorityqueue");
9
9
  const bitcoinjs_lib_1 = require("bitcoinjs-lib");
10
+ const noble_ecc_1 = require("./noble_ecc");
10
11
  const varuint = require('varuint-bitcoin');
11
12
  /**
12
13
  * The 0x02 prefix indicating an even Y coordinate which is implicitly assumed
@@ -96,7 +97,13 @@ function hashTapBranch(child1, child2) {
96
97
  }
97
98
  exports.hashTapBranch = hashTapBranch;
98
99
  function calculateTapTweak(pubkey, taptreeRoot) {
100
+ if (pubkey.length !== 32) {
101
+ throw new Error(`Invalid pubkey size ${pubkey.length}.`);
102
+ }
99
103
  if (taptreeRoot) {
104
+ if (taptreeRoot.length !== 32) {
105
+ throw new Error(`Invalid taptreeRoot size ${taptreeRoot.length}.`);
106
+ }
100
107
  return bitcoinjs_lib_1.crypto.taggedHash('TapTweak', Buffer.concat([pubkey, taptreeRoot]));
101
108
  }
102
109
  // If the spending conditions do not require a script path, the output key should commit to an
@@ -104,6 +111,7 @@ function calculateTapTweak(pubkey, taptreeRoot) {
104
111
  // https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#cite_note-22
105
112
  return bitcoinjs_lib_1.crypto.taggedHash('TapTweak', Buffer.from(pubkey));
106
113
  }
114
+ exports.calculateTapTweak = calculateTapTweak;
107
115
  /**
108
116
  * Tweaks a privkey, using the tagged hash of its pubkey, and (optionally) a taptree root
109
117
  * @param ecc Elliptic curve implementation
@@ -373,11 +381,46 @@ function getTaptreeRoot(ecc, controlBlock, tapscript, tapleafHash) {
373
381
  }
374
382
  exports.getTaptreeRoot = getTaptreeRoot;
375
383
  function getTweakedOutputKey(payment) {
384
+ var _a;
376
385
  assert(payment.output);
377
386
  if (payment.output.length === 34) {
378
- return payment.output?.subarray(2);
387
+ return (_a = payment.output) === null || _a === void 0 ? void 0 : _a.subarray(2);
379
388
  }
380
389
  throw new Error(`invalid p2tr tweaked output key size ${payment.output.length}`);
381
390
  }
382
391
  exports.getTweakedOutputKey = getTweakedOutputKey;
383
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFwcm9vdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90YXByb290LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxvRUFBb0U7QUFDcEUsaUVBQWlFO0FBQ2pFLGlFQUFpRTs7O0FBR2pFLGlDQUFrQztBQUNsQyx1REFBd0Q7QUFDeEQsaURBQTRGO0FBQzVGLE1BQU0sT0FBTyxHQUFHLE9BQU8sQ0FBQyxpQkFBaUIsQ0FBQyxDQUFDO0FBRTNDOzs7R0FHRztBQUNVLFFBQUEsbUJBQW1CLEdBQUcs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gIHJldHVybiBwYXltZW50Lm91dHB1dD8uc3ViYXJyYXkoMik7XG4gIH1cbiAgdGhyb3cgbmV3IEVycm9yKGBpbnZhbGlkIHAydHIgdHdlYWtlZCBvdXRwdXQga2V5IHNpemUgJHtwYXltZW50Lm91dHB1dC5sZW5ndGh9YCk7XG59XG4iXX0=
392
+ /**
393
+ * @returns output script for either script path input controlBlock
394
+ * & leafScript OR key path input internalPubKey & taptreeRoot
395
+ */
396
+ function createTaprootOutputScript(p2trArgs) {
397
+ let internalPubKey;
398
+ let taptreeRoot;
399
+ if ('internalPubKey' in p2trArgs) {
400
+ internalPubKey = p2trArgs.internalPubKey;
401
+ taptreeRoot = p2trArgs.taptreeRoot;
402
+ }
403
+ else {
404
+ internalPubKey = parseControlBlock(noble_ecc_1.ecc, p2trArgs.controlBlock).internalPubkey;
405
+ taptreeRoot = getTaptreeRoot(noble_ecc_1.ecc, p2trArgs.controlBlock, p2trArgs.leafScript);
406
+ }
407
+ const outputKey = tapTweakPubkey(noble_ecc_1.ecc, internalPubKey, taptreeRoot).xOnlyPubkey;
408
+ return bitcoinjs_lib_1.script.compile([bitcoinjs_lib_1.script.OPS.OP_1, Buffer.from(outputKey)]);
409
+ }
410
+ exports.createTaprootOutputScript = createTaprootOutputScript;
411
+ /**
412
+ * @returns x-only taproot output key (tapOutputKey)
413
+ */
414
+ function getTaprootOutputKey(outputScript) {
415
+ const outputDecompiled = bitcoinjs_lib_1.script.decompile(outputScript);
416
+ if ((outputDecompiled === null || outputDecompiled === void 0 ? void 0 : outputDecompiled.length) !== 2) {
417
+ throw new Error('invalid taproot output script');
418
+ }
419
+ const [op1, outputKey] = outputDecompiled;
420
+ if (op1 !== bitcoinjs_lib_1.script.OPS.OP_1 || !Buffer.isBuffer(outputKey) || outputKey.length !== 32) {
421
+ throw new Error('invalid taproot output script');
422
+ }
423
+ return outputKey;
424
+ }
425
+ exports.getTaprootOutputKey = getTaprootOutputKey;
426
+ //# sourceMappingURL=data:application/json;base64,eyJ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oJ2ludmFsaWQgdGFwcm9vdCBvdXRwdXQgc2NyaXB0Jyk7XG4gIH1cbiAgY29uc3QgW29wMSwgb3V0cHV0S2V5XSA9IG91dHB1dERlY29tcGlsZWQ7XG4gIGlmIChvcDEgIT09IGJzY3JpcHQuT1BTLk9QXzEgfHwgIUJ1ZmZlci5pc0J1ZmZlcihvdXRwdXRLZXkpIHx8IG91dHB1dEtleS5sZW5ndGggIT09IDMyKSB7XG4gICAgdGhyb3cgbmV3IEVycm9yKCdpbnZhbGlkIHRhcHJvb3Qgb3V0cHV0IHNjcmlwdCcpO1xuICB9XG4gIHJldHVybiBvdXRwdXRLZXk7XG59XG4iXX0=
@@ -1,3 +1,5 @@
1
1
  export * from './keys';
2
2
  export * from './mock';
3
+ export * from './psbt';
4
+ export * from './transaction';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/testutil/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/testutil/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC"}
@@ -12,4 +12,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./keys"), exports);
14
14
  __exportStar(require("./mock"), exports);
15
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvdGVzdHV0aWwvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7O0FBQUEseUNBQXVCO0FBQ3ZCLHlDQUF1QiIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCAqIGZyb20gJy4va2V5cyc7XG5leHBvcnQgKiBmcm9tICcuL21vY2snO1xuIl19
15
+ __exportStar(require("./psbt"), exports);
16
+ __exportStar(require("./transaction"), exports);
17
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvdGVzdHV0aWwvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7O0FBQUEseUNBQXVCO0FBQ3ZCLHlDQUF1QjtBQUN2Qix5Q0FBdUI7QUFDdkIsZ0RBQThCIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSAnLi9rZXlzJztcbmV4cG9ydCAqIGZyb20gJy4vbW9jayc7XG5leHBvcnQgKiBmcm9tICcuL3BzYnQnO1xuZXhwb3J0ICogZnJvbSAnLi90cmFuc2FjdGlvbic7XG4iXX0=
@@ -1,9 +1,12 @@
1
1
  import { BIP32Interface } from 'bip32';
2
2
  import { Triple } from '../bitgo';
3
3
  import { RootWalletKeys } from '../bitgo';
4
+ import { ECPairInterface } from '../noble_ecc';
4
5
  export declare type KeyTriple = Triple<BIP32Interface>;
6
+ export declare type UncompressedKeyTriple = Triple<ECPairInterface>;
5
7
  export declare function getKey(seed: string): BIP32Interface;
6
8
  export declare function getKeyTriple(seed: string): KeyTriple;
9
+ export declare function getUncompressedKeyTriple(inputs: Triple<number>): UncompressedKeyTriple;
7
10
  export declare function getKeyName(triple: Triple<BIP32Interface>, k: BIP32Interface): string | undefined;
8
11
  export declare function getDefaultCosigner<T>(keyset: Triple<T>, signer: T): T;
9
12
  export declare function getDefaultWalletKeys(): RootWalletKeys;
@@ -1 +1 @@
1
- {"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../../src/testutil/keys.ts"],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B,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,cAAc,GAAG,MAAM,GAAG,SAAS,CAEhG;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAarE;AAED,wBAAgB,oBAAoB,IAAI,cAAc,CAErD"}
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDefaultWalletKeys = exports.getDefaultCosigner = exports.getKeyName = exports.getKeyTriple = exports.getKey = void 0;
3
+ exports.getDefaultWalletKeys = exports.getDefaultCosigner = exports.getKeyName = exports.getUncompressedKeyTriple = exports.getKeyTriple = exports.getKey = void 0;
4
4
  const bip32_1 = require("bip32");
5
5
  const crypto = require("crypto");
6
6
  const bitgo_1 = require("../bitgo");
7
7
  const noble_ecc_1 = require("../noble_ecc");
8
+ const networks_1 = require("../networks");
8
9
  const bip32 = bip32_1.BIP32Factory(noble_ecc_1.ecc);
9
10
  function getKey(seed) {
10
11
  return bip32.fromSeed(crypto.createHash('sha256').update(seed).digest());
@@ -14,6 +15,20 @@ function getKeyTriple(seed) {
14
15
  return [getKey(seed + '.0'), getKey(seed + '.1'), getKey(seed + '.2')];
15
16
  }
16
17
  exports.getKeyTriple = getKeyTriple;
18
+ function getUncompressedKey(input) {
19
+ // Using input for deterministic randomness
20
+ return noble_ecc_1.ECPair.makeRandom({
21
+ compressed: false,
22
+ network: networks_1.networks.testnet,
23
+ rng: () => {
24
+ return Buffer.alloc(32, input);
25
+ },
26
+ });
27
+ }
28
+ function getUncompressedKeyTriple(inputs) {
29
+ return [getUncompressedKey(inputs[0]), getUncompressedKey(inputs[1]), getUncompressedKey(inputs[2])];
30
+ }
31
+ exports.getUncompressedKeyTriple = getUncompressedKeyTriple;
17
32
  function getKeyName(triple, k) {
18
33
  return ['user', 'backup', 'bitgo'][triple.indexOf(k)];
19
34
  }
@@ -37,4 +52,4 @@ function getDefaultWalletKeys() {
37
52
  return new bitgo_1.RootWalletKeys(getKeyTriple('default'));
38
53
  }
39
54
  exports.getDefaultWalletKeys = getDefaultWalletKeys;
40
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoia2V5cy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy90ZXN0dXRpbC9rZXlzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLGlDQUErRDtBQUMvRCxpQ0FBaUM7QUFHakMsb0NBQTBDO0FBQzFDLDRDQUFtQztBQUVuQyxNQUFNLEtBQUssR0FBYSxvQkFBWSxDQUFDLGVBQUcsQ0FBQyxDQUFDO0FBSTFDLFNBQWdCLE1BQU0sQ0FBQyxJQUFZO0lBQ2pDLE9BQU8sS0FBSyxDQUFDLFFBQVEsQ0FBQyxNQUFNLENBQUMsVUFBVSxDQUFDLFFBQVEsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxDQUFDO0FBQzNFLENBQUM7QUFGRCx3QkFFQztBQUVELFNBQWdCLFlBQVksQ0FBQyxJQUFZO0lBQ3ZDLE9BQU8sQ0FBQyxNQUFNLENBQUMsSUFBSSxHQUFHLElBQUksQ0FBQyxFQUFFLE1BQU0sQ0FBQyxJQUFJLEdBQUcsSUFBSSxDQUFDLEVBQUUsTUFBTSxDQUFDLElBQUksR0FBRyxJQUFJLENBQUMsQ0FBQyxDQUFDO0FBQ3pFLENBQUM7QUFGRCxvQ0FFQztBQUVELFNBQWdCLFVBQVUsQ0FBQyxNQUE4QixFQUFFLENBQWlCO0lBQzFFLE9BQU8sQ0FBQyxNQUFNLEVBQUUsUUFBUSxFQUFFLE9BQU8sQ0FBQyxDQUFDLE1BQU0sQ0FBQyxPQUFPLENBQUMsQ0FB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IHJldHVybiB1c2VyO1xuICB9XG4gIHRocm93IG5ldyBFcnJvcihgc2lnbmVyIG5vdCBpbiBwdWJrZXlzYCk7XG59XG5cbmV4cG9ydCBmdW5jdGlvbiBnZXREZWZhdWx0V2FsbGV0S2V5cygpOiBSb290V2FsbGV0S2V5cyB7XG4gIHJldHVybiBuZXcgUm9vdFdhbGxldEtleXMoZ2V0S2V5VHJpcGxlKCdkZWZhdWx0JykpO1xufVxuIl19
@@ -17,5 +17,5 @@ export declare function mockWalletUnspent<TNumber extends number | bigint>(netwo
17
17
  vout?: number;
18
18
  id?: string;
19
19
  }): WalletUnspent<TNumber> | NonWitnessWalletUnspent<TNumber>;
20
- export declare function mockUnspents<TNumber extends number | bigint>(rootWalletKeys: RootWalletKeys, inputScriptTypes: InputType[], testOutputAmount: TNumber, network: Network): WalletUnspent<TNumber>[];
20
+ export declare function mockUnspents<TNumber extends number | bigint>(rootWalletKeys: RootWalletKeys, inputScriptTypes: (InputType | outputScripts.ScriptTypeP2shP2pk)[], testOutputAmount: TNumber, network: Network): (Unspent<TNumber> | WalletUnspent<TNumber>)[];
21
21
  //# sourceMappingURL=mock.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../../src/testutil/mock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,EAAc,OAAO,EAAY,MAAM,aAAa,CAAC;AAE5D,OAAO,EACL,SAAS,EAMT,uBAAuB,EACvB,aAAa,EACb,cAAc,EAEd,OAAO,EACP,iBAAiB,EACjB,eAAe,EACf,aAAa,EACd,MAAM,UAAU,CAAC;AAMlB,oBAAY,SAAS,GAAG,aAAa,CAAC,cAAc,CAAC;AAErD,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,OAAO,GACf,eAAe,CAAC,MAAM,CAAC,C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AG,uBAAuB,CAAC,OAAO,CAAC,CA0B3D;AAED,wBAAgB,YAAY,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EAC1D,cAAc,EAAE,cAAc,EAC9B,gBAAgB,EAAE,CAAC,SAAS,GAAG,aAAa,CAAC,kBAAkB,CAAC,EAAE,EAClE,gBAAgB,EAAE,OAAO,EACzB,OAAO,EAAE,OAAO,GACf,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC,EAAE,CAgB/C"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mockUnspents = exports.mockWalletUnspent = exports.mockReplayProtectionUnspent = exports.isReplayProtectionUnspent = exports.replayProtectionKeyPair = exports.mockPrevTx = void 0;
4
+ const assert = require("assert");
4
5
  const noble = require("@noble/secp256k1");
5
6
  const utxolib = require("..");
6
7
  const networks_1 = require("../networks");
@@ -10,8 +11,9 @@ const outputScripts_1 = require("../bitgo/outputScripts");
10
11
  const keys_1 = require("./keys");
11
12
  function mockPrevTx(vout, outputScript, value, network) {
12
13
  const psbtFromNetwork = bitgo_1.createPsbtForNetwork({ network });
13
- const privKey = noble.utils.randomPrivateKey();
14
- const pubkey = Buffer.from(noble.getPublicKey(privKey, true));
14
+ const keypair = keys_1.getKey('mock-prev-tx');
15
+ const pubkey = keypair.publicKey;
16
+ assert(keypair.privateKey);
15
17
  const payment = utxolib.payments.p2wpkh({ pubkey });
16
18
  const destOutput = payment.output;
17
19
  if (!destOutput)
@@ -31,7 +33,7 @@ function mockPrevTx(vout, outputScript, value, network) {
31
33
  });
32
34
  psbtFromNetwork.signInput(0, {
33
35
  publicKey: pubkey,
34
- sign: (hash, lowR) => Buffer.from(noble.signSync(hash, privKey, { canonical: !lowR, der: false })),
36
+ sign: (hash, lowR) => Buffer.from(noble.signSync(hash, keypair.privateKey, { canonical: !lowR, der: false })),
35
37
  });
36
38
  psbtFromNetwork.validateSignaturesOfAllInputs();
37
39
  psbtFromNetwork.finalizeAllInputs();
@@ -79,8 +81,14 @@ function mockUnspents(rootWalletKeys, inputScriptTypes, testOutputAmount, networ
79
81
  vout: i,
80
82
  });
81
83
  }
84
+ else if (t === bitgo_1.outputScripts.scriptTypeP2shP2pk) {
85
+ return mockReplayProtectionUnspent(network, testOutputAmount, {
86
+ key: exports.replayProtectionKeyPair,
87
+ vout: i,
88
+ });
89
+ }
82
90
  throw new Error(`invalid input type ${t}`);
83
91
  });
84
92
  }
85
93
  exports.mockUnspents = mockUnspents;
86
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9jay5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy90ZXN0dXRpbC9tb2NrLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUNBLDBDQUEwQztBQUMxQyw4QkFBOEI7QUFDOUIsMENBQTREO0FBRTVELG9DQWVrQjtBQUNsQix3Q0FBOEM7QUFDOUMsMERBQTRGO0FBRTVGLGlDQUFzRDtBQUl0RCxTQUFnQixVQUFVLENBQ3hCLElBQVksRUFDWixZQUFvQixFQUNwQixLQUFhLEVBQ2IsT0FBZ0I7SUFFaEIsTUFBTSxlQUFlLEdBQUcsNEJBQW9CLENBQUMsRUFBRSxPQUFPLEVBQUUsQ0FBQyxDQUFDO0lBRTFELE1BQU0sT0FBTyxHQUFHLEtBQUssQ0FBQyxLQUFLLENBQUMsZ0JBQWdCLEVBQUUsQ0FBQztJQUMvQyxNQUFNLE1BQU0sR0FBRyxNQUFNLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxZQUFZLENBQUMsT0FBTyxFQUFFLElBQUksQ0FBQyxDQUFDLENBQUM7SUFDOUQsTUFBTSxPQUFPLEdBQUcsT0FBTyxDQUFDLFFBQVEsQ0FBQyxNQUFNLENBQUMsRUFBRSxNQUFNLEVBQUUsQ0FBQyxD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odCksXG4gICAgICAgIHZvdXQ6IGksXG4gICAgICB9KTtcbiAgICB9IGVsc2UgaWYgKHQgPT09IG91dHB1dFNjcmlwdHMuc2NyaXB0VHlwZVAyc2hQMnBrKSB7XG4gICAgICByZXR1cm4gbW9ja1JlcGxheVByb3RlY3Rpb25VbnNwZW50KG5ldHdvcmssIHRlc3RPdXRwdXRBbW91bnQsIHtcbiAgICAgICAga2V5OiByZXBsYXlQcm90ZWN0aW9uS2V5UGFpcixcbiAgICAgICAgdm91dDogaSxcbiAgICAgIH0pO1xuICAgIH1cbiAgICB0aHJvdyBuZXcgRXJyb3IoYGludmFsaWQgaW5wdXQgdHlwZSAke3R9YCk7XG4gIH0pO1xufVxuIl19
@@ -0,0 +1,89 @@
1
+ import { ScriptType, ScriptType2Of3 } from '../bitgo/outputScripts';
2
+ import { KeyName, RootWalletKeys, Unspent, UtxoPsbt, UtxoTransaction } from '../bitgo';
3
+ import { Network } from '../networks';
4
+ /**
5
+ * input script type and value.
6
+ * use p2trMusig2 for p2trMusig2 script path.
7
+ * use taprootKeyPathSpend for p2trMusig2 key path.
8
+ */
9
+ export declare type InputScriptType = ScriptType | 'taprootKeyPathSpend';
10
+ export declare type OutputScriptType = ScriptType2Of3;
11
+ /**
12
+ * input script type and value
13
+ */
14
+ export interface Input {
15
+ scriptType: InputScriptType;
16
+ value: bigint;
17
+ }
18
+ /**
19
+ * should set either address or scriptType, never both.
20
+ * set isInternalAddress=true for internal output address
21
+ */
22
+ export interface Output {
23
+ address?: string;
24
+ scriptType?: OutputScriptType;
25
+ value: bigint;
26
+ isInternalAddress?: boolean;
27
+ }
28
+ /**
29
+ * array of supported input script types.
30
+ * use p2trMusig2 for p2trMusig2 script path.
31
+ * use taprootKeyPathSpend for p2trMusig2 key path.
32
+ */
33
+ export declare const inputScriptTypes: readonly ["p2sh", "p2shP2wsh", "p2wsh", "p2tr", "p2trMusig2", "taprootKeyPathSpend", "p2shP2pk"];
34
+ /**
35
+ * array of supported output script types.
36
+ */
37
+ export declare const outputScriptTypes: readonly ["p2sh", "p2shP2wsh", "p2wsh", "p2tr", "p2trMusig2"];
38
+ /**
39
+ * create unspent object from input script type, index, network and root wallet key.
40
+ */
41
+ export declare function toUnspent(input: Input, index: number, network: Network, rootWalletKeys: RootWalletKeys): Unspent<bigint>;
42
+ /**
43
+ * returns signer and cosigner names for InputScriptType.
44
+ * user and undefined as signer and cosigner respectively for p2shP2pk.
45
+ * user and backup as signer and cosigner respectively for p2trMusig2.
46
+ * user and bitgo as signer and cosigner respectively for other input script types.
47
+ */
48
+ export declare function getSigners(inputType: InputScriptType): {
49
+ signerName: KeyName;
50
+ cosignerName?: KeyName;
51
+ };
52
+ /**
53
+ * signs with first or second signature for single input.
54
+ * p2shP2pk is signed only with first sign.
55
+ */
56
+ export declare function signPsbtInput(psbt: UtxoPsbt, input: Input, inputIndex: number, rootWalletKeys: RootWalletKeys, sign: 'halfsigned' | 'fullsigned', params?: {
57
+ signers?: {
58
+ signerName: KeyName;
59
+ cosignerName?: KeyName;
60
+ };
61
+ deterministic?: boolean;
62
+ }): void;
63
+ /**
64
+ * signs with first or second signature for all inputs.
65
+ * p2shP2pk is signed only with first sign.
66
+ */
67
+ export declare function signAllPsbtInputs(psbt: UtxoPsbt, inputs: Input[], rootWalletKeys: RootWalletKeys, sign: 'halfsigned' | 'fullsigned', params?: {
68
+ signers?: {
69
+ signerName: KeyName;
70
+ cosignerName?: KeyName;
71
+ };
72
+ deterministic?: boolean;
73
+ }): void;
74
+ /**
75
+ * construct psbt for given inputs, outputs, network and root wallet keys.
76
+ */
77
+ export declare function constructPsbt(inputs: Input[], outputs: Output[], network: Network, rootWalletKeys: RootWalletKeys, sign: 'unsigned' | 'halfsigned' | 'fullsigned', params?: {
78
+ signers?: {
79
+ signerName: KeyName;
80
+ cosignerName?: KeyName;
81
+ };
82
+ deterministic?: boolean;
83
+ }): UtxoPsbt;
84
+ /**
85
+ * Verifies signatures of fully signed tx (with taproot key path support).
86
+ * NOTE: taproot key path tx can only be built and signed with PSBT.
87
+ */
88
+ export declare function verifyFullySignedSignatures(tx: UtxoTransaction<bigint>, unspents: Unspent<bigint>[], walletKeys: RootWalletKeys, signer: KeyName, cosigner: KeyName): boolean;
89
+ //# sourceMappingURL=psbt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"psbt.d.ts","sourceRoot":"","sources":["../../../src/testutil/psbt.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,UAAU,EACV,cAAc,EAGf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EASL,OAAO,EAEP,cAAc,EAEd,OAAO,EACP,QAAQ,EACR,eAAe,EAEhB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAItC;;;;GAIG;AACH,oBAAY,eAAe,GAAG,UAAU,GAAG,qBAAqB,CAAC;AACjE,oBAAY,gBAAgB,GAAG,cAAc,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,UAAU,EAAE,eAAe,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,kGAA2E,CAAC;AAEzG;;GAEG;AACH,eAAO,MAAM,iBAAiB,+DAAkB,CAAC;AAEjD;;GAEG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,cAAc,GAC7B,OAAO,CAAC,MAAM,CAAC,CAYjB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,eAAe,GAAG;IAAE,UAAU,EAAE,OAAO,CAA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