utxo-lib 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (249) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +59 -0
  3. package/dist/src/address.d.ts +11 -0
  4. package/dist/src/address.d.ts.map +1 -0
  5. package/dist/src/address.js +37 -0
  6. package/dist/src/addressFormat.d.ts +53 -0
  7. package/dist/src/addressFormat.d.ts.map +1 -0
  8. package/dist/src/addressFormat.js +110 -0
  9. package/dist/src/bitgo/Musig2.d.ts +51 -0
  10. package/dist/src/bitgo/Musig2.d.ts.map +1 -0
  11. package/dist/src/bitgo/Musig2.js +175 -0
  12. package/dist/src/bitgo/Unspent.d.ts +95 -0
  13. package/dist/src/bitgo/Unspent.d.ts.map +1 -0
  14. package/dist/src/bitgo/Unspent.js +138 -0
  15. package/dist/src/bitgo/UtxoPsbt.d.ts +132 -0
  16. package/dist/src/bitgo/UtxoPsbt.d.ts.map +1 -0
  17. package/dist/src/bitgo/UtxoPsbt.js +469 -0
  18. package/dist/src/bitgo/UtxoTransaction.d.ts +22 -0
  19. package/dist/src/bitgo/UtxoTransaction.d.ts.map +1 -0
  20. package/dist/src/bitgo/UtxoTransaction.js +97 -0
  21. package/dist/src/bitgo/UtxoTransactionBuilder.d.ts +26 -0
  22. package/dist/src/bitgo/UtxoTransactionBuilder.d.ts.map +1 -0
  23. package/dist/src/bitgo/UtxoTransactionBuilder.js +67 -0
  24. package/dist/src/bitgo/bbc/DashPsbt.d.ts +12 -0
  25. package/dist/src/bitgo/bbc/DashPsbt.d.ts.map +1 -0
  26. package/dist/src/bitgo/bbc/DashPsbt.js +27 -0
  27. package/dist/src/bitgo/bbc/DashTransaction.d.ts +39 -0
  28. package/dist/src/bitgo/bbc/DashTransaction.d.ts.map +1 -0
  29. package/dist/src/bitgo/bbc/DashTransaction.js +109 -0
  30. package/dist/src/bitgo/bbc/DashTransactionBuilder.d.ts +14 -0
  31. package/dist/src/bitgo/bbc/DashTransactionBuilder.d.ts.map +1 -0
  32. package/dist/src/bitgo/bbc/DashTransactionBuilder.js +28 -0
  33. package/dist/src/bitgo/bbc/index.d.ts +4 -0
  34. package/dist/src/bitgo/bbc/index.d.ts.map +1 -0
  35. package/dist/src/bitgo/bbc/index.js +16 -0
  36. package/dist/src/bitgo/bitcoincash/address.d.ts +35 -0
  37. package/dist/src/bitgo/bitcoincash/address.d.ts.map +1 -0
  38. package/dist/src/bitgo/bitcoincash/address.js +151 -0
  39. package/dist/src/bitgo/bitcoincash/index.d.ts +2 -0
  40. package/dist/src/bitgo/bitcoincash/index.d.ts.map +1 -0
  41. package/dist/src/bitgo/bitcoincash/index.js +14 -0
  42. package/dist/src/bitgo/dash/DashPsbt.d.ts +12 -0
  43. package/dist/src/bitgo/dash/DashPsbt.d.ts.map +1 -0
  44. package/dist/src/bitgo/dash/DashPsbt.js +27 -0
  45. package/dist/src/bitgo/dash/DashTransaction.d.ts +39 -0
  46. package/dist/src/bitgo/dash/DashTransaction.d.ts.map +1 -0
  47. package/dist/src/bitgo/dash/DashTransaction.js +109 -0
  48. package/dist/src/bitgo/dash/DashTransactionBuilder.d.ts +14 -0
  49. package/dist/src/bitgo/dash/DashTransactionBuilder.d.ts.map +1 -0
  50. package/dist/src/bitgo/dash/DashTransactionBuilder.js +28 -0
  51. package/dist/src/bitgo/dash/index.d.ts +4 -0
  52. package/dist/src/bitgo/dash/index.d.ts.map +1 -0
  53. package/dist/src/bitgo/dash/index.js +16 -0
  54. package/dist/src/bitgo/index.d.ts +17 -0
  55. package/dist/src/bitgo/index.d.ts.map +1 -0
  56. package/dist/src/bitgo/index.js +30 -0
  57. package/dist/src/bitgo/keyutil.d.ts +17 -0
  58. package/dist/src/bitgo/keyutil.d.ts.map +1 -0
  59. package/dist/src/bitgo/keyutil.js +37 -0
  60. package/dist/src/bitgo/nonStandardHalfSigned.d.ts +7 -0
  61. package/dist/src/bitgo/nonStandardHalfSigned.d.ts.map +1 -0
  62. package/dist/src/bitgo/nonStandardHalfSigned.js +56 -0
  63. package/dist/src/bitgo/outputScripts.d.ts +84 -0
  64. package/dist/src/bitgo/outputScripts.d.ts.map +1 -0
  65. package/dist/src/bitgo/outputScripts.js +297 -0
  66. package/dist/src/bitgo/parseInput.d.ts +92 -0
  67. package/dist/src/bitgo/parseInput.d.ts.map +1 -0
  68. package/dist/src/bitgo/parseInput.js +344 -0
  69. package/dist/src/bitgo/psbt/fromHalfSigned.d.ts +24 -0
  70. package/dist/src/bitgo/psbt/fromHalfSigned.d.ts.map +1 -0
  71. package/dist/src/bitgo/psbt/fromHalfSigned.js +91 -0
  72. package/dist/src/bitgo/psbt/scriptTypes.d.ts +6 -0
  73. package/dist/src/bitgo/psbt/scriptTypes.d.ts.map +1 -0
  74. package/dist/src/bitgo/psbt/scriptTypes.js +23 -0
  75. package/dist/src/bitgo/signature.d.ts +84 -0
  76. package/dist/src/bitgo/signature.d.ts.map +1 -0
  77. package/dist/src/bitgo/signature.js +222 -0
  78. package/dist/src/bitgo/tnumber.d.ts +9 -0
  79. package/dist/src/bitgo/tnumber.d.ts.map +1 -0
  80. package/dist/src/bitgo/tnumber.js +31 -0
  81. package/dist/src/bitgo/transaction.d.ts +29 -0
  82. package/dist/src/bitgo/transaction.d.ts.map +1 -0
  83. package/dist/src/bitgo/transaction.js +247 -0
  84. package/dist/src/bitgo/types.d.ts +5 -0
  85. package/dist/src/bitgo/types.d.ts.map +1 -0
  86. package/dist/src/bitgo/types.js +12 -0
  87. package/dist/src/bitgo/wallet/Psbt.d.ts +47 -0
  88. package/dist/src/bitgo/wallet/Psbt.d.ts.map +1 -0
  89. package/dist/src/bitgo/wallet/Psbt.js +232 -0
  90. package/dist/src/bitgo/wallet/Unspent.d.ts +47 -0
  91. package/dist/src/bitgo/wallet/Unspent.d.ts.map +1 -0
  92. package/dist/src/bitgo/wallet/Unspent.js +154 -0
  93. package/dist/src/bitgo/wallet/WalletKeys.d.ts +72 -0
  94. package/dist/src/bitgo/wallet/WalletKeys.d.ts.map +1 -0
  95. package/dist/src/bitgo/wallet/WalletKeys.js +104 -0
  96. package/dist/src/bitgo/wallet/WalletOutput.d.ts +18 -0
  97. package/dist/src/bitgo/wallet/WalletOutput.d.ts.map +1 -0
  98. package/dist/src/bitgo/wallet/WalletOutput.js +69 -0
  99. package/dist/src/bitgo/wallet/WalletScripts.d.ts +7 -0
  100. package/dist/src/bitgo/wallet/WalletScripts.d.ts.map +1 -0
  101. package/dist/src/bitgo/wallet/WalletScripts.js +15 -0
  102. package/dist/src/bitgo/wallet/WalletUnspentSigner.d.ts +19 -0
  103. package/dist/src/bitgo/wallet/WalletUnspentSigner.d.ts.map +1 -0
  104. package/dist/src/bitgo/wallet/WalletUnspentSigner.js +47 -0
  105. package/dist/src/bitgo/wallet/chains.d.ts +57 -0
  106. package/dist/src/bitgo/wallet/chains.d.ts.map +1 -0
  107. package/dist/src/bitgo/wallet/chains.js +106 -0
  108. package/dist/src/bitgo/wallet/index.d.ts +8 -0
  109. package/dist/src/bitgo/wallet/index.d.ts.map +1 -0
  110. package/dist/src/bitgo/wallet/index.js +20 -0
  111. package/dist/src/bitgo/zcash/ZcashBufferutils.d.ts +26 -0
  112. package/dist/src/bitgo/zcash/ZcashBufferutils.d.ts.map +1 -0
  113. package/dist/src/bitgo/zcash/ZcashBufferutils.js +157 -0
  114. package/dist/src/bitgo/zcash/ZcashPsbt.d.ts +36 -0
  115. package/dist/src/bitgo/zcash/ZcashPsbt.d.ts.map +1 -0
  116. package/dist/src/bitgo/zcash/ZcashPsbt.js +146 -0
  117. package/dist/src/bitgo/zcash/ZcashTransaction.d.ts +61 -0
  118. package/dist/src/bitgo/zcash/ZcashTransaction.d.ts.map +1 -0
  119. package/dist/src/bitgo/zcash/ZcashTransaction.js +341 -0
  120. package/dist/src/bitgo/zcash/ZcashTransactionBuilder.d.ts +21 -0
  121. package/dist/src/bitgo/zcash/ZcashTransactionBuilder.d.ts.map +1 -0
  122. package/dist/src/bitgo/zcash/ZcashTransactionBuilder.js +105 -0
  123. package/dist/src/bitgo/zcash/address.d.ts +8 -0
  124. package/dist/src/bitgo/zcash/address.d.ts.map +1 -0
  125. package/dist/src/bitgo/zcash/address.js +57 -0
  126. package/dist/src/bitgo/zcash/hashZip0244.d.ts +27 -0
  127. package/dist/src/bitgo/zcash/hashZip0244.d.ts.map +1 -0
  128. package/dist/src/bitgo/zcash/hashZip0244.js +184 -0
  129. package/dist/src/bitgo/zcash/index.d.ts +4 -0
  130. package/dist/src/bitgo/zcash/index.d.ts.map +1 -0
  131. package/dist/src/bitgo/zcash/index.js +16 -0
  132. package/dist/src/classify.d.ts +19 -0
  133. package/dist/src/classify.d.ts.map +1 -0
  134. package/dist/src/classify.js +89 -0
  135. package/dist/src/index.d.ts +13 -0
  136. package/dist/src/index.d.ts.map +1 -0
  137. package/dist/src/index.js +36 -0
  138. package/dist/src/networks.d.ts +119 -0
  139. package/dist/src/networks.d.ts.map +1 -0
  140. package/dist/src/networks.js +477 -0
  141. package/dist/src/noble_ecc.d.ts +28 -0
  142. package/dist/src/noble_ecc.d.ts.map +1 -0
  143. package/dist/src/noble_ecc.js +168 -0
  144. package/dist/src/payments/index.d.ts +4 -0
  145. package/dist/src/payments/index.d.ts.map +1 -0
  146. package/dist/src/payments/index.js +8 -0
  147. package/dist/src/payments/p2tr.d.ts +3 -0
  148. package/dist/src/payments/p2tr.d.ts.map +1 -0
  149. package/dist/src/payments/p2tr.js +348 -0
  150. package/dist/src/payments/p2tr_ns.d.ts +3 -0
  151. package/dist/src/payments/p2tr_ns.d.ts.map +1 -0
  152. package/dist/src/payments/p2tr_ns.js +134 -0
  153. package/dist/src/taproot.d.ts +141 -0
  154. package/dist/src/taproot.d.ts.map +1 -0
  155. package/dist/src/taproot.js +384 -0
  156. package/dist/src/templates/multisig/index.d.ts +4 -0
  157. package/dist/src/templates/multisig/index.d.ts.map +1 -0
  158. package/dist/src/templates/multisig/index.js +8 -0
  159. package/dist/src/templates/multisig/input.d.ts +7 -0
  160. package/dist/src/templates/multisig/input.d.ts.map +1 -0
  161. package/dist/src/templates/multisig/input.js +25 -0
  162. package/dist/src/templates/multisig/output.d.ts +7 -0
  163. package/dist/src/templates/multisig/output.d.ts.map +1 -0
  164. package/dist/src/templates/multisig/output.js +38 -0
  165. package/dist/src/templates/nulldata.d.ts +10 -0
  166. package/dist/src/templates/nulldata.d.ts.map +1 -0
  167. package/dist/src/templates/nulldata.js +17 -0
  168. package/dist/src/templates/pubkey/index.d.ts +4 -0
  169. package/dist/src/templates/pubkey/index.d.ts.map +1 -0
  170. package/dist/src/templates/pubkey/index.js +8 -0
  171. package/dist/src/templates/pubkey/input.d.ts +7 -0
  172. package/dist/src/templates/pubkey/input.d.ts.map +1 -0
  173. package/dist/src/templates/pubkey/input.js +14 -0
  174. package/dist/src/templates/pubkey/output.d.ts +7 -0
  175. package/dist/src/templates/pubkey/output.d.ts.map +1 -0
  176. package/dist/src/templates/pubkey/output.js +15 -0
  177. package/dist/src/templates/pubkeyhash/index.d.ts +4 -0
  178. package/dist/src/templates/pubkeyhash/index.d.ts.map +1 -0
  179. package/dist/src/templates/pubkeyhash/index.js +8 -0
  180. package/dist/src/templates/pubkeyhash/input.d.ts +7 -0
  181. package/dist/src/templates/pubkeyhash/input.d.ts.map +1 -0
  182. package/dist/src/templates/pubkeyhash/input.js +16 -0
  183. package/dist/src/templates/pubkeyhash/output.d.ts +6 -0
  184. package/dist/src/templates/pubkeyhash/output.d.ts.map +1 -0
  185. package/dist/src/templates/pubkeyhash/output.js +20 -0
  186. package/dist/src/templates/scripthash/index.d.ts +4 -0
  187. package/dist/src/templates/scripthash/index.d.ts.map +1 -0
  188. package/dist/src/templates/scripthash/index.js +8 -0
  189. package/dist/src/templates/scripthash/input.d.ts +6 -0
  190. package/dist/src/templates/scripthash/input.d.ts.map +1 -0
  191. package/dist/src/templates/scripthash/input.js +43 -0
  192. package/dist/src/templates/scripthash/output.d.ts +6 -0
  193. package/dist/src/templates/scripthash/output.d.ts.map +1 -0
  194. package/dist/src/templates/scripthash/output.js +15 -0
  195. package/dist/src/templates/taproot/index.d.ts +4 -0
  196. package/dist/src/templates/taproot/index.d.ts.map +1 -0
  197. package/dist/src/templates/taproot/index.js +8 -0
  198. package/dist/src/templates/taproot/input.d.ts +6 -0
  199. package/dist/src/templates/taproot/input.d.ts.map +1 -0
  200. package/dist/src/templates/taproot/input.js +23 -0
  201. package/dist/src/templates/taproot/output.d.ts +6 -0
  202. package/dist/src/templates/taproot/output.d.ts.map +1 -0
  203. package/dist/src/templates/taproot/output.js +15 -0
  204. package/dist/src/templates/taprootnofn/index.d.ts +4 -0
  205. package/dist/src/templates/taprootnofn/index.d.ts.map +1 -0
  206. package/dist/src/templates/taprootnofn/index.js +8 -0
  207. package/dist/src/templates/taprootnofn/input.d.ts +7 -0
  208. package/dist/src/templates/taprootnofn/input.d.ts.map +1 -0
  209. package/dist/src/templates/taprootnofn/input.js +24 -0
  210. package/dist/src/templates/taprootnofn/output.d.ts +7 -0
  211. package/dist/src/templates/taprootnofn/output.d.ts.map +1 -0
  212. package/dist/src/templates/taprootnofn/output.js +28 -0
  213. package/dist/src/templates/witnesscommitment/index.d.ts +3 -0
  214. package/dist/src/templates/witnesscommitment/index.d.ts.map +1 -0
  215. package/dist/src/templates/witnesscommitment/index.js +6 -0
  216. package/dist/src/templates/witnesscommitment/output.d.ts +8 -0
  217. package/dist/src/templates/witnesscommitment/output.d.ts.map +1 -0
  218. package/dist/src/templates/witnesscommitment/output.js +31 -0
  219. package/dist/src/templates/witnesspubkeyhash/index.d.ts +4 -0
  220. package/dist/src/templates/witnesspubkeyhash/index.d.ts.map +1 -0
  221. package/dist/src/templates/witnesspubkeyhash/index.js +8 -0
  222. package/dist/src/templates/witnesspubkeyhash/input.d.ts +7 -0
  223. package/dist/src/templates/witnesspubkeyhash/input.d.ts.map +1 -0
  224. package/dist/src/templates/witnesspubkeyhash/input.js +19 -0
  225. package/dist/src/templates/witnesspubkeyhash/output.d.ts +6 -0
  226. package/dist/src/templates/witnesspubkeyhash/output.d.ts.map +1 -0
  227. package/dist/src/templates/witnesspubkeyhash/output.js +15 -0
  228. package/dist/src/templates/witnessscripthash/index.d.ts +4 -0
  229. package/dist/src/templates/witnessscripthash/index.d.ts.map +1 -0
  230. package/dist/src/templates/witnessscripthash/index.js +8 -0
  231. package/dist/src/templates/witnessscripthash/input.d.ts +6 -0
  232. package/dist/src/templates/witnessscripthash/input.d.ts.map +1 -0
  233. package/dist/src/templates/witnessscripthash/input.js +35 -0
  234. package/dist/src/templates/witnessscripthash/output.d.ts +6 -0
  235. package/dist/src/templates/witnessscripthash/output.d.ts.map +1 -0
  236. package/dist/src/templates/witnessscripthash/output.js +15 -0
  237. package/dist/src/testutil/index.d.ts +3 -0
  238. package/dist/src/testutil/index.d.ts.map +1 -0
  239. package/dist/src/testutil/index.js +15 -0
  240. package/dist/src/testutil/keys.d.ts +10 -0
  241. package/dist/src/testutil/keys.d.ts.map +1 -0
  242. package/dist/src/testutil/keys.js +40 -0
  243. package/dist/src/testutil/mock.d.ts +21 -0
  244. package/dist/src/testutil/mock.d.ts.map +1 -0
  245. package/dist/src/testutil/mock.js +86 -0
  246. package/dist/src/transaction_builder.d.ts +47 -0
  247. package/dist/src/transaction_builder.d.ts.map +1 -0
  248. package/dist/src/transaction_builder.js +1084 -0
  249. package/package.json +87 -0
