utxo-lib 1.1.5 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of utxo-lib might be problematic. Click here for more details.

Files changed (250) hide show
  1. package/index.js +47 -0
  2. package/package.json +6 -80
  3. package/LICENSE +0 -21
  4. package/README.md +0 -59
  5. package/dist/src/address.d.ts +0 -11
  6. package/dist/src/address.d.ts.map +0 -1
  7. package/dist/src/address.js +0 -37
  8. package/dist/src/addressFormat.d.ts +0 -53
  9. package/dist/src/addressFormat.d.ts.map +0 -1
  10. package/dist/src/addressFormat.js +0 -110
  11. package/dist/src/bitgo/Musig2.d.ts +0 -51
  12. package/dist/src/bitgo/Musig2.d.ts.map +0 -1
  13. package/dist/src/bitgo/Musig2.js +0 -175
  14. package/dist/src/bitgo/Unspent.d.ts +0 -95
  15. package/dist/src/bitgo/Unspent.d.ts.map +0 -1
  16. package/dist/src/bitgo/Unspent.js +0 -138
  17. package/dist/src/bitgo/UtxoPsbt.d.ts +0 -132
  18. package/dist/src/bitgo/UtxoPsbt.d.ts.map +0 -1
  19. package/dist/src/bitgo/UtxoPsbt.js +0 -469
  20. package/dist/src/bitgo/UtxoTransaction.d.ts +0 -22
  21. package/dist/src/bitgo/UtxoTransaction.d.ts.map +0 -1
  22. package/dist/src/bitgo/UtxoTransaction.js +0 -97
  23. package/dist/src/bitgo/UtxoTransactionBuilder.d.ts +0 -26
  24. package/dist/src/bitgo/UtxoTransactionBuilder.d.ts.map +0 -1
  25. package/dist/src/bitgo/UtxoTransactionBuilder.js +0 -67
  26. package/dist/src/bitgo/bbc/DashPsbt.d.ts +0 -12
  27. package/dist/src/bitgo/bbc/DashPsbt.d.ts.map +0 -1
  28. package/dist/src/bitgo/bbc/DashPsbt.js +0 -27
  29. package/dist/src/bitgo/bbc/DashTransaction.d.ts +0 -39
  30. package/dist/src/bitgo/bbc/DashTransaction.d.ts.map +0 -1
  31. package/dist/src/bitgo/bbc/DashTransaction.js +0 -109
  32. package/dist/src/bitgo/bbc/DashTransactionBuilder.d.ts +0 -14
  33. package/dist/src/bitgo/bbc/DashTransactionBuilder.d.ts.map +0 -1
  34. package/dist/src/bitgo/bbc/DashTransactionBuilder.js +0 -28
  35. package/dist/src/bitgo/bbc/index.d.ts +0 -4
  36. package/dist/src/bitgo/bbc/index.d.ts.map +0 -1
  37. package/dist/src/bitgo/bbc/index.js +0 -16
  38. package/dist/src/bitgo/bitcoincash/address.d.ts +0 -35
  39. package/dist/src/bitgo/bitcoincash/address.d.ts.map +0 -1
  40. package/dist/src/bitgo/bitcoincash/address.js +0 -151
  41. package/dist/src/bitgo/bitcoincash/index.d.ts +0 -2
  42. package/dist/src/bitgo/bitcoincash/index.d.ts.map +0 -1
  43. package/dist/src/bitgo/bitcoincash/index.js +0 -14
  44. package/dist/src/bitgo/dash/DashPsbt.d.ts +0 -12
  45. package/dist/src/bitgo/dash/DashPsbt.d.ts.map +0 -1
  46. package/dist/src/bitgo/dash/DashPsbt.js +0 -27
  47. package/dist/src/bitgo/dash/DashTransaction.d.ts +0 -39
  48. package/dist/src/bitgo/dash/DashTransaction.d.ts.map +0 -1
  49. package/dist/src/bitgo/dash/DashTransaction.js +0 -109
  50. package/dist/src/bitgo/dash/DashTransactionBuilder.d.ts +0 -14
  51. package/dist/src/bitgo/dash/DashTransactionBuilder.d.ts.map +0 -1
  52. package/dist/src/bitgo/dash/DashTransactionBuilder.js +0 -28
  53. package/dist/src/bitgo/dash/index.d.ts +0 -4
  54. package/dist/src/bitgo/dash/index.d.ts.map +0 -1
  55. package/dist/src/bitgo/dash/index.js +0 -16
  56. package/dist/src/bitgo/index.d.ts +0 -17
  57. package/dist/src/bitgo/index.d.ts.map +0 -1
  58. package/dist/src/bitgo/index.js +0 -30
  59. package/dist/src/bitgo/keyutil.d.ts +0 -17
  60. package/dist/src/bitgo/keyutil.d.ts.map +0 -1
  61. package/dist/src/bitgo/keyutil.js +0 -37
  62. package/dist/src/bitgo/nonStandardHalfSigned.d.ts +0 -7
  63. package/dist/src/bitgo/nonStandardHalfSigned.d.ts.map +0 -1
  64. package/dist/src/bitgo/nonStandardHalfSigned.js +0 -56
  65. package/dist/src/bitgo/outputScripts.d.ts +0 -84
  66. package/dist/src/bitgo/outputScripts.d.ts.map +0 -1
  67. package/dist/src/bitgo/outputScripts.js +0 -297
  68. package/dist/src/bitgo/parseInput.d.ts +0 -92
  69. package/dist/src/bitgo/parseInput.d.ts.map +0 -1
  70. package/dist/src/bitgo/parseInput.js +0 -344
  71. package/dist/src/bitgo/psbt/fromHalfSigned.d.ts +0 -24
  72. package/dist/src/bitgo/psbt/fromHalfSigned.d.ts.map +0 -1
  73. package/dist/src/bitgo/psbt/fromHalfSigned.js +0 -91
  74. package/dist/src/bitgo/psbt/scriptTypes.d.ts +0 -6
  75. package/dist/src/bitgo/psbt/scriptTypes.d.ts.map +0 -1
  76. package/dist/src/bitgo/psbt/scriptTypes.js +0 -23
  77. package/dist/src/bitgo/signature.d.ts +0 -84
  78. package/dist/src/bitgo/signature.d.ts.map +0 -1
  79. package/dist/src/bitgo/signature.js +0 -222
  80. package/dist/src/bitgo/tnumber.d.ts +0 -9
  81. package/dist/src/bitgo/tnumber.d.ts.map +0 -1
  82. package/dist/src/bitgo/tnumber.js +0 -31
  83. package/dist/src/bitgo/transaction.d.ts +0 -29
  84. package/dist/src/bitgo/transaction.d.ts.map +0 -1
  85. package/dist/src/bitgo/transaction.js +0 -231
  86. package/dist/src/bitgo/types.d.ts +0 -5
  87. package/dist/src/bitgo/types.d.ts.map +0 -1
  88. package/dist/src/bitgo/types.js +0 -12
  89. package/dist/src/bitgo/wallet/Psbt.d.ts +0 -47
  90. package/dist/src/bitgo/wallet/Psbt.d.ts.map +0 -1
  91. package/dist/src/bitgo/wallet/Psbt.js +0 -232
  92. package/dist/src/bitgo/wallet/Unspent.d.ts +0 -47
  93. package/dist/src/bitgo/wallet/Unspent.d.ts.map +0 -1
  94. package/dist/src/bitgo/wallet/Unspent.js +0 -154
  95. package/dist/src/bitgo/wallet/WalletKeys.d.ts +0 -72
  96. package/dist/src/bitgo/wallet/WalletKeys.d.ts.map +0 -1
  97. package/dist/src/bitgo/wallet/WalletKeys.js +0 -104
  98. package/dist/src/bitgo/wallet/WalletOutput.d.ts +0 -18
  99. package/dist/src/bitgo/wallet/WalletOutput.d.ts.map +0 -1
  100. package/dist/src/bitgo/wallet/WalletOutput.js +0 -69
  101. package/dist/src/bitgo/wallet/WalletScripts.d.ts +0 -7
  102. package/dist/src/bitgo/wallet/WalletScripts.d.ts.map +0 -1
  103. package/dist/src/bitgo/wallet/WalletScripts.js +0 -15
  104. package/dist/src/bitgo/wallet/WalletUnspentSigner.d.ts +0 -19
  105. package/dist/src/bitgo/wallet/WalletUnspentSigner.d.ts.map +0 -1
  106. package/dist/src/bitgo/wallet/WalletUnspentSigner.js +0 -47
  107. package/dist/src/bitgo/wallet/chains.d.ts +0 -57
  108. package/dist/src/bitgo/wallet/chains.d.ts.map +0 -1
  109. package/dist/src/bitgo/wallet/chains.js +0 -106
  110. package/dist/src/bitgo/wallet/index.d.ts +0 -8
  111. package/dist/src/bitgo/wallet/index.d.ts.map +0 -1
  112. package/dist/src/bitgo/wallet/index.js +0 -20
  113. package/dist/src/bitgo/zcash/ZcashBufferutils.d.ts +0 -26
  114. package/dist/src/bitgo/zcash/ZcashBufferutils.d.ts.map +0 -1
  115. package/dist/src/bitgo/zcash/ZcashBufferutils.js +0 -157
  116. package/dist/src/bitgo/zcash/ZcashPsbt.d.ts +0 -36
  117. package/dist/src/bitgo/zcash/ZcashPsbt.d.ts.map +0 -1
  118. package/dist/src/bitgo/zcash/ZcashPsbt.js +0 -146
  119. package/dist/src/bitgo/zcash/ZcashTransaction.d.ts +0 -61
  120. package/dist/src/bitgo/zcash/ZcashTransaction.d.ts.map +0 -1
  121. package/dist/src/bitgo/zcash/ZcashTransaction.js +0 -341
  122. package/dist/src/bitgo/zcash/ZcashTransactionBuilder.d.ts +0 -21
  123. package/dist/src/bitgo/zcash/ZcashTransactionBuilder.d.ts.map +0 -1
  124. package/dist/src/bitgo/zcash/ZcashTransactionBuilder.js +0 -105
  125. package/dist/src/bitgo/zcash/address.d.ts +0 -8
  126. package/dist/src/bitgo/zcash/address.d.ts.map +0 -1
  127. package/dist/src/bitgo/zcash/address.js +0 -57
  128. package/dist/src/bitgo/zcash/hashZip0244.d.ts +0 -27
  129. package/dist/src/bitgo/zcash/hashZip0244.d.ts.map +0 -1
  130. package/dist/src/bitgo/zcash/hashZip0244.js +0 -184
  131. package/dist/src/bitgo/zcash/index.d.ts +0 -4
  132. package/dist/src/bitgo/zcash/index.d.ts.map +0 -1
  133. package/dist/src/bitgo/zcash/index.js +0 -16
  134. package/dist/src/classify.d.ts +0 -19
  135. package/dist/src/classify.d.ts.map +0 -1
  136. package/dist/src/classify.js +0 -89
  137. package/dist/src/index.d.ts +0 -13
  138. package/dist/src/index.d.ts.map +0 -1
  139. package/dist/src/index.js +0 -36
  140. package/dist/src/networks.d.ts +0 -115
  141. package/dist/src/networks.d.ts.map +0 -1
  142. package/dist/src/networks.js +0 -458
  143. package/dist/src/noble_ecc.d.ts +0 -28
  144. package/dist/src/noble_ecc.d.ts.map +0 -1
  145. package/dist/src/noble_ecc.js +0 -168
  146. package/dist/src/payments/index.d.ts +0 -4
  147. package/dist/src/payments/index.d.ts.map +0 -1
  148. package/dist/src/payments/index.js +0 -8
  149. package/dist/src/payments/p2tr.d.ts +0 -3
  150. package/dist/src/payments/p2tr.d.ts.map +0 -1
  151. package/dist/src/payments/p2tr.js +0 -348
  152. package/dist/src/payments/p2tr_ns.d.ts +0 -3
  153. package/dist/src/payments/p2tr_ns.d.ts.map +0 -1
  154. package/dist/src/payments/p2tr_ns.js +0 -134
  155. package/dist/src/taproot.d.ts +0 -141
  156. package/dist/src/taproot.d.ts.map +0 -1
  157. package/dist/src/taproot.js +0 -384
  158. package/dist/src/templates/multisig/index.d.ts +0 -4
  159. package/dist/src/templates/multisig/index.d.ts.map +0 -1
  160. package/dist/src/templates/multisig/index.js +0 -8
  161. package/dist/src/templates/multisig/input.d.ts +0 -7
  162. package/dist/src/templates/multisig/input.d.ts.map +0 -1
  163. package/dist/src/templates/multisig/input.js +0 -25
  164. package/dist/src/templates/multisig/output.d.ts +0 -7
  165. package/dist/src/templates/multisig/output.d.ts.map +0 -1
  166. package/dist/src/templates/multisig/output.js +0 -38
  167. package/dist/src/templates/nulldata.d.ts +0 -10
  168. package/dist/src/templates/nulldata.d.ts.map +0 -1
  169. package/dist/src/templates/nulldata.js +0 -17
  170. package/dist/src/templates/pubkey/index.d.ts +0 -4
  171. package/dist/src/templates/pubkey/index.d.ts.map +0 -1
  172. package/dist/src/templates/pubkey/index.js +0 -8
  173. package/dist/src/templates/pubkey/input.d.ts +0 -7
  174. package/dist/src/templates/pubkey/input.d.ts.map +0 -1
  175. package/dist/src/templates/pubkey/input.js +0 -14
  176. package/dist/src/templates/pubkey/output.d.ts +0 -7
  177. package/dist/src/templates/pubkey/output.d.ts.map +0 -1
  178. package/dist/src/templates/pubkey/output.js +0 -15
  179. package/dist/src/templates/pubkeyhash/index.d.ts +0 -4
  180. package/dist/src/templates/pubkeyhash/index.d.ts.map +0 -1
  181. package/dist/src/templates/pubkeyhash/index.js +0 -8
  182. package/dist/src/templates/pubkeyhash/input.d.ts +0 -7
  183. package/dist/src/templates/pubkeyhash/input.d.ts.map +0 -1
  184. package/dist/src/templates/pubkeyhash/input.js +0 -16
  185. package/dist/src/templates/pubkeyhash/output.d.ts +0 -6
  186. package/dist/src/templates/pubkeyhash/output.d.ts.map +0 -1
  187. package/dist/src/templates/pubkeyhash/output.js +0 -20
  188. package/dist/src/templates/scripthash/index.d.ts +0 -4
  189. package/dist/src/templates/scripthash/index.d.ts.map +0 -1
  190. package/dist/src/templates/scripthash/index.js +0 -8
  191. package/dist/src/templates/scripthash/input.d.ts +0 -6
  192. package/dist/src/templates/scripthash/input.d.ts.map +0 -1
  193. package/dist/src/templates/scripthash/input.js +0 -43
  194. package/dist/src/templates/scripthash/output.d.ts +0 -6
  195. package/dist/src/templates/scripthash/output.d.ts.map +0 -1
  196. package/dist/src/templates/scripthash/output.js +0 -15
  197. package/dist/src/templates/taproot/index.d.ts +0 -4
  198. package/dist/src/templates/taproot/index.d.ts.map +0 -1
  199. package/dist/src/templates/taproot/index.js +0 -8
  200. package/dist/src/templates/taproot/input.d.ts +0 -6
  201. package/dist/src/templates/taproot/input.d.ts.map +0 -1
  202. package/dist/src/templates/taproot/input.js +0 -23
  203. package/dist/src/templates/taproot/output.d.ts +0 -6
  204. package/dist/src/templates/taproot/output.d.ts.map +0 -1
  205. package/dist/src/templates/taproot/output.js +0 -15
  206. package/dist/src/templates/taprootnofn/index.d.ts +0 -4
  207. package/dist/src/templates/taprootnofn/index.d.ts.map +0 -1
  208. package/dist/src/templates/taprootnofn/index.js +0 -8
  209. package/dist/src/templates/taprootnofn/input.d.ts +0 -7
  210. package/dist/src/templates/taprootnofn/input.d.ts.map +0 -1
  211. package/dist/src/templates/taprootnofn/input.js +0 -24
  212. package/dist/src/templates/taprootnofn/output.d.ts +0 -7
  213. package/dist/src/templates/taprootnofn/output.d.ts.map +0 -1
  214. package/dist/src/templates/taprootnofn/output.js +0 -28
  215. package/dist/src/templates/witnesscommitment/index.d.ts +0 -3
  216. package/dist/src/templates/witnesscommitment/index.d.ts.map +0 -1
  217. package/dist/src/templates/witnesscommitment/index.js +0 -6
  218. package/dist/src/templates/witnesscommitment/output.d.ts +0 -8
  219. package/dist/src/templates/witnesscommitment/output.d.ts.map +0 -1
  220. package/dist/src/templates/witnesscommitment/output.js +0 -31
  221. package/dist/src/templates/witnesspubkeyhash/index.d.ts +0 -4
  222. package/dist/src/templates/witnesspubkeyhash/index.d.ts.map +0 -1
  223. package/dist/src/templates/witnesspubkeyhash/index.js +0 -8
  224. package/dist/src/templates/witnesspubkeyhash/input.d.ts +0 -7
  225. package/dist/src/templates/witnesspubkeyhash/input.d.ts.map +0 -1
  226. package/dist/src/templates/witnesspubkeyhash/input.js +0 -19
  227. package/dist/src/templates/witnesspubkeyhash/output.d.ts +0 -6
  228. package/dist/src/templates/witnesspubkeyhash/output.d.ts.map +0 -1
  229. package/dist/src/templates/witnesspubkeyhash/output.js +0 -15
  230. package/dist/src/templates/witnessscripthash/index.d.ts +0 -4
  231. package/dist/src/templates/witnessscripthash/index.d.ts.map +0 -1
  232. package/dist/src/templates/witnessscripthash/index.js +0 -8
  233. package/dist/src/templates/witnessscripthash/input.d.ts +0 -6
  234. package/dist/src/templates/witnessscripthash/input.d.ts.map +0 -1
  235. package/dist/src/templates/witnessscripthash/input.js +0 -35
  236. package/dist/src/templates/witnessscripthash/output.d.ts +0 -6
  237. package/dist/src/templates/witnessscripthash/output.d.ts.map +0 -1
  238. package/dist/src/templates/witnessscripthash/output.js +0 -15
  239. package/dist/src/testutil/index.d.ts +0 -3
  240. package/dist/src/testutil/index.d.ts.map +0 -1
  241. package/dist/src/testutil/index.js +0 -15
  242. package/dist/src/testutil/keys.d.ts +0 -10
  243. package/dist/src/testutil/keys.d.ts.map +0 -1
  244. package/dist/src/testutil/keys.js +0 -40
  245. package/dist/src/testutil/mock.d.ts +0 -21
  246. package/dist/src/testutil/mock.d.ts.map +0 -1
  247. package/dist/src/testutil/mock.js +0 -86
  248. package/dist/src/transaction_builder.d.ts +0 -47
  249. package/dist/src/transaction_builder.d.ts.map +0 -1
  250. package/dist/src/transaction_builder.js +0 -1084
