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,168 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.musig = exports.bip32 = exports.ECPair = exports.ecc = void 0;
4
- const createHash = require("create-hash");
5
- const createHmac = require("create-hmac");
6
- const ecpair_1 = require("ecpair");
7
- const necc = require("@noble/secp256k1");
8
- const bip32_1 = require("bip32");
9
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
10
- // @ts-ignore base_crypto is exported as a subPath export, ignoring since compiler complains about importing like this
11
- const baseCrypto = require("@brandonblack/musig/lib/base_crypto");
12
- const musig_1 = require("@brandonblack/musig");
13
- necc.utils.sha256Sync = (...messages) => {
14
- const sha256 = createHash('sha256');
15
- for (const message of messages)
16
- sha256.update(message);
17
- return sha256.digest();
18
- };
19
- necc.utils.hmacSha256Sync = (key, ...messages) => {
20
- const hash = createHmac('sha256', Buffer.from(key));
21
- messages.forEach((m) => hash.update(m));
22
- return Uint8Array.from(hash.digest());
23
- };
24
- const defaultTrue = (param) => param !== false;
25
- function throwToNull(fn) {
26
- try {
27
- return fn();
28
- }
29
- catch (e) {
30
- return null;
31
- }
32
- }
33
- function isPoint(p, xOnly) {
34
- if ((p.length === 32) !== xOnly)
35
- return false;
36
- try {
37
- return !!necc.Point.fromHex(p);
38
- }
39
- catch (e) {
40
- return false;
41
- }
42
- }
43
- function toBigInt(b) {
44
- return Buffer.from(b).readBigUint64BE();
45
- }
46
- const ecc = {
47
- isPoint: (p) => isPoint(p, false),
48
- isPrivate: (d) => necc.utils.isValidPrivateKey(d),
49
- isXOnlyPoint: (p) => isPoint(p, true),
50
- xOnlyPointAddTweak: (p, tweak) => throwToNull(() => {
51
- const P = necc.utils.pointAddScalar(p, tweak, true);
52
- const parity = P[0] % 2 === 1 ? 1 : 0;
53
- return { parity, xOnlyPubkey: P.slice(1) };
54
- }),
55
- pointFromScalar: (sk, compressed) => throwToNull(() => necc.getPublicKey(sk, defaultTrue(compressed))),
56
- pointCompress: (p, compressed) => {
57
- return necc.Point.fromHex(p).toRawBytes(defaultTrue(compressed));
58
- },
59
- pointMultiply: (a, tweak, compressed) => throwToNull(() => necc.utils.pointMultiply(a, tweak, defaultTrue(compressed))),
60
- pointAdd: (a, b, compressed) => throwToNull(() => {
61
- const A = necc.Point.fromHex(a);
62
- const B = necc.Point.fromHex(b);
63
- return A.add(B).toRawBytes(defaultTrue(compressed));
64
- }),
65
- pointAddScalar: (p, tweak, compressed) => throwToNull(() => necc.utils.pointAddScalar(p, tweak, defaultTrue(compressed))),
66
- privateAdd: (d, tweak) => throwToNull(() => {
67
- const res = necc.utils.privateAdd(d, tweak);
68
- // tiny-secp256k1 returns null rather than allowing a 0 private key to be returned
69
- // ECPair.testEcc() requires that behavior.
70
- if (res === null || res === void 0 ? void 0 : res.every((i) => i === 0))
71
- return null;
72
- return res;
73
- }),
74
- privateNegate: (d) => necc.utils.privateNegate(d),
75
- sign: (h, d, e) => {
76
- return necc.signSync(h, d, { der: false, extraEntropy: e });
77
- },
78
- signSchnorr: (h, d, e = Buffer.alloc(32, 0x00)) => {
79
- return necc.schnorr.signSync(h, d, e);
80
- },
81
- verify: (h, Q, signature, strict) => {
82
- return necc.verify(signature, h, Q, { strict });
83
- },
84
- verifySchnorr: (h, Q, signature) => {
85
- return necc.schnorr.verifySync(signature, h, Q);
86
- },
87
- };
88
- exports.ecc = ecc;
89
- const crypto = {
90
- ...baseCrypto,
91
- pointMultiplyUnsafe(p, a, compress) {
92
- try {
93
- const product = necc.Point.fromHex(p).multiplyAndAddUnsafe(necc.Point.ZERO, toBigInt(a), BigInt(1));
94
- if (!product)
95
- return null;
96
- return product.toRawBytes(compress);
97
- }
98
- catch {
99
- return null;
100
- }
101
- },
102
- pointMultiplyAndAddUnsafe(p1, a, p2, compress) {
103
- try {
104
- const p2p = necc.Point.fromHex(p2);
105
- const p = necc.Point.fromHex(p1).multiplyAndAddUnsafe(p2p, toBigInt(a), BigInt(1));
106
- if (!p)
107
- return null;
108
- return p.toRawBytes(compress);
109
- }
110
- catch {
111
- return null;
112
- }
113
- },
114
- pointAdd(a, b, compress) {
115
- try {
116
- return necc.Point.fromHex(a).add(necc.Point.fromHex(b)).toRawBytes(compress);
117
- }
118
- catch {
119
- return null;
120
- }
121
- },
122
- pointAddTweak(p, tweak, compress) {
123
- try {
124
- const P = necc.Point.fromHex(p);
125
- const t = baseCrypto.readSecret(tweak);
126
- const Q = necc.Point.BASE.multiplyAndAddUnsafe(P, t, BigInt(1));
127
- if (!Q)
128
- throw new Error('Tweaked point at infinity');
129
- return Q.toRawBytes(compress);
130
- }
131
- catch {
132
- return null;
133
- }
134
- },
135
- pointCompress(p, compress = true) {
136
- return necc.Point.fromHex(p).toRawBytes(compress);
137
- },
138
- liftX(p) {
139
- try {
140
- return necc.Point.fromHex(p).toRawBytes(false);
141
- }
142
- catch {
143
- return null;
144
- }
145
- },
146
- getPublicKey(s, compress) {
147
- try {
148
- return necc.getPublicKey(s, compress);
149
- }
150
- catch {
151
- return null;
152
- }
153
- },
154
- taggedHash: necc.utils.taggedHashSync,
155
- sha256(...messages) {
156
- const sha256 = createHash('sha256');
157
- for (const message of messages)
158
- sha256.update(message);
159
- return sha256.digest();
160
- },
161
- };
162
- const ECPair = ecpair_1.ECPairFactory(ecc);
163
- exports.ECPair = ECPair;
164
- const bip32 = bip32_1.BIP32Factory(ecc);
165
- exports.bip32 = bip32;
166
- const musig = musig_1.MuSigFactory(crypto);
167
- exports.musig = musig;
168
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm9ibGVfZWNjLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL25vYmxlX2VjYy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSwwQ0FBMEM7QUFDMUMsMENBQTBDO0FBQzFDLG1DQUFtRTtBQUNuRSx5Q0FBeUM7QUFDekMsaUNBQStEO0FBQy9ELDZEQUE2RDtBQUM3RCxzSEFBc0g7QUFDdEgsa0VBQWtFO0FBQ2xFLCtDQUEwRDtBQUUxRCxJQUFJLENBQUMsS0FBSyxDQUFDLFVBQVUsR0FBRyxDQUFDLEdBQUcsUUFBc0IsRUFBYyxFQUFFO0lBQ2hFLE1BQU0sTUFBTSxHQUFHLFVBQVUsQ0FBQyxRQUFRLENBQUMsQ0FBQztJQUNwQyxLQUFLLE1BQU0sT0FBTyxJQUFJLFFBQVE7UUFBRSxNQUFNLENBQUMsTUFBTSxDQUFDLE9BQU8sQ0FBQyxDQUFDO0lBQ3ZELE9BQU8sTUFBTSxDQUFDLE1BQU0sRUFBRSxDQUFDO0FBQ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5jb25zdCBFQ1BhaXI6IEVDUGFpckFQSSA9IEVDUGFpckZhY3RvcnkoZWNjKTtcbmNvbnN0IGJpcDMyOiBCSVAzMkFQSSA9IEJJUDMyRmFjdG9yeShlY2MpO1xuY29uc3QgbXVzaWc6IE11U2lnID0gTXVTaWdGYWN0b3J5KGNyeXB0byk7XG5cbmV4cG9ydCB7IGVjYywgRUNQYWlyLCBFQ1BhaXJBUEksIEVDUGFpckludGVyZmFjZSwgYmlwMzIsIEJJUDMyQVBJLCBCSVAzMkludGVyZmFjZSwgbXVzaWcsIE11U2lnIH07XG4iXX0=
@@ -1,4 +0,0 @@
1
- import { p2tr_ns } from './p2tr_ns';
2
- import { p2tr } from './p2tr';
3
- export { p2tr_ns, p2tr };
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/payments/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC"}
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.p2tr = exports.p2tr_ns = void 0;
4
- const p2tr_ns_1 = require("./p2tr_ns");
5
- Object.defineProperty(exports, "p2tr_ns", { enumerable: true, get: function () { return p2tr_ns_1.p2tr_ns; } });
6
- const p2tr_1 = require("./p2tr");
7
- Object.defineProperty(exports, "p2tr", { enumerable: true, get: function () { return p2tr_1.p2tr; } });
8
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvcGF5bWVudHMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsdUNBQW9DO0FBRzNCLHdGQUhBLGlCQUFPLE9BR0E7QUFGaEIsaUNBQThCO0FBRVoscUZBRlQsV0FBSSxPQUVTIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgcDJ0cl9ucyB9IGZyb20gJy4vcDJ0cl9ucyc7XG5pbXBvcnQgeyBwMnRyIH0gZnJvbSAnLi9wMnRyJztcblxuZXhwb3J0IHsgcDJ0cl9ucywgcDJ0ciB9O1xuIl19
@@ -1,3 +0,0 @@
1
- import { Payment, PaymentOpts } from 'bitcoinjs-lib';
2
- export declare function p2tr(a: Payment, opts?: PaymentOpts): Payment;
3
- //# sourceMappingURL=p2tr.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"p2tr.d.ts","sourceRoot":"","sources":["../../../src/payments/p2tr.ts"],"names":[],"mappings":"AAIA,OAAO,EAAqB,OAAO,EAAE,WAAW,EAAQ,MAAM,eAAe,CAAC;AAgC9E,wBAAgB,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAwU5D"}
@@ -1,348 +0,0 @@
1
- "use strict";
2
- // SegWit version 1 P2TR output type for Taproot defined in
3
- // https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.p2tr = void 0;
6
- const networks_1 = require("../networks");
7
- const bitcoinjs_lib_1 = require("bitcoinjs-lib");
8
- const taproot = require("../taproot");
9
- const noble_ecc_1 = require("../noble_ecc");
10
- const necc = require("@noble/secp256k1");
11
- const typef = require('typeforce');
12
- const OPS = bitcoinjs_lib_1.script.OPS;
13
- const { bech32m } = require('bech32');
14
- const BITCOIN_NETWORK = networks_1.networks.bitcoin;
15
- /**
16
- * A secp256k1 x coordinate with unknown discrete logarithm used for eliminating
17
- * keypath spends, equal to SHA256(uncompressedDER(SECP256K1_GENERATOR_POINT)).
18
- */
19
- const H = Buffer.from('50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0', 'hex');
20
- const EMPTY_BUFFER = Buffer.alloc(0);
21
- function isPlainPubkey(pubKey) {
22
- if (pubKey.length !== 33)
23
- return false;
24
- try {
25
- return !!necc.Point.fromHex(pubKey);
26
- }
27
- catch (e) {
28
- return false;
29
- }
30
- }
31
- function isPlainPubkeys(pubkeys) {
32
- return pubkeys.every(isPlainPubkey);
33
- }
34
- // output: OP_1 {witnessProgram}
35
- function p2tr(a, opts) {
36
- var _a, _b, _c, _d;
37
- if (!a.address && !a.pubkey && !a.pubkeys && !(a.redeems && a.redeems.length) && !a.output && !a.witness) {
38
- throw new TypeError('Not enough data');
39
- }
40
- opts = Object.assign({ validate: true }, opts || {});
41
- if (!opts.eccLib)
42
- throw new Error('ECC Library is required for p2tr.');
43
- const ecc = opts.eccLib;
44
- typef({
45
- network: typef.maybe(typef.Object),
46
- address: typef.maybe(typef.String),
47
- // the output script should be a fixed 34 bytes.
48
- // 1 byte for OP_1 indicating segwit version 1, one byte for 0x20 to push
49
- // the next 32 bytes, followed by the 32 byte witness program
50
- output: typef.maybe(typef.BufferN(34)),
51
- // a single pubkey
52
- pubkey: typef.maybe(ecc.isXOnlyPoint),
53
- // the pub key(s) used for keypath signing.
54
- // aggregated with MuSig2* if > 1
55
- pubkeys: typef.maybe(typef.anyOf(typef.arrayOf(ecc.isXOnlyPoint), typef.arrayOf(isPlainPubkey))),
56
- redeems: typef.maybe(typef.arrayOf({
57
- network: typef.maybe(typef.Object),
58
- output: typef.maybe(typef.Buffer),
59
- weight: typef.maybe(typef.Number),
60
- depth: typef.maybe(typef.Number),
61
- witness: typef.maybe(typef.arrayOf(typef.Buffer)),
62
- })),
63
- redeemIndex: typef.maybe(typef.Number),
64
- signature: typef.maybe(bitcoinjs_lib_1.script.isCanonicalSchnorrSignature),
65
- controlBlock: typef.maybe(typef.Buffer),
66
- annex: typef.maybe(typef.Buffer),
67
- }, a);
68
- const _address = bitcoinjs_lib_1.lazy.value(() => {
69
- if (!a.address)
70
- return undefined;
71
- const result = bech32m.decode(a.address);
72
- const version = result.words.shift();
73
- const data = bech32m.fromWords(result.words);
74
- return {
75
- version,
76
- prefix: result.prefix,
77
- data: Buffer.from(data),
78
- };
79
- });
80
- const _outputPubkey = bitcoinjs_lib_1.lazy.value(() => {
81
- // we remove the first two bytes (OP_1 0x20) from the output script to
82
- // extract the 32 byte taproot pubkey (aka witness program)
83
- return a.output && a.output.slice(2);
84
- });
85
- const network = a.network || BITCOIN_NETWORK;
86
- const o = { network };
87
- const _taprootPaths = bitcoinjs_lib_1.lazy.value(() => {
88
- if (!a.redeems)
89
- return;
90
- if (o.tapTree) {
91
- return taproot.getDepthFirstTaptree(o.tapTree);
92
- }
93
- const outputs = a.redeems.map(({ output }) => output);
94
- if (!outputs.every((output) => output))
95
- return;
96
- return taproot.getHuffmanTaptree(outputs, a.redeems.map(({ weight }) => weight));
97
- });
98
- const _parsedWitness = bitcoinjs_lib_1.lazy.value(() => {
99
- if (!a.witness)
100
- return;
101
- return taproot.parseTaprootWitness(a.witness);
102
- });
103
- const _parsedControlBlock = bitcoinjs_lib_1.lazy.value(() => {
104
- // Can't use o.controlBlock, because it could be circular
105
- if (a.controlBlock)
106
- return taproot.parseControlBlock(ecc, a.controlBlock);
107
- const parsedWitness = _parsedWitness();
108
- if (parsedWitness && parsedWitness.spendType === 'Script') {
109
- return taproot.parseControlBlock(ecc, parsedWitness.controlBlock);
110
- }
111
- });
112
- bitcoinjs_lib_1.lazy.prop(o, 'internalPubkey', () => {
113
- var _a;
114
- if (a.pubkey) {
115
- // single pubkey
116
- return a.pubkey;
117
- }
118
- else if (a.pubkeys && a.pubkeys.length === 1) {
119
- return a.pubkeys[0];
120
- }
121
- else if (a.pubkeys && a.pubkeys.length > 1) {
122
- // multiple pubkeys
123
- if (isPlainPubkeys(a.pubkeys)) {
124
- return Buffer.from(noble_ecc_1.musig.getXOnlyPubkey(noble_ecc_1.musig.keyAgg(noble_ecc_1.musig.keySort(a.pubkeys))));
125
- }
126
- return Buffer.from(taproot.aggregateMuSigPubkeys(ecc, a.pubkeys));
127
- }
128
- else if (_parsedControlBlock()) {
129
- return (_a = _parsedControlBlock()) === null || _a === void 0 ? void 0 : _a.internalPubkey;
130
- }
131
- else {
132
- // If there is no key path spending condition, we use an internal key with unknown secret key.
133
- // TODO: In order to avoid leaking the information that key path spending is not possible it
134
- // is recommended to pick a fresh integer r in the range 0...n-1 uniformly at random and use
135
- // H + rG as internal key. It is possible to prove that this internal key does not have a
136
- // known discrete logarithm with respect to G by revealing r to a verifier who can then
137
- // reconstruct how the internal key was created.
138
- return H;
139
- }
140
- });
141
- const _taprootPubkey = bitcoinjs_lib_1.lazy.value(() => {
142
- var _a;
143
- const parsedControlBlock = _parsedControlBlock();
144
- const parsedWitness = _parsedWitness();
145
- // Refuse to create an unspendable key
146
- if (!a.pubkey && !(a.pubkeys && a.pubkeys.length) && !a.redeems && !parsedControlBlock) {
147
- return;
148
- }
149
- let taptreeRoot;
150
- // Prefer to get the root via the control block because not all redeems may
151
- // be available
152
- if (parsedControlBlock) {
153
- let tapscript;
154
- if (parsedWitness && parsedWitness.spendType === 'Script') {
155
- tapscript = parsedWitness.tapscript;
156
- }
157
- else if (o.redeem && o.redeem.output) {
158
- tapscript = o.redeem.output;
159
- }
160
- if (tapscript)
161
- taptreeRoot = taproot.getTaptreeRoot(ecc, parsedControlBlock, tapscript);
162
- }
163
- if (!taptreeRoot && _taprootPaths())
164
- taptreeRoot = (_a = _taprootPaths()) === null || _a === void 0 ? void 0 : _a.root;
165
- return taproot.tapTweakPubkey(ecc, o === null || o === void 0 ? void 0 : o.internalPubkey, taptreeRoot);
166
- });
167
- bitcoinjs_lib_1.lazy.prop(o, 'tapTree', () => {
168
- if (!a.redeems)
169
- return;
170
- if (a.redeems.find(({ depth }) => depth === undefined)) {
171
- console.warn('Deprecation Warning: Weight-based tap tree construction will be removed in the future. ' +
172
- 'Please use depth-first coding as specified in BIP-0371.');
173
- return;
174
- }
175
- if (!a.redeems.every(({ output }) => output))
176
- return;
177
- return {
178
- leaves: a.redeems.map(({ output, depth }) => {
179
- return {
180
- script: output,
181
- leafVersion: taproot.INITIAL_TAPSCRIPT_VERSION,
182
- depth,
183
- };
184
- }),
185
- };
186
- });
187
- bitcoinjs_lib_1.lazy.prop(o, 'address', () => {
188
- var _a;
189
- const pubkey = _outputPubkey() || (_taprootPubkey() && ((_a = _taprootPubkey()) === null || _a === void 0 ? void 0 : _a.xOnlyPubkey));
190
- // only encode the 32 byte witness program as bech32m
191
- const words = bech32m.toWords(pubkey);
192
- words.unshift(0x01);
193
- return bech32m.encode(network.bech32, words);
194
- });
195
- bitcoinjs_lib_1.lazy.prop(o, 'controlBlock', () => {
196
- const parsedWitness = _parsedWitness();
197
- if (parsedWitness && parsedWitness.spendType === 'Script') {
198
- return parsedWitness.controlBlock;
199
- }
200
- const taprootPubkey = _taprootPubkey();
201
- const taprootPaths = _taprootPaths();
202
- if (!taprootPaths || !taprootPubkey || a.redeemIndex === undefined)
203
- return;
204
- return taproot.getControlBlock(taprootPubkey.parity, o.internalPubkey, taprootPaths.paths[a.redeemIndex]);
205
- });
206
- bitcoinjs_lib_1.lazy.prop(o, 'signature', () => {
207
- const parsedWitness = _parsedWitness();
208
- if (parsedWitness && parsedWitness.spendType === 'Key') {
209
- return parsedWitness.signature;
210
- }
211
- });
212
- bitcoinjs_lib_1.lazy.prop(o, 'annex', () => {
213
- if (!_parsedWitness())
214
- return;
215
- return _parsedWitness().annex;
216
- });
217
- bitcoinjs_lib_1.lazy.prop(o, 'output', () => {
218
- if (a.address) {
219
- const { data } = _address();
220
- return bitcoinjs_lib_1.script.compile([OPS.OP_1, data]);
221
- }
222
- const taprootPubkey = _taprootPubkey();
223
- if (!taprootPubkey)
224
- return;
225
- // OP_1 indicates segwit version 1
226
- return bitcoinjs_lib_1.script.compile([OPS.OP_1, Buffer.from(taprootPubkey.xOnlyPubkey)]);
227
- });
228
- bitcoinjs_lib_1.lazy.prop(o, 'witness', () => {
229
- if (!a.redeems) {
230
- if (a.signature)
231
- return [a.signature]; // Keypath spend
232
- return;
233
- }
234
- else if (!o.redeem) {
235
- return; // No chosen redeem script, can't make witness
236
- }
237
- else if (!o.controlBlock) {
238
- return;
239
- }
240
- let redeemWitness;
241
- // some callers may provide witness elements in the input script
242
- if (o.redeem.input && o.redeem.input.length > 0 && o.redeem.output && o.redeem.output.length > 0) {
243
- // transform redeem input to witness stack
244
- redeemWitness = bitcoinjs_lib_1.script.toStack(bitcoinjs_lib_1.script.decompile(o.redeem.input));
245
- // assigns a new object to o.redeem
246
- o.redeems[a.redeemIndex] = Object.assign({ witness: redeemWitness }, o.redeem);
247
- o.redeem.input = EMPTY_BUFFER;
248
- }
249
- else if (o.redeem.output && o.redeem.output.length > 0 && o.redeem.witness && o.redeem.witness.length > 0) {
250
- redeemWitness = o.redeem.witness;
251
- }
252
- else {
253
- return;
254
- }
255
- const witness = [...redeemWitness, o.redeem.output, o.controlBlock];
256
- if (a.annex) {
257
- witness.push(a.annex);
258
- }
259
- return witness;
260
- });
261
- bitcoinjs_lib_1.lazy.prop(o, 'name', () => {
262
- const nameParts = ['p2tr'];
263
- return nameParts.join('-');
264
- });
265
- bitcoinjs_lib_1.lazy.prop(o, 'redeem', () => {
266
- if (a.redeems) {
267
- if (a.redeemIndex === undefined)
268
- return;
269
- return a.redeems[a.redeemIndex];
270
- }
271
- const parsedWitness = _parsedWitness();
272
- if (parsedWitness && parsedWitness.spendType === 'Script') {
273
- return {
274
- witness: parsedWitness.scriptSig,
275
- output: parsedWitness.tapscript,
276
- };
277
- }
278
- });
279
- // extended validation
280
- if (opts.validate) {
281
- const taprootPubkey = _taprootPubkey();
282
- if (a.output) {
283
- if (a.output[0] !== OPS.OP_1 || a.output[1] !== 0x20) {
284
- throw new TypeError('Output is invalid');
285
- }
286
- // if we're passed both an output script and an address, ensure they match
287
- if (a.address && _outputPubkey && !((_a = _outputPubkey()) === null || _a === void 0 ? void 0 : _a.equals((_b = _address()) === null || _b === void 0 ? void 0 : _b.data))) {
288
- throw new TypeError('mismatch between address & output');
289
- }
290
- if (taprootPubkey && _outputPubkey && !((_c = _outputPubkey()) === null || _c === void 0 ? void 0 : _c.equals(taprootPubkey.xOnlyPubkey))) {
291
- throw new TypeError('mismatch between output and taproot pubkey');
292
- }
293
- }
294
- if (a.address) {
295
- if (taprootPubkey && !((_d = _address()) === null || _d === void 0 ? void 0 : _d.data.equals(taprootPubkey.xOnlyPubkey))) {
296
- throw new TypeError('mismatch between address and taproot pubkey');
297
- }
298
- }
299
- const parsedControlBlock = _parsedControlBlock();
300
- if (parsedControlBlock) {
301
- if (!parsedControlBlock.internalPubkey.equals(o === null || o === void 0 ? void 0 : o.internalPubkey)) {
302
- throw new TypeError('Internal pubkey mismatch');
303
- }
304
- if (taprootPubkey && parsedControlBlock.parity !== taprootPubkey.parity) {
305
- throw new TypeError('Parity mismatch');
306
- }
307
- }
308
- if (a.redeems) {
309
- if (!a.redeems.length)
310
- throw new TypeError('Empty redeems');
311
- if (a.redeemIndex !== undefined && (a.redeemIndex < 0 || a.redeemIndex >= a.redeems.length)) {
312
- throw new TypeError('invalid redeem index');
313
- }
314
- a.redeems.forEach((redeem) => {
315
- if (redeem.network && redeem.network !== network) {
316
- throw new TypeError('Network mismatch');
317
- }
318
- });
319
- }
320
- const chosenRedeem = a.redeems && a.redeemIndex !== undefined && a.redeems[a.redeemIndex];
321
- const parsedWitness = _parsedWitness();
322
- if (parsedWitness && parsedWitness.spendType === 'Key') {
323
- if (a.controlBlock) {
324
- throw new TypeError('unexpected control block for key path');
325
- }
326
- if (a.signature && !a.signature.equals(parsedWitness.signature)) {
327
- throw new TypeError('mismatch between witness & signature');
328
- }
329
- }
330
- if (parsedWitness && parsedWitness.spendType === 'Script') {
331
- if (a.signature) {
332
- throw new TypeError('unexpected signature with script path witness');
333
- }
334
- if (a.controlBlock && !a.controlBlock.equals(parsedWitness.controlBlock)) {
335
- throw new TypeError('control block mismatch');
336
- }
337
- if (a.annex && parsedWitness.annex && !a.annex.equals(parsedWitness.annex)) {
338
- throw new TypeError('annex mismatch');
339
- }
340
- if (chosenRedeem && chosenRedeem.output && !chosenRedeem.output.equals(parsedWitness.tapscript)) {
341
- throw new TypeError('tapscript mismatch');
342
- }
343
- }
344
- }
345
- return Object.assign(o, a);
346
- }
347
- exports.p2tr = p2tr;
348
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicDJ0ci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wYXltZW50cy9wMnRyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSwyREFBMkQ7QUFDM0QsaUVBQWlFOzs7QUFFakUsMENBQXVDO0FBQ3ZDLGlEQUE4RTtBQUM5RSxzQ0FBc0M7QUFDdEMsNENBQXFDO0FBQ3JDLHlDQUF5QztBQUN6QyxNQUFNLEtBQUssR0FBRyxPQUFPLENBQUMsV0FBVyxDQUFDLENBQUM7QUFDbkMsTUFBTSxHQUFHLEdBQUcsc0JBQU8sQ0FBQyxHQUFHLENBQUM7QUFFeEIsTUFBTSxFQUFFLE9BQU8sRUFBRSxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQztBQUV0QyxNQUFNLGVBQWUsR0FBRyxtQkFBUSxDQUFDLE9BQU8sQ0FBQztBQUV6Qzs7O0dBR0c7QUFDSCxNQUFNLENBQUMsR0FBRyxNQUFNLENBQUMsSUFBSSxDQUFDLGtFQUFrRSxFQUFFLEtBQUssQ0FBQyxDQUFDO0FBQ2pHLE1BQU0sWUFBWSxHQUFHLE1BQU0sQ0FBQyxLQUFLLENBQUMsQ0FBQyxDQUFDLENBQUM7QUFFckMsU0FBUyxhQUFhLENBQUMsTUFBa0I7SUFDdkMsSUFBSSxNQUFNLENBQUMsTUFBTSxLQUFLLEVBQUU7UUFBRSxPQUFPLEtBQUssQ0FBQztJQUN2QyxJQUFJO1FBQ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VhbHMocGFyc2VkV2l0bmVzcy5hbm5leCkpIHtcbiAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcignYW5uZXggbWlzbWF0Y2gnKTtcbiAgICAgIH1cblxuICAgICAgaWYgKGNob3NlblJlZGVlbSAmJiBjaG9zZW5SZWRlZW0ub3V0cHV0ICYmICFjaG9zZW5SZWRlZW0ub3V0cHV0LmVxdWFscyhwYXJzZWRXaXRuZXNzLnRhcHNjcmlwdCkpIHtcbiAgICAgICAgdGhyb3cgbmV3IFR5cGVFcnJvcigndGFwc2NyaXB0IG1pc21hdGNoJyk7XG4gICAgICB9XG4gICAgfVxuICB9XG5cbiAgcmV0dXJuIE9iamVjdC5hc3NpZ24obywgYSk7XG59XG4iXX0=
@@ -1,3 +0,0 @@
1
- import { Payment, PaymentOpts } from 'bitcoinjs-lib';
2
- export declare function p2tr_ns(a: Payment, opts?: PaymentOpts): Payment;
3
- //# sourceMappingURL=p2tr_ns.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"p2tr_ns.d.ts","sourceRoot":"","sources":["../../../src/payments/p2tr_ns.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,OAAO,EAAE,WAAW,EAAe,MAAM,eAAe,CAAC;AAiBrF,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAgI/D"}