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,344 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parsePubScript = exports.parseSignatureScript2Of3 = exports.parseSignatureScript = exports.getScriptPathLevel = exports.calculateScriptPathLevel = exports.isValidControlBock = exports.isPlaceholderSignature = void 0;
4
- const opcodes = require("bitcoin-ops");
5
- const bitcoinjs_lib_1 = require("bitcoinjs-lib");
6
- const outputScripts_1 = require("./outputScripts");
7
- const types_1 = require("./types");
8
- function isPlaceholderSignature(v) {
9
- if (Buffer.isBuffer(v)) {
10
- return v.length === 0;
11
- }
12
- return v === 0;
13
- }
14
- exports.isPlaceholderSignature = isPlaceholderSignature;
15
- /**
16
- * @return true iff P2TR script path's control block matches BitGo's need
17
- */
18
- function isValidControlBock(controlBlock) {
19
- // The last stack element is called the control block c, and must have length 33 + 32m
20
- return Buffer.isBuffer(controlBlock) && 33 <= controlBlock.length && controlBlock.length % 32 === 1;
21
- }
22
- exports.isValidControlBock = isValidControlBock;
23
- /**
24
- * @return script path level for P2TR control block
25
- */
26
- function calculateScriptPathLevel(controlBlock) {
27
- if (!Buffer.isBuffer(controlBlock)) {
28
- throw new Error('Invalid control block type.');
29
- }
30
- if (controlBlock.length === 65) {
31
- return 1;
32
- }
33
- if (controlBlock.length === 97) {
34
- return 2;
35
- }
36
- throw new Error('unexpected control block length.');
37
- }
38
- exports.calculateScriptPathLevel = calculateScriptPathLevel;
39
- /**
40
- * @return leaf version for P2TR control block.
41
- */
42
- function getScriptPathLevel(controlBlock) {
43
- if (Buffer.isBuffer(controlBlock) && controlBlock.length > 0) {
44
- return controlBlock[0] & 0xfe;
45
- }
46
- throw new Error('unexpected leafVersion.');
47
- }
48
- exports.getScriptPathLevel = getScriptPathLevel;
49
- function emptyMatchResult() {
50
- return {
51
- ':pubkey': [],
52
- ':pubkey-xonly': [],
53
- ':control-block': [],
54
- ':signature': [],
55
- ':script': [],
56
- };
57
- }
58
- class MatchError extends Error {
59
- constructor(message) {
60
- super(message);
61
- // this property is required to prohibit `return new Error()` when the return type demands `MatchError`
62
- this.__type = 'MatchError';
63
- }
64
- static forPatternElement(p) {
65
- if (typeof p === 'object' && ':script' in p) {
66
- return new MatchError(`error matching nested script`);
67
- }
68
- return new MatchError(`error matching ${p}`);
69
- }
70
- }
71
- /**
72
- * @param script
73
- * @param pattern
74
- * @return MatchResult if script matches pattern. The result will contain the matched values.
75
- */
76
- function matchScript(script, pattern) {
77
- /**
78
- * Match a single script element with a ScriptPatternElement
79
- */
80
- function matchElement(e, p) {
81
- switch (p) {
82
- case 'OP_0':
83
- return e === opcodes.OP_0 || (Buffer.isBuffer(e) && e.length === 0);
84
- case 'OP_1':
85
- case 'OP_2':
86
- case 'OP_3':
87
- case 'OP_CHECKMULTISIG':
88
- case 'OP_CHECKSIG':
89
- case 'OP_CHECKSIGVERIFY':
90
- return e === opcodes[p];
91
- case ':pubkey':
92
- return Buffer.isBuffer(e) && e.length === 33;
93
- case ':pubkey-xonly':
94
- return Buffer.isBuffer(e) && e.length === 32;
95
- case ':signature':
96
- return Buffer.isBuffer(e) || isPlaceholderSignature(e);
97
- case ':control-block':
98
- return Buffer.isBuffer(e) && isValidControlBock(e);
99
- default:
100
- throw new Error(`unknown pattern element ${p}`);
101
- }
102
- }
103
- if (script.length !== pattern.length) {
104
- return new MatchError(`length mismatch`);
105
- }
106
- // Go over each pattern element.
107
- // Collect captures into a result object.
108
- return pattern.reduce((obj, p, i) => {
109
- // if we had a previous mismatch, short-circuit
110
- if (obj instanceof MatchError) {
111
- return obj;
112
- }
113
- const e = script[i];
114
- // for ':script' pattern elements, decompile script element and recurse
115
- if (typeof p === 'object' && ':script' in p) {
116
- if (!Buffer.isBuffer(e)) {
117
- return new MatchError(`expected buffer for :script`);
118
- }
119
- const dec = bitcoinjs_lib_1.script.decompile(e);
120
- if (!dec) {
121
- return new MatchError(`error decompiling nested script`);
122
- }
123
- const match = matchScript(dec, p[':script']);
124
- if (match instanceof MatchError) {
125
- return match;
126
- }
127
- obj[':script'].push({
128
- buffer: e,
129
- match,
130
- });
131
- return obj;
132
- }
133
- const match = matchElement(e, p);
134
- if (!match) {
135
- return MatchError.forPatternElement(p);
136
- }
137
- // if pattern element is a capture, add it to the result obj
138
- if (p === ':signature' && e === 0) {
139
- obj[p].push(e);
140
- }
141
- else if (p in obj) {
142
- if (!Buffer.isBuffer(e)) {
143
- throw new Error(`invalid capture value`);
144
- }
145
- obj[p].push(e);
146
- }
147
- return obj;
148
- }, emptyMatchResult());
149
- }
150
- /**
151
- * @param script
152
- * @param patterns
153
- * @return first match
154
- */
155
- function matchScriptSome(script, patterns) {
156
- for (const p of patterns) {
157
- const m = matchScript(script, p);
158
- if (m instanceof MatchError) {
159
- continue;
160
- }
161
- return m;
162
- }
163
- return new MatchError(`no match for script`);
164
- }
165
- function isLegacy(p) {
166
- return Boolean(p.script && !p.witness);
167
- }
168
- function isWrappedSegwit(p) {
169
- return Boolean(p.script && p.witness);
170
- }
171
- function isNativeSegwit(p) {
172
- return Boolean(!p.script && p.witness);
173
- }
174
- const parseP2shP2pk = (p) => {
175
- if (!isLegacy(p)) {
176
- return new MatchError(`expected legacy input`);
177
- }
178
- const match = matchScript(p.script, [':signature', { ':script': [':pubkey', 'OP_CHECKSIG'] }]);
179
- if (match instanceof MatchError) {
180
- return match;
181
- }
182
- return {
183
- scriptType: 'p2shP2pk',
184
- publicKeys: match[':script'][0].match[':pubkey'],
185
- signatures: match[':signature'],
186
- };
187
- };
188
- function parseP2ms(decScript, scriptType) {
189
- const pattern2Of3 = ['OP_2', ':pubkey', ':pubkey', ':pubkey', 'OP_3', 'OP_CHECKMULTISIG'];
190
- const match = matchScriptSome(decScript, [
191
- /* full-signed, no placeholder signature */
192
- ['OP_0', ':signature', ':signature', { ':script': pattern2Of3 }],
193
- /* half-signed, placeholder signatures */
194
- ['OP_0', ':signature', ':signature', ':signature', { ':script': pattern2Of3 }],
195
- ]);
196
- if (match instanceof MatchError) {
197
- return match;
198
- }
199
- const [redeemScript] = match[':script'];
200
- if (!types_1.isTriple(redeemScript.match[':pubkey'])) {
201
- throw new Error(`invalid pubkey count`);
202
- }
203
- return {
204
- scriptType,
205
- publicKeys: redeemScript.match[':pubkey'],
206
- pubScript: redeemScript.buffer,
207
- signatures: match[':signature'],
208
- redeemScript: scriptType === 'p2sh' ? redeemScript.buffer : undefined,
209
- witnessScript: scriptType === 'p2shP2wsh' || scriptType === 'p2wsh' ? redeemScript.buffer : undefined,
210
- };
211
- }
212
- const parseP2sh2Of3 = (p) => {
213
- if (!isLegacy(p)) {
214
- return new MatchError(`expected legacy input`);
215
- }
216
- return parseP2ms(p.script, 'p2sh');
217
- };
218
- const parseP2shP2wsh2Of3 = (p) => {
219
- if (!isWrappedSegwit(p)) {
220
- return new MatchError(`expected wrapped segwit input`);
221
- }
222
- return { ...parseP2ms(p.witness, 'p2shP2wsh'), redeemScript: p.script[0] };
223
- };
224
- const parseP2wsh2Of3 = (p) => {
225
- if (!isNativeSegwit(p)) {
226
- return new MatchError(`expected native segwit`);
227
- }
228
- return parseP2ms(p.witness, 'p2wsh');
229
- };
230
- const parseP2tr2Of3 = (p) => {
231
- if (!isNativeSegwit(p)) {
232
- return new MatchError(`expected native segwit`);
233
- }
234
- // assumes no annex
235
- const match = matchScript(p.witness, [
236
- ':signature',
237
- ':signature',
238
- { ':script': [':pubkey-xonly', 'OP_CHECKSIGVERIFY', ':pubkey-xonly', 'OP_CHECKSIG'] },
239
- ':control-block',
240
- ]);
241
- if (match instanceof MatchError) {
242
- return match;
243
- }
244
- const [controlBlock] = match[':control-block'];
245
- const scriptPathLevel = calculateScriptPathLevel(controlBlock);
246
- const leafVersion = getScriptPathLevel(controlBlock);
247
- return {
248
- scriptType: 'p2tr',
249
- pubScript: match[':script'][0].buffer,
250
- publicKeys: match[':script'][0].match[':pubkey-xonly'],
251
- signatures: match[':signature'],
252
- controlBlock,
253
- scriptPathLevel,
254
- leafVersion,
255
- };
256
- };
257
- /**
258
- * Parse a transaction's signature script to obtain public keys, signatures, the sig script,
259
- * and other properties.
260
- *
261
- * Only supports script types used in BitGo transactions.
262
- *
263
- * @param input
264
- * @returns ParsedSignatureScript
265
- */
266
- function parseSignatureScript(input) {
267
- const decScript = bitcoinjs_lib_1.script.decompile(input.script);
268
- const parsers = [parseP2sh2Of3, parseP2shP2wsh2Of3, parseP2wsh2Of3, parseP2tr2Of3, parseP2shP2pk];
269
- for (const f of parsers) {
270
- const parsed = f({
271
- script: (decScript === null || decScript === void 0 ? void 0 : decScript.length) === 0 ? null : decScript,
272
- witness: input.witness.length === 0 ? null : input.witness,
273
- });
274
- if (parsed instanceof MatchError) {
275
- continue;
276
- }
277
- return parsed;
278
- }
279
- throw new Error(`could not parse input`);
280
- }
281
- exports.parseSignatureScript = parseSignatureScript;
282
- function parseSignatureScript2Of3(input) {
283
- const result = parseSignatureScript(input);
284
- if (!outputScripts_1.isScriptType2Of3(result.scriptType)) {
285
- throw new Error(`invalid script type`);
286
- }
287
- if (!result.signatures) {
288
- throw new Error(`missing signatures`);
289
- }
290
- if (result.publicKeys.length !== 3 && (result.publicKeys.length !== 2 || result.scriptType !== 'p2tr')) {
291
- throw new Error(`unexpected pubkey count`);
292
- }
293
- return result;
294
- }
295
- exports.parseSignatureScript2Of3 = parseSignatureScript2Of3;
296
- const parseP2msPubScript = (pubScript, scriptType) => {
297
- const match = matchScript([pubScript], [{ ':script': ['OP_2', ':pubkey', ':pubkey', ':pubkey', 'OP_3', 'OP_CHECKMULTISIG'] }]);
298
- if (match instanceof MatchError) {
299
- return match;
300
- }
301
- const [redeemScript] = match[':script'];
302
- if (!types_1.isTriple(redeemScript.match[':pubkey'])) {
303
- throw new Error('invalid pubkey count');
304
- }
305
- return {
306
- scriptType,
307
- publicKeys: redeemScript.match[':pubkey'],
308
- pubScript: redeemScript.buffer,
309
- redeemScript: scriptType === 'p2sh' ? redeemScript.buffer : undefined,
310
- witnessScript: scriptType === 'p2shP2wsh' || scriptType === 'p2wsh' ? redeemScript.buffer : undefined,
311
- };
312
- };
313
- const parseP2tr2Of3PubScript = (pubScript, scriptType) => {
314
- const match = matchScript([pubScript], [{ ':script': [':pubkey-xonly', 'OP_CHECKSIGVERIFY', ':pubkey-xonly', 'OP_CHECKSIG'] }]);
315
- if (match instanceof MatchError) {
316
- return match;
317
- }
318
- return {
319
- scriptType: 'p2tr',
320
- pubScript: match[':script'][0].buffer,
321
- publicKeys: match[':script'][0].match[':pubkey-xonly'],
322
- };
323
- };
324
- /**
325
- * @return pubScript (scriptPubKey/redeemScript/witnessScript) is parsed.
326
- * P2SH => scriptType, pubScript (redeemScript), redeemScript, public keys
327
- * PW2SH => scriptType, pubScript (witnessScript), witnessScript, public keys.
328
- * P2SH-PW2SH => scriptType, pubScript (witnessScript), witnessScript, public keys.
329
- * P2TR => scriptType, pubScript, controlBlock, scriptPathLevel, leafVersion, pub keys, signatures.
330
- */
331
- function parsePubScript(inputPubScript, scriptType) {
332
- const result = scriptType === 'p2tr'
333
- ? parseP2tr2Of3PubScript(inputPubScript, scriptType)
334
- : parseP2msPubScript(inputPubScript, scriptType);
335
- if (result instanceof MatchError) {
336
- throw new Error(result.message);
337
- }
338
- if (result.publicKeys.length !== 3 && (result.publicKeys.length !== 2 || result.scriptType !== 'p2tr')) {
339
- throw new Error('unexpected pubkey count');
340
- }
341
- return result;
342
- }
343
- exports.parsePubScript = parsePubScript;
344
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGFyc2VJbnB1dC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9iaXRnby9wYXJzZUlucHV0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLHVDQUF1QztBQUN2QyxpREFBMkQ7QUFFM0QsbURBQStFO0FBQy9FLG1DQUFtQztBQUVuQyxTQUFnQixzQkFBc0IsQ0FBQyxDQUFrQjtJQUN2RCxJQUFJLE1BQU0sQ0FBQyxRQUFRLENBQUMsQ0FBQyxDQUFDLEVBQUU7UUFDdEIsT0FBTyxDQUFDLENBQUMsTUFBTSxLQUFLLENBQUMsQ0FBQztLQUN2QjtJQUNELE9BQU8sQ0FBQyxLQUFLLENBQUMsQ0FBQztBQUNqQixDQUFDO0FBTEQsd0RBS0M7QUFFRDs7R0FFRztBQUNILFNBQWdCLGtCQUFrQixDQUFDLFlBQW9CO0lBQ3JELHNGQUFzRjtJQUN0RixPQUFPLE1BQU0sQ0FBQyxRQUFRLENBQUMsWUFBWSxDQUFDLElBQUksRUFBRSxJQUFJLFlBQVksQ0FBQyxNQUFNLElBQUksWUFBWSxDQUFD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wdChpbnB1dFB1YlNjcmlwdCwgc2NyaXB0VHlwZSk7XG5cbiAgaWYgKHJlc3VsdCBpbnN0YW5jZW9mIE1hdGNoRXJyb3IpIHtcbiAgICB0aHJvdyBuZXcgRXJyb3IocmVzdWx0Lm1lc3NhZ2UpO1xuICB9XG5cbiAgaWYgKHJlc3VsdC5wdWJsaWNLZXlzLmxlbmd0aCAhPT0gMyAmJiAocmVzdWx0LnB1YmxpY0tleXMubGVuZ3RoICE9PSAyIHx8IHJlc3VsdC5zY3JpcHRUeXBlICE9PSAncDJ0cicpKSB7XG4gICAgdGhyb3cgbmV3IEVycm9yKCd1bmV4cGVjdGVkIHB1YmtleSBjb3VudCcpO1xuICB9XG5cbiAgcmV0dXJuIHJlc3VsdDtcbn1cbiJdfQ==
@@ -1,24 +0,0 @@
1
- /// <reference types="node" />
2
- import { PsbtInputUpdate } from 'bip174/src/lib/interfaces';
3
- import { TxOutput } from '../..';
4
- import { UtxoTransaction } from '../UtxoTransaction';
5
- export declare function getInputUpdate(tx: UtxoTransaction<bigint>, vin: number, prevOuts: (TxOutput<bigint> & {
6
- prevTx?: Buffer;
7
- })[]): PsbtInputUpdate;
8
- /**
9
- * Takes a partially signed transaction and removes the scripts and signatures.
10
- *
11
- * Inputs must be one of:
12
- * - p2shP2pk
13
- * - p2sh 2-of-3
14
- * - p2shP2wsh 2-of-3
15
- * - p2wsh 2-of-3
16
- * - p2tr script path 2-of-2
17
- *
18
- * @param tx the partially signed transaction
19
- * @param prevOuts
20
- *
21
- * @return the removed scripts and signatures, ready to be added to a PSBT
22
- */
23
- export declare function unsign(tx: UtxoTransaction<bigint>, prevOuts: TxOutput<bigint>[]): PsbtInputUpdate[];
24
- //# sourceMappingURL=fromHalfSigned.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fromHalfSigned.d.ts","sourceRoot":"","sources":["../../../../src/bitgo/psbt/fromHalfSigned.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAc,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAiB,QAAQ,EAAiC,MAAM,OAAO,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AASrD,wBAAgB,cAAc,CAC5B,EAAE,EAAE,eAAe,CAAC,MAAM,CAAC,EAC3B,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,EAAE,GACnD,eAAe,CA2DjB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,EAAE,EAAE,eAAe,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,GAAG,eAAe,EAAE,CAOnG"}
@@ -1,91 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unsign = exports.getInputUpdate = void 0;
4
- const __1 = require("../..");
5
- const parseInput_1 = require("../parseInput");
6
- const signature_1 = require("../signature");
7
- const outputScripts_1 = require("../outputScripts");
8
- function omitUndefined(v) {
9
- return Object.fromEntries(Object.entries(v).filter(([k, v]) => v !== undefined));
10
- }
11
- function getInputUpdate(tx, vin, prevOuts) {
12
- const nonWitnessUtxo = prevOuts[vin].prevTx;
13
- const { script, witness } = tx.ins[vin];
14
- if (script.length === 0 && witness.length === 0) {
15
- return nonWitnessUtxo ? { nonWitnessUtxo } : {};
16
- }
17
- const parsedInput = parseInput_1.parseSignatureScript(tx.ins[vin]);
18
- function getPartialSigs() {
19
- return signature_1.getSignaturesWithPublicKeys(tx, vin, prevOuts, parsedInput.publicKeys).flatMap((signature, i) => signature
20
- ? [
21
- {
22
- pubkey: parsedInput.publicKeys[i],
23
- signature,
24
- },
25
- ]
26
- : []);
27
- }
28
- // Because Zcash directly hashes the value for non-segwit transactions, we do not need to check indirectly
29
- // with the previous transaction. Therefore, we can treat Zcash non-segwit transactions as Bitcoin
30
- // segwit transactions
31
- if (!outputScripts_1.hasWitnessData(parsedInput.scriptType) && !nonWitnessUtxo && __1.getMainnet(tx.network) !== __1.networks.zcash) {
32
- throw new Error(`scriptType ${parsedInput.scriptType} requires prevTx Buffer`);
33
- }
34
- switch (parsedInput.scriptType) {
35
- case 'p2shP2pk':
36
- return {
37
- nonWitnessUtxo,
38
- partialSig: [{ pubkey: parsedInput.publicKeys[0], signature: parsedInput.signatures[0] }],
39
- };
40
- case 'p2sh':
41
- case 'p2wsh':
42
- case 'p2shP2wsh':
43
- return omitUndefined({
44
- nonWitnessUtxo,
45
- partialSig: getPartialSigs(),
46
- redeemScript: parsedInput.redeemScript,
47
- witnessScript: parsedInput.witnessScript,
48
- });
49
- case 'p2tr':
50
- if (!('controlBlock' in parsedInput)) {
51
- throw new Error(`keypath not implemented`);
52
- }
53
- const leafHash = __1.taproot.getTapleafHash(__1.ecc, parsedInput.controlBlock, parsedInput.pubScript);
54
- return {
55
- tapLeafScript: [
56
- {
57
- controlBlock: parsedInput.controlBlock,
58
- script: parsedInput.pubScript,
59
- leafVersion: parsedInput.leafVersion,
60
- },
61
- ],
62
- tapScriptSig: getPartialSigs().map((obj) => ({ ...obj, leafHash })),
63
- };
64
- }
65
- }
66
- exports.getInputUpdate = getInputUpdate;
67
- /**
68
- * Takes a partially signed transaction and removes the scripts and signatures.
69
- *
70
- * Inputs must be one of:
71
- * - p2shP2pk
72
- * - p2sh 2-of-3
73
- * - p2shP2wsh 2-of-3
74
- * - p2wsh 2-of-3
75
- * - p2tr script path 2-of-2
76
- *
77
- * @param tx the partially signed transaction
78
- * @param prevOuts
79
- *
80
- * @return the removed scripts and signatures, ready to be added to a PSBT
81
- */
82
- function unsign(tx, prevOuts) {
83
- return tx.ins.map((input, vin) => {
84
- const update = getInputUpdate(tx, vin, prevOuts);
85
- input.witness = [];
86
- input.script = Buffer.alloc(0);
87
- return update;
88
- });
89
- }
90
- exports.unsign = unsign;
91
- //# sourceMappingURL=data:application/json;base64,e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biAqIEBwYXJhbSB0eCB0aGUgcGFydGlhbGx5IHNpZ25lZCB0cmFuc2FjdGlvblxuICogQHBhcmFtIHByZXZPdXRzXG4gKlxuICogQHJldHVybiB0aGUgcmVtb3ZlZCBzY3JpcHRzIGFuZCBzaWduYXR1cmVzLCByZWFkeSB0byBiZSBhZGRlZCB0byBhIFBTQlRcbiAqL1xuZXhwb3J0IGZ1bmN0aW9uIHVuc2lnbih0eDogVXR4b1RyYW5zYWN0aW9uPGJpZ2ludD4sIHByZXZPdXRzOiBUeE91dHB1dDxiaWdpbnQ+W10pOiBQc2J0SW5wdXRVcGRhdGVbXSB7XG4gIHJldHVybiB0eC5pbnMubWFwKChpbnB1dCwgdmluKSA9PiB7XG4gICAgY29uc3QgdXBkYXRlID0gZ2V0SW5wdXRVcGRhdGUodHgsIHZpbiwgcHJldk91dHMpO1xuICAgIGlucHV0LndpdG5lc3MgPSBbXTtcbiAgICBpbnB1dC5zY3JpcHQgPSBCdWZmZXIuYWxsb2MoMCk7XG4gICAgcmV0dXJuIHVwZGF0ZTtcbiAgfSk7XG59XG4iXX0=
@@ -1,6 +0,0 @@
1
- /// <reference types="node" />
2
- export declare function isP2wsh(scriptPubkey: Buffer, redeemScript?: Buffer): boolean;
3
- export declare function isP2wpkh(scriptPubkey: Buffer, redeemScript?: Buffer): boolean;
4
- export declare function isTaproot(scriptPubkey: Buffer): boolean;
5
- export declare function isSegwit(scriptPubkey: Buffer, redeemScript?: Buffer): boolean;
6
- //# sourceMappingURL=scriptTypes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scriptTypes.d.ts","sourceRoot":"","sources":["../../../../src/bitgo/psbt/scriptTypes.ts"],"names":[],"mappings":";AAEA,wBAAgB,OAAO,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAG5E;AAED,wBAAgB,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAG7E;AAED,wBAAgB,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED,wBAAgB,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAE7E"}
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isSegwit = exports.isTaproot = exports.isP2wpkh = exports.isP2wsh = void 0;
4
- const opcodes = require("bitcoin-ops");
5
- function isP2wsh(scriptPubkey, redeemScript) {
6
- const witnessProgramCandidate = redeemScript !== null && redeemScript !== void 0 ? redeemScript : scriptPubkey;
7
- return witnessProgramCandidate[0] === opcodes.OP_0 && witnessProgramCandidate.length === 34;
8
- }
9
- exports.isP2wsh = isP2wsh;
10
- function isP2wpkh(scriptPubkey, redeemScript) {
11
- const witnessProgramCandidate = redeemScript !== null && redeemScript !== void 0 ? redeemScript : scriptPubkey;
12
- return witnessProgramCandidate[0] === opcodes.OP_0 && witnessProgramCandidate.length === 22;
13
- }
14
- exports.isP2wpkh = isP2wpkh;
15
- function isTaproot(scriptPubkey) {
16
- return scriptPubkey[0] === opcodes.OP_1 && scriptPubkey.length === 34;
17
- }
18
- exports.isTaproot = isTaproot;
19
- function isSegwit(scriptPubkey, redeemScript) {
20
- return isTaproot(scriptPubkey) || isP2wsh(scriptPubkey, redeemScript) || isP2wpkh(scriptPubkey, redeemScript);
21
- }
22
- exports.isSegwit = isSegwit;
23
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2NyaXB0VHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYml0Z28vcHNidC9zY3JpcHRUeXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSx1Q0FBdUM7QUFFdkMsU0FBZ0IsT0FBTyxDQUFDLFlBQW9CLEVBQUUsWUFBc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