@@ -1,231 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createTransactionBuilderFromTransaction = exports.createTransactionBuilderForNetwork = exports.createPsbtForNetwork = exports.setPsbtDefaults = exports.setTransactionBuilderDefaults = exports.getDefaultTransactionVersion = exports.createTransactionFromHex = exports.createPsbtFromTransaction = exports.createPsbtFromHex = exports.createPsbtFromBuffer = exports.createTransactionFromBuffer = void 0;
4
- const networks_1 = require("../networks");
5
- const UtxoPsbt_1 = require("./UtxoPsbt");
6
- const UtxoTransaction_1 = require("./UtxoTransaction");
7
- const UtxoTransactionBuilder_1 = require("./UtxoTransactionBuilder");
8
- const DashPsbt_1 = require("./dash/DashPsbt");
9
- const DashTransaction_1 = require("./dash/DashTransaction");
10
- const DashTransactionBuilder_1 = require("./dash/DashTransactionBuilder");
11
- const ZcashPsbt_1 = require("./zcash/ZcashPsbt");
12
- const ZcashTransactionBuilder_1 = require("./zcash/ZcashTransactionBuilder");
13
- const ZcashTransaction_1 = require("./zcash/ZcashTransaction");
14
- function createTransactionFromBuffer(buf, network, { version, amountType } = {}, deprecatedAmountType) {
15
- if (amountType) {
16
- if (deprecatedAmountType && amountType !== deprecatedAmountType) {
17
- throw new Error(`invalid arguments`);
18
- }
19
- }
20
- else {
21
- if (deprecatedAmountType) {
22
- amountType = deprecatedAmountType;
23
- }
24
- else {
25
- amountType = 'number';
26
- }
27
- }
28
- switch (networks_1.getMainnet(network)) {
29
- case networks_1.networks.bitcoin:
30
- case networks_1.networks.bitcoincash:
31
- case networks_1.networks.bitcoinsv:
32
- case networks_1.networks.bitcoingold:
33
- case networks_1.networks.dogecoin:
34
- case networks_1.networks.ecash:
35
- case networks_1.networks.litecoin:
36
- return UtxoTransaction_1.UtxoTransaction.fromBuffer(buf, false, amountType, network);
37
- case networks_1.networks.dash:
38
- return DashTransaction_1.DashTransaction.fromBuffer(buf, false, amountType, network);
39
- case networks_1.networks.zcash:
40
- return ZcashTransaction_1.ZcashTransaction.fromBufferWithVersion(buf, network, version, amountType);
41
- }
42
- /* istanbul ignore next */
43
- throw new Error(`invalid network`);
44
- }
45
- exports.createTransactionFromBuffer = createTransactionFromBuffer;
46
- function createPsbtFromBuffer(buf, network, bip32PathsAbsolute = false) {
47
- switch (networks_1.getMainnet(network)) {
48
- case networks_1.networks.bitcoin:
49
- case networks_1.networks.bitcoincash:
50
- case networks_1.networks.bitcoinsv:
51
- case networks_1.networks.bitcoingold:
52
- case networks_1.networks.dogecoin:
53
- case networks_1.networks.ecash:
54
- case networks_1.networks.litecoin:
55
- return UtxoPsbt_1.UtxoPsbt.fromBuffer(buf, { network, bip32PathsAbsolute });
56
- case networks_1.networks.dash:
57
- return DashPsbt_1.DashPsbt.fromBuffer(buf, { network, bip32PathsAbsolute });
58
- case networks_1.networks.zcash:
59
- return ZcashPsbt_1.ZcashPsbt.fromBuffer(buf, { network, bip32PathsAbsolute });
60
- }
61
- /* istanbul ignore next */
62
- throw new Error(`invalid network`);
63
- }
64
- exports.createPsbtFromBuffer = createPsbtFromBuffer;
65
- function createPsbtFromHex(hex, network, bip32PathsAbsolute = false) {
66
- return createPsbtFromBuffer(Buffer.from(hex, 'hex'), network, bip32PathsAbsolute);
67
- }
68
- exports.createPsbtFromHex = createPsbtFromHex;
69
- function createPsbtFromTransaction(tx, prevOuts) {
70
- switch (networks_1.getMainnet(tx.network)) {
71
- case networks_1.networks.bitcoin:
72
- case networks_1.networks.bitcoincash:
73
- case networks_1.networks.bitcoinsv:
74
- case networks_1.networks.bitcoingold:
75
- case networks_1.networks.dogecoin:
76
- case networks_1.networks.ecash:
77
- case networks_1.networks.litecoin:
78
- return UtxoPsbt_1.UtxoPsbt.fromTransaction(tx, prevOuts);
79
- case networks_1.networks.dash:
80
- return DashPsbt_1.DashPsbt.fromTransaction(tx, prevOuts);
81
- case networks_1.networks.zcash:
82
- return ZcashPsbt_1.ZcashPsbt.fromTransaction(tx, prevOuts);
83
- }
84
- /* istanbul ignore next */
85
- throw new Error(`invalid network`);
86
- }
87
- exports.createPsbtFromTransaction = createPsbtFromTransaction;
88
- /* istanbul ignore next */
89
- function createTransactionFromHex(hex, network, amountType = 'number') {
90
- return createTransactionFromBuffer(Buffer.from(hex, 'hex'), network, { amountType });
91
- }
92
- exports.createTransactionFromHex = createTransactionFromHex;
93
- function getDefaultTransactionVersion(network) {
94
- switch (networks_1.getMainnet(network)) {
95
- case networks_1.networks.bitcoincash:
96
- case networks_1.networks.bitcoinsv:
97
- case networks_1.networks.bitcoingold:
98
- case networks_1.networks.ecash:
99
- return 2;
100
- case networks_1.networks.zcash:
101
- return ZcashTransaction_1.ZcashTransaction.VERSION4_BRANCH_NU5;
102
- default:
103
- return 1;
104
- }
105
- }
106
- exports.getDefaultTransactionVersion = getDefaultTransactionVersion;
107
- function setTransactionBuilderDefaults(txb, network, { version = getDefaultTransactionVersion(network) } = {}) {
108
- switch (networks_1.getMainnet(network)) {
109
- case networks_1.networks.bitcoincash:
110
- case networks_1.networks.bitcoinsv:
111
- case networks_1.networks.bitcoingold:
112
- case networks_1.networks.ecash:
113
- if (version !== 2) {
114
- throw new Error(`invalid version`);
115
- }
116
- txb.setVersion(version);
117
- break;
118
- case networks_1.networks.zcash:
119
- txb.setDefaultsForVersion(network, version);
120
- break;
121
- default:
122
- if (version !== 1) {
123
- throw new Error(`invalid version`);
124
- }
125
- }
126
- }
127
- exports.setTransactionBuilderDefaults = setTransactionBuilderDefaults;
128
- function setPsbtDefaults(psbt, network, { version = getDefaultTransactionVersion(network) } = {}) {
129
- switch (networks_1.getMainnet(network)) {
130
- case networks_1.networks.bitcoincash:
131
- case networks_1.networks.bitcoinsv:
132
- case networks_1.networks.bitcoingold:
133
- case networks_1.networks.ecash:
134
- if (version !== 2) {
135
- throw new Error(`invalid version`);
136
- }
137
- break;
138
- case networks_1.networks.zcash:
139
- if (![
140
- ZcashTransaction_1.ZcashTransaction.VERSION4_BRANCH_CANOPY,
141
- ZcashTransaction_1.ZcashTransaction.VERSION4_BRANCH_NU5,
142
- ZcashTransaction_1.ZcashTransaction.VERSION5_BRANCH_NU5,
143
- ].includes(version)) {
144
- throw new Error(`invalid version`);
145
- }
146
- psbt.setDefaultsForVersion(network, version);
147
- break;
148
- default:
149
- if (version !== 1) {
150
- throw new Error(`invalid version`);
151
- }
152
- // FIXME: set version here, because there's a bug in the upstream PSBT
153
- // that defaults transactions to v2.
154
- psbt.setVersion(version);
155
- }
156
- }
157
- exports.setPsbtDefaults = setPsbtDefaults;
158
- function createPsbtForNetwork(psbtOpts, { version } = {}) {
159
- let psbt;
160
- switch (networks_1.getMainnet(psbtOpts.network)) {
161
- case networks_1.networks.bitcoin:
162
- case networks_1.networks.bitcoincash:
163
- case networks_1.networks.bitcoinsv:
164
- case networks_1.networks.bitcoingold:
165
- case networks_1.networks.dogecoin:
166
- case networks_1.networks.ecash:
167
- case networks_1.networks.litecoin: {
168
- psbt = UtxoPsbt_1.UtxoPsbt.createPsbt(psbtOpts);
169
- break;
170
- }
171
- case networks_1.networks.dash: {
172
- psbt = DashPsbt_1.DashPsbt.createPsbt(psbtOpts);
173
- break;
174
- }
175
- case networks_1.networks.zcash: {
176
- psbt = ZcashPsbt_1.ZcashPsbt.createPsbt(psbtOpts);
177
- break;
178
- }
179
- default:
180
- throw new Error(`unsupported network`);
181
- }
182
- setPsbtDefaults(psbt, psbtOpts.network, { version });
183
- return psbt;
184
- }
185
- exports.createPsbtForNetwork = createPsbtForNetwork;
186
- function createTransactionBuilderForNetwork(network, { version } = {}) {
187
- let txb;
188
- switch (networks_1.getMainnet(network)) {
189
- case networks_1.networks.bitcoin:
190
- case networks_1.networks.bitcoincash:
191
- case networks_1.networks.bitcoinsv:
192
- case networks_1.networks.bitcoingold:
193
- case networks_1.networks.dogecoin:
194
- case networks_1.networks.ecash:
195
- case networks_1.networks.litecoin: {
196
- txb = new UtxoTransactionBuilder_1.UtxoTransactionBuilder(network);
197
- break;
198
- }
199
- case networks_1.networks.dash:
200
- txb = new DashTransactionBuilder_1.DashTransactionBuilder(network);
201
- break;
202
- case networks_1.networks.zcash: {
203
- txb = new ZcashTransactionBuilder_1.ZcashTransactionBuilder(network);
204
- break;
205
- }
206
- default:
207
- throw new Error(`unsupported network`);
208
- }
209
- setTransactionBuilderDefaults(txb, network, { version });
210
- return txb;
211
- }
212
- exports.createTransactionBuilderForNetwork = createTransactionBuilderForNetwork;
213
- function createTransactionBuilderFromTransaction(tx, prevOutputs) {
214
- switch (networks_1.getMainnet(tx.network)) {
215
- case networks_1.networks.bitcoin:
216
- case networks_1.networks.bitcoincash:
217
- case networks_1.networks.bitcoinsv:
218
- case networks_1.networks.bitcoingold:
219
- case networks_1.networks.dogecoin:
220
- case networks_1.networks.ecash:
221
- case networks_1.networks.litecoin:
222
- return UtxoTransactionBuilder_1.UtxoTransactionBuilder.fromTransaction(tx, undefined, prevOutputs);
223
- case networks_1.networks.dash:
224
- return DashTransactionBuilder_1.DashTransactionBuilder.fromTransaction(tx, undefined, prevOutputs);
225
- case networks_1.networks.zcash:
226
- return ZcashTransactionBuilder_1.ZcashTransactionBuilder.fromTransaction(tx, undefined, prevOutputs);
227
- }
228
- throw new Error(`invalid network`);
229
- }
230
- exports.createTransactionBuilderFromTransaction = createTransactionBuilderFromTransaction;
231
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJhbnNhY3Rpb24uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYml0Z28vdHJhbnNhY3Rpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBRUEsMENBQTREO0FBRTVELHlDQUFnRDtBQUNoRCx1REFBb0Q7QUFDcEQscUVBQWtFO0FBQ2xFLDhDQUEyQztBQUMzQyw0REFBeUQ7QUFDekQsMEVBQXVFO0FBQ3ZFLGlEQUE4QztBQUM5Qyw2RUFBMEU7QUFDMUUsK0RBQTBFO0FBRTFFLFNBQWdCLDJCQUEyQixDQUN6QyxHQUFXLEVBQ1gsT0FBZ0IsRUFDaEIsRUFBRSxPQUFPLEVBQUUsVUFBVSxLQUE2RCxFQUFFLEVBQ3BGLG9CQUEwQztJQUUxQyxJQUFJLFVBQVUsRUFBRTtRQUNkLElBQUksb0JBQW9CLElBQUksVUFBVSxLQUFLLG9CQUFvQixFQUFFO1lBQy9ELE1BQU0sSUFBSSxLQUFLLENBQUMsbUJBQW1CLENBQUMsQ0FBQztTQUN0QztLQUNGO1NBQU07UUFDTCxJQUFJLG9CQUFvQixFQUFFO1lBQ3hCLFVBQVUsR0FBRyxvQkFBb0IsQ0FBQztTQUNuQzthQUFNO1l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pbjpcbiAgICBjYXNlIG5ldHdvcmtzLmVjYXNoOlxuICAgIGNhc2UgbmV0d29ya3MubGl0ZWNvaW46XG4gICAgICByZXR1cm4gVXR4b1RyYW5zYWN0aW9uQnVpbGRlci5mcm9tVHJhbnNhY3Rpb248VE51bWJlcj4odHgsIHVuZGVmaW5lZCwgcHJldk91dHB1dHMpO1xuICAgIGNhc2UgbmV0d29ya3MuZGFzaDpcbiAgICAgIHJldHVybiBEYXNoVHJhbnNhY3Rpb25CdWlsZGVyLmZyb21UcmFuc2FjdGlvbjxUTnVtYmVyPihcbiAgICAgICAgdHggYXMgRGFzaFRyYW5zYWN0aW9uPFROdW1iZXI+LFxuICAgICAgICB1bmRlZmluZWQsXG4gICAgICAgIHByZXZPdXRwdXRzIGFzIFR4T3V0cHV0PFROdW1iZXI+W11cbiAgICAgICk7XG4gICAgY2FzZSBuZXR3b3Jrcy56Y2FzaDpcbiAgICAgIHJldHVybiBaY2FzaFRyYW5zYWN0aW9uQnVpbGRlci5mcm9tVHJhbnNhY3Rpb248VE51bWJlcj4oXG4gICAgICAgIHR4IGFzIFpjYXNoVHJhbnNhY3Rpb248VE51bWJlcj4sXG4gICAgICAgIHVuZGVmaW5lZCxcbiAgICAgICAgcHJldk91dHB1dHMgYXMgVHhPdXRwdXQ8VE51bWJlcj5bXVxuICAgICAgKTtcbiAgfVxuXG4gIHRocm93IG5ldyBFcnJvcihgaW52YWxpZCBuZXR3b3JrYCk7XG59XG4iXX0=
@@ -1,5 +0,0 @@
1
- export declare type Tuple<T> = [T, T];
2
- export declare function isTuple<T>(arr: T[]): arr is Tuple<T>;
3
- export declare type Triple<T> = [T, T, T];
4
- export declare function isTriple<T>(arr: T[]): arr is Triple<T>;
5
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/bitgo/types.ts"],"names":[],"mappings":"AAAA,oBAAY,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE9B,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,CAEpD;AAED,oBAAY,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAElC,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,CAEtD"}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isTriple = exports.isTuple = void 0;
4
- function isTuple(arr) {
5
- return arr.length === 2;
6
- }
7
- exports.isTuple = isTuple;
8
- function isTriple(arr) {
9
- return arr.length === 3;
10
- }
11
- exports.isTriple = isTriple;
12
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYml0Z28vdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBRUEsU0FBZ0IsT0FBTyxDQUFJLEdBQVE7SUFDakMsT0FBTyxHQUFHLENBQUMsTUFBTSxLQUFLLENBQUMsQ0FBQztBQUMxQixDQUFDO0FBRkQsMEJBRUM7QUFJRCxTQUFnQixRQUFRLENBQUksR0FBUTtJQUNsQyxPQUFPLEdBQUcsQ0FBQyxNQUFNLEtBQUssQ0FBQyxDQUFDO0FBQzFCLENBQUM7QUFGRCw0QkFFQyIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCB0eXBlIFR1cGxlPFQ+ID0gW1QsIFRdO1xuXG5leHBvcnQgZnVuY3Rpb24gaXNUdXBsZTxUPihhcnI6IFRbXSk6IGFyciBpcyBUdXBsZTxUPiB7XG4gIHJldHVybiBhcnIubGVuZ3RoID09PSAyO1xufVxuXG5leHBvcnQgdHlwZSBUcmlwbGU8VD4gPSBbVCwgVCwgVF07XG5cbmV4cG9ydCBmdW5jdGlvbiBpc1RyaXBsZTxUPihhcnI6IFRbXSk6IGFyciBpcyBUcmlwbGU8VD4ge1xuICByZXR1cm4gYXJyLmxlbmd0aCA9PT0gMztcbn1cbiJdfQ==
@@ -1,47 +0,0 @@
1
- /// <reference types="node" />
2
- import { UtxoPsbt } from '../UtxoPsbt';
3
- import { UtxoTransaction } from '../UtxoTransaction';
4
- import { RootWalletKeys } from './WalletKeys';
5
- import { BIP32Interface } from 'bip32';
6
- import { WalletUnspent } from './Unspent';
7
- import { ParsedPubScript2Of3, ParsedPubScriptTaprootScriptPath } from '../parseInput';
8
- declare type Signatures = [Buffer] | [Buffer, Buffer] | undefined;
9
- export interface ParsedPsbt2Of3 extends ParsedPubScript2Of3 {
10
- signatures: Signatures;
11
- }
12
- export interface ParsedPsbtP2TR extends ParsedPubScriptTaprootScriptPath {
13
- signatures: Signatures;
14
- controlBlock: Buffer;
15
- leafVersion: number;
16
- /** Indicates the level inside the taptree. */
17
- scriptPathLevel: number;
18
- }
19
- /**
20
- * @return PSBT filled with metatdata as per input params tx, unspents and rootWalletKeys.
21
- * Unsigned PSBT for taproot input with witnessUtxo
22
- * Unsigned PSBT for other input with witnessUtxo/nonWitnessUtxo, redeemScript/witnessScript, bip32Derivation
23
- * Signed PSBT for taproot input with witnessUtxo, tapLeafScript, tapBip32Derivation, tapScriptSig
24
- * Signed PSBT for other input with witnessUtxo/nonWitnessUtxo, redeemScript/witnessScript, bip32Derivation, partialSig
25
- */
26
- export declare function toWalletPsbt(tx: UtxoTransaction<bigint>, unspents: WalletUnspent<bigint>[], rootWalletKeys: RootWalletKeys): UtxoPsbt;
27
- /**
28
- * @param psbt
29
- * @param inputIndex
30
- * @param signer
31
- * @param unspent
32
- * @return signed PSBT with signer's key for unspent
33
- */
34
- export declare function signWalletPsbt(psbt: UtxoPsbt, inputIndex: number, signer: BIP32Interface, unspent: WalletUnspent<bigint>): void;
35
- /**
36
- * @return psbt metadata are parsed as per below conditions.
37
- * redeemScript/witnessScript/tapLeafScript matches BitGo.
38
- * signature and public key count matches BitGo.
39
- * P2SH => scriptType, redeemScript, public keys, signatures.
40
- * PW2SH => scriptType, witnessScript, public keys, signatures.
41
- * P2SH-PW2SH => scriptType, redeemScript, witnessScript, public keys, signatures.
42
- * P2TR => scriptType, pubScript (witnessScript), controlBlock, scriptPathLevel, leafVersion, public keys, signatures.
43
- * Any unsigned PSBT and without required metadata is returned with undefined.
44
- */
45
- export declare function parsePsbtInput(psbt: UtxoPsbt, inputIndex: number): ParsedPsbt2Of3 | ParsedPsbtP2TR | undefined;
46
- export {};
47
- //# sourceMappingURL=Psbt.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Psbt.d.ts","sourceRoot":"","sources":["../../../../src/bitgo/wallet/Psbt.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAQrD,OAAO,EAAqB,cAAc,EAAE,MAAM,cAAc,CAAC;AAGjE,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAmB,aAAa,EAAE,MAAM,WAAW,CAAC;AAG3D,OAAO,EAIL,mBAAmB,EACnB,gCAAgC,EAEjC,MAAM,eAAe,CAAC;AAEvB,aAAK,UAAU,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;AAE1D,MAAM,WAAW,cAAe,SAAQ,mBAAmB;IACzD,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,MAAM,WAAW,cAAe,SAAQ,gCAAgC;IACtE,UAAU,EAAE,UAAU,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,eAAe,EAAE,MAAM,CAAC;CACzB;AAkFD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,EAAE,EAAE,eAAe,CAAC,MAAM,CAAC,EAC3B,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,EACjC,cAAc,EAAE,cAAc,GAC7B,QAAQ,CASV;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,QAAQ,EACd,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,GAC7B,IAAI,CAMN;AA6GD;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,GAAG,cAAc,GAAG,cAAc,GAAG,SAAS,CAa9G"}
@@ -1,232 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parsePsbtInput = exports.signWalletPsbt = exports.toWalletPsbt = void 0;
4
- const outputScripts_1 = require("../outputScripts");
5
- const Unspent_1 = require("../Unspent");
6
- const transaction_1 = require("../transaction");
7
- const Unspent_2 = require("./Unspent");
8
- const utils_1 = require("bip174/src/lib/utils");
9
- const parseInput_1 = require("../parseInput");
10
- function getTaprootSigners(script, walletKeys) {
11
- const parsedPublicKeys = parseInput_1.parsePubScript(script, 'p2tr').publicKeys;
12
- const walletSigners = parsedPublicKeys.map((publicKey) => {
13
- const index = walletKeys.publicKeys.findIndex((walletPublicKey) => outputScripts_1.toXOnlyPublicKey(walletPublicKey).equals(publicKey));
14
- if (index >= 0) {
15
- return { walletKey: walletKeys.triple[index], rootKey: walletKeys.parent.triple[index] };
16
- }
17
- throw new Error('Taproot public key is not a wallet public key');
18
- });
19
- return [walletSigners[0], walletSigners[1]];
20
- }
21
- function updatePsbtInput(psbt, inputIndex, unspent, rootWalletKeys) {
22
- const signatureCount = psbt.getSignatureCount(inputIndex);
23
- const scriptType = outputScripts_1.scriptTypeForChain(unspent.chain);
24
- if (signatureCount === 0 && scriptType === 'p2tr') {
25
- return;
26
- }
27
- const walletKeys = rootWalletKeys.deriveForChainAndIndex(unspent.chain, unspent.index);
28
- if (scriptType === 'p2tr') {
29
- const input = psbt.data.inputs[inputIndex];
30
- if (!Array.isArray(input.tapLeafScript) || input.tapLeafScript.length === 0) {
31
- throw new Error('Invalid PSBT state. Missing required fields.');
32
- }
33
- if (input.tapLeafScript.length > 1) {
34
- throw new Error('Bitgo only supports a single tap leaf script per input');
35
- }
36
- const [signer, cosigner] = getTaprootSigners(input.tapLeafScript[0].script, walletKeys);
37
- const leafHash = outputScripts_1.getLeafHash({
38
- publicKeys: walletKeys.publicKeys,
39
- signer: signer.walletKey.publicKey,
40
- cosigner: cosigner.walletKey.publicKey,
41
- });
42
- psbt.updateInput(inputIndex, {
43
- tapBip32Derivation: [signer, cosigner].map((walletSigner) => ({
44
- leafHashes: [leafHash],
45
- pubkey: outputScripts_1.toXOnlyPublicKey(walletSigner.walletKey.publicKey),
46
- path: rootWalletKeys.getDerivationPath(walletSigner.rootKey, unspent.chain, unspent.index),
47
- masterFingerprint: walletSigner.rootKey.fingerprint,
48
- })),
49
- });
50
- }
51
- else {
52
- if (signatureCount === 0) {
53
- const { witnessScript, redeemScript } = outputScripts_1.createOutputScript2of3(walletKeys.publicKeys, scriptType);
54
- if (witnessScript && psbt.data.inputs[inputIndex].witnessScript === undefined) {
55
- psbt.updateInput(inputIndex, { witnessScript });
56
- }
57
- if (redeemScript && psbt.data.inputs[inputIndex].redeemScript === undefined) {
58
- psbt.updateInput(inputIndex, { redeemScript });
59
- }
60
- }
61
- psbt.updateInput(inputIndex, {
62
- bip32Derivation: [0, 1, 2].map((idx) => ({
63
- pubkey: walletKeys.triple[idx].publicKey,
64
- path: walletKeys.paths[idx],
65
- masterFingerprint: rootWalletKeys.triple[idx].fingerprint,
66
- })),
67
- });
68
- }
69
- }
70
- /**
71
- * @return PSBT filled with metatdata as per input params tx, unspents and rootWalletKeys.
72
- * Unsigned PSBT for taproot input with witnessUtxo
73
- * Unsigned PSBT for other input with witnessUtxo/nonWitnessUtxo, redeemScript/witnessScript, bip32Derivation
74
- * Signed PSBT for taproot input with witnessUtxo, tapLeafScript, tapBip32Derivation, tapScriptSig
75
- * Signed PSBT for other input with witnessUtxo/nonWitnessUtxo, redeemScript/witnessScript, bip32Derivation, partialSig
76
- */
77
- function toWalletPsbt(tx, unspents, rootWalletKeys) {
78
- const prevOutputs = unspents.map((u) => Unspent_1.toPrevOutputWithPrevTx(u, tx.network));
79
- const psbt = transaction_1.createPsbtFromTransaction(tx, prevOutputs);
80
- unspents.forEach((u, i) => {
81
- if (Unspent_2.isWalletUnspent(u) && u.index !== undefined) {
82
- updatePsbtInput(psbt, i, u, rootWalletKeys);
83
- }
84
- });
85
- return psbt;
86
- }
87
- exports.toWalletPsbt = toWalletPsbt;
88
- /**
89
- * @param psbt
90
- * @param inputIndex
91
- * @param signer
92
- * @param unspent
93
- * @return signed PSBT with signer's key for unspent
94
- */
95
- function signWalletPsbt(psbt, inputIndex, signer, unspent) {
96
- if (outputScripts_1.scriptTypeForChain(unspent.chain) === 'p2tr') {
97
- psbt.signTaprootInputHD(inputIndex, signer);
98
- }
99
- else {
100
- psbt.signInputHD(inputIndex, signer);
101
- }
102
- }
103
- exports.signWalletPsbt = signWalletPsbt;
104
- function classifyScriptType(input) {
105
- let scriptType;
106
- if (Buffer.isBuffer(input.redeemScript) && Buffer.isBuffer(input.witnessScript)) {
107
- scriptType = 'p2shP2wsh';
108
- }
109
- else if (Buffer.isBuffer(input.redeemScript)) {
110
- scriptType = 'p2sh';
111
- }
112
- else if (Buffer.isBuffer(input.witnessScript)) {
113
- scriptType = 'p2wsh';
114
- }
115
- if (Array.isArray(input.tapLeafScript) && input.tapLeafScript.length > 0) {
116
- if (scriptType) {
117
- throw new Error(`Found both ${scriptType} and p2tr PSBT metadata.`);
118
- }
119
- if (input.tapLeafScript.length > 1) {
120
- throw new Error('Bitgo only supports a single tap leaf script per input.');
121
- }
122
- scriptType = 'p2tr';
123
- }
124
- return scriptType;
125
- }
126
- function parseSignatures(input, scriptType) {
127
- const validate = (sig) => {
128
- if (Buffer.isBuffer(sig)) {
129
- return sig;
130
- }
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)];
146
- }
147
- if (input.tapScriptSig && input.tapScriptSig.length > 0) {
148
- throw new Error('Invalid PSBT signature state');
149
- }
150
- if (!input.partialSig || input.partialSig.length === 0) {
151
- return undefined;
152
- }
153
- if (input.partialSig.length > 2) {
154
- throw new Error('unexpected signature count');
155
- }
156
- return input.partialSig.length === 1
157
- ? [validate(input.partialSig[0].signature)]
158
- : [validate(input.partialSig[0].signature), validate(input.partialSig[1].signature)];
159
- }
160
- function parseScript(input, scriptType) {
161
- let pubScript;
162
- if (scriptType === 'p2sh') {
163
- pubScript = input.redeemScript;
164
- }
165
- else if (scriptType === 'p2wsh' || scriptType === 'p2shP2wsh') {
166
- pubScript = input.witnessScript;
167
- }
168
- else {
169
- pubScript = input.tapLeafScript ? input.tapLeafScript[0].script : undefined;
170
- }
171
- if (!pubScript) {
172
- throw new Error(`Invalid PSBT state for ${scriptType}. Missing required fields.`);
173
- }
174
- return parseInput_1.parsePubScript(pubScript, scriptType);
175
- }
176
- function parseInputMetadata(input, scriptType) {
177
- const parsedPubScript = parseScript(input, scriptType);
178
- const signatures = parseSignatures(input, scriptType);
179
- if (parsedPubScript.scriptType === 'p2tr') {
180
- if (!input.tapLeafScript) {
181
- throw new Error('Invalid PSBT state for p2tr. Missing required fields.');
182
- }
183
- const controlBlock = input.tapLeafScript[0].controlBlock;
184
- if (!parseInput_1.isValidControlBock(controlBlock)) {
185
- throw new Error('Invalid PSBT p2tr script path controlBlock.');
186
- }
187
- const scriptPathLevel = parseInput_1.calculateScriptPathLevel(controlBlock);
188
- const leafVersion = parseInput_1.getScriptPathLevel(controlBlock);
189
- return {
190
- ...parsedPubScript,
191
- signatures,
192
- controlBlock,
193
- scriptPathLevel,
194
- leafVersion,
195
- };
196
- }
197
- else {
198
- if (parsedPubScript.scriptType === 'p2shP2wsh') {
199
- parsedPubScript.redeemScript = input.redeemScript;
200
- }
201
- return {
202
- ...parsedPubScript,
203
- signatures,
204
- };
205
- }
206
- }
207
- /**
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.
216
- */
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');
221
- }
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.');
226
- }
227
- return undefined;
228
- }
229
- return parseInputMetadata(input, scriptType);
230
- }
231
- exports.parsePsbtInput = parsePsbtInput;
232
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUHNidC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4u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