@opcat-labs/opcat 1.0.0 → 1.0.2

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 (293) hide show
  1. package/.cjs2esm.json +18 -0
  2. package/.mocharc.yaml +1 -1
  3. package/CHANGELOG.md +13 -0
  4. package/README.md +6 -0
  5. package/{lib/address.js → cjs/address.cjs} +77 -72
  6. package/cjs/block/block.cjs +332 -0
  7. package/{lib/block/blockheader.js → cjs/block/blockheader.cjs} +8 -7
  8. package/cjs/block/index.cjs +2 -0
  9. package/{lib/block/merkleblock.js → cjs/block/merkleblock.cjs} +23 -15
  10. package/cjs/bn.cjs +3411 -0
  11. package/{lib/crypto/bn.js → cjs/crypto/bn.cjs} +3 -3
  12. package/{lib/crypto/ecdsa.js → cjs/crypto/ecdsa.cjs} +150 -14
  13. package/{lib/crypto/hash.node.js → cjs/crypto/hash.cjs} +13 -2
  14. package/cjs/crypto/index.cjs +16 -0
  15. package/{lib/crypto/point.js → cjs/crypto/point.cjs} +11 -4
  16. package/cjs/crypto/random.cjs +18 -0
  17. package/{lib/crypto/signature.js → cjs/crypto/signature.cjs} +158 -8
  18. package/{lib/encoding/base58.js → cjs/encoding/base58.cjs} +58 -2
  19. package/cjs/encoding/base58check.cjs +192 -0
  20. package/cjs/encoding/bufferreader.cjs +333 -0
  21. package/cjs/encoding/bufferwriter.cjs +244 -0
  22. package/{lib/encoding/decode-asm.js → cjs/encoding/decode-asm.cjs} +4 -4
  23. package/{lib/encoding/decode-hex.js → cjs/encoding/decode-hex.cjs} +1 -1
  24. package/cjs/encoding/index.cjs +14 -0
  25. package/cjs/encoding/varint.cjs +116 -0
  26. package/{lib/errors/index.js → cjs/errors/index.cjs} +9 -9
  27. package/{lib/errors/spec.js → cjs/errors/spec.cjs} +2 -2
  28. package/cjs/hash-cache.cjs +98 -0
  29. package/{lib/hdprivatekey.js → cjs/hdprivatekey.cjs} +232 -140
  30. package/{lib/hdpublickey.js → cjs/hdpublickey.cjs} +120 -93
  31. package/cjs/index.cjs +94 -0
  32. package/cjs/interpreter/index.cjs +2 -0
  33. package/cjs/interpreter/interpreter.cjs +1988 -0
  34. package/{lib/script/stack.js → cjs/interpreter/stack.cjs} +9 -2
  35. package/{lib/message/message.js → cjs/message/message.cjs} +62 -25
  36. package/cjs/mnemonic/index.cjs +3 -0
  37. package/{lib/mnemonic/mnemonic.js → cjs/mnemonic/mnemonic.cjs} +44 -13
  38. package/{lib/mnemonic/pbkdf2.node.js → cjs/mnemonic/pbkdf2.cjs} +9 -2
  39. package/cjs/mnemonic/words/index.cjs +66 -0
  40. package/cjs/network.cjs +13 -0
  41. package/cjs/networks.cjs +321 -0
  42. package/{lib/opcode.js → cjs/opcode.cjs} +69 -5
  43. package/cjs/privatekey.cjs +422 -0
  44. package/{lib/publickey.js → cjs/publickey.cjs} +14 -16
  45. package/cjs/script/index.cjs +2 -0
  46. package/{lib/script/script.js → cjs/script/script.cjs} +322 -67
  47. package/cjs/transaction/index.cjs +5 -0
  48. package/cjs/transaction/input/index.cjs +34 -0
  49. package/cjs/transaction/input/input.cjs +396 -0
  50. package/{lib/transaction/input/multisig.js → cjs/transaction/input/multisig.cjs} +112 -18
  51. package/{lib/transaction/input/publickey.js → cjs/transaction/input/publickey.cjs} +29 -19
  52. package/{lib/transaction/input/publickeyhash.js → cjs/transaction/input/publickeyhash.cjs} +25 -17
  53. package/{lib/transaction/output.js → cjs/transaction/output.cjs} +100 -15
  54. package/cjs/transaction/sighash.cjs +187 -0
  55. package/{lib/transaction/signature.js → cjs/transaction/signature.cjs} +30 -6
  56. package/cjs/transaction/transaction.cjs +2000 -0
  57. package/{lib/transaction/unspentoutput.js → cjs/transaction/unspentoutput.cjs} +5 -5
  58. package/cjs/util/derivation.cjs +53 -0
  59. package/cjs/util/index.cjs +11 -0
  60. package/cjs/util/js.cjs +95 -0
  61. package/{lib/util/preconditions.js → cjs/util/preconditions.cjs} +2 -2
  62. package/esm/address.js +483 -0
  63. package/{lib → esm}/block/block.js +82 -27
  64. package/esm/block/blockheader.js +296 -0
  65. package/esm/block/index.js +2 -0
  66. package/esm/block/merkleblock.js +331 -0
  67. package/esm/bn.js +3411 -0
  68. package/esm/crypto/bn.js +278 -0
  69. package/esm/crypto/ecdsa.js +475 -0
  70. package/{lib/crypto/hash.browser.js → esm/crypto/hash.js} +18 -7
  71. package/esm/crypto/index.js +16 -0
  72. package/esm/crypto/point.js +228 -0
  73. package/esm/crypto/random.js +18 -0
  74. package/esm/crypto/signature.js +475 -0
  75. package/esm/encoding/base58.js +167 -0
  76. package/esm/encoding/base58check.js +192 -0
  77. package/esm/encoding/bufferreader.js +333 -0
  78. package/esm/encoding/bufferwriter.js +243 -0
  79. package/esm/encoding/decode-asm.js +24 -0
  80. package/esm/encoding/decode-hex.js +32 -0
  81. package/esm/encoding/decode-script-chunks.js +43 -0
  82. package/esm/encoding/encode-hex.js +284 -0
  83. package/esm/encoding/index.js +14 -0
  84. package/esm/encoding/is-hex.js +7 -0
  85. package/esm/encoding/varint.js +116 -0
  86. package/esm/errors/index.js +54 -0
  87. package/esm/errors/spec.js +314 -0
  88. package/esm/hash-cache.js +98 -0
  89. package/esm/hdprivatekey.js +768 -0
  90. package/esm/hdpublickey.js +549 -0
  91. package/esm/index.js +66 -0
  92. package/esm/interpreter/index.js +2 -0
  93. package/{lib/script → esm/interpreter}/interpreter.js +219 -66
  94. package/esm/interpreter/stack.js +116 -0
  95. package/esm/message/message.js +228 -0
  96. package/esm/mnemonic/index.js +3 -0
  97. package/esm/mnemonic/mnemonic.js +332 -0
  98. package/{lib/mnemonic/pbkdf2.browser.js → esm/mnemonic/pbkdf2.js} +13 -6
  99. package/esm/mnemonic/words/chinese.js +2054 -0
  100. package/esm/mnemonic/words/english.js +2054 -0
  101. package/esm/mnemonic/words/french.js +2054 -0
  102. package/esm/mnemonic/words/index.js +66 -0
  103. package/esm/mnemonic/words/italian.js +2054 -0
  104. package/esm/mnemonic/words/japanese.js +2054 -0
  105. package/esm/mnemonic/words/spanish.js +2054 -0
  106. package/esm/network.js +13 -0
  107. package/{lib → esm}/networks.js +61 -120
  108. package/esm/opcode.js +319 -0
  109. package/{lib → esm}/privatekey.js +76 -28
  110. package/esm/publickey.js +384 -0
  111. package/esm/script/index.js +2 -0
  112. package/esm/script/script.js +1329 -0
  113. package/esm/script/write-i32-le.js +17 -0
  114. package/esm/script/write-push-data.js +35 -0
  115. package/esm/script/write-u16-le.js +12 -0
  116. package/esm/script/write-u32-le.js +16 -0
  117. package/esm/script/write-u64-le.js +24 -0
  118. package/esm/script/write-u8-le.js +8 -0
  119. package/esm/script/write-varint.js +46 -0
  120. package/esm/transaction/index.js +5 -0
  121. package/esm/transaction/input/index.js +33 -0
  122. package/{lib → esm}/transaction/input/input.js +132 -90
  123. package/esm/transaction/input/multisig.js +335 -0
  124. package/esm/transaction/input/publickey.js +108 -0
  125. package/esm/transaction/input/publickeyhash.js +124 -0
  126. package/esm/transaction/output.js +316 -0
  127. package/{lib → esm}/transaction/sighash.js +42 -22
  128. package/esm/transaction/signature.js +120 -0
  129. package/{lib → esm}/transaction/transaction.js +522 -163
  130. package/esm/transaction/unspentoutput.js +112 -0
  131. package/esm/util/_.js +47 -0
  132. package/esm/util/derivation.js +53 -0
  133. package/esm/util/index.js +12 -0
  134. package/esm/util/js.js +95 -0
  135. package/esm/util/preconditions.js +33 -0
  136. package/fixup.cjs +17 -0
  137. package/package.json +40 -26
  138. package/test/{address.js → address.cjs} +14 -43
  139. package/test/block/{block.js → block.cjs} +3 -5
  140. package/test/block/{blockheader.js → blockheader.cjs} +2 -2
  141. package/test/block/{merklebloack.js → merklebloack.cjs} +2 -2
  142. package/test/crypto/{ecdsa.js → ecdsa.cjs} +9 -9
  143. package/test/crypto/{hash.browser.js → hash.browser.cjs} +2 -1
  144. package/test/crypto/{signature.js → signature.cjs} +2 -2
  145. package/test/data/bitcoind/script_tests.json +5 -5
  146. package/test/{hashCache.js → hashCache.cjs} +2 -1
  147. package/test/{hdkeys.js → hdkeys.cjs} +4 -2
  148. package/test/{hdprivatekey.js → hdprivatekey.cjs} +7 -6
  149. package/test/{hdpublickey.js → hdpublickey.cjs} +2 -7
  150. package/test/mnemonic/{pbkdf2.test.js → pbkdf2.test.cjs} +2 -2
  151. package/test/{networks.js → networks.cjs} +12 -31
  152. package/test/{publickey.js → publickey.cjs} +2 -2
  153. package/test/script/{interpreter.js → interpreter.cjs} +5 -5
  154. package/test/script/{script.js → script.cjs} +8 -2
  155. package/test/transaction/{deserialize.js → deserialize.cjs} +2 -2
  156. package/test/transaction/input/{input.js → input.cjs} +1 -1
  157. package/test/transaction/input/{multisig.js → multisig.cjs} +2 -1
  158. package/test/transaction/input/{publickeyhash.js → publickeyhash.cjs} +1 -1
  159. package/test/transaction/{sighash.js → sighash.cjs} +1 -1
  160. package/test/transaction/{transaction.js → transaction.cjs} +2 -2
  161. package/tsconfig.json +13 -0
  162. package/types/address.d.cts +252 -0
  163. package/types/block/block.d.cts +139 -0
  164. package/types/block/blockheader.d.cts +125 -0
  165. package/types/block/index.d.cts +2 -0
  166. package/types/block/merkleblock.d.cts +95 -0
  167. package/types/bn.d.cts +202 -0
  168. package/types/crypto/bn.d.cts +2 -0
  169. package/types/crypto/ecdsa.d.cts +187 -0
  170. package/types/crypto/hash.d.cts +118 -0
  171. package/types/crypto/index.d.cts +7 -0
  172. package/types/crypto/point.d.cts +134 -0
  173. package/types/crypto/random.d.cts +13 -0
  174. package/types/crypto/signature.d.cts +160 -0
  175. package/types/encoding/base58.d.cts +106 -0
  176. package/types/encoding/base58check.d.cts +107 -0
  177. package/types/encoding/bufferreader.d.cts +164 -0
  178. package/types/encoding/bufferwriter.d.cts +126 -0
  179. package/types/encoding/decode-asm.d.cts +2 -0
  180. package/types/encoding/decode-hex.d.cts +2 -0
  181. package/types/encoding/decode-script-chunks.d.cts +14 -0
  182. package/types/encoding/encode-hex.d.cts +2 -0
  183. package/types/encoding/index.d.cts +6 -0
  184. package/types/encoding/is-hex.d.cts +2 -0
  185. package/types/encoding/varint.d.cts +66 -0
  186. package/types/errors/index.d.cts +4 -0
  187. package/types/errors/spec.d.cts +22 -0
  188. package/types/hash-cache.d.cts +65 -0
  189. package/types/hdprivatekey.d.cts +281 -0
  190. package/types/hdpublickey.d.cts +240 -0
  191. package/types/index.d.cts +26 -0
  192. package/types/interpreter/index.d.cts +2 -0
  193. package/types/interpreter/interpreter.d.cts +228 -0
  194. package/types/interpreter/stack.d.cts +35 -0
  195. package/types/message/message.d.cts +110 -0
  196. package/types/mnemonic/index.d.cts +2 -0
  197. package/types/mnemonic/mnemonic.d.cts +171 -0
  198. package/types/mnemonic/pbkdf2.d.cts +14 -0
  199. package/types/mnemonic/words/chinese.d.cts +2 -0
  200. package/types/mnemonic/words/english.d.cts +2 -0
  201. package/types/mnemonic/words/french.d.cts +2 -0
  202. package/types/mnemonic/words/index.d.cts +22 -0
  203. package/types/mnemonic/words/italian.d.cts +2 -0
  204. package/types/mnemonic/words/japanese.d.cts +2 -0
  205. package/types/mnemonic/words/spanish.d.cts +2 -0
  206. package/types/network.d.cts +11 -0
  207. package/types/networks.d.cts +76 -0
  208. package/types/opcode.d.cts +93 -0
  209. package/types/privatekey.d.cts +169 -0
  210. package/types/publickey.d.cts +202 -0
  211. package/types/script/index.d.cts +2 -0
  212. package/types/script/script.d.cts +449 -0
  213. package/types/script/write-i32-le.d.cts +2 -0
  214. package/types/script/write-push-data.d.cts +2 -0
  215. package/types/script/write-u16-le.d.cts +2 -0
  216. package/types/script/write-u32-le.d.cts +2 -0
  217. package/types/script/write-u64-le.d.cts +2 -0
  218. package/types/script/write-u8-le.d.cts +2 -0
  219. package/types/script/write-varint.d.cts +2 -0
  220. package/types/transaction/index.d.cts +2 -0
  221. package/types/transaction/input/index.d.cts +2 -0
  222. package/types/transaction/input/input.d.cts +178 -0
  223. package/types/transaction/input/multisig.d.cts +127 -0
  224. package/types/transaction/input/publickey.d.cts +44 -0
  225. package/types/transaction/input/publickeyhash.d.cts +45 -0
  226. package/types/transaction/output.d.cts +118 -0
  227. package/types/transaction/sighash.d.cts +61 -0
  228. package/types/transaction/signature.d.cts +43 -0
  229. package/types/transaction/transaction.d.cts +716 -0
  230. package/types/transaction/unspentoutput.d.cts +83 -0
  231. package/types/util/_.d.cts +26 -0
  232. package/types/util/derivation.d.cts +21 -0
  233. package/types/util/index.d.cts +5 -0
  234. package/types/util/js.d.cts +50 -0
  235. package/types/util/preconditions.d.cts +3 -0
  236. package/index.d.ts +0 -1541
  237. package/index.js +0 -74
  238. package/lib/block/index.js +0 -4
  239. package/lib/bn.js +0 -3423
  240. package/lib/crypto/hash.js +0 -2
  241. package/lib/crypto/random.browser.js +0 -28
  242. package/lib/crypto/random.js +0 -2
  243. package/lib/crypto/random.node.js +0 -11
  244. package/lib/encoding/base58check.js +0 -121
  245. package/lib/encoding/bufferreader.js +0 -212
  246. package/lib/encoding/bufferwriter.js +0 -140
  247. package/lib/encoding/varint.js +0 -75
  248. package/lib/hash-cache.js +0 -50
  249. package/lib/mnemonic/pbkdf2.js +0 -2
  250. package/lib/mnemonic/words/index.js +0 -8
  251. package/lib/script/index.js +0 -5
  252. package/lib/transaction/index.js +0 -7
  253. package/lib/transaction/input/index.js +0 -5
  254. package/lib/util/js.js +0 -90
  255. /package/{lib/encoding/decode-script-chunks.js → cjs/encoding/decode-script-chunks.cjs} +0 -0
  256. /package/{lib/encoding/encode-hex.js → cjs/encoding/encode-hex.cjs} +0 -0
  257. /package/{lib/encoding/is-hex.js → cjs/encoding/is-hex.cjs} +0 -0
  258. /package/{lib/mnemonic/words/chinese.js → cjs/mnemonic/words/chinese.cjs} +0 -0
  259. /package/{lib/mnemonic/words/english.js → cjs/mnemonic/words/english.cjs} +0 -0
  260. /package/{lib/mnemonic/words/french.js → cjs/mnemonic/words/french.cjs} +0 -0
  261. /package/{lib/mnemonic/words/italian.js → cjs/mnemonic/words/italian.cjs} +0 -0
  262. /package/{lib/mnemonic/words/japanese.js → cjs/mnemonic/words/japanese.cjs} +0 -0
  263. /package/{lib/mnemonic/words/spanish.js → cjs/mnemonic/words/spanish.cjs} +0 -0
  264. /package/{lib/script/write-i32-le.js → cjs/script/write-i32-le.cjs} +0 -0
  265. /package/{lib/script/write-push-data.js → cjs/script/write-push-data.cjs} +0 -0
  266. /package/{lib/script/write-u16-le.js → cjs/script/write-u16-le.cjs} +0 -0
  267. /package/{lib/script/write-u32-le.js → cjs/script/write-u32-le.cjs} +0 -0
  268. /package/{lib/script/write-u64-le.js → cjs/script/write-u64-le.cjs} +0 -0
  269. /package/{lib/script/write-u8-le.js → cjs/script/write-u8-le.cjs} +0 -0
  270. /package/{lib/script/write-varint.js → cjs/script/write-varint.cjs} +0 -0
  271. /package/{lib/util/_.js → cjs/util/_.cjs} +0 -0
  272. /package/test/crypto/{bn.js → bn.cjs} +0 -0
  273. /package/test/crypto/{hash.js → hash.cjs} +0 -0
  274. /package/test/crypto/{point.js → point.cjs} +0 -0
  275. /package/test/crypto/{random.js → random.cjs} +0 -0
  276. /package/test/data/{blk86756-testnet.js → blk86756-testnet.cjs} +0 -0
  277. /package/test/data/{merkleblocks.js → merkleblocks.cjs} +0 -0
  278. /package/test/encoding/{base58.js → base58.cjs} +0 -0
  279. /package/test/encoding/{base58check.js → base58check.cjs} +0 -0
  280. /package/test/encoding/{bufferreader.js → bufferreader.cjs} +0 -0
  281. /package/test/encoding/{bufferwriter.js → bufferwriter.cjs} +0 -0
  282. /package/test/encoding/{varint.js → varint.cjs} +0 -0
  283. /package/test/{index.js → index.cjs} +0 -0
  284. /package/test/message/{message.js → message.cjs} +0 -0
  285. /package/test/mnemonic/{mnemonic.js → mnemonic.cjs} +0 -0
  286. /package/test/{opcode.js → opcode.cjs} +0 -0
  287. /package/test/{privatekey.js → privatekey.cjs} +0 -0
  288. /package/test/transaction/input/{publickey.js → publickey.cjs} +0 -0
  289. /package/test/transaction/{output.js → output.cjs} +0 -0
  290. /package/test/transaction/{signature.js → signature.cjs} +0 -0
  291. /package/test/transaction/{unspentoutput.js → unspentoutput.cjs} +0 -0
  292. /package/test/util/{js.js → js.cjs} +0 -0
  293. /package/test/util/{preconditions.js → preconditions.cjs} +0 -0
