@onetokenfe/coinselect 3.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +95 -0
  3. package/accumulative.js +38 -0
  4. package/blackjack.js +35 -0
  5. package/break.js +34 -0
  6. package/index.js +21 -0
  7. package/package.json +82 -0
  8. package/split.js +45 -0
  9. package/third-party/utils/addDashesToSpaces.d.ts +2 -0
  10. package/third-party/utils/addDashesToSpaces.js +6 -0
  11. package/third-party/utils/arrayDistinct.d.ts +2 -0
  12. package/third-party/utils/arrayDistinct.js +6 -0
  13. package/third-party/utils/arrayPartition.d.ts +7 -0
  14. package/third-party/utils/arrayPartition.js +6 -0
  15. package/third-party/utils/arrayShuffle.d.ts +4 -0
  16. package/third-party/utils/arrayShuffle.js +13 -0
  17. package/third-party/utils/arrayToDictionary.d.ts +10 -0
  18. package/third-party/utils/arrayToDictionary.js +27 -0
  19. package/third-party/utils/asciiUtils.d.ts +3 -0
  20. package/third-party/utils/asciiUtils.js +16 -0
  21. package/third-party/utils/bigNumber.d.ts +5 -0
  22. package/third-party/utils/bigNumber.js +9 -0
  23. package/third-party/utils/bufferUtils.d.ts +3 -0
  24. package/third-party/utils/bufferUtils.js +23 -0
  25. package/third-party/utils/bytesToHumanReadable.d.ts +2 -0
  26. package/third-party/utils/bytesToHumanReadable.js +15 -0
  27. package/third-party/utils/capitalizeFirstLetter.d.ts +2 -0
  28. package/third-party/utils/capitalizeFirstLetter.js +6 -0
  29. package/third-party/utils/cloneObject.d.ts +2 -0
  30. package/third-party/utils/cloneObject.js +32 -0
  31. package/third-party/utils/countBytesInString.d.ts +2 -0
  32. package/third-party/utils/countBytesInString.js +6 -0
  33. package/third-party/utils/createCooldown.d.ts +2 -0
  34. package/third-party/utils/createCooldown.js +16 -0
  35. package/third-party/utils/createDeferred.d.ts +14 -0
  36. package/third-party/utils/createDeferred.js +19 -0
  37. package/third-party/utils/createDeferredManager.d.ts +19 -0
  38. package/third-party/utils/createDeferredManager.js +67 -0
  39. package/third-party/utils/createLazy.d.ts +7 -0
  40. package/third-party/utils/createLazy.js +42 -0
  41. package/third-party/utils/createTimeoutPromise.d.ts +2 -0
  42. package/third-party/utils/createTimeoutPromise.js +6 -0
  43. package/third-party/utils/enumUtils.d.ts +6 -0
  44. package/third-party/utils/enumUtils.js +12 -0
  45. package/third-party/utils/extractUrlsFromText.d.ts +5 -0
  46. package/third-party/utils/extractUrlsFromText.js +28 -0
  47. package/third-party/utils/getLocaleSeparators.d.ts +5 -0
  48. package/third-party/utils/getLocaleSeparators.js +13 -0
  49. package/third-party/utils/getLocaleSeparators.native.d.ts +5 -0
  50. package/third-party/utils/getLocaleSeparators.native.js +17 -0
  51. package/third-party/utils/getMutex.d.ts +2 -0
  52. package/third-party/utils/getMutex.js +22 -0
  53. package/third-party/utils/getNumberFromPixelString.d.ts +2 -0
  54. package/third-party/utils/getNumberFromPixelString.js +6 -0
  55. package/third-party/utils/getRandomInt.d.ts +2 -0
  56. package/third-party/utils/getRandomInt.js +56 -0
  57. package/third-party/utils/getSynchronize.d.ts +4 -0
  58. package/third-party/utils/getSynchronize.js +10 -0
  59. package/third-party/utils/getWeakRandomId.d.ts +2 -0
  60. package/third-party/utils/getWeakRandomId.js +13 -0
  61. package/third-party/utils/getWeakRandomInt.d.ts +2 -0
  62. package/third-party/utils/getWeakRandomInt.js +11 -0
  63. package/third-party/utils/getWeakRandomNumberInRange.d.ts +2 -0
  64. package/third-party/utils/getWeakRandomNumberInRange.js +6 -0
  65. package/third-party/utils/hasUppercaseLetter.d.ts +2 -0
  66. package/third-party/utils/hasUppercaseLetter.js +7 -0
  67. package/third-party/utils/index.d.ts +52 -0
  68. package/third-party/utils/index.js +56 -0
  69. package/third-party/utils/isArrayMember.d.ts +2 -0
  70. package/third-party/utils/isArrayMember.js +6 -0
  71. package/third-party/utils/isFullPath.d.ts +2 -0
  72. package/third-party/utils/isFullPath.js +9 -0
  73. package/third-party/utils/isHex.d.ts +2 -0
  74. package/third-party/utils/isHex.js +9 -0
  75. package/third-party/utils/isNotUndefined.d.ts +2 -0
  76. package/third-party/utils/isNotUndefined.js +6 -0
  77. package/third-party/utils/isUrl.d.ts +2 -0
  78. package/third-party/utils/isUrl.js +7 -0
  79. package/third-party/utils/logs.d.ts +32 -0
  80. package/third-party/utils/logs.js +82 -0
  81. package/third-party/utils/logsManager.d.ts +17 -0
  82. package/third-party/utils/logsManager.js +53 -0
  83. package/third-party/utils/mergeDeepObject.d.ts +26 -0
  84. package/third-party/utils/mergeDeepObject.js +68 -0
  85. package/third-party/utils/objectPartition.d.ts +6 -0
  86. package/third-party/utils/objectPartition.js +12 -0
  87. package/third-party/utils/parseElectrumUrl.d.ts +6 -0
  88. package/third-party/utils/parseElectrumUrl.js +17 -0
  89. package/third-party/utils/parseHostname.d.ts +2 -0
  90. package/third-party/utils/parseHostname.js +7 -0
  91. package/third-party/utils/promiseAllSequence.d.ts +2 -0
  92. package/third-party/utils/promiseAllSequence.js +14 -0
  93. package/third-party/utils/redactUserPath.d.ts +3 -0
  94. package/third-party/utils/redactUserPath.js +7 -0
  95. package/third-party/utils/scheduleAction.d.ts +15 -0
  96. package/third-party/utils/scheduleAction.js +125 -0
  97. package/third-party/utils/splitStringEveryNCharacters.d.ts +2 -0
  98. package/third-party/utils/splitStringEveryNCharacters.js +12 -0
  99. package/third-party/utils/throttler.d.ts +11 -0
  100. package/third-party/utils/throttler.js +38 -0
  101. package/third-party/utils/throwError.d.ts +2 -0
  102. package/third-party/utils/throwError.js +8 -0
  103. package/third-party/utils/topologicalSort.d.ts +2 -0
  104. package/third-party/utils/topologicalSort.js +19 -0
  105. package/third-party/utils/truncateMiddle.d.ts +2 -0
  106. package/third-party/utils/truncateMiddle.js +12 -0
  107. package/third-party/utils/typedEventEmitter.d.ts +23 -0
  108. package/third-party/utils/typedEventEmitter.js +11 -0
  109. package/third-party/utils/urlToOnion.d.ts +4 -0
  110. package/third-party/utils/urlToOnion.js +12 -0
  111. package/third-party/utils/versionUtils.d.ts +9 -0
  112. package/third-party/utils/versionUtils.js +28 -0
  113. package/third-party/utils/xssFilters.d.ts +4 -0
  114. package/third-party/utils/xssFilters.js +13 -0
  115. package/third-party/utxo-lib/address.d.ts +17 -0
  116. package/third-party/utxo-lib/address.js +174 -0
  117. package/third-party/utxo-lib/bip32.d.ts +28 -0
  118. package/third-party/utxo-lib/bip32.js +253 -0
  119. package/third-party/utxo-lib/bs58check.d.ts +12 -0
  120. package/third-party/utxo-lib/bs58check.js +92 -0
  121. package/third-party/utxo-lib/bufferutils.d.ts +59 -0
  122. package/third-party/utxo-lib/bufferutils.js +219 -0
  123. package/third-party/utxo-lib/coinselect/coinselectUtils.d.ts +53 -0
  124. package/third-party/utxo-lib/coinselect/coinselectUtils.js +232 -0
  125. package/third-party/utxo-lib/coinselect/index.d.ts +3 -0
  126. package/third-party/utxo-lib/coinselect/index.js +19 -0
  127. package/third-party/utxo-lib/coinselect/inputs/accumulative.d.ts +3 -0
  128. package/third-party/utxo-lib/coinselect/inputs/accumulative.js +55 -0
  129. package/third-party/utxo-lib/coinselect/inputs/branchAndBound.d.ts +3 -0
  130. package/third-party/utxo-lib/coinselect/inputs/branchAndBound.js +123 -0
  131. package/third-party/utxo-lib/coinselect/outputs/split.d.ts +3 -0
  132. package/third-party/utxo-lib/coinselect/outputs/split.js +35 -0
  133. package/third-party/utxo-lib/coinselect/tryconfirmed.d.ts +3 -0
  134. package/third-party/utxo-lib/coinselect/tryconfirmed.js +65 -0
  135. package/third-party/utxo-lib/compose/index.d.ts +3 -0
  136. package/third-party/utxo-lib/compose/index.js +20 -0
  137. package/third-party/utxo-lib/compose/request.d.ts +5 -0
  138. package/third-party/utxo-lib/compose/request.js +168 -0
  139. package/third-party/utxo-lib/compose/result.d.ts +4 -0
  140. package/third-party/utxo-lib/compose/result.js +64 -0
  141. package/third-party/utxo-lib/compose/sorting/bip69SortingStrategy.d.ts +3 -0
  142. package/third-party/utxo-lib/compose/sorting/bip69SortingStrategy.js +32 -0
  143. package/third-party/utxo-lib/compose/sorting/convertOutput.d.ts +13 -0
  144. package/third-party/utxo-lib/compose/sorting/convertOutput.js +14 -0
  145. package/third-party/utxo-lib/compose/sorting/noneSortingStrategy.d.ts +3 -0
  146. package/third-party/utxo-lib/compose/sorting/noneSortingStrategy.js +19 -0
  147. package/third-party/utxo-lib/compose/sorting/randomSortingStrategy.d.ts +3 -0
  148. package/third-party/utxo-lib/compose/sorting/randomSortingStrategy.js +28 -0
  149. package/third-party/utxo-lib/compose/sorting/sortingStrategy.d.ts +9 -0
  150. package/third-party/utxo-lib/compose/sorting/sortingStrategy.js +3 -0
  151. package/third-party/utxo-lib/compose/transaction.d.ts +3 -0
  152. package/third-party/utxo-lib/compose/transaction.js +16 -0
  153. package/third-party/utxo-lib/crypto.d.ts +9 -0
  154. package/third-party/utxo-lib/crypto.js +44 -0
  155. package/third-party/utxo-lib/derivation.d.ts +24 -0
  156. package/third-party/utxo-lib/derivation.js +121 -0
  157. package/third-party/utxo-lib/discovery.d.ts +9 -0
  158. package/third-party/utxo-lib/discovery.js +30 -0
  159. package/third-party/utxo-lib/global.d.ts +62 -0
  160. package/third-party/utxo-lib/global.js +2 -0
  161. package/third-party/utxo-lib/index.d.ts +18 -0
  162. package/third-party/utxo-lib/index.js +28 -0
  163. package/third-party/utxo-lib/networks.d.ts +45 -0
  164. package/third-party/utxo-lib/networks.js +250 -0
  165. package/third-party/utxo-lib/payments/embed.d.ts +3 -0
  166. package/third-party/utxo-lib/payments/embed.js +49 -0
  167. package/third-party/utxo-lib/payments/index.d.ts +13 -0
  168. package/third-party/utxo-lib/payments/index.js +28 -0
  169. package/third-party/utxo-lib/payments/lazy.d.ts +3 -0
  170. package/third-party/utxo-lib/payments/lazy.js +33 -0
  171. package/third-party/utxo-lib/payments/p2ms.d.ts +3 -0
  172. package/third-party/utxo-lib/payments/p2ms.js +139 -0
  173. package/third-party/utxo-lib/payments/p2pk.d.ts +3 -0
  174. package/third-party/utxo-lib/payments/p2pk.js +72 -0
  175. package/third-party/utxo-lib/payments/p2pkh.d.ts +3 -0
  176. package/third-party/utxo-lib/payments/p2pkh.js +132 -0
  177. package/third-party/utxo-lib/payments/p2sh.d.ts +3 -0
  178. package/third-party/utxo-lib/payments/p2sh.js +171 -0
  179. package/third-party/utxo-lib/payments/p2tr.d.ts +3 -0
  180. package/third-party/utxo-lib/payments/p2tr.js +123 -0
  181. package/third-party/utxo-lib/payments/p2wpkh.d.ts +3 -0
  182. package/third-party/utxo-lib/payments/p2wpkh.js +137 -0
  183. package/third-party/utxo-lib/payments/p2wsh.d.ts +3 -0
  184. package/third-party/utxo-lib/payments/p2wsh.js +183 -0
  185. package/third-party/utxo-lib/payments/sstxchange.d.ts +3 -0
  186. package/third-party/utxo-lib/payments/sstxchange.js +79 -0
  187. package/third-party/utxo-lib/payments/sstxcommitment.d.ts +3 -0
  188. package/third-party/utxo-lib/payments/sstxcommitment.js +74 -0
  189. package/third-party/utxo-lib/payments/sstxpkh.d.ts +3 -0
  190. package/third-party/utxo-lib/payments/sstxpkh.js +79 -0
  191. package/third-party/utxo-lib/payments/sstxsh.d.ts +3 -0
  192. package/third-party/utxo-lib/payments/sstxsh.js +70 -0
  193. package/third-party/utxo-lib/script/index.d.ts +17 -0
  194. package/third-party/utxo-lib/script/index.js +167 -0
  195. package/third-party/utxo-lib/script/ops.d.ts +4 -0
  196. package/third-party/utxo-lib/script/ops.js +13 -0
  197. package/third-party/utxo-lib/script/scriptNumber.d.ts +3 -0
  198. package/third-party/utxo-lib/script/scriptNumber.js +62 -0
  199. package/third-party/utxo-lib/script/scriptSignature.d.ts +8 -0
  200. package/third-party/utxo-lib/script/scriptSignature.js +55 -0
  201. package/third-party/utxo-lib/transaction/base.d.ts +56 -0
  202. package/third-party/utxo-lib/transaction/base.js +108 -0
  203. package/third-party/utxo-lib/transaction/bitcoin.d.ts +4 -0
  204. package/third-party/utxo-lib/transaction/bitcoin.js +109 -0
  205. package/third-party/utxo-lib/transaction/dash.d.ts +8 -0
  206. package/third-party/utxo-lib/transaction/dash.js +105 -0
  207. package/third-party/utxo-lib/transaction/decred.d.ts +4 -0
  208. package/third-party/utxo-lib/transaction/decred.js +149 -0
  209. package/third-party/utxo-lib/transaction/index.d.ts +15 -0
  210. package/third-party/utxo-lib/transaction/index.js +44 -0
  211. package/third-party/utxo-lib/transaction/peercoin.d.ts +4 -0
  212. package/third-party/utxo-lib/transaction/peercoin.js +64 -0
  213. package/third-party/utxo-lib/transaction/zcash.d.ts +66 -0
  214. package/third-party/utxo-lib/transaction/zcash.js +451 -0
  215. package/third-party/utxo-lib/types/coinselect.d.ts +61 -0
  216. package/third-party/utxo-lib/types/coinselect.js +3 -0
  217. package/third-party/utxo-lib/types/compose.d.ts +98 -0
  218. package/third-party/utxo-lib/types/compose.js +10 -0
  219. package/third-party/utxo-lib/types/index.d.ts +5 -0
  220. package/third-party/utxo-lib/types/index.js +8 -0
  221. package/third-party/utxo-lib/types/payments.d.ts +30 -0
  222. package/third-party/utxo-lib/types/payments.js +3 -0
  223. package/third-party/utxo-lib/types/typeforce.d.ts +8 -0
  224. package/third-party/utxo-lib/types/typeforce.js +16 -0
  225. package/third-party/utxo-lib/vsize.d.ts +13 -0
  226. package/third-party/utxo-lib/vsize.js +50 -0
  227. package/utils.js +78 -0
  228. package/witness.d.ts +70 -0
  229. package/witness.js +30 -0