@@ -0,0 +1,1084 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TransactionBuilder = void 0;
4
+ const types = require("bitcoinjs-lib/src/types");
5
+ const _1 = require("./");
6
+ const bufferutils = require("bitcoinjs-lib/src/bufferutils");
7
+ const classify = require("./classify");
8
+ const _2 = require("./");
9
+ const _3 = require("./");
10
+ const _4 = require("./");
11
+ const _5 = require("./");
12
+ const _6 = require("./");
13
+ const _7 = require("./");
14
+ const _8 = require("./");
15
+ const noble_ecc_1 = require("./noble_ecc");
16
+ const typeforce = require('typeforce');
17
+ const tfFullSigner = (obj) => {
18
+ return typeforce.Buffer(obj.publicKey) && typeof obj.sign === 'function' && typeof obj.signSchnorr === 'function';
19
+ };
20
+ const SCRIPT_TYPES = classify.types;
21
+ const PREVOUT_TYPES = new Set([
22
+ // Raw
23
+ 'p2pkh',
24
+ 'p2pk',
25
+ 'p2wpkh',
26
+ 'p2ms',
27
+ // P2SH wrapped
28
+ 'p2sh-p2pkh',
29
+ 'p2sh-p2pk',
30
+ 'p2sh-p2wpkh',
31
+ 'p2sh-p2ms',
32
+ // P2WSH wrapped
33
+ 'p2wsh-p2pkh',
34
+ 'p2wsh-p2pk',
35
+ 'p2wsh-p2ms',
36
+ // P2SH-P2WSH wrapper
37
+ 'p2sh-p2wsh-p2pkh',
38
+ 'p2sh-p2wsh-p2pk',
39
+ 'p2sh-p2wsh-p2ms',
40
+ // P2TR KeyPath
41
+ 'p2tr',
42
+ // P2TR ScriptPath
43
+ 'p2tr-p2ns',
44
+ ]);
45
+ function tfMessage(type, value, message) {
46
+ try {
47
+ typeforce(type, value);
48
+ }
49
+ catch (err) {
50
+ throw new Error(message);
51
+ }
52
+ }
53
+ function txIsString(tx) {
54
+ return typeof tx === 'string' || tx instanceof String;
55
+ }
56
+ function txIsTransaction(tx) {
57
+ return tx instanceof _8.Transaction;
58
+ }
59
+ class TransactionBuilder {
60
+ // WARNING: maximumFeeRate is __NOT__ to be relied on,
61
+ // it's just another potential safety mechanism (safety in-depth)
62
+ constructor(network = _3.networks.bitcoin, maximumFeeRate = 2500) {
63
+ this.network = network;
64
+ this.maximumFeeRate = maximumFeeRate;
65
+ this.__PREV_TX_SET = {};
66
+ this.__INPUTS = [];
67
+ this.__TX = new _8.Transaction();
68
+ this.__TX.version = 2;
69
+ this.__USE_LOW_R = false;
70
+ console.warn('Deprecation Warning: TransactionBuilder will be removed in the future. ' +
71
+ '(v6.x.x or later) Please use the Psbt class instead. Examples of usage ' +
72
+ 'are available in the transactions-psbt.js integration test file on our ' +
73
+ 'Github. A high level explanation is available in the psbt.ts and psbt.js ' +
74
+ 'files as well.');
75
+ }
76
+ static fromTransaction(transaction, network, prevOutputs) {
77
+ const txb = new TransactionBuilder(network);
78
+ // Copy transaction fields
79
+ txb.setVersion(transaction.version);
80
+ txb.setLockTime(transaction.locktime);
81
+ // Copy outputs (done first to avoid signature invalidation)
82
+ transaction.outs.forEach((txOut) => {
83
+ txb.addOutput(txOut.script, txOut.value);
84
+ });
85
+ // Copy inputs
86
+ transaction.ins.forEach((txIn) => {
87
+ txb.__addInputUnsafe(txIn.hash, txIn.index, {
88
+ sequence: txIn.sequence,
89
+ script: txIn.script,
90
+ witness: txIn.witness,
91
+ });
92
+ });
93
+ // fix some things not possible through the public API
94
+ txb.__INPUTS.forEach((input, i) => {
95
+ fixMultisigOrder(input, transaction, i, prevOutputs);
96
+ });
97
+ return txb;
98
+ }
99
+ setLowR(setting) {
100
+ typeforce(typeforce.maybe(typeforce.Boolean), setting);
101
+ if (setting === undefined) {
102
+ setting = true;
103
+ }
104
+ this.__USE_LOW_R = setting;
105
+ return setting;
106
+ }
107
+ setLockTime(locktime) {
108
+ typeforce(types.UInt32, locktime);
109
+ // if any signatures exist, throw
110
+ if (this.__INPUTS.some((input) => {
111
+ if (!input.signatures)
112
+ return false;
113
+ return input.signatures.some((s) => s !== undefined);
114
+ })) {
115
+ throw new Error('No, this would invalidate signatures');
116
+ }
117
+ this.__TX.locktime = locktime;
118
+ }
119
+ setVersion(version) {
120
+ typeforce(types.UInt32, version);
121
+ // XXX: this might eventually become more complex depending on what the versions represent
122
+ this.__TX.version = version;
123
+ }
124
+ addInput(txHash, vout, sequence, prevOutScript, value) {
125
+ if (!this.__canModifyInputs()) {
126
+ throw new Error('No, this would invalidate signatures');
127
+ }
128
+ // is it a hex string?
129
+ if (txIsString(txHash)) {
130
+ // transaction hashs's are displayed in reverse order, un-reverse it
131
+ txHash = bufferutils.reverseBuffer(Buffer.from(txHash, 'hex'));
132
+ // is it a Transaction object?
133
+ }
134
+ else if (txIsTransaction(txHash)) {
135
+ const txOut = txHash.outs[vout];
136
+ prevOutScript = txOut.script;
137
+ value = txOut.value;
138
+ txHash = txHash.getHash(false);
139
+ }
140
+ return this.__addInputUnsafe(txHash, vout, {
141
+ sequence,
142
+ prevOutScript,
143
+ value,
144
+ });
145
+ }
146
+ addOutput(scriptPubKey, value) {
147
+ if (!this.__canModifyOutputs()) {
148
+ throw new Error('No, this would invalidate signatures');
149
+ }
150
+ // Attempt to get a script if it's a base58 or bech32 address string
151
+ if (typeof scriptPubKey === 'string') {
152
+ scriptPubKey = _1.address.toOutputScript(scriptPubKey, this.network);
153
+ }
154
+ return this.__TX.addOutput(scriptPubKey, value);
155
+ }
156
+ build() {
157
+ return this.__build(false);
158
+ }
159
+ buildIncomplete() {
160
+ return this.__build(true);
161
+ }
162
+ sign(signParams, keyPair, redeemScript, hashType, witnessValue, witnessScript, controlBlock, annex) {
163
+ trySign(getSigningData(this.network, this.__INPUTS, this.__needsOutputs.bind(this), this.__TX, signParams, keyPair, redeemScript, hashType, witnessValue, witnessScript, controlBlock, annex, this.__USE_LOW_R));
164
+ }
165
+ __addInputUnsafe(txHash, vout, options) {
166
+ if (_8.Transaction.isCoinbaseHash(txHash)) {
167
+ throw new Error('coinbase inputs not supported');
168
+ }
169
+ const prevTxOut = txHash.toString('hex') + ':' + vout;
170
+ if (this.__PREV_TX_SET[prevTxOut] !== undefined)
171
+ throw new Error('Duplicate TxOut: ' + prevTxOut);
172
+ let input = {};
173
+ // derive what we can from the scriptSig
174
+ if (options.script !== undefined || options.witness !== undefined) {
175
+ input = expandInput(options.script, options.witness);
176
+ }
177
+ // if an input value was given, retain it
178
+ if (options.value !== undefined) {
179
+ input.value = options.value;
180
+ }
181
+ // derive what we can from the previous transactions output script
182
+ if (!input.prevOutScript && options.prevOutScript) {
183
+ let prevOutType;
184
+ if (!input.pubkeys && !input.signatures) {
185
+ const expanded = expandOutput(options.prevOutScript);
186
+ if (expanded.pubkeys) {
187
+ input.pubkeys = expanded.pubkeys;
188
+ input.signatures = expanded.signatures;
189
+ }
190
+ prevOutType = expanded.type;
191
+ }
192
+ input.prevOutScript = options.prevOutScript;
193
+ input.prevOutType = prevOutType || classify.output(options.prevOutScript);
194
+ }
195
+ const vin = this.__TX.addInput(txHash, vout, options.sequence, options.scriptSig);
196
+ this.__INPUTS[vin] = input;
197
+ this.__PREV_TX_SET[prevTxOut] = true;
198
+ return vin;
199
+ }
200
+ __build(allowIncomplete) {
201
+ if (!allowIncomplete) {
202
+ if (!this.__TX.ins.length)
203
+ throw new Error('Transaction has no inputs');
204
+ if (!this.__TX.outs.length)
205
+ throw new Error('Transaction has no outputs');
206
+ }
207
+ const tx = this.__TX.clone();
208
+ // create script signatures from inputs
209
+ this.__INPUTS.forEach((input, i) => {
210
+ if (!input.prevOutType && !allowIncomplete)
211
+ throw new Error('Transaction is not complete');
212
+ const result = build(input.prevOutType, input, allowIncomplete);
213
+ if (!result) {
214
+ if (!allowIncomplete && input.prevOutType === SCRIPT_TYPES.NONSTANDARD)
215
+ throw new Error('Unknown input type');
216
+ if (!allowIncomplete)
217
+ throw new Error('Not enough information');
218
+ return;
219
+ }
220
+ if (result.input) {
221
+ tx.setInputScript(i, result.input);
222
+ }
223
+ tx.setWitness(i, result.witness);
224
+ });
225
+ if (!allowIncomplete) {
226
+ // do not rely on this, its merely a last resort
227
+ if (this.__overMaximumFees(tx.virtualSize())) {
228
+ throw new Error('Transaction has absurd fees');
229
+ }
230
+ }
231
+ return tx;
232
+ }
233
+ __canModifyInputs() {
234
+ return this.__INPUTS.every((input) => {
235
+ if (!input.signatures)
236
+ return true;
237
+ return input.signatures.every((signature) => {
238
+ if (!signature)
239
+ return true;
240
+ const hashType = signatureHashType(signature);
241
+ // if SIGHASH_ANYONECANPAY is set, signatures would not
242
+ // be invalidated by more inputs
243
+ return (hashType & _8.Transaction.SIGHASH_ANYONECANPAY) !== 0;
244
+ });
245
+ });
246
+ }
247
+ __needsOutputs(signingHashType) {
248
+ if (signingHashType === _8.Transaction.SIGHASH_ALL || signingHashType === _8.Transaction.SIGHASH_DEFAULT) {
249
+ return this.__TX.outs.length === 0;
250
+ }
251
+ // if inputs are being signed with SIGHASH_NONE, we don't strictly need outputs
252
+ // .build() will fail, but .buildIncomplete() is OK
253
+ return (this.__TX.outs.length === 0 &&
254
+ this.__INPUTS.some((input) => {
255
+ if (!input.signatures)
256
+ return false;
257
+ return input.signatures.some((signature) => {
258
+ if (!signature)
259
+ return false; // no signature, no issue
260
+ const hashType = signatureHashType(signature);
261
+ if (hashType & _8.Transaction.SIGHASH_NONE)
262
+ return false; // SIGHASH_NONE doesn't care about outputs
263
+ return true; // SIGHASH_* does care
264
+ });
265
+ }));
266
+ }
267
+ __canModifyOutputs() {
268
+ const nInputs = this.__TX.ins.length;
269
+ const nOutputs = this.__TX.outs.length;
270
+ return this.__INPUTS.every((input) => {
271
+ if (input.signatures === undefined)
272
+ return true;
273
+ return input.signatures.every((signature) => {
274
+ if (!signature)
275
+ return true;
276
+ const hashType = signatureHashType(signature);
277
+ const hashTypeMod = hashType & 0x1f;
278
+ if (hashTypeMod === _8.Transaction.SIGHASH_NONE)
279
+ return true;
280
+ if (hashTypeMod === _8.Transaction.SIGHASH_SINGLE) {
281
+ // if SIGHASH_SINGLE is set, and nInputs > nOutputs
282
+ // some signatures would be invalidated by the addition
283
+ // of more outputs
284
+ return nInputs <= nOutputs;
285
+ }
286
+ return false;
287
+ });
288
+ });
289
+ }
290
+ __overMaximumFees(bytes) {
291
+ // not all inputs will have .value defined
292
+ const incoming = this.__INPUTS.reduce((a, x) => a + (typeof x.value !== 'undefined' ? BigInt(x.value) : BigInt(0)), BigInt(0));
293
+ // but all outputs do, and if we have any input value
294
+ // we can immediately determine if the outputs are too small
295
+ const outgoing = this.__TX.outs.reduce((a, x) => a + BigInt(x.value), BigInt(0));
296
+ const fee = incoming - outgoing;
297
+ const feeRate = Number(fee) / bytes; // assume fee fits within number
298
+ return feeRate > this.maximumFeeRate;
299
+ }
300
+ }
301
+ exports.TransactionBuilder = TransactionBuilder;
302
+ function expandInput(scriptSig, witnessStack = [], type, scriptPubKey) {
303
+ if (scriptSig && scriptSig.length === 0 && witnessStack.length === 0)
304
+ return {};
305
+ if (!type) {
306
+ let ssType = scriptSig ? classify.input(scriptSig, true) : undefined;
307
+ let wsType = classify.witness(witnessStack, true);
308
+ if (ssType === SCRIPT_TYPES.NONSTANDARD)
309
+ ssType = undefined;
310
+ if (wsType === SCRIPT_TYPES.NONSTANDARD)
311
+ wsType = undefined;
312
+ type = ssType || wsType;
313
+ }
314
+ switch (type) {
315
+ case SCRIPT_TYPES.P2WPKH: {
316
+ const { output, pubkey, signature } = _4.payments.p2wpkh({
317
+ witness: witnessStack,
318
+ });
319
+ return {
320
+ prevOutScript: output,
321
+ prevOutType: SCRIPT_TYPES.P2WPKH,
322
+ pubkeys: [pubkey],
323
+ signatures: [signature],
324
+ };
325
+ }
326
+ case SCRIPT_TYPES.P2PKH: {
327
+ const { output, pubkey, signature } = _4.payments.p2pkh({
328
+ input: scriptSig,
329
+ });
330
+ return {
331
+ prevOutScript: output,
332
+ prevOutType: SCRIPT_TYPES.P2PKH,
333
+ pubkeys: [pubkey],
334
+ signatures: [signature],
335
+ };
336
+ }
337
+ case SCRIPT_TYPES.P2PK: {
338
+ const { signature } = _4.payments.p2pk({ input: scriptSig });
339
+ return {
340
+ prevOutType: SCRIPT_TYPES.P2PK,
341
+ pubkeys: [undefined],
342
+ signatures: [signature],
343
+ };
344
+ }
345
+ case SCRIPT_TYPES.P2MS: {
346
+ const { m, pubkeys, signatures } = _4.payments.p2ms({
347
+ input: scriptSig,
348
+ output: scriptPubKey,
349
+ }, { allowIncomplete: true });
350
+ return {
351
+ prevOutType: SCRIPT_TYPES.P2MS,
352
+ pubkeys,
353
+ signatures,
354
+ maxSignatures: m,
355
+ };
356
+ }
357
+ case SCRIPT_TYPES.P2TR_NS: {
358
+ const { n, pubkeys, signatures } = _1.p2trPayments.p2tr_ns({
359
+ // Witness signatures are reverse of pubkeys, because it's a stack
360
+ signatures: witnessStack.length ? witnessStack.reverse() : undefined,
361
+ output: scriptPubKey,
362
+ }, { allowIncomplete: true, eccLib: noble_ecc_1.ecc });
363
+ return {
364
+ prevOutType: SCRIPT_TYPES.P2TR_NS,
365
+ pubkeys,
366
+ signatures,
367
+ maxSignatures: n,
368
+ };
369
+ }
370
+ }
371
+ if (type === SCRIPT_TYPES.P2SH) {
372
+ const { output, redeem } = _4.payments.p2sh({
373
+ input: scriptSig,
374
+ witness: witnessStack,
375
+ });
376
+ const outputType = classify.output(redeem.output);
377
+ const expanded = expandInput(redeem.input, redeem.witness, outputType, redeem.output);
378
+ if (!expanded.prevOutType)
379
+ return {};
380
+ return {
381
+ prevOutScript: output,
382
+ prevOutType: SCRIPT_TYPES.P2SH,
383
+ redeemScript: redeem.output,
384
+ redeemScriptType: expanded.prevOutType,
385
+ witnessScript: expanded.witnessScript,
386
+ witnessScriptType: expanded.witnessScriptType,
387
+ pubkeys: expanded.pubkeys,
388
+ signatures: expanded.signatures,
389
+ };
390
+ }
391
+ if (type === SCRIPT_TYPES.P2WSH) {
392
+ const { output, redeem } = _4.payments.p2wsh({
393
+ input: scriptSig,
394
+ witness: witnessStack,
395
+ });
396
+ const outputType = classify.output(redeem.output);
397
+ let expanded;
398
+ if (outputType === SCRIPT_TYPES.P2WPKH) {
399
+ expanded = expandInput(redeem.input, redeem.witness, outputType);
400
+ }
401
+ else {
402
+ expanded = expandInput(_5.script.compile(redeem.witness), [], outputType, redeem.output);
403
+ }
404
+ if (!expanded.prevOutType)
405
+ return {};
406
+ return {
407
+ prevOutScript: output,
408
+ prevOutType: SCRIPT_TYPES.P2WSH,
409
+ witnessScript: redeem.output,
410
+ witnessScriptType: expanded.prevOutType,
411
+ pubkeys: expanded.pubkeys,
412
+ signatures: expanded.signatures,
413
+ };
414
+ }
415
+ if (type === SCRIPT_TYPES.P2TR) {
416
+ const parsedWitness = _7.taproot.parseTaprootWitness(witnessStack);
417
+ if (parsedWitness.spendType === 'Key') {
418
+ // key path spend, nothing to expand
419
+ const { signature, annex } = parsedWitness;
420
+ return {
421
+ prevOutType: SCRIPT_TYPES.P2TR,
422
+ signatures: [signature],
423
+ annex,
424
+ };
425
+ }
426
+ else {
427
+ // script path spend
428
+ const { tapscript, controlBlock, annex } = parsedWitness;
429
+ const prevOutScript = _1.p2trPayments.p2tr({
430
+ redeems: [{ output: tapscript }],
431
+ redeemIndex: 0,
432
+ controlBlock,
433
+ annex,
434
+ }, { eccLib: noble_ecc_1.ecc }).output;
435
+ const witnessScriptType = classify.output(tapscript);
436
+ const { pubkeys, signatures } = expandInput(undefined, parsedWitness.scriptSig, witnessScriptType, tapscript);
437
+ return {
438
+ prevOutScript,
439
+ prevOutType: SCRIPT_TYPES.P2TR,
440
+ witnessScript: tapscript,
441
+ witnessScriptType,
442
+ controlBlock,
443
+ annex,
444
+ pubkeys,
445
+ signatures,
446
+ };
447
+ }
448
+ }
449
+ return {
450
+ prevOutType: SCRIPT_TYPES.NONSTANDARD,
451
+ prevOutScript: scriptSig,
452
+ };
453
+ }
454
+ // could be done in expandInput, but requires the original Transaction for hashForSignature
455
+ function fixMultisigOrder(input, transaction, vin, prevOutputs) {
456
+ if (input.redeemScriptType !== SCRIPT_TYPES.P2MS || !input.redeemScript)
457
+ return;
458
+ if (input.pubkeys.length === input.signatures.length)
459
+ return;
460
+ const prevOutput = prevOutputs && prevOutputs[vin];
461
+ const unmatched = input.signatures.concat();
462
+ input.signatures = input.pubkeys.map((pubKey) => {
463
+ const keyPair = noble_ecc_1.ECPair.fromPublicKey(pubKey);
464
+ let match;
465
+ // check for a signature
466
+ unmatched.some((signature, i) => {
467
+ // skip if undefined || OP_0
468
+ if (!signature)
469
+ return false;
470
+ // TODO: avoid O(n) hashForSignature
471
+ const parsed = _5.script.signature.decode(signature);
472
+ const hash = transaction.hashForSignature(vin, input.redeemScript, parsed.hashType, prevOutput === null || prevOutput === void 0 ? void 0 : prevOutput.value);
473
+ // skip if signature does not match pubKey
474
+ if (!keyPair.verify(hash, parsed.signature))
475
+ return false;
476
+ // remove matched signature from unmatched
477
+ unmatched[i] = undefined;
478
+ match = signature;
479
+ return true;
480
+ });
481
+ return match;
482
+ });
483
+ }
484
+ function expandOutput(script, ourPubKey, controlBlock) {
485
+ typeforce(types.Buffer, script);
486
+ const type = classify.output(script);
487
+ switch (type) {
488
+ case SCRIPT_TYPES.P2PKH: {
489
+ if (!ourPubKey)
490
+ return { type };
491
+ // does our hash160(pubKey) match the output scripts?
492
+ const pkh1 = _4.payments.p2pkh({ output: script }).hash;
493
+ const pkh2 = _2.crypto.hash160(ourPubKey);
494
+ if (!pkh1.equals(pkh2))
495
+ return { type };
496
+ return {
497
+ type,
498
+ pubkeys: [ourPubKey],
499
+ signatures: [undefined],
500
+ };
501
+ }
502
+ case SCRIPT_TYPES.P2WPKH: {
503
+ if (!ourPubKey)
504
+ return { type };
505
+ // does our hash160(pubKey) match the output scripts?
506
+ const wpkh1 = _4.payments.p2wpkh({ output: script }).hash;
507
+ const wpkh2 = _2.crypto.hash160(ourPubKey);
508
+ if (!wpkh1.equals(wpkh2))
509
+ return { type };
510
+ return {
511
+ type,
512
+ pubkeys: [ourPubKey],
513
+ signatures: [undefined],
514
+ };
515
+ }
516
+ case SCRIPT_TYPES.P2TR: {
517
+ if (!ourPubKey)
518
+ return { type };
519
+ // HACK ourPubKey to BIP340-style
520
+ if (ourPubKey.length === 33)
521
+ ourPubKey = ourPubKey.slice(1);
522
+ // TODO: support multiple pubkeys
523
+ const p2tr = _1.p2trPayments.p2tr({ pubkey: ourPubKey, controlBlock }, { eccLib: noble_ecc_1.ecc });
524
+ // Does tweaked output for a single pubkey match?
525
+ if (!script.equals(p2tr.output))
526
+ return { type };
527
+ // P2TR KeyPath, single key
528
+ return {
529
+ type,
530
+ pubkeys: [ourPubKey],
531
+ signatures: [undefined],
532
+ };
533
+ }
534
+ case SCRIPT_TYPES.P2TR_NS: {
535
+ const p2trNs = _1.p2trPayments.p2tr_ns({ output: script }, { eccLib: noble_ecc_1.ecc });
536
+ // P2TR ScriptPath
537
+ return {
538
+ type,
539
+ pubkeys: p2trNs.pubkeys,
540
+ signatures: p2trNs.pubkeys.map(() => undefined),
541
+ maxSignatures: p2trNs.pubkeys.length,
542
+ };
543
+ }
544
+ case SCRIPT_TYPES.P2PK: {
545
+ const p2pk = _4.payments.p2pk({ output: script });
546
+ return {
547
+ type,
548
+ pubkeys: [p2pk.pubkey],
549
+ signatures: [undefined],
550
+ };
551
+ }
552
+ case SCRIPT_TYPES.P2MS: {
553
+ const p2ms = _4.payments.p2ms({ output: script });
554
+ return {
555
+ type,
556
+ pubkeys: p2ms.pubkeys,
557
+ signatures: p2ms.pubkeys.map(() => undefined),
558
+ maxSignatures: p2ms.m,
559
+ };
560
+ }
561
+ }
562
+ return { type };
563
+ }
564
+ function prepareInput(input, ourPubKey, redeemScript, witnessScript, controlBlock, annex) {
565
+ if (redeemScript && witnessScript) {
566
+ const p2wsh = _4.payments.p2wsh({
567
+ redeem: { output: witnessScript },
568
+ });
569
+ const p2wshAlt = _4.payments.p2wsh({ output: redeemScript });
570
+ const p2sh = _4.payments.p2sh({ redeem: { output: redeemScript } });
571
+ const p2shAlt = _4.payments.p2sh({ redeem: p2wsh });
572
+ // enforces P2SH(P2WSH(...))
573
+ if (!p2wsh.hash.equals(p2wshAlt.hash))
574
+ throw new Error('Witness script inconsistent with prevOutScript');
575
+ if (!p2sh.hash.equals(p2shAlt.hash))
576
+ throw new Error('Redeem script inconsistent with prevOutScript');
577
+ const expanded = expandOutput(p2wsh.redeem.output, ourPubKey);
578
+ if (!expanded.pubkeys) {
579
+ throw new Error(expanded.type + ' not supported as witnessScript (' + _5.script.toASM(witnessScript) + ')');
580
+ }
581
+ if (input.signatures && input.signatures.some((x) => x !== undefined)) {
582
+ expanded.signatures = input.signatures;
583
+ }
584
+ const signScript = witnessScript;
585
+ if (expanded.type === SCRIPT_TYPES.P2WPKH)
586
+ throw new Error('P2SH(P2WSH(P2WPKH)) is a consensus failure');
587
+ return {
588
+ redeemScript,
589
+ redeemScriptType: SCRIPT_TYPES.P2WSH,
590
+ witnessScript,
591
+ witnessScriptType: expanded.type,
592
+ prevOutType: SCRIPT_TYPES.P2SH,
593
+ prevOutScript: p2sh.output,
594
+ witnessVersion: 0,
595
+ signScript,
596
+ signType: expanded.type,
597
+ pubkeys: expanded.pubkeys,
598
+ signatures: expanded.signatures,
599
+ maxSignatures: expanded.maxSignatures,
600
+ };
601
+ }
602
+ if (redeemScript) {
603
+ const p2sh = _4.payments.p2sh({ redeem: { output: redeemScript } });
604
+ if (input.prevOutScript) {
605
+ let p2shAlt;
606
+ try {
607
+ p2shAlt = _4.payments.p2sh({ output: input.prevOutScript });
608
+ }
609
+ catch (e) {
610
+ throw new Error('PrevOutScript must be P2SH');
611
+ }
612
+ if (!p2sh.hash.equals(p2shAlt.hash))
613
+ throw new Error('Redeem script inconsistent with prevOutScript');
614
+ }
615
+ const expanded = expandOutput(p2sh.redeem.output, ourPubKey);
616
+ if (!expanded.pubkeys) {
617
+ throw new Error(expanded.type + ' not supported as redeemScript (' + _5.script.toASM(redeemScript) + ')');
618
+ }
619
+ if (input.signatures && input.signatures.some((x) => x !== undefined)) {
620
+ expanded.signatures = input.signatures;
621
+ }
622
+ let signScript = redeemScript;
623
+ if (expanded.type === SCRIPT_TYPES.P2WPKH) {
624
+ signScript = _4.payments.p2pkh({ pubkey: expanded.pubkeys[0] }).output;
625
+ }
626
+ return {
627
+ redeemScript,
628
+ redeemScriptType: expanded.type,
629
+ prevOutType: SCRIPT_TYPES.P2SH,
630
+ prevOutScript: p2sh.output,
631
+ witnessVersion: expanded.type === SCRIPT_TYPES.P2WPKH ? 0 : undefined,
632
+ signScript,
633
+ signType: expanded.type,
634
+ pubkeys: expanded.pubkeys,
635
+ signatures: expanded.signatures,
636
+ maxSignatures: expanded.maxSignatures,
637
+ };
638
+ }
639
+ if (witnessScript && controlBlock) {
640
+ // P2TR ScriptPath
641
+ /* tslint:disable-next-line:no-shadowed-variable */
642
+ let prevOutScript = input.prevOutScript;
643
+ if (!prevOutScript) {
644
+ prevOutScript = _1.p2trPayments.p2tr({
645
+ redeems: [{ output: witnessScript }],
646
+ redeemIndex: 0,
647
+ controlBlock,
648
+ annex,
649
+ }, { eccLib: noble_ecc_1.ecc }).output;
650
+ }
651
+ const expanded = expandOutput(witnessScript, ourPubKey);
652
+ if (!expanded.pubkeys) {
653
+ throw new Error(expanded.type + ' not supported as witnessScript (' + _5.script.toASM(witnessScript) + ')');
654
+ }
655
+ if (input.signatures && input.signatures.some((x) => x !== undefined)) {
656
+ expanded.signatures = input.signatures;
657
+ }
658
+ return {
659
+ witnessScript,
660
+ witnessScriptType: expanded.type,
661
+ prevOutType: SCRIPT_TYPES.P2TR,
662
+ prevOutScript,
663
+ witnessVersion: 1,
664
+ signScript: witnessScript,
665
+ signType: expanded.type,
666
+ pubkeys: expanded.pubkeys,
667
+ signatures: expanded.signatures,
668
+ maxSignatures: expanded.maxSignatures,
669
+ controlBlock,
670
+ annex,
671
+ };
672
+ }
673
+ if (witnessScript) {
674
+ const p2wsh = _4.payments.p2wsh({ redeem: { output: witnessScript } });
675
+ if (input.prevOutScript) {
676
+ const p2wshAlt = _4.payments.p2wsh({ output: input.prevOutScript });
677
+ if (!p2wsh.hash.equals(p2wshAlt.hash))
678
+ throw new Error('Witness script inconsistent with prevOutScript');
679
+ }
680
+ const expanded = expandOutput(p2wsh.redeem.output, ourPubKey);
681
+ if (!expanded.pubkeys) {
682
+ throw new Error(expanded.type + ' not supported as witnessScript (' + _5.script.toASM(witnessScript) + ')');
683
+ }
684
+ if (input.signatures && input.signatures.some((x) => x !== undefined)) {
685
+ expanded.signatures = input.signatures;
686
+ }
687
+ const signScript = witnessScript;
688
+ if (expanded.type === SCRIPT_TYPES.P2WPKH)
689
+ throw new Error('P2WSH(P2WPKH) is a consensus failure');
690
+ return {
691
+ witnessScript,
692
+ witnessScriptType: expanded.type,
693
+ prevOutType: SCRIPT_TYPES.P2WSH,
694
+ prevOutScript: p2wsh.output,
695
+ witnessVersion: 0,
696
+ signScript,
697
+ signType: expanded.type,
698
+ pubkeys: expanded.pubkeys,
699
+ signatures: expanded.signatures,
700
+ maxSignatures: expanded.maxSignatures,
701
+ };
702
+ }
703
+ if (input.prevOutType && input.prevOutScript) {
704
+ // embedded scripts are not possible without extra information
705
+ if (input.prevOutType === SCRIPT_TYPES.P2SH) {
706
+ throw new Error('PrevOutScript is ' + input.prevOutType + ', requires redeemScript');
707
+ }
708
+ if (input.prevOutType === SCRIPT_TYPES.P2WSH) {
709
+ throw new Error('PrevOutScript is ' + input.prevOutType + ', requires witnessScript');
710
+ }
711
+ const expanded = expandOutput(input.prevOutScript, ourPubKey);
712
+ if (!expanded.pubkeys) {
713
+ throw new Error(expanded.type + ' not supported (' + _5.script.toASM(input.prevOutScript) + ')');
714
+ }
715
+ if (input.signatures && input.signatures.some((x) => x !== undefined)) {
716
+ expanded.signatures = input.signatures;
717
+ }
718
+ let signScript = input.prevOutScript;
719
+ if (expanded.type === SCRIPT_TYPES.P2WPKH) {
720
+ signScript = _4.payments.p2pkh({ pubkey: expanded.pubkeys[0] }).output;
721
+ }
722
+ let witnessVersion;
723
+ if (expanded.type === SCRIPT_TYPES.P2WPKH) {
724
+ witnessVersion = 0;
725
+ }
726
+ else if (expanded.type === SCRIPT_TYPES.P2TR) {
727
+ witnessVersion = 1;
728
+ }
729
+ return {
730
+ prevOutType: expanded.type,
731
+ prevOutScript: input.prevOutScript,
732
+ witnessVersion,
733
+ signScript,
734
+ signType: expanded.type,
735
+ pubkeys: expanded.pubkeys,
736
+ signatures: expanded.signatures,
737
+ maxSignatures: expanded.maxSignatures,
738
+ };
739
+ }
740
+ const prevOutScript = _4.payments.p2pkh({ pubkey: ourPubKey }).output;
741
+ return {
742
+ prevOutType: SCRIPT_TYPES.P2PKH,
743
+ prevOutScript,
744
+ signScript: prevOutScript,
745
+ signType: SCRIPT_TYPES.P2PKH,
746
+ pubkeys: [ourPubKey],
747
+ signatures: [undefined],
748
+ };
749
+ }
750
+ function build(type, input, allowIncomplete) {
751
+ const pubkeys = (input.pubkeys || []);
752
+ let signatures = (input.signatures || []);
753
+ switch (type) {
754
+ case SCRIPT_TYPES.P2PKH: {
755
+ if (pubkeys.length === 0)
756
+ break;
757
+ if (signatures.length === 0)
758
+ break;
759
+ return _4.payments.p2pkh({ pubkey: pubkeys[0], signature: signatures[0] });
760
+ }
761
+ case SCRIPT_TYPES.P2WPKH: {
762
+ if (pubkeys.length === 0)
763
+ break;
764
+ if (signatures.length === 0)
765
+ break;
766
+ return _4.payments.p2wpkh({ pubkey: pubkeys[0], signature: signatures[0] });
767
+ }
768
+ case SCRIPT_TYPES.P2PK: {
769
+ if (pubkeys.length === 0)
770
+ break;
771
+ if (signatures.length === 0)
772
+ break;
773
+ return _4.payments.p2pk({ signature: signatures[0] });
774
+ }
775
+ case SCRIPT_TYPES.P2MS: {
776
+ const m = input.maxSignatures;
777
+ if (allowIncomplete) {
778
+ signatures = signatures.map((x) => x || _6.opcodes.OP_0);
779
+ }
780
+ else {
781
+ signatures = signatures.filter((x) => x);
782
+ }
783
+ // if the transaction is not not complete (complete), or if signatures.length === m, validate
784
+ // otherwise, the number of OP_0's may be >= m, so don't validate (boo)
785
+ const validate = !allowIncomplete || m === signatures.length;
786
+ return _4.payments.p2ms({ m, pubkeys, signatures }, { allowIncomplete, validate });
787
+ }
788
+ case SCRIPT_TYPES.P2SH: {
789
+ const redeem = build(input.redeemScriptType, input, allowIncomplete);
790
+ if (!redeem)
791
+ return;
792
+ return _4.payments.p2sh({
793
+ redeem: {
794
+ output: redeem.output || input.redeemScript,
795
+ input: redeem.input,
796
+ witness: redeem.witness,
797
+ },
798
+ });
799
+ }
800
+ case SCRIPT_TYPES.P2WSH: {
801
+ const redeem = build(input.witnessScriptType, input, allowIncomplete);
802
+ if (!redeem)
803
+ return;
804
+ return _4.payments.p2wsh({
805
+ redeem: {
806
+ output: input.witnessScript,
807
+ input: redeem.input,
808
+ witness: redeem.witness,
809
+ },
810
+ });
811
+ }
812
+ case SCRIPT_TYPES.P2TR: {
813
+ if (input.witnessScriptType === SCRIPT_TYPES.P2TR_NS) {
814
+ // ScriptPath
815
+ const redeem = build(input.witnessScriptType, input, allowIncomplete);
816
+ return _1.p2trPayments.p2tr({
817
+ output: input.prevOutScript,
818
+ controlBlock: input.controlBlock,
819
+ annex: input.annex,
820
+ redeems: [redeem],
821
+ redeemIndex: 0,
822
+ }, { eccLib: noble_ecc_1.ecc });
823
+ }
824
+ // KeyPath
825
+ if (signatures.length === 0)
826
+ break;
827
+ return _1.p2trPayments.p2tr({ pubkeys, signature: signatures[0] }, { eccLib: noble_ecc_1.ecc });
828
+ }
829
+ case SCRIPT_TYPES.P2TR_NS: {
830
+ const m = input.maxSignatures;
831
+ if (allowIncomplete) {
832
+ signatures = signatures.map((x) => x || _6.opcodes.OP_0);
833
+ }
834
+ else {
835
+ signatures = signatures.filter((x) => x);
836
+ }
837
+ // if the transaction is not not complete (complete), or if signatures.length === m, validate
838
+ // otherwise, the number of OP_0's may be >= m, so don't validate (boo)
839
+ const validate = !allowIncomplete || m === signatures.length;
840
+ return _1.p2trPayments.p2tr_ns({ pubkeys, signatures }, { allowIncomplete, validate, eccLib: noble_ecc_1.ecc });
841
+ }
842
+ }
843
+ }
844
+ function canSign(input) {
845
+ return (input.signScript !== undefined &&
846
+ input.signType !== undefined &&
847
+ input.pubkeys !== undefined &&
848
+ input.signatures !== undefined &&
849
+ input.signatures.length === input.pubkeys.length &&
850
+ input.pubkeys.length > 0 &&
851
+ (input.witnessVersion === undefined || input.value !== undefined));
852
+ }
853
+ function signatureHashType(buffer) {
854
+ if (_5.script.isCanonicalSchnorrSignature(buffer) && buffer.length === 64) {
855
+ return _8.Transaction.SIGHASH_DEFAULT;
856
+ }
857
+ return buffer.readUInt8(buffer.length - 1);
858
+ }
859
+ function checkSignArgs(inputs, signParams) {
860
+ if (!PREVOUT_TYPES.has(signParams.prevOutScriptType)) {
861
+ throw new TypeError(`Unknown prevOutScriptType "${signParams.prevOutScriptType}"`);
862
+ }
863
+ tfMessage(typeforce.Number, signParams.vin, `sign must include vin parameter as Number (input index)`);
864
+ tfMessage(tfFullSigner, signParams.keyPair, `sign must include keyPair parameter as Signer interface`);
865
+ tfMessage(typeforce.maybe(typeforce.Number), signParams.hashType, `sign hashType parameter must be a number`);
866
+ const prevOutType = (inputs[signParams.vin] || []).prevOutType;
867
+ const posType = signParams.prevOutScriptType;
868
+ switch (posType) {
869
+ case 'p2pkh':
870
+ if (prevOutType && prevOutType !== 'pubkeyhash') {
871
+ throw new TypeError(`input #${signParams.vin} is not of type p2pkh: ${prevOutType}`);
872
+ }
873
+ tfMessage(typeforce.value(undefined), signParams.witnessScript, `${posType} requires NO witnessScript`);
874
+ tfMessage(typeforce.value(undefined), signParams.redeemScript, `${posType} requires NO redeemScript`);
875
+ tfMessage(typeforce.value(undefined), signParams.witnessValue, `${posType} requires NO witnessValue`);
876
+ break;
877
+ case 'p2pk':
878
+ if (prevOutType && prevOutType !== 'pubkey') {
879
+ throw new TypeError(`input #${signParams.vin} is not of type p2pk: ${prevOutType}`);
880
+ }
881
+ tfMessage(typeforce.value(undefined), signParams.witnessScript, `${posType} requires NO witnessScript`);
882
+ tfMessage(typeforce.value(undefined), signParams.redeemScript, `${posType} requires NO redeemScript`);
883
+ tfMessage(typeforce.value(undefined), signParams.witnessValue, `${posType} requires NO witnessValue`);
884
+ break;
885
+ case 'p2wpkh':
886
+ if (prevOutType && prevOutType !== 'witnesspubkeyhash') {
887
+ throw new TypeError(`input #${signParams.vin} is not of type p2wpkh: ${prevOutType}`);
888
+ }
889
+ tfMessage(typeforce.value(undefined), signParams.witnessScript, `${posType} requires NO witnessScript`);
890
+ tfMessage(typeforce.value(undefined), signParams.redeemScript, `${posType} requires NO redeemScript`);
891
+ tfMessage(types.Satoshi, signParams.witnessValue, `${posType} requires witnessValue`);
892
+ break;
893
+ case 'p2ms':
894
+ if (prevOutType && prevOutType !== 'multisig') {
895
+ throw new TypeError(`input #${signParams.vin} is not of type p2ms: ${prevOutType}`);
896
+ }
897
+ tfMessage(typeforce.value(undefined), signParams.witnessScript, `${posType} requires NO witnessScript`);
898
+ tfMessage(typeforce.value(undefined), signParams.redeemScript, `${posType} requires NO redeemScript`);
899
+ tfMessage(typeforce.value(undefined), signParams.witnessValue, `${posType} requires NO witnessValue`);
900
+ break;
901
+ case 'p2sh-p2wpkh':
902
+ if (prevOutType && prevOutType !== 'scripthash') {
903
+ throw new TypeError(`input #${signParams.vin} is not of type p2sh-p2wpkh: ${prevOutType}`);
904
+ }
905
+ tfMessage(typeforce.value(undefined), signParams.witnessScript, `${posType} requires NO witnessScript`);
906
+ tfMessage(typeforce.Buffer, signParams.redeemScript, `${posType} requires redeemScript`);
907
+ tfMessage(types.Satoshi, signParams.witnessValue, `${posType} requires witnessValue`);
908
+ break;
909
+ case 'p2sh-p2ms':
910
+ case 'p2sh-p2pk':
911
+ case 'p2sh-p2pkh':
912
+ if (prevOutType && prevOutType !== 'scripthash') {
913
+ throw new TypeError(`input #${signParams.vin} is not of type ${posType}: ${prevOutType}`);
914
+ }
915
+ tfMessage(typeforce.value(undefined), signParams.witnessScript, `${posType} requires NO witnessScript`);
916
+ tfMessage(typeforce.Buffer, signParams.redeemScript, `${posType} requires redeemScript`);
917
+ tfMessage(typeforce.value(undefined), signParams.witnessValue, `${posType} requires NO witnessValue`);
918
+ break;
919
+ case 'p2wsh-p2ms':
920
+ case 'p2wsh-p2pk':
921
+ case 'p2wsh-p2pkh':
922
+ if (prevOutType && prevOutType !== 'witnessscripthash') {
923
+ throw new TypeError(`input #${signParams.vin} is not of type ${posType}: ${prevOutType}`);
924
+ }
925
+ tfMessage(typeforce.Buffer, signParams.witnessScript, `${posType} requires witnessScript`);
926
+ tfMessage(typeforce.value(undefined), signParams.redeemScript, `${posType} requires NO redeemScript`);
927
+ tfMessage(types.Satoshi, signParams.witnessValue, `${posType} requires witnessValue`);
928
+ break;
929
+ case 'p2sh-p2wsh-p2ms':
930
+ case 'p2sh-p2wsh-p2pk':
931
+ case 'p2sh-p2wsh-p2pkh':
932
+ if (prevOutType && prevOutType !== 'scripthash') {
933
+ throw new TypeError(`input #${signParams.vin} is not of type ${posType}: ${prevOutType}`);
934
+ }
935
+ tfMessage(typeforce.Buffer, signParams.witnessScript, `${posType} requires witnessScript`);
936
+ tfMessage(typeforce.Buffer, signParams.redeemScript, `${posType} requires witnessScript`);
937
+ tfMessage(types.Satoshi, signParams.witnessValue, `${posType} requires witnessScript`);
938
+ break;
939
+ case 'p2tr':
940
+ if (prevOutType && prevOutType !== 'taproot') {
941
+ throw new TypeError(`input #${signParams.vin} is not of type ${posType}: ${prevOutType}`);
942
+ }
943
+ tfMessage(typeforce.value(undefined), signParams.witnessScript, `${posType} requires NO witnessScript`);
944
+ tfMessage(typeforce.value(undefined), signParams.redeemScript, `${posType} requires NO redeemScript`);
945
+ tfMessage(typeforce.value(undefined), signParams.witnessValue, `${posType} requires NO witnessValue`);
946
+ break;
947
+ case 'p2tr-p2ns':
948
+ if (prevOutType && prevOutType !== 'taproot') {
949
+ throw new TypeError(`input #${signParams.vin} is not of type ${posType}: ${prevOutType}`);
950
+ }
951
+ inputs[signParams.vin].prevOutType = inputs[signParams.vin].prevOutType || 'taproot';
952
+ tfMessage(typeforce.Buffer, signParams.witnessScript, `${posType} requires witnessScript`);
953
+ tfMessage(typeforce.Buffer, signParams.controlBlock, `${posType} requires controlBlock`);
954
+ tfMessage(typeforce.value(undefined), signParams.redeemScript, `${posType} requires NO redeemScript`);
955
+ break;
956
+ }
957
+ }
958
+ function trySign({ input, ourPubKey, keyPair, signatureHash, hashType, useLowR, taptreeRoot, }) {
959
+ if (input.witnessVersion === 1 && ourPubKey.length === 33)
960
+ ourPubKey = ourPubKey.slice(1);
961
+ // enforce in order signing of public keys
962
+ let signed = false;
963
+ for (const [i, pubKey] of input.pubkeys.entries()) {
964
+ if (!ourPubKey.equals(pubKey))
965
+ continue;
966
+ if (input.signatures[i] && input.signatures[i].length > 0)
967
+ throw new Error('Signature already exists');
968
+ // TODO: add tests
969
+ if (ourPubKey.length !== 33 && input.witnessVersion === 0) {
970
+ throw new Error('BIP143 (Witness v0) inputs require compressed pubkeys');
971
+ }
972
+ else if (ourPubKey.length !== 32 && input.witnessVersion === 1) {
973
+ throw new Error('BIP341 (Witness v1) inputs require x-only pubkeys');
974
+ }
975
+ if (input.witnessVersion === 1) {
976
+ if (!input.witnessScript) {
977
+ // FIXME: Workaround for not having proper tweaking support for key path
978
+ if (!keyPair.privateKey) {
979
+ throw new Error(`unexpected keypair`);
980
+ }
981
+ const privateKey = _7.taproot.tapTweakPrivkey(noble_ecc_1.ecc, ourPubKey, keyPair.privateKey, taptreeRoot);
982
+ keyPair = noble_ecc_1.ECPair.fromPrivateKey(Buffer.from(privateKey));
983
+ }
984
+ // https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#common-signature-message
985
+ const signature = keyPair.signSchnorr(signatureHash);
986
+ // SIGHASH_DEFAULT is omitted from the signature
987
+ if (hashType === _8.Transaction.SIGHASH_DEFAULT) {
988
+ input.signatures[i] = Buffer.from(signature);
989
+ }
990
+ else {
991
+ input.signatures[i] = Buffer.concat([signature, Buffer.of(hashType)]);
992
+ }
993
+ }
994
+ else {
995
+ const signature = keyPair.sign(signatureHash, useLowR);
996
+ input.signatures[i] = _5.script.signature.encode(signature, hashType);
997
+ }
998
+ signed = true;
999
+ }
1000
+ if (!signed)
1001
+ throw new Error('Key pair cannot sign for this input');
1002
+ }
1003
+ function getSigningData(network, inputs, needsOutputs, tx, signParams, keyPair, redeemScript, hashType, witnessValue, witnessScript, controlBlock, annex, useLowR) {
1004
+ let vin;
1005
+ if (typeof signParams === 'number') {
1006
+ console.warn('DEPRECATED: TransactionBuilder sign method arguments ' + 'will change in v6, please use the TxbSignArg interface');
1007
+ vin = signParams;
1008
+ }
1009
+ else if (typeof signParams === 'object') {
1010
+ checkSignArgs(inputs, signParams);
1011
+ ({ vin, keyPair, redeemScript, hashType, witnessValue, witnessScript, controlBlock, annex } = signParams);
1012
+ }
1013
+ else {
1014
+ throw new TypeError('TransactionBuilder sign first arg must be TxbSignArg or number');
1015
+ }
1016
+ if (keyPair === undefined) {
1017
+ throw new Error('sign requires keypair');
1018
+ }
1019
+ if (!inputs[vin])
1020
+ throw new Error('No input at index: ' + vin);
1021
+ const input = inputs[vin];
1022
+ // if redeemScript was previously provided, enforce consistency
1023
+ if (input.redeemScript !== undefined && redeemScript && !input.redeemScript.equals(redeemScript)) {
1024
+ throw new Error('Inconsistent redeemScript');
1025
+ }
1026
+ const ourPubKey = keyPair.publicKey || (keyPair.getPublicKey && keyPair.getPublicKey());
1027
+ if (!canSign(input)) {
1028
+ if (witnessValue !== undefined) {
1029
+ if (input.value !== undefined && input.value !== witnessValue) {
1030
+ throw new Error('Input did not match witnessValue');
1031
+ }
1032
+ typeforce(types.Satoshi, witnessValue);
1033
+ input.value = witnessValue;
1034
+ }
1035
+ if (!canSign(input)) {
1036
+ const prepared = prepareInput(input, ourPubKey, redeemScript, witnessScript, controlBlock, annex);
1037
+ // updates inline
1038
+ Object.assign(input, prepared);
1039
+ }
1040
+ if (!canSign(input))
1041
+ throw Error(input.prevOutType + ' not supported');
1042
+ }
1043
+ // hashType can be 0 in Taproot, so can't use hashType || SIGHASH_ALL
1044
+ if (input.witnessVersion === 1) {
1045
+ hashType = hashType === undefined ? _8.Transaction.SIGHASH_DEFAULT : hashType;
1046
+ }
1047
+ else {
1048
+ hashType = hashType || _8.Transaction.SIGHASH_ALL;
1049
+ }
1050
+ if (needsOutputs(hashType))
1051
+ throw new Error('Transaction needs outputs');
1052
+ // TODO: This is not the best place to do this, but might stick with it until PSBT
1053
+ let leafHash;
1054
+ let taptreeRoot;
1055
+ if (controlBlock && witnessScript) {
1056
+ leafHash = _7.taproot.getTapleafHash(noble_ecc_1.ecc, controlBlock, witnessScript);
1057
+ taptreeRoot = _7.taproot.getTaptreeRoot(noble_ecc_1.ecc, controlBlock, witnessScript, leafHash);
1058
+ }
1059
+ // ready to sign
1060
+ let signatureHash;
1061
+ switch (input.witnessVersion) {
1062
+ case undefined:
1063
+ signatureHash = tx.hashForSignature(vin, input.signScript, hashType, input.value);
1064
+ break;
1065
+ case 0:
1066
+ signatureHash = tx.hashForWitnessV0(vin, input.signScript, input.value, hashType);
1067
+ break;
1068
+ case 1:
1069
+ signatureHash = tx.hashForWitnessV1(vin, inputs.map(({ prevOutScript }) => prevOutScript), inputs.map(({ value }) => value), hashType, leafHash);
1070
+ break;
1071
+ default:
1072
+ throw new TypeError('Unsupported witness version');
1073
+ }
1074
+ return {
1075
+ input,
1076
+ ourPubKey,
1077
+ keyPair,
1078
+ signatureHash,
1079
+ hashType,
1080
+ useLowR: !!useLowR,
1081
+ taptreeRoot,
1082
+ };
1083
+ }
1084
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJhbnNhY3Rpb25fYnVpbGRlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90cmFuc2FjdGlvbl9idWlsZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLGlEQUFpRDtBQUNqRCx5QkFBdUQ7QUFDdkQsNkRBQTZEO0FBQzdELHVDQUF1QztBQUN2Qyx5QkFBdUM7QUFDdkMseUJBQThCO0FBRTlCLHlCQUE4QjtBQUU5Qix5QkFBdUM7QUFDdkMseUJBQW9DO0FBQ3BDLHlCQUE2QjtBQUM3Qix5QkFBMkM7QUFDM0MsMkNBQW9EO0FBVXBELE1BQU0sU0FBUyxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQztBQUV2QyxNQUFNLFlBQVksR0FBRyxDQUFDLEdBQVEsRUFBVyxFQUFFO0lBQ3pDLE9BQU8sU0FBUyxDQUFDLE1BQU0sQ0FBQyxHQUFHLENBQUMsU0FBUyxDQUFDLElBQUksT0FBTyxHQUFHLENBQUMsSUFBSSxLQUFLLFVBQVUsSUFBSSxPQUFPLEdBQUcsQ0FBQyxXQUFX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WRXaXRuZXNzO1xuICAgICAgY29uc3QgcHJldk91dFNjcmlwdCA9IHAydHJQYXltZW50cy5wMnRyKFxuICAgICAgICB7XG4gICAgICAgICAgcmVkZWVtczogW3sgb3V0cHV0OiB0YXBzY3JpcHQgfV0sXG4gICAgICAgICAgcmVkZWVtSW5kZXg6IDAsXG4gICAgICAgICAgY29udHJvbEJsb2NrLFxuICAgICAgICAgIGFubmV4LFxuICAgICAgICB9LFxuICAgICAgICB7IGVjY0xpYiB9XG4gICAgICApLm91dHB1dDtcbiAgICAgIGNvbnN0IHdpdG5lc3NTY3JpcHRUeXBlID0gY2xhc3NpZnkub3V0cHV0KHRhcHNjcmlwdCk7XG4gICAgICBjb25zdCB7IHB1YmtleXMsIHNpZ25hdHVyZXMgfSA9IGV4cGFuZElucHV0PFROdW1iZXI+KFxuICAgICAgICB1bmRlZmluZWQsXG4gICAgICAgIHBhcnNlZFdpdG5lc3Muc2NyaXB0U2lnLFxuICAgICAgICB3aXRuZXNzU2NyaXB0VHlwZSxcbiAgICAgICAgdGFwc2NyaXB0XG4gICAgICApO1xuXG4gICAgICByZXR1cm4ge1xuICAgICAgICBwcmV2T3V0U2NyaXB0LFxuICAgICAgICBwcmV2T3V0VHlwZTogU0NSSVBUX1RZUEVTLlAyVFIsXG4gICAgICAgIHdpdG5lc3NTY3JpcHQ6IHRhcHNjcmlwdCxcbiAgICAgICAgd2l0bmVzc1NjcmlwdFR5cGUsXG5cbiAgICAgICAgY29udHJvbEJsb2NrLFxuICAgICAgICBhbm5leCxcblxuICAgICAgICBwdWJrZXlzLFxuICAgICAgICBzaWduYXR1cmVzLFxuICAgICAgfTtcbiAgICB9XG4gIH1cblxuICByZXR1cm4ge1xuICAgIHByZXZPdXRUeXBlOiBTQ1JJUFRfVFlQRVMuTk9OU1RBTkRBUkQsXG4gICAgcHJldk91dFNjcmlwdDogc2NyaXB0U2lnLFxuICB9O1xufVxuXG4vLyBjb3VsZCBiZSBkb25lIGluIGV4cGFuZElucHV0L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6IHJlZGVlbS53aXRuZXNzLFxuICAgICAgICB9LFxuICAgICAgfSk7XG4gICAgfVxuICAgIGNhc2UgU0NSSVBUX1RZUEVTLlAyVFI6IHtcbiAgICAgIGlmIChpbnB1dC53aXRuZXNzU2NyaXB0VHlwZSA9PT0gU0NSSVBUX1RZUEVTLlAyVFJfTlMpIHtcbiAgICAgICAgLy8gU2NyaXB0UGF0aFxuICAgICAgICBjb25zdCByZWRlZW0gPSBidWlsZDxUTnVtYmVyPihpbnB1dC53aXRuZXNzU2NyaXB0VHlwZSEsIGlucHV0LCBhbGxvd0luY29tcGxldGUpO1xuICAgICAgICByZXR1cm4gcDJ0clBheW1lbnRzLnAydHIoXG4gICAgICAgICAge1xuICAgICAgICAgICAgb3V0cHV0OiBpbnB1dC5wcmV2T3V0U2NyaXB0LFxuICAgICAgICAgICAgY29udHJvbEJsb2NrOiBpbnB1dC5jb250cm9sQmxvY2ssXG4gICAgICAgICAgICBhbm5leDogaW5wdXQuYW5uZXgsXG4gICAgICAgICAgICByZWRlZW1zOiBbcmVkZWVtIV0sXG4gICAgICAgICAgICByZWRlZW1JbmRleDogMCxcbiAgICAgICAgICB9LFxuICAgICAgICAgIHsgZWNjTGliIH1cbiAgICAgICAgKTtcbiAgICAgIH1cblxuICAgICAgLy8gS2V5UGF0aFxuICAgICAgaWYgKHNpZ25hdHVyZXMubGVuZ3RoID09PSAwKSBicmVhaztcblxuICAgICAgcmV0dXJuIHAydHJQYXltZW50cy5wMnRyKHsgcHVia2V5cywgc2lnbmF0dXJlOiBzaWduYXR1cmVzWzBdIH0sIHsgZWNjTGliIH0pO1xuICAgIH1cbiAgICBjYXNlIFNDUklQVF9UWVBFUy5QMlRSX05TOiB7XG4gICAgICBjb25zdCBtID0gaW5wdXQubWF4U2lnbmF0dXJlcztcbiAgICAgIGlmIChhbGxvd0luY29tcGxldGUpIHtcbiAgICAgICAgc2lnbmF0dXJlcyA9IHNpZ25hdHVyZXMubWFwKCh4KSA9PiB4IHx8IG9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