@@ -1435,7 +1435,7 @@
1435
1435
  "'a' 'zngyivniryrgefgnvqwfwqplmramujzilzyrsdvinxfkfmuowdpuzycnzbupwwpzrfxsbyrhdlsyixyzysodseayvvrtbsfxtikrjwkbduulrjyjlwlaigomhyohsukawdwbrpuacdijzzgxhataguajvuopuktvtklwhsxqvzzfttpdgnxtnbpsiqecxurlczqmoxznlsuejvneiyejetcxlblzrydscnrbydnqytorstjtuzlbbtbyzfiniuehbisqnqhvexylhohjiyiknzgjowvobsrwcxyfowqcvakgdolwpltfcxtrhuysrrvtprzpsucgogsjapdkrbobpxccqgkdumskaleycwsbkabdkuukqiyizceduplmauszwjdzptvmthxocwrignxjogxsvrsjrrlecvdmazlpfkgmskiqqitrevuwiisvpxvkeypzaqjwwiozvmahmtvtjpbolwrymvzfstopzcexalirwbbcqgjvfjfuirrcnlgcfyqnafhh'",
1436
1436
  "CAT",
1437
1437
  "P2SH,STRICTENC,MONOLITH_OPCODES",
1438
- "PUSH_SIZE",
1438
+ "OK",
1439
1439
  "CAT oversized result"