@@ -0,0 +1,250 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.doge = exports.decredSim = exports.decredTest = exports.decred = exports.komodo = exports.peercoinTest = exports.peercoin = exports.zcashTest = exports.zcash = exports.dashTest = exports.dash = exports.litecoinTest = exports.litecoin = exports.bitcoingold = exports.bitcoincashTest = exports.bitcoincash = exports.testnet = exports.regtest = exports.bitcoin = void 0;
4
+ exports.isNetworkType = isNetworkType;
5
+ const typeforce_1 = require("./types/typeforce");
6
+ exports.bitcoin = {
7
+ messagePrefix: '\x18Bitcoin Signed Message:\n',
8
+ bech32: 'bc',
9
+ bip32: {
10
+ public: 0x0488b21e,
11
+ private: 0x0488ade4,
12
+ },
13
+ pubKeyHash: 0x00,
14
+ scriptHash: 0x05,
15
+ wif: 0x80,
16
+ };
17
+ exports.regtest = {
18
+ messagePrefix: '\x18Bitcoin Signed Message:\n',
19
+ bech32: 'bcrt',
20
+ bip32: {
21
+ public: 0x043587cf,
22
+ private: 0x04358394,
23
+ },
24
+ pubKeyHash: 0x6f,
25
+ scriptHash: 0xc4,
26
+ wif: 0xef,
27
+ };
28
+ exports.testnet = {
29
+ messagePrefix: '\x18Bitcoin Signed Message:\n',
30
+ bech32: 'tb',
31
+ bip32: {
32
+ public: 0x043587cf,
33
+ private: 0x04358394,
34
+ },
35
+ pubKeyHash: 0x6f,
36
+ scriptHash: 0xc4,
37
+ wif: 0xef,
38
+ };
39
+ exports.bitcoincash = {
40
+ messagePrefix: '\x18Bitcoin Signed Message:\n',
41
+ bech32: '',
42
+ bip32: {
43
+ public: 0x0488b21e,
44
+ private: 0x0488ade4,
45
+ },
46
+ pubKeyHash: 0x00,
47
+ scriptHash: 0x05,
48
+ wif: 0x80,
49
+ forkId: 0x00,
50
+ };
51
+ exports.bitcoincashTest = {
52
+ messagePrefix: '\x18Bitcoin Signed Message:\n',
53
+ bech32: '',
54
+ bip32: {
55
+ public: 0x043587cf,
56
+ private: 0x04358394,
57
+ },
58
+ pubKeyHash: 0x6f,
59
+ scriptHash: 0xc4,
60
+ wif: 0xef,
61
+ forkId: 0x00,
62
+ };
63
+ exports.bitcoingold = {
64
+ messagePrefix: '\x18Bitcoin Gold Signed Message:\n',
65
+ bech32: 'btg',
66
+ bip32: {
67
+ public: 0x0488b21e,
68
+ private: 0x0488ade4,
69
+ },
70
+ pubKeyHash: 0x26,
71
+ scriptHash: 0x17,
72
+ wif: 0x80,
73
+ forkId: 0x4f,
74
+ };
75
+ exports.litecoin = {
76
+ messagePrefix: '\x19Litecoin Signed Message:\n',
77
+ bech32: 'ltc',
78
+ bip32: {
79
+ public: 0x019da462,
80
+ private: 0x019d9cfe,
81
+ },
82
+ pubKeyHash: 0x30,
83
+ scriptHash: 0x32,
84
+ wif: 0xb0,
85
+ };
86
+ exports.litecoinTest = {
87
+ messagePrefix: '\x19Litecoin Signed Message:\n',
88
+ bech32: 'tltc',
89
+ bip32: {
90
+ public: 0x043587cf,
91
+ private: 0x04358394,
92
+ },
93
+ pubKeyHash: 0x6f,
94
+ scriptHash: 0x3a,
95
+ wif: 0xb0,
96
+ };
97
+ exports.dash = {
98
+ messagePrefix: '\x19DarkCoin Signed Message:\n',
99
+ bech32: '',
100
+ bip32: {
101
+ public: 0x02fe52cc,
102
+ private: 0x2fe52f8,
103
+ },
104
+ pubKeyHash: 0x4c,
105
+ scriptHash: 0x10,
106
+ wif: 0xcc,
107
+ };
108
+ exports.dashTest = {
109
+ messagePrefix: '\x19DarkCoin Signed Message:\n',
110
+ bech32: '',
111
+ bip32: {
112
+ public: 0x043587cf,
113
+ private: 0x04358394,
114
+ },
115
+ pubKeyHash: 0x8c,
116
+ scriptHash: 0x13,
117
+ wif: 0xef,
118
+ };
119
+ exports.zcash = {
120
+ messagePrefix: '\x18ZCash Signed Message:\n',
121
+ bech32: '',
122
+ bip32: {
123
+ public: 0x0488b21e,
124
+ private: 0x0488ade4,
125
+ },
126
+ pubKeyHash: 0x1cb8,
127
+ scriptHash: 0x1cbd,
128
+ wif: 0x80,
129
+ };
130
+ exports.zcashTest = {
131
+ messagePrefix: '\x18ZCash Signed Message:\n',
132
+ bech32: '',
133
+ bip32: {
134
+ public: 0x043587cf,
135
+ private: 0x04358394,
136
+ },
137
+ pubKeyHash: 0x1d25,
138
+ scriptHash: 0x1cba,
139
+ wif: 0xef,
140
+ };
141
+ exports.peercoin = {
142
+ messagePrefix: '\x18Peercoin Signed Message:\n',
143
+ bech32: 'pc',
144
+ bip32: {
145
+ public: 0x488b21e,
146
+ private: 0x0488ade4,
147
+ },
148
+ pubKeyHash: 0x37,
149
+ scriptHash: 0x75,
150
+ wif: 0,
151
+ };
152
+ exports.peercoinTest = {
153
+ messagePrefix: '\x18Peercoin Signed Message:\n',
154
+ bech32: 'tpc',
155
+ bip32: {
156
+ public: 0x43587cf,
157
+ private: 0x04358394,
158
+ },
159
+ pubKeyHash: 0x6f,
160
+ scriptHash: 0xc4,
161
+ wif: 0,
162
+ };
163
+ exports.komodo = {
164
+ messagePrefix: '\x18Komodo Signed Message:\n',
165
+ bech32: '',
166
+ bip32: {
167
+ public: 0x0488b21e,
168
+ private: 0x0488ade4,
169
+ },
170
+ pubKeyHash: 0x3c,
171
+ scriptHash: 0x55,
172
+ wif: 0xbc,
173
+ };
174
+ exports.decred = {
175
+ messagePrefix: '\x17Decred Signed Message:\n',
176
+ bech32: '',
177
+ bip32: {
178
+ public: 0x02fda926,
179
+ private: 0x02fda4e8,
180
+ },
181
+ pubKeyHash: 0x073f,
182
+ scriptHash: 0x071a,
183
+ wif: 0x22de,
184
+ };
185
+ exports.decredTest = {
186
+ messagePrefix: '\x17Decred Signed Message:\n',
187
+ bech32: '',
188
+ bip32: {
189
+ public: 0x043587d1,
190
+ private: 0x04358397,
191
+ },
192
+ pubKeyHash: 0x0f21,
193
+ scriptHash: 0x0efc,
194
+ wif: 0x230e,
195
+ };
196
+ exports.decredSim = {
197
+ messagePrefix: '\x17Decred Signed Message:\n',
198
+ bech32: '',
199
+ bip32: {
200
+ public: 0x0420bd3d,
201
+ private: 0x0420b903,
202
+ },
203
+ pubKeyHash: 0x0e91,
204
+ scriptHash: 0x0e6c,
205
+ wif: 0x2307,
206
+ };
207
+ exports.doge = {
208
+ messagePrefix: '\x19Dogecoin Signed Message:\n',
209
+ bech32: '',
210
+ bip32: {
211
+ public: 0x02facafd,
212
+ private: 0x02fac398,
213
+ },
214
+ pubKeyHash: 0x1e,
215
+ scriptHash: 0x16,
216
+ wif: 0x9e,
217
+ };
218
+ const NETWORK_TYPES = {
219
+ bitcoinCash: [exports.bitcoincash, exports.bitcoincashTest],
220
+ dash: [exports.dash, exports.dashTest],
221
+ decred: [exports.decred, exports.decredTest, exports.decredSim],
222
+ peercoin: [exports.peercoin, exports.peercoinTest],
223
+ zcash: [exports.zcash, exports.zcashTest, exports.komodo],
224
+ litecoin: [exports.litecoin, exports.litecoinTest],
225
+ doge: [exports.doge],
226
+ };
227
+ function isNetworkType(type, network) {
228
+ if (typeof type !== 'string' || !network || !NETWORK_TYPES[type])
229
+ return false;
230
+ try {
231
+ (0, typeforce_1.typeforce)({
232
+ bip32: {
233
+ public: typeforce_1.typeforce.UInt32,
234
+ private: typeforce_1.typeforce.UInt32,
235
+ },
236
+ pubKeyHash: typeforce_1.typeforce.anyOf(typeforce_1.typeforce.UInt8, typeforce_1.typeforce.UInt16),
237
+ scriptHash: typeforce_1.typeforce.anyOf(typeforce_1.typeforce.UInt8, typeforce_1.typeforce.UInt16),
238
+ }, network);
239
+ }
240
+ catch (_a) {
241
+ return false;
242
+ }
243
+ return !!NETWORK_TYPES[type].find(n => n.bip32.public === network.bip32.public &&
244
+ n.bip32.private === network.bip32.private &&
245
+ ((!n.bech32 && !network.bech32) || n.bech32 === network.bech32) &&
246
+ ((!n.forkId && !network.forkId) || n.forkId === network.forkId) &&
247
+ n.pubKeyHash === network.pubKeyHash &&
248
+ n.scriptHash === network.scriptHash);
249
+ }
250
+ //# sourceMappingURL=networks.js.map
@@ -0,0 +1,3 @@
1
+ import { Payment, PaymentOpts } from '../types';
2
+ export declare function p2data(a: Payment, opts?: PaymentOpts): Payment;
3
+ //# sourceMappingURL=embed.d.ts.map
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.p2data = p2data;
4
+ const tslib_1 = require("tslib");
5
+ const networks_1 = require("../networks");
6
+ const bscript = tslib_1.__importStar(require("../script"));
7
+ const lazy = tslib_1.__importStar(require("./lazy"));
8
+ const types_1 = require("../types");
9
+ const { OPS } = bscript;
10
+ function stacksEqual(a, b) {
11
+ if (a.length !== b.length)
12
+ return false;
13
+ return a.every((x, i) => x.equals(b[i]));
14
+ }
15
+ function p2data(a, opts) {
16
+ if (!a.data && !a.output)
17
+ throw new TypeError('Not enough data');
18
+ opts = Object.assign({ validate: true }, opts || {});
19
+ (0, types_1.typeforce)({
20
+ network: types_1.typeforce.maybe(types_1.typeforce.Object),
21
+ output: types_1.typeforce.maybe(types_1.typeforce.Buffer),
22
+ data: types_1.typeforce.maybe(types_1.typeforce.arrayOf(types_1.typeforce.Buffer)),
23
+ }, a);
24
+ const network = a.network || networks_1.bitcoin;
25
+ const o = { name: 'embed', network };
26
+ lazy.prop(o, 'output', () => {
27
+ if (!a.data)
28
+ return;
29
+ return bscript.compile([OPS.OP_RETURN].concat(a.data));
30
+ });
31
+ lazy.prop(o, 'data', () => {
32
+ if (!a.output)
33
+ return;
34
+ return bscript.decompile(a.output).slice(1);
35
+ });
36
+ if (opts.validate) {
37
+ if (a.output) {
38
+ const chunks = bscript.decompile(a.output);
39
+ if (chunks[0] !== OPS.OP_RETURN)
40
+ throw new TypeError('Output is invalid');
41
+ if (!chunks.slice(1).every(types_1.typeforce.Buffer))
42
+ throw new TypeError('Output is invalid');
43
+ if (a.data && !stacksEqual(a.data, o.data))
44
+ throw new TypeError('Data mismatch');
45
+ }
46
+ }
47
+ return Object.assign(o, a);
48
+ }
49
+ //# sourceMappingURL=embed.js.map
@@ -0,0 +1,13 @@
1
+ export { p2data as embed } from './embed';
2
+ export { p2ms } from './p2ms';
3
+ export { p2pk } from './p2pk';
4
+ export { p2pkh } from './p2pkh';
5
+ export { p2sh } from './p2sh';
6
+ export { p2tr } from './p2tr';
7
+ export { p2wpkh } from './p2wpkh';
8
+ export { p2wsh } from './p2wsh';
9
+ export { sstxchange } from './sstxchange';
10
+ export { sstxcommitment } from './sstxcommitment';
11
+ export { sstxpkh } from './sstxpkh';
12
+ export { sstxsh } from './sstxsh';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sstxsh = exports.sstxpkh = exports.sstxcommitment = exports.sstxchange = exports.p2wsh = exports.p2wpkh = exports.p2tr = exports.p2sh = exports.p2pkh = exports.p2pk = exports.p2ms = exports.embed = void 0;
4
+ var embed_1 = require("./embed");
5
+ Object.defineProperty(exports, "embed", { enumerable: true, get: function () { return embed_1.p2data; } });
6
+ var p2ms_1 = require("./p2ms");
7
+ Object.defineProperty(exports, "p2ms", { enumerable: true, get: function () { return p2ms_1.p2ms; } });
8
+ var p2pk_1 = require("./p2pk");
9
+ Object.defineProperty(exports, "p2pk", { enumerable: true, get: function () { return p2pk_1.p2pk; } });
10
+ var p2pkh_1 = require("./p2pkh");
11
+ Object.defineProperty(exports, "p2pkh", { enumerable: true, get: function () { return p2pkh_1.p2pkh; } });
12
+ var p2sh_1 = require("./p2sh");
13
+ Object.defineProperty(exports, "p2sh", { enumerable: true, get: function () { return p2sh_1.p2sh; } });
14
+ var p2tr_1 = require("./p2tr");
15
+ Object.defineProperty(exports, "p2tr", { enumerable: true, get: function () { return p2tr_1.p2tr; } });
16
+ var p2wpkh_1 = require("./p2wpkh");
17
+ Object.defineProperty(exports, "p2wpkh", { enumerable: true, get: function () { return p2wpkh_1.p2wpkh; } });
18
+ var p2wsh_1 = require("./p2wsh");
19
+ Object.defineProperty(exports, "p2wsh", { enumerable: true, get: function () { return p2wsh_1.p2wsh; } });
20
+ var sstxchange_1 = require("./sstxchange");
21
+ Object.defineProperty(exports, "sstxchange", { enumerable: true, get: function () { return sstxchange_1.sstxchange; } });
22
+ var sstxcommitment_1 = require("./sstxcommitment");
23
+ Object.defineProperty(exports, "sstxcommitment", { enumerable: true, get: function () { return sstxcommitment_1.sstxcommitment; } });
24
+ var sstxpkh_1 = require("./sstxpkh");
25
+ Object.defineProperty(exports, "sstxpkh", { enumerable: true, get: function () { return sstxpkh_1.sstxpkh; } });
26
+ var sstxsh_1 = require("./sstxsh");
27
+ Object.defineProperty(exports, "sstxsh", { enumerable: true, get: function () { return sstxsh_1.sstxsh; } });
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,3 @@
1
+ export declare function prop(object: Record<string, any>, name: string, f: () => any): void;
2
+ export declare function value<T>(f: () => T): () => T;
3
+ //# sourceMappingURL=lazy.d.ts.map
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prop = prop;
4
+ exports.value = value;
5
+ function prop(object, name, f) {
6
+ Object.defineProperty(object, name, {
7
+ configurable: true,
8
+ enumerable: true,
9
+ get() {
10
+ const value = f.call(this);
11
+ this[name] = value;
12
+ return value;
13
+ },
14
+ set(value) {
15
+ Object.defineProperty(this, name, {
16
+ configurable: true,
17
+ enumerable: true,
18
+ value,
19
+ writable: true,
20
+ });
21
+ },
22
+ });
23
+ }
24
+ function value(f) {
25
+ let value;
26
+ return () => {
27
+ if (value !== undefined)
28
+ return value;
29
+ value = f();
30
+ return value;
31
+ };
32
+ }
33
+ //# sourceMappingURL=lazy.js.map
@@ -0,0 +1,3 @@
1
+ import { Payment, PaymentOpts } from '../types';
2
+ export declare function p2ms(a: Payment, opts?: PaymentOpts): Payment;
3
+ //# sourceMappingURL=p2ms.d.ts.map
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.p2ms = p2ms;
4
+ const tslib_1 = require("tslib");
5
+ const tiny_secp256k1_1 = tslib_1.__importDefault(require("tiny-secp256k1"));
6
+ const networks_1 = require("../networks");
7
+ const bscript = tslib_1.__importStar(require("../script"));
8
+ const lazy = tslib_1.__importStar(require("./lazy"));
9
+ const types_1 = require("../types");
10
+ const { OPS } = bscript;
11
+ const OP_INT_BASE = OPS.OP_RESERVED;
12
+ function stacksEqual(a, b) {
13
+ if (a.length !== b.length)
14
+ return false;
15
+ return a.every((x, i) => x.equals(b[i]));
16
+ }
17
+ function p2ms(a, opts) {
18
+ if (!a.input && !a.output && !(a.pubkeys && a.m !== undefined) && !a.signatures)
19
+ throw new TypeError('Not enough data');
20
+ opts = Object.assign({ validate: true }, opts || {});
21
+ function isAcceptableSignature(x) {
22
+ return (bscript.isCanonicalScriptSignature(x) ||
23
+ (opts.allowIncomplete && x === OPS.OP_0) !== undefined);
24
+ }
25
+ (0, types_1.typeforce)({
26
+ network: types_1.typeforce.maybe(types_1.typeforce.Object),
27
+ m: types_1.typeforce.maybe(types_1.typeforce.Number),
28
+ n: types_1.typeforce.maybe(types_1.typeforce.Number),
29
+ output: types_1.typeforce.maybe(types_1.typeforce.Buffer),
30
+ pubkeys: types_1.typeforce.maybe(types_1.typeforce.arrayOf(tiny_secp256k1_1.default.isPoint)),
31
+ signatures: types_1.typeforce.maybe(types_1.typeforce.arrayOf(isAcceptableSignature)),
32
+ input: types_1.typeforce.maybe(types_1.typeforce.Buffer),
33
+ }, a);
34
+ const network = a.network || networks_1.bitcoin;
35
+ const o = { name: 'p2ms', network };
36
+ let chunks = [];
37
+ let decoded = false;
38
+ function decode(output) {
39
+ if (decoded)
40
+ return;
41
+ decoded = true;
42
+ chunks = bscript.decompile(output);
43
+ o.m = chunks[0] - OP_INT_BASE;
44
+ o.n = chunks[chunks.length - 2] - OP_INT_BASE;
45
+ o.pubkeys = chunks.slice(1, -2);
46
+ }
47
+ lazy.prop(o, 'output', () => {
48
+ if (!a.m)
49
+ return;
50
+ if (!o.n)
51
+ return;
52
+ if (!a.pubkeys)
53
+ return;
54
+ return bscript.compile([].concat(OP_INT_BASE + a.m, a.pubkeys, OP_INT_BASE + o.n, OPS.OP_CHECKMULTISIG));
55
+ });
56
+ lazy.prop(o, 'm', () => {
57
+ if (!o.output)
58
+ return;
59
+ decode(o.output);
60
+ return o.m;
61
+ });
62
+ lazy.prop(o, 'n', () => {
63
+ if (!o.pubkeys)
64
+ return;
65
+ return o.pubkeys.length;
66
+ });
67
+ lazy.prop(o, 'pubkeys', () => {
68
+ if (!a.output)
69
+ return;
70
+ decode(a.output);
71
+ return o.pubkeys;
72
+ });
73
+ lazy.prop(o, 'signatures', () => {
74
+ if (!a.input)
75
+ return;
76
+ return bscript.decompile(a.input).slice(1);
77
+ });
78
+ lazy.prop(o, 'input', () => {
79
+ if (!a.signatures)
80
+ return;
81
+ return bscript.compile([OPS.OP_0].concat(a.signatures));
82
+ });
83
+ lazy.prop(o, 'witness', () => {
84
+ if (!o.input)
85
+ return;
86
+ return [];
87
+ });
88
+ lazy.prop(o, 'name', () => {
89
+ if (!o.m || !o.n)
90
+ return;
91
+ return `p2ms(${o.m} of ${o.n})`;
92
+ });
93
+ if (opts.validate) {
94
+ if (a.output) {
95
+ decode(a.output);
96
+ if (!types_1.typeforce.Number(chunks[0]))
97
+ throw new TypeError('Output is invalid');
98
+ if (!types_1.typeforce.Number(chunks[chunks.length - 2]))
99
+ throw new TypeError('Output is invalid');
100
+ if (chunks[chunks.length - 1] !== OPS.OP_CHECKMULTISIG)
101
+ throw new TypeError('Output is invalid');
102
+ if (o.m <= 0 || o.n > 16 || o.m > o.n || o.n !== chunks.length - 3)
103
+ throw new TypeError('Output is invalid');
104
+ if (!o.pubkeys.every(x => tiny_secp256k1_1.default.isPoint(x)))
105
+ throw new TypeError('Output is invalid');
106
+ if (a.m !== undefined && a.m !== o.m)
107
+ throw new TypeError('m mismatch');
108
+ if (a.n !== undefined && a.n !== o.n)
109
+ throw new TypeError('n mismatch');
110
+ if (a.pubkeys && !stacksEqual(a.pubkeys, o.pubkeys))
111
+ throw new TypeError('Pubkeys mismatch');
112
+ }
113
+ if (a.pubkeys) {
114
+ if (a.n !== undefined && a.n !== a.pubkeys.length)
115
+ throw new TypeError('Pubkey count mismatch');
116
+ o.n = a.pubkeys.length;
117
+ if (o.n < o.m)
118
+ throw new TypeError('Pubkey count cannot be less than m');
119
+ }
120
+ if (a.signatures) {
121
+ if (a.signatures.length < o.m)
122
+ throw new TypeError('Not enough signatures provided');
123
+ if (a.signatures.length > o.m)
124
+ throw new TypeError('Too many signatures provided');
125
+ }
126
+ if (a.input) {
127
+ if (a.input[0] !== OPS.OP_0)
128
+ throw new TypeError('Input is invalid');
129
+ if (o.signatures.length === 0 || !o.signatures.every(isAcceptableSignature))
130
+ throw new TypeError('Input has invalid signature(s)');
131
+ if (a.signatures && !stacksEqual(a.signatures, o.signatures))
132
+ throw new TypeError('Signature mismatch');
133
+ if (a.m !== undefined && a.m !== a.signatures.length)
134
+ throw new TypeError('Signature count mismatch');
135
+ }
136
+ }
137
+ return Object.assign(o, a);
138
+ }
139
+ //# sourceMappingURL=p2ms.js.map
@@ -0,0 +1,3 @@
1
+ import { Payment, PaymentOpts } from '../types';
2
+ export declare function p2pk(a: Payment, opts?: PaymentOpts): Payment;
3
+ //# sourceMappingURL=p2pk.d.ts.map
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.p2pk = p2pk;
4
+ const tslib_1 = require("tslib");
5
+ const tiny_secp256k1_1 = tslib_1.__importDefault(require("tiny-secp256k1"));
6
+ const networks_1 = require("../networks");
7
+ const bscript = tslib_1.__importStar(require("../script"));
8
+ const lazy = tslib_1.__importStar(require("./lazy"));
9
+ const types_1 = require("../types");
10
+ const { OPS } = bscript;
11
+ function p2pk(a, opts) {
12
+ if (!a.input && !a.output && !a.pubkey && !a.input && !a.signature)
13
+ throw new TypeError('Not enough data');
14
+ opts = Object.assign({ validate: true }, opts || {});
15
+ (0, types_1.typeforce)({
16
+ network: types_1.typeforce.maybe(types_1.typeforce.Object),
17
+ output: types_1.typeforce.maybe(types_1.typeforce.Buffer),
18
+ pubkey: types_1.typeforce.maybe(tiny_secp256k1_1.default.isPoint),
19
+ signature: types_1.typeforce.maybe(bscript.isCanonicalScriptSignature),
20
+ input: types_1.typeforce.maybe(types_1.typeforce.Buffer),
21
+ }, a);
22
+ const _chunks = lazy.value(() => bscript.decompile(a.input));
23
+ const network = a.network || networks_1.bitcoin;
24
+ const o = { name: 'p2pk', network };
25
+ lazy.prop(o, 'output', () => {
26
+ if (!a.pubkey)
27
+ return;
28
+ return bscript.compile([a.pubkey, OPS.OP_CHECKSIG]);
29
+ });
30
+ lazy.prop(o, 'pubkey', () => {
31
+ if (!a.output)
32
+ return;
33
+ return a.output.subarray(1, -1);
34
+ });
35
+ lazy.prop(o, 'signature', () => {
36
+ if (!a.input)
37
+ return;
38
+ return _chunks()[0];
39
+ });
40
+ lazy.prop(o, 'input', () => {
41
+ if (!a.signature)
42
+ return;
43
+ return bscript.compile([a.signature]);
44
+ });
45
+ lazy.prop(o, 'witness', () => {
46
+ if (!o.input)
47
+ return;
48
+ return [];
49
+ });
50
+ if (opts.validate) {
51
+ if (a.output) {
52
+ if (a.output[a.output.length - 1] !== OPS.OP_CHECKSIG)
53
+ throw new TypeError('Output is invalid');
54
+ if (!tiny_secp256k1_1.default.isPoint(o.pubkey))
55
+ throw new TypeError('Output pubkey is invalid');
56
+ if (a.pubkey && !a.pubkey.equals(o.pubkey))
57
+ throw new TypeError('Pubkey mismatch');
58
+ }
59
+ if (a.signature) {
60
+ if (a.input && !a.input.equals(o.input))
61
+ throw new TypeError('Signature mismatch');
62
+ }
63
+ if (a.input) {
64
+ if (_chunks().length !== 1)
65
+ throw new TypeError('Input is invalid');
66
+ if (!bscript.isCanonicalScriptSignature(o.signature))
67
+ throw new TypeError('Input has invalid signature');
68
+ }
69
+ }
70
+ return Object.assign(o, a);
71
+ }
72
+ //# sourceMappingURL=p2pk.js.map
@@ -0,0 +1,3 @@
1
+ import { Payment, PaymentOpts } from '../types';
2
+ export declare function p2pkh(a: Payment, opts?: PaymentOpts): Payment;
3
+ //# sourceMappingURL=p2pkh.d.ts.map