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,134 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.p2tr_ns = void 0;
4
- const networks_1 = require("../networks");
5
- const bitcoinjs_lib_1 = require("bitcoinjs-lib");
6
- const OPS = bitcoinjs_lib_1.script.OPS;
7
- const typef = require('typeforce');
8
- const BITCOIN_NETWORK = networks_1.networks.bitcoin;
9
- function stacksEqual(a, b) {
10
- if (a.length !== b.length)
11
- return false;
12
- return a.every((x, i) => {
13
- return x.equals(b[i]);
14
- });
15
- }
16
- // input: [signatures ...]
17
- // output: [pubKeys[0:n-1] OP_CHECKSIGVERIFY] pubKeys[n-1] OP_CHECKSIG
18
- function p2tr_ns(a, opts) {
19
- if (!a.input && !a.output && !(a.pubkeys && a.pubkeys.length) && !a.signatures) {
20
- throw new TypeError('Not enough data');
21
- }
22
- opts = Object.assign({ validate: true }, opts || {});
23
- if (!opts.eccLib)
24
- throw new Error('ECC Library is required for p2tr_ns.');
25
- const ecc = opts.eccLib;
26
- function isAcceptableSignature(x) {
27
- if (Buffer.isBuffer(x)) {
28
- return (
29
- // empty signatures may be represented as empty buffers
30
- (opts && opts.allowIncomplete && x.length === 0) || bitcoinjs_lib_1.script.isCanonicalSchnorrSignature(x));
31
- }
32
- return !!(opts && opts.allowIncomplete && x === OPS.OP_0);
33
- }
34
- typef({
35
- network: typef.maybe(typef.Object),
36
- output: typef.maybe(typef.Buffer),
37
- pubkeys: typef.maybe(typef.arrayOf(ecc.isXOnlyPoint)),
38
- signatures: typef.maybe(typef.arrayOf(isAcceptableSignature)),
39
- input: typef.maybe(typef.Buffer),
40
- }, a);
41
- const network = a.network || BITCOIN_NETWORK;
42
- const o = { network };
43
- const _chunks = bitcoinjs_lib_1.lazy.value(() => {
44
- if (!a.output)
45
- return;
46
- return bitcoinjs_lib_1.script.decompile(a.output);
47
- });
48
- bitcoinjs_lib_1.lazy.prop(o, 'output', () => {
49
- if (!a.pubkeys)
50
- return;
51
- return bitcoinjs_lib_1.script.compile([].concat(...a.pubkeys.map((pk, i, pks) => [pk, i === pks.length - 1 ? OPS.OP_CHECKSIG : OPS.OP_CHECKSIGVERIFY])));
52
- });
53
- bitcoinjs_lib_1.lazy.prop(o, 'n', () => {
54
- if (!o.pubkeys)
55
- return;
56
- return o.pubkeys.length;
57
- });
58
- bitcoinjs_lib_1.lazy.prop(o, 'pubkeys', () => {
59
- const chunks = _chunks();
60
- if (!chunks)
61
- return;
62
- return chunks.filter((_, index) => index % 2 === 0);
63
- });
64
- bitcoinjs_lib_1.lazy.prop(o, 'signatures', () => {
65
- var _a;
66
- if (!a.input)
67
- return;
68
- return (_a = bitcoinjs_lib_1.script.decompile(a.input)) === null || _a === void 0 ? void 0 : _a.reverse();
69
- });
70
- bitcoinjs_lib_1.lazy.prop(o, 'input', () => {
71
- if (!a.signatures)
72
- return;
73
- return bitcoinjs_lib_1.script.compile([...a.signatures].reverse());
74
- });
75
- bitcoinjs_lib_1.lazy.prop(o, 'witness', () => {
76
- if (!o.input)
77
- return;
78
- return [];
79
- });
80
- bitcoinjs_lib_1.lazy.prop(o, 'name', () => {
81
- if (!o.n)
82
- return;
83
- return `p2tr_ns(${o.n})`;
84
- });
85
- // extended validation
86
- if (opts.validate) {
87
- const chunks = _chunks();
88
- if (chunks) {
89
- if (chunks[chunks.length - 1] !== OPS.OP_CHECKSIG) {
90
- throw new TypeError('Output ends with unexpected opcode');
91
- }
92
- if (chunks
93
- .filter((_, index) => index % 2 === 1)
94
- .slice(0, -1)
95
- .some((op) => op !== OPS.OP_CHECKSIGVERIFY)) {
96
- throw new TypeError('Output contains unexpected opcode');
97
- }
98
- if (o.n > 16 || o.n !== chunks.length / 2) {
99
- throw new TypeError('Output contains too many pubkeys');
100
- }
101
- if (o.pubkeys.some((x) => !ecc.isXOnlyPoint(x))) {
102
- throw new TypeError('Output contains invalid pubkey(s)');
103
- }
104
- if (a.pubkeys && !stacksEqual(a.pubkeys, o.pubkeys)) {
105
- throw new TypeError('Pubkeys mismatch');
106
- }
107
- }
108
- if (a.pubkeys && a.pubkeys.length) {
109
- o.n = a.pubkeys.length;
110
- }
111
- if (a.signatures && o.n) {
112
- if (a.signatures.length < o.n) {
113
- throw new TypeError('Not enough signatures provided');
114
- }
115
- if (a.signatures.length > o.n) {
116
- throw new TypeError('Too many signatures provided');
117
- }
118
- }
119
- if (a.input) {
120
- if (!o.signatures.every(isAcceptableSignature)) {
121
- throw new TypeError('Input has invalid signature(s)');
122
- }
123
- if (a.signatures && !stacksEqual(a.signatures, o.signatures)) {
124
- throw new TypeError('Signature mismatch');
125
- }
126
- if (o.n !== o.signatures.length) {
127
- throw new TypeError(`Signature count mismatch (n: ${o.n}, signatures.length: ${o.signatures.length}`);
128
- }
129
- }
130
- }
131
- return Object.assign(o, a);
132
- }
133
- exports.p2tr_ns = p2tr_ns;
134
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicDJ0cl9ucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wYXltZW50cy9wMnRyX25zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLDBDQUF1QztBQUN2QyxpREFBcUY7QUFFckYsTUFBTSxHQUFHLEdBQUcsc0JBQU8sQ0FBQyxHQUFHLENBQUM7QUFDeEIsTUFBTSxLQUFLLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxDQUFDO0FBRW5DLE1BQU0sZUFBZSxHQUFHLG1CQUFRLENBQUMsT0FBTyxDQUFDO0FBRXpDLFNBQVMsV0FBVyxDQUFDLENBQVcsRUFBRSxDQUFXO0lBQzNDLElBQUksQ0FBQyxDQUFDLE1BQU0sS0FBSyxDQUFDLENBQUMsTUFBTTtRQUFFLE9BQU8sS0FBSyxDQUFDO0lBRXhDLE9BQU8sQ0FBQyxDQUFDLEtBQUssQ0FBQyxDQUFDLENBQUMsRUFBRSxDQUFDLEVBQUUsRUFBRTtRQUN0QixPQUFPLENBQUMsQ0FBQyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7SUFDeEIsQ0FBQyxDQUFDLENBQUM7QUFDTCxDQUFDO0FBRUQsMEJBQTBCO0FBQzFCLHNFQUFzRTtBQUN0RSxTQUFnQixPQUFPLENBQUMsQ0FBVSxFQUFFLElBQWtCO0lBQ3BELElBQUksQ0FBQyxDQUFDLENBQUMsS0FBSyxJQUFJLENBQUMsQ0FBQyxDQUFDLE1BQU0sSUFBSSxDQUFDLENBQUMsQ0FBQyxDQUFDLE9BQU8sSUFBSSxDQUFD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IHRocm93IG5ldyBUeXBlRXJyb3IoJ1NpZ25hdHVyZSBtaXNtYXRjaCcpO1xuICAgICAgfVxuICAgICAgaWYgKG8ubiAhPT0gby5zaWduYXR1cmVzIS5sZW5ndGgpIHtcbiAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcihgU2lnbmF0dXJlIGNvdW50IG1pc21hdGNoIChuOiAke28ubn0sIHNpZ25hdHVyZXMubGVuZ3RoOiAke28uc2lnbmF0dXJlcyEubGVuZ3RofWApO1xuICAgICAgfVxuICAgIH1cbiAgfVxuXG4gIHJldHVybiBPYmplY3QuYXNzaWduKG8sIGEpO1xufVxuIl19
@@ -1,141 +0,0 @@
1
- /// <reference types="node" />
2
- import { TapTree as PsbtTapTree } from 'bip174/src/lib/interfaces';
3
- import { payments as bpayments } from 'bitcoinjs-lib';
4
- /**
5
- * The 0x02 prefix indicating an even Y coordinate which is implicitly assumed
6
- * on all 32 byte x-only pub keys as defined in BIP340.
7
- */
8
- export declare const EVEN_Y_COORD_PREFIX: Buffer;
9
- export declare const INITIAL_TAPSCRIPT_VERSION = 192;
10
- export interface TinySecp256k1Interface {
11
- isXOnlyPoint(p: Uint8Array): boolean;
12
- xOnlyPointAddTweak(p: Uint8Array, tweak: Uint8Array): XOnlyPointAddTweakResult | null;
13
- pointFromScalar(sk: Uint8Array, compressed?: boolean): Uint8Array | null;
14
- pointMultiply(a: Uint8Array, b: Uint8Array): Uint8Array | null;
15
- pointAdd(a: Uint8Array, b: Uint8Array): Uint8Array | null;
16
- privateAdd(d: Uint8Array, tweak: Uint8Array): Uint8Array | null;
17
- privateNegate(d: Uint8Array): Uint8Array;
18
- }
19
- /**
20
- * Aggregates a list of public keys into a single MuSig2* public key
21
- * according to the MuSig2 paper.
22
- * @param ecc Elliptic curve implementation
23
- * @param pubkeys The list of pub keys to aggregate
24
- * @returns a 32 byte Buffer representing the aggregate key
25
- */
26
- export declare function aggregateMuSigPubkeys(ecc: TinySecp256k1Interface, pubkeys: Buffer[]): Uint8Array;
27
- /**
28
- * Encodes the length of a script as a bitcoin variable length integer.
29
- * @param script
30
- * @returns
31
- */
32
- export declare function serializeScriptSize(script: Buffer): Buffer;
33
- /**
34
- * Gets a tapleaf tagged hash from a script.
35
- * @param script
36
- * @returns
37
- */
38
- export declare function hashTapLeaf(script: Buffer, leafVersion?: number): Buffer;
39
- /**
40
- * Creates a lexicographically sorted tapbranch from two child taptree nodes
41
- * and returns its tagged hash.
42
- * @param child1
43
- * @param child2
44
- * @returns the tagged tapbranch hash
45
- */
46
- export declare function hashTapBranch(child1: Buffer, child2: Buffer): Buffer;
47
- /**
48
- * Tweaks a privkey, using the tagged hash of its pubkey, and (optionally) a taptree root
49
- * @param ecc Elliptic curve implementation
50
- * @param pubkey public key, used to calculate the tweak
51
- * @param privkey the privkey to tweak
52
- * @param taptreeRoot the taptree root tagged hash
53
- * @returns {Buffer} the tweaked privkey
54
- */
55
- export declare function tapTweakPrivkey(ecc: TinySecp256k1Interface, pubkey: Uint8Array, privkey: Uint8Array, taptreeRoot?: Uint8Array): Uint8Array;
56
- export interface XOnlyPointAddTweakResult {
57
- parity: 1 | 0;
58
- xOnlyPubkey: Uint8Array;
59
- }
60
- /**
61
- * Tweaks an internal pubkey, using the tagged hash of itself, and (optionally) a taptree root
62
- * @param ecc Elliptic curve implementation
63
- * @param pubkey the internal pubkey to tweak
64
- * @param taptreeRoot the taptree root tagged hash
65
- * @returns {TweakedPubkey} the tweaked pubkey
66
- */
67
- export declare function tapTweakPubkey(ecc: TinySecp256k1Interface, pubkey: Uint8Array, taptreeRoot?: Buffer): XOnlyPointAddTweakResult;
68
- export interface Taptree {
69
- root: Buffer;
70
- paths: Buffer[][];
71
- }
72
- /**
73
- * Gets the root hash and hash-paths of a taptree from the depth-first
74
- * construction used in BIP-0371 PSBTs
75
- * @param tree
76
- * @returns {Taptree} the tree, represented by its root hash, and the paths to
77
- * that root from each of the input scripts
78
- */
79
- export declare function getDepthFirstTaptree(tree: PsbtTapTree): Taptree;
80
- /**
81
- * Gets the root hash of a taptree using a weighted Huffman construction from a
82
- * list of scripts and corresponding weights.
83
- * @param scripts
84
- * @param weights
85
- * @returns {Taptree} the tree, represented by its root hash, and the paths to that root from each of the input scripts
86
- */
87
- export declare function getHuffmanTaptree(scripts: Buffer[], weights: Array<number | undefined>): Taptree;
88
- export declare function getControlBlock(parity: 0 | 1, pubkey: Uint8Array, path: Buffer[], leafVersion?: number): Buffer;
89
- export interface KeyPathWitness {
90
- spendType: 'Key';
91
- signature: Buffer;
92
- annex?: Buffer;
93
- }
94
- export interface ScriptPathWitness {
95
- spendType: 'Script';
96
- scriptSig: Buffer[];
97
- tapscript: Buffer;
98
- controlBlock: Buffer;
99
- annex?: Buffer;
100
- }
101
- export interface ControlBlock {
102
- parity: number;
103
- internalPubkey: Buffer;
104
- leafVersion: number;
105
- path: Buffer[];
106
- }
107
- /**
108
- * Parses a taproot witness stack and extracts key data elements.
109
- * @param witnessStack
110
- * @returns {ScriptPathWitness|KeyPathWitness} an object representing the
111
- * parsed witness for a script path or key path spend.
112
- * @throws {Error} if the witness stack does not conform to the BIP 341 script validation rules
113
- */
114
- export declare function parseTaprootWitness(witnessStack: Buffer[]): ScriptPathWitness | KeyPathWitness;
115
- /**
116
- * Parses a taproot control block.
117
- * @param ecc Elliptic curve implementation
118
- * @param controlBlock the control block to parse
119
- * @returns {ControlBlock} the parsed control block
120
- * @throws {Error} if the witness stack does not conform to the BIP 341 script validation rules
121
- */
122
- export declare function parseControlBlock(ecc: TinySecp256k1Interface, controlBlock: Buffer): ControlBlock;
123
- /**
124
- * Calculates the tapleaf hash from a control block and script.
125
- * @param ecc Elliptic curve implementation
126
- * @param controlBlock the control block, either raw or parsed
127
- * @param tapscript the leaf script corresdponding to the control block
128
- * @returns {Buffer} the tapleaf hash
129
- */
130
- export declare function getTapleafHash(ecc: TinySecp256k1Interface, controlBlock: Buffer | ControlBlock, tapscript: Buffer): Buffer;
131
- /**
132
- * Calculates the taptree root hash from a control block and script.
133
- * @param ecc Elliptic curve implementation
134
- * @param controlBlock the control block, either raw or parsed
135
- * @param tapscript the leaf script corresdponding to the control block
136
- * @param tapleafHash the leaf hash if already calculated
137
- * @returns {Buffer} the taptree root hash
138
- */
139
- export declare function getTaptreeRoot(ecc: TinySecp256k1Interface, controlBlock: Buffer | ControlBlock, tapscript: Buffer, tapleafHash?: Buffer): Buffer;
140
- export declare function getTweakedOutputKey(payment: bpayments.Payment): Buffer;
141
- //# sourceMappingURL=taproot.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"taproot.d.ts","sourceRoot":"","sources":["../../src/taproot.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,OAAO,IAAI,WAAW,EAA0B,MAAM,2BAA2B,CAAC;AAG3F,OAAO,EAAwC,QAAQ,IAAI,SAAS,EAAE,MAAM,eAAe,CAAC;AAG5F;;;GAGG;AACH,eAAO,MAAM,mBAAmB,QAAkB,CAAC;AACnD,eAAO,MAAM,yBAAyB,MAAO,CAAC;AAE9C,MAAM,WAAW,sBAAsB;IACrC,YAAY,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;IACrC,kBAAkB,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAG,wBAAwB,GAAG,IAAI,CAAC;IACtF,eAAe,CAAC,EAAE,EAAE,UAAU,EAAE,UAAU,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAAC;IACzE,aAAa,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,CAAC;IAC/D,QAAQ,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,CAAC;IAC1D,UAAU,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,CAAC;IAChE,aAAa,CAAC,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;CAC1C;AAED;;;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