1440
1440
  ],
1441
1441
 
@@ -1563,8 +1563,8 @@
1563
1563
  "-42 521",
1564
1564
  "NUM2BIN",
1565
1565
  "P2SH,STRICTENC,MONOLITH_OPCODES",
1566
- "PUSH_SIZE",
1567
- "Pushing 521 bytes is not"
1566
+ "OK",
1567
+ "Pushing 521 bytes is OK"
1568
1568
  ],
1569
1569
  ["-42 -3", "NUM2BIN", "P2SH,STRICTENC,MONOLITH_OPCODES", "PUSH_SIZE", "Negative size"],
1570
1570
  [
@@ -2670,14 +2670,14 @@
2670
2670
  "NOP",
2671
2671
  "'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'",
2672
2672
  "P2SH,STRICTENC",
2673
- "PUSH_SIZE",
2673
+ "OK",
2674
2674
  ">520 byte push"
2675
2675
  ],
2676
2676
  [
2677
2677
  "0",
2678
2678
  "IF 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' ENDIF 1",
2679
2679
  "P2SH,STRICTENC",
2680
- "PUSH_SIZE",
2680
+ "OK",
2681
2681
  ">520 byte push in non-executed IF branch"
2682
2682
  ],
2683
2683
  [
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
- var HashCache = require('../lib/hash-cache');
2
+ var opcat = require('../');
3
+ var HashCache = opcat.HashCache;
3
4
  var chai = require('chai');
4
5
  var should = chai.should();
5
6
 
@@ -6,11 +6,11 @@
6
6
  // * store test vectors at the end, latedef: false
7
7
  // * should call is never defined
8
8
 
9
- var _ = require('../lib/util/_');
10
9
  require('chai').should();
11
10
  var expect = require('chai').expect;
12
11
  var sinon = require('sinon');
13
12
  var opcat = require('..');
13
+ var _ = opcat.util._;
14
14
  var Networks = opcat.Networks;
15
15
  var HDPrivateKey = opcat.HDPrivateKey;
16
16
  var HDPublicKey = opcat.HDPublicKey;
@@ -57,7 +57,9 @@ describe('BIP32 compliance', function () {
57
57
  });
58
58
 
59
59
  it('can initialize a public key from an extended private key', function () {
60
- new HDPublicKey(vector1MPrivate).xpubkey.should.equal(vector1MPublic);
60
+ expect(()=> {
61
+ new HDPublicKey(vector1MPrivate)
62
+ }).to.throw(/Argument is an extended private key/)
61
63
  });
62
64
 
63
65
  it('toString should be equal to the `xpubkey` member', function () {
@@ -1,15 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var _ = require('../lib/util/_');
4
3
  var assert = require('assert');
5
4
  var should = require('chai').should();
6
5
  var expect = require('chai').expect;
7
6
  var opcat = require('..');
7
+ var _ = opcat.util._;
8
8
  var errors = opcat.errors;
9
9
  var hdErrors = errors.HDPrivateKey;
10
10
  var buffer = require('buffer');
11
11
  var Networks = opcat.Networks;
12
- var JSUtil = require('../lib/util/js');
12
+ var JSUtil = opcat.util.js;
13
+ var Derivation = opcat.util.derivation;
13
14
  var HDPrivateKey = opcat.HDPrivateKey;
14
15
  var Base58Check = opcat.encoding.Base58Check;
15
16
 
@@ -237,20 +238,20 @@ describe('HDPrivate key interface', function () {
237
238
  invalid.forEach(function (datum) {
238
239
  it('rejects illegal path ' + datum, function () {
239
240
  HDPrivateKey.isValidPath(datum).should.equal(false);
240
- expect(HDPrivateKey._getDerivationIndexes(datum)).to.equal(null);
241
+ expect(Derivation.getDerivationIndexes(datum)).to.equal(null);
241
242
  });
242
243
  });
243
244
 
244
245
  it('generates deriving indexes correctly', function () {
245
246
  var indexes;
246
247
 
247
- indexes = HDPrivateKey._getDerivationIndexes('m/-1/12');
248
+ indexes = Derivation.getDerivationIndexes('m/-1/12');
248
249
  expect(indexes).to.equal(null);
249
250
 
250
- indexes = HDPrivateKey._getDerivationIndexes("m/0/12/12'");
251
+ indexes = Derivation.getDerivationIndexes("m/0/12/12'");
251
252
  indexes.should.eql([0, 12, HDPrivateKey.Hardened + 12]);
252
253
 
253
- indexes = HDPrivateKey._getDerivationIndexes("m/0/12/12'");
254
+ indexes = Derivation.getDerivationIndexes("m/0/12/12'");
254
255
  indexes.should.eql([0, 12, HDPrivateKey.Hardened + 12]);
255
256
  });
256
257
  });
@@ -7,7 +7,7 @@ var opcat = require('..');
7
7
  var buffer = require('buffer');
8
8
  var errors = opcat.errors;
9
9
  var hdErrors = opcat.errors.HDPublicKey;
10
- var JSUtil = require('../lib/util/js');
10
+ var JSUtil = opcat.util.js;
11
11
  var HDPrivateKey = opcat.HDPrivateKey;
12
12
  var HDPublicKey = opcat.HDPublicKey;
13
13
  var Base58Check = opcat.encoding.Base58Check;
@@ -50,11 +50,6 @@ describe('HDPublicKey interface', function () {
50
50
  publicKey.should.equal(new HDPublicKey(publicKey));
51
51
  });
52
52
 
53
- it('returns the correct xpubkey for a xprivkey', function () {
54
- var publicKey = new HDPublicKey(xprivkey);
55
- publicKey.xpubkey.should.equal(xpubkey);
56
- });
57
-
58
53
  it('allows to call the argument with no "new" keyword', function () {
59
54
  HDPublicKey(xpubkey).xpubkey.should.equal(new HDPublicKey(xpubkey).xpubkey);
60
55
  });
@@ -64,7 +59,7 @@ describe('HDPublicKey interface', function () {
64
59
  });
65
60
 
66
61
  it('should not be able to change read-only properties', function () {
67
- var publicKey = new HDPublicKey(xprivkey);
62
+ var publicKey = HDPublicKey(xpubkey);
68
63
  expect(function () {
69
64
  publicKey.fingerPrint = 'notafingerprint';
70
65
  }).to.throw(TypeError);
@@ -2,8 +2,8 @@
2
2
 
3
3
  var chai = require('chai');
4
4
  chai.should();
5
-
6
- var pbkdf2 = require('../../lib/mnemonic/pbkdf2');
5
+ var opcat = require('../../')
6
+ var pbkdf2 = opcat.Mnemonic.pbkdf2;
7
7
 
8
8
  describe('pbkdf2', function () {
9
9
  this.timeout(10000);
@@ -11,7 +11,7 @@ describe('Networks', function () {
11
11
  it('should contain all Networks', function () {
12
12
  should.exist(networks.livenet);
13
13
  should.exist(networks.testnet);
14
- should.exist(networks.stn);
14
+ should.exist(networks.regtest);
15
15
  should.exist(networks.defaultNetwork);
16
16
  });
17
17
 
@@ -45,11 +45,6 @@ describe('Networks', function () {
45
45
  Buffer.isBuffer(testnet.networkMagic).should.equal(true);
46
46
  });
47
47
 
48
- it('should have network magic for stn', function () {
49
- var stn = networks.get('stn');
50
- Buffer.isBuffer(stn.networkMagic).should.equal(true);
51
- });
52
-
53
48
  it('can remove a custom network', function () {
54
49
  networks.remove(customnet);
55
50
  var net = networks.get('customnet');
@@ -80,10 +75,10 @@ describe('Networks', function () {
80
75
  var constants = ['name', 'alias', 'pubkeyhash', 'scripthash', 'xpubkey', 'xprivkey'];
81
76
 
82
77
  constants.forEach(function (key) {
83
- it('should have constant ' + key + ' for livenet, testnet and stn', function () {
78
+ it('should have constant ' + key + ' for livenet, testnet and regtest', function () {
84
79
  networks.testnet.hasOwnProperty(key).should.equal(true);
85
80
  networks.livenet.hasOwnProperty(key).should.equal(true);
86
- networks.stn.hasOwnProperty(key).should.equal(true);
81
+ networks.regtest.hasOwnProperty(key).should.equal(true);
87
82
  });
88
83
  });
89
84
 
@@ -106,44 +101,30 @@ describe('Networks', function () {
106
101
  expect(networks.get('testnet').name).to.equal('testnet');
107
102
  });
108
103
 
109
- it('should have stn network', function () {
110
- expect(networks.get('stn').name).to.equal('stn');
111
- });
112
-
113
104
  it('should have livenet network', function () {
114
105
  expect(networks.get('livenet').name).to.equal('livenet');
115
106
  });
116
107
 
117
- it('should have bchtest cashAddrPrefix', function () {
118
- expect(networks.get('testnet').cashAddrPrefix).to.equal('bchtest');
108
+ it('should have opcattest cashAddrPrefix', function () {
109
+ expect(networks.get('testnet').cashAddrPrefix).to.equal('opcattest');
119
110
  });
120
111
 
121
- it('should have bchreg cashAddrPrefix', function () {
122
- expect(networks.get('regtest').cashAddrPrefix).to.equal('bchreg');
112
+ it('should have opcatreg cashAddrPrefix', function () {
113
+ expect(networks.get('regtest').cashAddrPrefix).to.equal('opcatreg');
123
114
  });
124
115
 
125
- it('should have bchreg cashAddrPrefix after enableRegtest is called', function () {
116
+ it('should have opcatreg cashAddrPrefix after enableRegtest is called', function () {
126
117
  var network = networks.get('testnet');
127
118
  networks.enableRegtest();
128
- expect(network.cashAddrPrefix).to.equal('bchreg');
119
+ expect(network.cashAddrPrefix).to.equal('opcatreg');
129
120
  });
130
121
 
131
- it('should have bchtest cashAddrPrefix after disableRegtest is called', function () {
122
+ it('should have opcattest cashAddrPrefix after disableRegtest is called', function () {
132
123
  var network = networks.get('testnet');
133
124
  networks.disableRegtest();
134
- expect(network.cashAddrPrefix).to.equal('bchtest');
135
- });
136
- it('should have opcatstn cashAddrPrefix after enableStn is called', function () {
137
- var network = networks.get('testnet');
138
- networks.enableStn();
139
- expect(network.cashAddrPrefix).to.equal('opcatstn');
140
- });
141
-
142
- it('should have bchtest cashAddrPrefix after disableStn is called', function () {
143
- var network = networks.get('testnet');
144
- networks.disableStn();
145
- expect(network.cashAddrPrefix).to.equal('bchtest');
125
+ expect(network.cashAddrPrefix).to.equal('opcattest');
146
126
  });
127
+
147
128
 
148
129
  it('converts to string using the "name" property', function () {
149
130
  networks.livenet.toString().should.equal('livenet');
@@ -46,7 +46,7 @@ describe('PublicKey', function () {
46
46
  var privhex = '906977a061af29276e40bf377042ffbde414e496ae2260bbf1fa9d085637bfff';
47
47
  var pubhex = '02a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc';
48
48
  var privkey = new PrivateKey(new BN(Buffer.from(privhex, 'hex')));
49
- var pk = new PublicKey(privkey);
49
+ var pk = privkey.toPublicKey();
50
50
  pk.toString().should.equal(pubhex);
51
51
  });
52
52
 
@@ -512,7 +512,7 @@ describe('PublicKey', function () {
512
512
 
513
513
  it('should output known compressed pubkey with network for console', function () {
514
514
  var privkey = PrivateKey.fromWIF('L3T1s1TYP9oyhHpXgkyLoJFGniEgkv2Jhi138d7R2yJ9F4QdDU2m');
515
- var pubkey = new PublicKey(privkey);
515
+ var pubkey = privkey.toPublicKey();
516
516
  pubkey
517
517
  .inspect()
518
518
  .should.equal(
@@ -2,18 +2,18 @@
2
2
 
3
3
  var should = require('chai').should();
4
4
  var opcat = require('../../');
5
- var Interpreter = opcat.Script.Interpreter;
5
+ var Interpreter = opcat.Interpreter;
6
6
  var Transaction = opcat.Transaction;
7
7
  var PrivateKey = opcat.PrivateKey;
8
8
  var Script = opcat.Script;
9
9
  var BN = opcat.crypto.BN;
10
10
  var BufferWriter = opcat.encoding.BufferWriter;
11
11
  var Opcode = opcat.Opcode;
12
- var _ = require('../../lib/util/_');
12
+ var _ = opcat.util._;
13
13
 
14
- var scriptTests = require('../data/bitcoind/script_tests');
15
- var txValid = require('../data/bitcoind/tx_valid');
16
- var txInvalid = require('../data/bitcoind/tx_invalid');
14
+ var scriptTests = require('../data/bitcoind/script_tests.json');
15
+ var txValid = require('../data/bitcoind/tx_valid.json');
16
+ var txInvalid = require('../data/bitcoind/tx_invalid.json');
17
17
 
18
18
  // the script string format used in bitcoind data tests
19
19
  Script.fromBitcoindString = function (str) {
@@ -1349,7 +1349,10 @@ describe('Script', function () {
1349
1349
  });
1350
1350
 
1351
1351
  it('fails if content is not recognized', function () {
1352
- Script().toAddress(Networks.livenet).should.equal(false);
1352
+ expect(function () {
1353
+ Script().toAddress(Networks.livenet)
1354
+ }).to.throw(/Can't derive address associated with script:/);
1355
+
1353
1356
  });
1354
1357
 
1355
1358
  it('works for p2pkh output', function () {
@@ -1376,7 +1379,10 @@ describe('Script', function () {
1376
1379
  // no address scripts
1377
1380
  it('works for OP_RETURN script', function () {
1378
1381
  var script = new Script('OP_RETURN 20 0x99d29051af0c29adcb9040034752bba7dde33e35');
1379
- script.toAddress().should.equal(false);
1382
+ expect(function () {
1383
+ script.toAddress()
1384
+ }).to.throw(/Can't derive address associated with script: OP_RETURN 20 0x99d29051af0c29adcb9040034752bba7dde33e35, needs to be p2pkh in, p2pkh out/);
1385
+
1380
1386
  });
1381
1387
  });
1382
1388
  describe('equals', function () {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
-
3
- var Transaction = require('../../lib/transaction');
2
+ var opcat = require('../../')
3
+ var Transaction = opcat.Transaction;
4
4
 
5
5
  var vectorsValid = require('../data/bitcoind/tx_valid.json');
6
6
  var vectorsInvalid = require('../data/bitcoind/tx_invalid.json');
@@ -13,7 +13,7 @@ var Input = opcat.Transaction.Input;
13
13
  describe('Transaction.Input', function () {
14
14
  var privateKey = new PrivateKey('KwF9LjRraetZuEjR8VqEq539z137LW5anYDUnVK11vM3mNMHTWb4');
15
15
  var publicKey = privateKey.publicKey;
16
- var address = new Address(publicKey, Networks.livenet);
16
+ var address = new Address(publicKey.toBuffer(), Networks.livenet);
17
17
  var output = {
18
18
  address: '33zbk2aSZYdNbRsMPPt6jgy6Kq1kQreqeb',
19
19
  prevTxId: '66e64ef8a3b384164b78453fa8c8194de9a473ba14f89485a0e433699daec140',
@@ -1,13 +1,14 @@
1
1
  'use strict';
2
2
 
3
3
  var should = require('chai').should();
4
- var _ = require('../../../lib/util/_');
5
4
 
6
5
  var opcat = require('../../..');
7
6
  var Transaction = opcat.Transaction;
8
7
  var PrivateKey = opcat.PrivateKey;
9
8
  var Script = opcat.Script;
10
9
  var MultiSigInput = opcat.Transaction.Input.MultiSig;
10
+ var _ = opcat.util._;
11
+
11
12
 
12
13
  describe('MultiSigInput', function () {
13
14
  var privateKey1 = new PrivateKey('KwF9LjRraetZuEjR8VqEq539z137LW5anYDUnVK11vM3mNMHTWb4');
@@ -12,7 +12,7 @@ var Networks = opcat.Networks;
12
12
  describe('PublicKeyHashInput', function () {
13
13
  var privateKey = new PrivateKey('KwF9LjRraetZuEjR8VqEq539z137LW5anYDUnVK11vM3mNMHTWb4');
14
14
  var publicKey = privateKey.publicKey;
15
- var address = new Address(publicKey, Networks.livenet);
15
+ var address = new Address(publicKey.toBuffer(), Networks.livenet);
16
16
 
17
17
  var output = {
18
18
  address: address.toString(),
@@ -9,7 +9,7 @@ var Script = opcat.Script;
9
9
  var BN = opcat.crypto.BN;
10
10
  var Transaction = opcat.Transaction;
11
11
  var Signature = opcat.crypto.Signature;
12
- var sighash = Transaction.sighash;
12
+ var sighash = Transaction.Sighash;
13
13
 
14
14
  var vectorsSighash = require('../data/sighash.json');
15
15
 
@@ -5,7 +5,7 @@ var expect = require('chai').expect;
5
5
  var sinon = require('sinon');
6
6
 
7
7
  var opcat = require('../..');
8
- var _ = opcat.deps._;
8
+ var _ = opcat.util._
9
9
  var BN = opcat.crypto.BN;
10
10
  var Transaction = opcat.Transaction;
11
11
  var Input = opcat.Transaction.Input;
@@ -258,8 +258,8 @@ describe('Transaction', function () {
258
258
  .from(simpleUtxoWith100000Satoshis)
259
259
  .addSafeData('genesis is coming')
260
260
  .change(changeAddress)
261
+ .feePerKb(50)
261
262
  .sign(privateKey);
262
- // update if change default FEE_PER_KB
263
263
  transaction
264
264
  .serialize()
265
265
  .should.equal(
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "allowJs": true,
4
+ "module": "CommonJS",
5
+ "moduleResolution": "node",
6
+ "declaration": true,
7
+ "emitDeclarationOnly": true,
8
+ "outDir": "types",
9
+ "strict": false
10
+ },
11
+ "include": ["cjs/**/*.cjs"],
12
+ "exclude": ["node_modules/**/*"]
13
+ }
@@ -0,0 +1,252 @@
1
+ export = Address;
2
+ /**
3
+ * Instantiate an address from an address String or Buffer, a public key hash Buffer,
4
+ * or a {@link PublicKey} Buffer.
5
+ *
6
+ * This is an immutable class, and if the first parameter provided to this constructor is an
7
+ * `Address` instance, the same argument will be returned.
8
+ *
9
+ * An address has two key properties: `network` and `type`. The type is either
10
+ * `Address.PayToPublicKeyHash` (value is the `'pubkeyhash'` string).
11
+ * The network is an instance of {@link Network}.
12
+ * You can quickly check whether an address is of a given kind by using the methods
13
+ * `isPayToPublicKeyHash`
14
+ *
15
+ * @example
16
+ * ```javascript
17
+ * // validate that an input field is valid
18
+ * var error = Address.getValidationError(input, 'testnet');
19
+ * if (!error) {
20
+ * var address = Address(input, 'testnet');
21
+ * } else {
22
+ * // invalid network or checksum (typo?)
23
+ * var message = error.messsage;
24
+ * }
25
+ *
26
+ * // get an address from a public key
27
+ * var address = Address(publicKey, 'testnet').toString();
28
+ * ```
29
+ *
30
+ * @param {*} data - The encoded data in various formats
31
+ * @param {Network|String|number} [network] - The network: 'livenet' or 'testnet'
32
+ * @param {string} [type] - The type of address: 'pubkey'
33
+ * @returns {Address} A new valid and frozen instance of an Address
34
+ * @constructor
35
+ */
36
+ declare function Address(data: any, network?: Network | string | number, type?: string): Address;
37
+ declare class Address {
38
+ /**
39
+ * Instantiate an address from an address String or Buffer, a public key hash Buffer,
40
+ * or a {@link PublicKey} Buffer.
41
+ *
42
+ * This is an immutable class, and if the first parameter provided to this constructor is an
43
+ * `Address` instance, the same argument will be returned.
44
+ *
45
+ * An address has two key properties: `network` and `type`. The type is either
46
+ * `Address.PayToPublicKeyHash` (value is the `'pubkeyhash'` string).
47
+ * The network is an instance of {@link Network}.
48
+ * You can quickly check whether an address is of a given kind by using the methods
49
+ * `isPayToPublicKeyHash`
50
+ *
51
+ * @example
52
+ * ```javascript
53
+ * // validate that an input field is valid
54
+ * var error = Address.getValidationError(input, 'testnet');
55
+ * if (!error) {
56
+ * var address = Address(input, 'testnet');
57
+ * } else {
58
+ * // invalid network or checksum (typo?)
59
+ * var message = error.messsage;
60
+ * }
61
+ *
62
+ * // get an address from a public key
63
+ * var address = Address(publicKey, 'testnet').toString();
64
+ * ```
65
+ *
66
+ * @param {*} data - The encoded data in various formats
67
+ * @param {Network|String|number} [network] - The network: 'livenet' or 'testnet'
68
+ * @param {string} [type] - The type of address: 'pubkey'
69
+ * @returns {Address} A new valid and frozen instance of an Address
70
+ * @constructor
71
+ */
72
+ constructor(data: any, network?: Network | string | number, type?: string);
73
+ get hashBuffer(): any;
74
+ get network(): any;
75
+ get type(): any;
76
+ private _classifyArguments;
77
+ /**
78
+ * Returns true if an address is of pay to public key hash type
79
+ * @return boolean
80
+ */
81
+ isPayToPublicKeyHash(): boolean;
82
+ /**
83
+ * Will return a buffer representation of the address
84
+ *
85
+ * @returns {Buffer} Bitcoin address buffer
86
+ */
87
+ toBuffer(): Buffer;
88
+ /**
89
+ * Converts the address to a hexadecimal string representation.
90
+ * @returns {string} The hexadecimal string representation of the address.
91
+ */
92
+ toHex(): string;
93
+ /**
94
+ * Converts the address to a publickey hash string representation.
95
+ * @returns {string} The hexadecimal string of the publickey hash buffer.
96
+ */
97
+ toPublickeyHash(): string;
98
+ /**
99
+ * @returns {Object} A plain object with the address information
100
+ */
101
+ toObject: () => any;
102
+ toJSON(): any;
103
+ /**
104
+ * Will return a string formatted for the console
105
+ *
106
+ * @returns {string} Bitcoin address
107
+ */
108
+ inspect(): string;
109
+ /**
110
+ * Will return a the base58 string representation of the address
111
+ *
112
+ * @returns {string} Bitcoin address
113
+ */
114
+ toString(): string;
115
+ }
116
+ declare namespace Address {
117
+ let PayToPublicKeyHash: string;
118
+ /**
119
+ * @param {Buffer} hash - An instance of a hash Buffer
120
+ * @returns {Object} An object with keys: hashBuffer
121
+ * @private
122
+ */
123
+ function _transformHash(hash: Buffer): any;
124
+ /**
125
+ * Deserializes an address serialized through `Address#toObject()`
126
+ * @param {Object} data
127
+ * @param {string} data.hash - the hash that this address encodes
128
+ * @param {string} data.type - either 'pubkeyhash' or 'scripthash'
129
+ * @param {Network=} data.network - the name of the network associated
130
+ * @return {Address}
131
+ * @private
132
+ */
133
+ function _transformObject(data: {
134
+ hash: string;
135
+ type: string;
136
+ network?: Network;
137
+ }): Address;
138
+ /**
139
+ * Internal function to discover the network and type based on the first data byte
140
+ *
141
+ * @param {Buffer} buffer - An instance of a hex encoded address Buffer
142
+ * @returns {Object} An object with keys: network and type
143
+ * @private
144
+ */
145
+ function _classifyFromVersion(buffer: Buffer): any;
146
+ /**
147
+ * Internal function to transform a bitcoin address buffer
148
+ *
149
+ * @param {Buffer} buffer - An instance of a hex encoded address Buffer
150
+ * @param {string=} network - The network: 'livenet' or 'testnet'
151
+ * @param {string=} type - The type: 'pubkeyhash' or 'scripthash'
152
+ * @returns {Object} An object with keys: hashBuffer, network and type
153
+ * @private
154
+ */
155
+ function _transformBuffer(buffer: Buffer, network?: string, type?: string): any;
156
+ /**
157
+ * Internal function to transform a {@link PublicKey}
158
+ *
159
+ * @param {PublicKey} pubkey - An instance of PublicKey
160
+ * @returns {Object} An object with keys: hashBuffer, type
161
+ * @private
162
+ */
163
+ function _transformPublicKey(pubkey: PublicKey): any;
164
+ /**
165
+ * Internal function to transform a bitcoin cash address string
166
+ *
167
+ * @param {string} data
168
+ * @param {String|Network=} network - either a Network instance, 'livenet', or 'testnet'
169
+ * @param {string=} type - The type: 'pubkeyhash'
170
+ * @returns {Object} An object with keys: hashBuffer, network and type
171
+ * @private
172
+ */
173
+ function _transformString(data: string, network?: any, type?: string): any;
174
+ /**
175
+ * Instantiate an address from a PublicKey buffer
176
+ *
177
+ * @param {Buffer} data - A buffer of the public key
178
+ * @param {String|Network} network - either a Network instance, 'livenet', or 'testnet'
179
+ * @returns {Address} A new valid and frozen instance of an Address
180
+ */
181
+ function fromPublicKey(data: Buffer, network: any): Address;
182
+ /**
183
+ * Instantiate an address from a ripemd160 public key hash
184
+ *
185
+ * @param {Buffer} hash - An instance of buffer of the hash
186
+ * @param {String|Network} network - either a Network instance, 'livenet', or 'testnet'
187
+ * @returns {Address} A new valid and frozen instance of an Address
188
+ */
189
+ function fromPublicKeyHash(hash: Buffer, network: any): Address;
190
+ /**
191
+ * Instantiate an address from a bitcoin address buffer
192
+ *
193
+ * @param {Buffer} buffer - An instance of buffer of the address
194
+ * @param {String|Network=} network - either a Network instance, 'livenet', or 'testnet'
195
+ * @param {string=} type - The type of address: 'pubkey'
196
+ * @returns {Address} A new valid and frozen instance of an Address
197
+ */
198
+ function fromBuffer(buffer: Buffer, network?: any, type?: string): Address;
199
+ /**
200
+ * Creates an Address instance from a hex string.
201
+ * @param {string} hex - The hex string representation of the address.
202
+ * @param {Network} network - The network type (e.g., 'mainnet', 'testnet').
203
+ * @param {AddressType} [type] - Optional address type.
204
+ * @returns {Address} The Address instance created from the hex string.
205
+ */
206
+ function fromHex(hex: string, network: Network, type?: AddressType): Address;
207
+ /**
208
+ * Instantiate an address from an address string
209
+ *
210
+ * @param {string} str - An string of the bitcoin address
211
+ * @param {String|Network=} network - either a Network instance, 'livenet', or 'testnet'
212
+ * @param {string=} type - The type of address: 'pubkey'
213
+ * @returns {Address} A new valid and frozen instance of an Address
214
+ */
215
+ function fromString(str: string, network?: any, type?: string): Address;
216
+ /**
217
+ * Instantiate an address from an Object
218
+ *
219
+ * @param {string} json - An JSON string or Object with keys: hash, network and type
220
+ * @returns {Address} A new valid instance of an Address
221
+ */
222
+ function fromObject(obj: any): Address;
223
+ /**
224
+ * Will return a validation error if exists
225
+ *
226
+ * @example
227
+ * ```javascript
228
+ * // a network mismatch error
229
+ * var error = Address.getValidationError('15vkcKf7gB23wLAnZLmbVuMiiVDc1Nm4a2', 'testnet');
230
+ * ```
231
+ *
232
+ * @param {string} data - The encoded data
233
+ * @param {String|Network} network - either a Network instance, 'livenet', or 'testnet'
234
+ * @param {string} type - The type of address: 'pubkey'
235
+ * @returns {null|Error} The corresponding error message
236
+ */
237
+ function getValidationError(data: string, network: any, type: string): Error;
238
+ /**
239
+ * Will return a boolean if an address is valid
240
+ *
241
+ * @example
242
+ * ```javascript
243
+ * assert(Address.isValid('15vkcKf7gB23wLAnZLmbVuMiiVDc1Nm4a2', 'livenet'));
244
+ * ```
245
+ *
246
+ * @param {string} data - The encoded data
247
+ * @param {String|Network} network - either a Network instance, 'livenet', or 'testnet'
248
+ * @param {string} type - The type of address: 'pubkey'
249
+ * @returns {boolean} The corresponding error message
250
+ */
251
+ function isValid(data: string, network: any, type: string): boolean;
252
+ }