mainnet-js 0.5.9 → 1.0.0-rc.1

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 (684) hide show
  1. package/dist/index.html +9 -1
  2. package/dist/mainnet-1.0.0-rc.1.js +2928 -0
  3. package/dist/module/chain.d.ts +1 -0
  4. package/dist/module/chain.d.ts.map +1 -0
  5. package/dist/module/cli.d.ts +1 -0
  6. package/dist/module/cli.d.ts.map +1 -0
  7. package/dist/module/cli.js +2 -2
  8. package/dist/module/cli.js.map +1 -1
  9. package/dist/module/constant.d.ts +1 -0
  10. package/dist/module/constant.d.ts.map +1 -0
  11. package/dist/module/db/ExchangeRateProvider.d.ts +2 -1
  12. package/dist/module/db/ExchangeRateProvider.d.ts.map +1 -0
  13. package/dist/module/db/IndexedDBProvider.d.ts +3 -2
  14. package/dist/module/db/IndexedDBProvider.d.ts.map +1 -0
  15. package/dist/module/db/SqlProvider.d.ts +7 -8
  16. package/dist/module/db/SqlProvider.d.ts.map +1 -0
  17. package/dist/module/db/SqlProvider.js +10 -8
  18. package/dist/module/db/SqlProvider.js.map +1 -1
  19. package/dist/module/db/StorageProvider.d.ts +2 -1
  20. package/dist/module/db/StorageProvider.d.ts.map +1 -0
  21. package/dist/module/db/getStorageProvider.d.ts +3 -0
  22. package/dist/module/db/getStorageProvider.d.ts.map +1 -0
  23. package/dist/module/db/getStorageProvider.js +19 -0
  24. package/dist/module/db/getStorageProvider.js.map +1 -0
  25. package/dist/module/db/index.d.ts +4 -3
  26. package/dist/module/db/index.d.ts.map +1 -0
  27. package/dist/module/db/index.js +2 -2
  28. package/dist/module/db/index.js.map +1 -1
  29. package/dist/module/db/interface.d.ts +1 -0
  30. package/dist/module/db/interface.d.ts.map +1 -0
  31. package/dist/module/db/util.d.ts +2 -3
  32. package/dist/module/db/util.d.ts.map +1 -0
  33. package/dist/module/db/util.js +0 -17
  34. package/dist/module/db/util.js.map +1 -1
  35. package/dist/module/enum.d.ts +1 -0
  36. package/dist/module/enum.d.ts.map +1 -0
  37. package/dist/module/history/electrumTransformer.d.ts +3 -2
  38. package/dist/module/history/electrumTransformer.d.ts.map +1 -0
  39. package/dist/module/history/electrumTransformer.js +11 -11
  40. package/dist/module/history/electrumTransformer.js.map +1 -1
  41. package/dist/module/history/interface.d.ts +2 -1
  42. package/dist/module/history/interface.d.ts.map +1 -0
  43. package/dist/module/index.d.ts +26 -21
  44. package/dist/module/index.d.ts.map +1 -0
  45. package/dist/module/index.js +25 -17
  46. package/dist/module/index.js.map +1 -1
  47. package/dist/module/interface.d.ts +14 -0
  48. package/dist/module/interface.d.ts.map +1 -0
  49. package/dist/module/interface.js +5 -0
  50. package/dist/module/interface.js.map +1 -1
  51. package/dist/module/message/index.d.ts +3 -2
  52. package/dist/module/message/index.d.ts.map +1 -0
  53. package/dist/module/message/index.js +2 -2
  54. package/dist/module/message/index.js.map +1 -1
  55. package/dist/module/message/interface.d.ts +1 -0
  56. package/dist/module/message/interface.d.ts.map +1 -0
  57. package/dist/module/message/signed.d.ts +2 -1
  58. package/dist/module/message/signed.d.ts.map +1 -0
  59. package/dist/module/message/signed.js +10 -4
  60. package/dist/module/message/signed.js.map +1 -1
  61. package/dist/module/mine/index.d.ts +2 -1
  62. package/dist/module/mine/index.d.ts.map +1 -0
  63. package/dist/module/mine/index.js +1 -1
  64. package/dist/module/mine/index.js.map +1 -1
  65. package/dist/module/mine/mine.d.ts +1 -0
  66. package/dist/module/mine/mine.d.ts.map +1 -0
  67. package/dist/module/mine/mine.js +3 -3
  68. package/dist/module/mine/mine.js.map +1 -1
  69. package/dist/module/network/Connection.d.ts +3 -2
  70. package/dist/module/network/Connection.d.ts.map +1 -0
  71. package/dist/module/network/Connection.js +3 -3
  72. package/dist/module/network/Connection.js.map +1 -1
  73. package/dist/module/network/ElectrumNetworkProvider.d.ts +8 -5
  74. package/dist/module/network/ElectrumNetworkProvider.d.ts.map +1 -0
  75. package/dist/module/network/ElectrumNetworkProvider.js +59 -13
  76. package/dist/module/network/ElectrumNetworkProvider.js.map +1 -1
  77. package/dist/module/network/NetworkProvider.d.ts +2 -1
  78. package/dist/module/network/NetworkProvider.d.ts.map +1 -0
  79. package/dist/module/network/configuration.d.ts +8 -10
  80. package/dist/module/network/configuration.d.ts.map +1 -0
  81. package/dist/module/network/configuration.js +29 -17
  82. package/dist/module/network/configuration.js.map +1 -1
  83. package/dist/module/network/constant.d.ts +1 -0
  84. package/dist/module/network/constant.d.ts.map +1 -0
  85. package/dist/module/network/constant.js +8 -4
  86. package/dist/module/network/constant.js.map +1 -1
  87. package/dist/module/network/default.d.ts +4 -3
  88. package/dist/module/network/default.d.ts.map +1 -0
  89. package/dist/module/network/default.js +7 -7
  90. package/dist/module/network/default.js.map +1 -1
  91. package/dist/module/network/getRelayFeeCache.d.ts +2 -1
  92. package/dist/module/network/getRelayFeeCache.d.ts.map +1 -0
  93. package/dist/module/network/getRelayFeeCache.js +2 -2
  94. package/dist/module/network/getRelayFeeCache.js.map +1 -1
  95. package/dist/module/network/index.d.ts +3 -2
  96. package/dist/module/network/index.d.ts.map +1 -0
  97. package/dist/module/network/index.js +2 -2
  98. package/dist/module/network/index.js.map +1 -1
  99. package/dist/module/network/interface.d.ts +1 -0
  100. package/dist/module/network/interface.d.ts.map +1 -0
  101. package/dist/module/network/util.d.ts +2 -1
  102. package/dist/module/network/util.d.ts.map +1 -0
  103. package/dist/module/qr/Qr.d.ts +2 -1
  104. package/dist/module/qr/Qr.d.ts.map +1 -0
  105. package/dist/module/qr/Qr.js +2 -2
  106. package/dist/module/qr/Qr.js.map +1 -1
  107. package/dist/module/qr/interface.d.ts +1 -0
  108. package/dist/module/qr/interface.d.ts.map +1 -0
  109. package/dist/module/rate/ExchangeRate.d.ts +1 -0
  110. package/dist/module/rate/ExchangeRate.d.ts.map +1 -0
  111. package/dist/module/rate/ExchangeRate.js +5 -5
  112. package/dist/module/rate/ExchangeRate.js.map +1 -1
  113. package/dist/module/slp/GsppProvider.d.ts +4 -3
  114. package/dist/module/slp/GsppProvider.d.ts.map +1 -0
  115. package/dist/module/slp/GsppProvider.js +7 -7
  116. package/dist/module/slp/GsppProvider.js.map +1 -1
  117. package/dist/module/slp/SlpDbProvider.d.ts +4 -3
  118. package/dist/module/slp/SlpDbProvider.d.ts.map +1 -0
  119. package/dist/module/slp/SlpDbProvider.js +8 -8
  120. package/dist/module/slp/SlpDbProvider.js.map +1 -1
  121. package/dist/module/slp/SlpDbTemplates.d.ts +1 -0
  122. package/dist/module/slp/SlpDbTemplates.d.ts.map +1 -0
  123. package/dist/module/slp/SlpLibAuth.d.ts +7 -14
  124. package/dist/module/slp/SlpLibAuth.d.ts.map +1 -0
  125. package/dist/module/slp/SlpLibAuth.js +48 -39
  126. package/dist/module/slp/SlpLibAuth.js.map +1 -1
  127. package/dist/module/slp/SlpProvider.d.ts +2 -1
  128. package/dist/module/slp/SlpProvider.d.ts.map +1 -0
  129. package/dist/module/slp/SlpProvider.js.map +1 -1
  130. package/dist/module/slp/index.d.ts +5 -4
  131. package/dist/module/slp/index.d.ts.map +1 -0
  132. package/dist/module/slp/index.js +3 -3
  133. package/dist/module/slp/index.js.map +1 -1
  134. package/dist/module/slp/interface.d.ts +2 -1
  135. package/dist/module/slp/interface.d.ts.map +1 -0
  136. package/dist/module/test/axios.d.ts +3 -0
  137. package/dist/module/test/axios.d.ts.map +1 -0
  138. package/dist/module/test/axios.js +35 -0
  139. package/dist/module/test/axios.js.map +1 -0
  140. package/dist/module/test/expect.d.ts +6 -1
  141. package/dist/module/test/expect.d.ts.map +1 -0
  142. package/dist/module/test/expect.js +22 -1
  143. package/dist/module/test/expect.js.map +1 -1
  144. package/dist/module/transaction/Wif.d.ts +19 -16
  145. package/dist/module/transaction/Wif.d.ts.map +1 -0
  146. package/dist/module/transaction/Wif.js +152 -55
  147. package/dist/module/transaction/Wif.js.map +1 -1
  148. package/dist/module/transaction/allocateFee.d.ts +5 -4
  149. package/dist/module/transaction/allocateFee.d.ts.map +1 -0
  150. package/dist/module/transaction/allocateFee.js +11 -8
  151. package/dist/module/transaction/allocateFee.js.map +1 -1
  152. package/dist/module/util/amountInSatoshi.d.ts +1 -0
  153. package/dist/module/util/amountInSatoshi.d.ts.map +1 -0
  154. package/dist/module/util/amountInSatoshi.js +4 -4
  155. package/dist/module/util/amountInSatoshi.js.map +1 -1
  156. package/dist/module/util/asSendRequestObject.d.ts +3 -2
  157. package/dist/module/util/asSendRequestObject.d.ts.map +1 -0
  158. package/dist/module/util/asSendRequestObject.js +6 -3
  159. package/dist/module/util/asSendRequestObject.js.map +1 -1
  160. package/dist/module/util/balanceObjectFromSatoshi.d.ts +1 -0
  161. package/dist/module/util/balanceObjectFromSatoshi.d.ts.map +1 -0
  162. package/dist/module/util/balanceObjectFromSatoshi.js +5 -5
  163. package/dist/module/util/balanceObjectFromSatoshi.js.map +1 -1
  164. package/dist/module/util/base64.d.ts +2 -1
  165. package/dist/module/util/base64.d.ts.map +1 -0
  166. package/dist/module/util/base64.js +5 -25
  167. package/dist/module/util/base64.js.map +1 -1
  168. package/dist/module/util/bchaddr.d.ts +1 -0
  169. package/dist/module/util/bchaddr.d.ts.map +1 -0
  170. package/dist/module/util/browserNotSupported.d.ts +1 -0
  171. package/dist/module/util/browserNotSupported.d.ts.map +1 -0
  172. package/dist/module/util/browserNotSupported.js +1 -1
  173. package/dist/module/util/browserNotSupported.js.map +1 -1
  174. package/dist/module/util/checkForEmptySeed.d.ts +1 -0
  175. package/dist/module/util/checkForEmptySeed.d.ts.map +1 -0
  176. package/dist/module/util/checkWifNetwork.d.ts +2 -1
  177. package/dist/module/util/checkWifNetwork.d.ts.map +1 -0
  178. package/dist/module/util/checkWifNetwork.js +1 -1
  179. package/dist/module/util/checkWifNetwork.js.map +1 -1
  180. package/dist/module/util/convert.d.ts +1 -0
  181. package/dist/module/util/convert.d.ts.map +1 -0
  182. package/dist/module/util/convert.js +2 -2
  183. package/dist/module/util/convert.js.map +1 -1
  184. package/dist/module/util/delay.d.ts +1 -0
  185. package/dist/module/util/delay.d.ts.map +1 -0
  186. package/dist/module/util/deriveCashaddr.d.ts +6 -1
  187. package/dist/module/util/deriveCashaddr.d.ts.map +1 -0
  188. package/dist/module/util/deriveCashaddr.js +85 -6
  189. package/dist/module/util/deriveCashaddr.js.map +1 -1
  190. package/dist/module/util/deriveLockscript.d.ts +1 -0
  191. package/dist/module/util/deriveLockscript.d.ts.map +1 -0
  192. package/dist/module/util/deriveNetwork.d.ts +1 -0
  193. package/dist/module/util/deriveNetwork.d.ts.map +1 -0
  194. package/dist/module/util/deriveNetwork.js +2 -2
  195. package/dist/module/util/deriveNetwork.js.map +1 -1
  196. package/dist/module/util/derivePublicKeyHash.d.ts +3 -1
  197. package/dist/module/util/derivePublicKeyHash.d.ts.map +1 -0
  198. package/dist/module/util/derivePublicKeyHash.js +1 -1
  199. package/dist/module/util/derivePublicKeyHash.js.map +1 -1
  200. package/dist/module/util/eventsource.d.ts +1 -0
  201. package/dist/module/util/eventsource.d.ts.map +1 -0
  202. package/dist/module/util/eventsource.js +3 -2
  203. package/dist/module/util/eventsource.js.map +1 -1
  204. package/dist/module/util/floor.d.ts +1 -0
  205. package/dist/module/util/floor.d.ts.map +1 -0
  206. package/dist/module/util/getAddrsByXpubKey.d.ts +8 -8
  207. package/dist/module/util/getAddrsByXpubKey.d.ts.map +1 -0
  208. package/dist/module/util/getAddrsByXpubKey.js +17 -21
  209. package/dist/module/util/getAddrsByXpubKey.js.map +1 -1
  210. package/dist/module/util/getRuntimePlatform.d.ts +1 -0
  211. package/dist/module/util/getRuntimePlatform.d.ts.map +1 -0
  212. package/dist/module/util/getUsdRate.d.ts +1 -0
  213. package/dist/module/util/getUsdRate.d.ts.map +1 -0
  214. package/dist/module/util/getUsdRate.js +1 -1
  215. package/dist/module/util/getUsdRate.js.map +1 -1
  216. package/dist/module/util/getXPubKey.d.ts +2 -1
  217. package/dist/module/util/getXPubKey.d.ts.map +1 -0
  218. package/dist/module/util/getXPubKey.js +6 -7
  219. package/dist/module/util/getXPubKey.js.map +1 -1
  220. package/dist/module/util/hash160.d.ts +2 -1
  221. package/dist/module/util/hash160.d.ts.map +1 -0
  222. package/dist/module/util/hash160.js +2 -4
  223. package/dist/module/util/hash160.js.map +1 -1
  224. package/dist/module/util/index.d.ts +21 -20
  225. package/dist/module/util/index.d.ts.map +1 -0
  226. package/dist/module/util/index.js +20 -20
  227. package/dist/module/util/index.js.map +1 -1
  228. package/dist/module/util/randomBytes.d.ts +3 -1
  229. package/dist/module/util/randomBytes.d.ts.map +1 -0
  230. package/dist/module/util/randomBytes.js +2 -3
  231. package/dist/module/util/randomBytes.js.map +1 -1
  232. package/dist/module/util/randomInt.d.ts +1 -0
  233. package/dist/module/util/randomInt.d.ts.map +1 -0
  234. package/dist/module/util/randomValues.d.ts +1 -0
  235. package/dist/module/util/randomValues.d.ts.map +1 -0
  236. package/dist/module/util/randomValues.js +7 -7
  237. package/dist/module/util/randomValues.js.map +1 -1
  238. package/dist/module/util/sanitizeAddress.d.ts +1 -0
  239. package/dist/module/util/sanitizeAddress.d.ts.map +1 -0
  240. package/dist/module/util/sanitizeAddress.js +1 -1
  241. package/dist/module/util/sanitizeAddress.js.map +1 -1
  242. package/dist/module/util/sanitizeUnit.d.ts +2 -1
  243. package/dist/module/util/sanitizeUnit.d.ts.map +1 -0
  244. package/dist/module/util/satoshiToAmount.d.ts +1 -0
  245. package/dist/module/util/satoshiToAmount.d.ts.map +1 -0
  246. package/dist/module/util/satoshiToAmount.js +4 -4
  247. package/dist/module/util/satoshiToAmount.js.map +1 -1
  248. package/dist/module/util/sumSendRequestAmounts.d.ts +3 -2
  249. package/dist/module/util/sumSendRequestAmounts.d.ts.map +1 -0
  250. package/dist/module/util/sumSendRequestAmounts.js +5 -2
  251. package/dist/module/util/sumSendRequestAmounts.js.map +1 -1
  252. package/dist/module/util/sumUtxoValue.d.ts +4 -2
  253. package/dist/module/util/sumUtxoValue.d.ts.map +1 -0
  254. package/dist/module/util/sumUtxoValue.js +17 -3
  255. package/dist/module/util/sumUtxoValue.js.map +1 -1
  256. package/dist/module/util/transaction.d.ts +2 -0
  257. package/dist/module/util/transaction.d.ts.map +1 -0
  258. package/dist/module/util/transaction.js +7 -0
  259. package/dist/module/util/transaction.js.map +1 -0
  260. package/dist/module/wallet/Base.d.ts +8 -7
  261. package/dist/module/wallet/Base.d.ts.map +1 -0
  262. package/dist/module/wallet/Base.js +7 -7
  263. package/dist/module/wallet/Base.js.map +1 -1
  264. package/dist/module/wallet/Bcmr.d.ts +88 -0
  265. package/dist/module/wallet/Bcmr.d.ts.map +1 -0
  266. package/dist/module/wallet/Bcmr.js +281 -0
  267. package/dist/module/wallet/Bcmr.js.map +1 -0
  268. package/dist/module/wallet/Slp.d.ts +6 -5
  269. package/dist/module/wallet/Slp.d.ts.map +1 -0
  270. package/dist/module/wallet/Slp.js +15 -15
  271. package/dist/module/wallet/Slp.js.map +1 -1
  272. package/dist/module/wallet/Util.d.ts +3 -2
  273. package/dist/module/wallet/Util.d.ts.map +1 -0
  274. package/dist/module/wallet/Util.js +9 -14
  275. package/dist/module/wallet/Util.js.map +1 -1
  276. package/dist/module/wallet/Wif.d.ts +124 -20
  277. package/dist/module/wallet/Wif.d.ts.map +1 -0
  278. package/dist/module/wallet/Wif.js +406 -74
  279. package/dist/module/wallet/Wif.js.map +1 -1
  280. package/dist/module/wallet/bcmr-v1.schema.d.ts +623 -0
  281. package/dist/module/wallet/bcmr-v1.schema.d.ts.map +1 -0
  282. package/dist/module/wallet/bcmr-v1.schema.js +2 -0
  283. package/dist/module/wallet/bcmr-v1.schema.js.map +1 -0
  284. package/dist/module/wallet/createWallet.d.ts +3 -2
  285. package/dist/module/wallet/createWallet.d.ts.map +1 -0
  286. package/dist/module/wallet/createWallet.js +3 -3
  287. package/dist/module/wallet/createWallet.js.map +1 -1
  288. package/dist/module/wallet/enum.d.ts +1 -0
  289. package/dist/module/wallet/enum.d.ts.map +1 -0
  290. package/dist/module/wallet/interface.d.ts +10 -6
  291. package/dist/module/wallet/interface.d.ts.map +1 -0
  292. package/dist/module/wallet/model.d.ts +81 -5
  293. package/dist/module/wallet/model.d.ts.map +1 -0
  294. package/dist/module/wallet/model.js +102 -17
  295. package/dist/module/wallet/model.js.map +1 -1
  296. package/dist/module/webhook/Webhook.d.ts +3 -2
  297. package/dist/module/webhook/Webhook.d.ts.map +1 -0
  298. package/dist/module/webhook/Webhook.js +4 -1
  299. package/dist/module/webhook/Webhook.js.map +1 -1
  300. package/dist/module/webhook/WebhookBch.d.ts +4 -3
  301. package/dist/module/webhook/WebhookBch.d.ts.map +1 -0
  302. package/dist/module/webhook/WebhookBch.js +4 -4
  303. package/dist/module/webhook/WebhookBch.js.map +1 -1
  304. package/dist/module/webhook/WebhookSlp.d.ts +5 -4
  305. package/dist/module/webhook/WebhookSlp.d.ts.map +1 -0
  306. package/dist/module/webhook/WebhookSlp.js +4 -4
  307. package/dist/module/webhook/WebhookSlp.js.map +1 -1
  308. package/dist/module/webhook/WebhookWorker.d.ts +3 -2
  309. package/dist/module/webhook/WebhookWorker.d.ts.map +1 -0
  310. package/dist/module/webhook/WebhookWorker.js +1 -1
  311. package/dist/module/webhook/WebhookWorker.js.map +1 -1
  312. package/dist/module/webhook/index.d.ts +6 -5
  313. package/dist/module/webhook/index.d.ts.map +1 -0
  314. package/dist/module/webhook/index.js +5 -5
  315. package/dist/module/webhook/index.js.map +1 -1
  316. package/dist/module/webhook/interface.d.ts +1 -0
  317. package/dist/module/webhook/interface.d.ts.map +1 -0
  318. package/dist/tsconfig.tsbuildinfo +1 -1
  319. package/package.json +9 -9
  320. package/polyfill/{bip39.browser.js → bip39.browser.cjs} +1 -0
  321. package/polyfill/{util.js → util.cjs} +0 -0
  322. package/src/Wallet.test.headless.js +6 -6
  323. package/src/cli.ts +3 -3
  324. package/src/db/ExchangeRateProvider.ts +1 -1
  325. package/src/db/IndexedDBProvider.test.ts +0 -1
  326. package/src/db/IndexedDBProvider.ts +2 -2
  327. package/src/db/SqlProvider.ts +14 -12
  328. package/src/db/StorageProvider.ts +1 -1
  329. package/src/db/getStorageProvider.ts +20 -0
  330. package/src/db/index.ts +3 -3
  331. package/src/db/util.ts +1 -20
  332. package/src/history/electrumTransformer.ts +13 -14
  333. package/src/history/interface.ts +1 -1
  334. package/src/index.ts +29 -21
  335. package/src/interface.ts +15 -0
  336. package/src/message/index.ts +2 -2
  337. package/src/message/signed.test.ts +4 -4
  338. package/src/message/signed.ts +23 -6
  339. package/src/mine/index.ts +1 -1
  340. package/src/mine/mine.ts +3 -3
  341. package/src/network/Connection.ts +5 -5
  342. package/src/network/ElectrumNetworkProvider.ts +85 -20
  343. package/src/network/NetworkProvider.ts +1 -1
  344. package/src/network/configuration.test.ts +33 -8
  345. package/src/network/configuration.ts +33 -18
  346. package/src/network/constant.ts +9 -4
  347. package/src/network/default.ts +13 -10
  348. package/src/network/getRelayFeeCache.ts +3 -3
  349. package/src/network/index.ts +6 -2
  350. package/src/network/util.ts +1 -1
  351. package/src/qr/Qr.ts +3 -3
  352. package/src/rate/ExchangeRate.ts +14 -15
  353. package/src/slp/GsppProvider.test.ts +2 -2
  354. package/src/slp/GsppProvider.ts +11 -8
  355. package/src/slp/SlpDbProvider.test.ts +1 -1
  356. package/src/slp/SlpDbProvider.ts +12 -9
  357. package/src/slp/SlpLibAuth.test.ts +1 -1
  358. package/src/slp/SlpLibAuth.ts +52 -42
  359. package/src/slp/SlpProvider.ts +6 -1
  360. package/src/slp/index.ts +4 -4
  361. package/src/slp/interface.ts +1 -1
  362. package/src/test/axios.ts +47 -0
  363. package/src/test/expect.ts +27 -2
  364. package/src/transaction/Wif.ts +203 -77
  365. package/src/transaction/allocateFee.ts +32 -14
  366. package/src/util/amountInSatoshi.ts +4 -4
  367. package/src/util/asSendRequestObject.ts +42 -30
  368. package/src/util/balanceObjectFromSatoshi.ts +5 -5
  369. package/src/util/base64.ts +5 -24
  370. package/src/util/browserNotSupported.ts +1 -1
  371. package/src/util/checkWifNetwork.ts +1 -1
  372. package/src/util/convert.ts +2 -2
  373. package/src/util/deriveCashaddr.test.ts +43 -0
  374. package/src/util/deriveCashaddr.ts +123 -7
  375. package/src/util/deriveNetwork.ts +2 -2
  376. package/src/util/derivePublicKeyHash.test.ts +3 -0
  377. package/src/util/derivePublicKeyHash.ts +18 -5
  378. package/src/util/eventsource.ts +4 -2
  379. package/src/util/getAddrsByXpubKey.test.ts +5 -5
  380. package/src/util/getAddrsByXpubKey.ts +23 -28
  381. package/src/util/getUsdRate.ts +1 -1
  382. package/src/util/getXPubKey.ts +5 -7
  383. package/src/util/hash160.test.ts +2 -2
  384. package/src/util/hash160.ts +2 -4
  385. package/src/util/index.ts +26 -20
  386. package/src/util/randomBytes.ts +2 -3
  387. package/src/util/randomValues.ts +8 -8
  388. package/src/util/sanitizeAddress.ts +1 -1
  389. package/src/util/sanitizeUnit.ts +1 -1
  390. package/src/util/satoshiToAmount.ts +4 -4
  391. package/src/util/sumSendRequestAmounts.ts +10 -4
  392. package/src/util/sumUtxoValue.ts +19 -7
  393. package/src/util/transaction.ts +10 -0
  394. package/src/wallet/Base.ts +11 -11
  395. package/src/wallet/Bcmr.test.headless.js +353 -0
  396. package/src/wallet/Bcmr.test.ts +610 -0
  397. package/src/wallet/Bcmr.ts +390 -0
  398. package/src/wallet/Cashtokens.test.headless.js +467 -0
  399. package/src/wallet/Cashtokens.test.ts +475 -0
  400. package/src/wallet/Slp.test.headless.js +6 -8
  401. package/src/wallet/Slp.test.ts +2 -2
  402. package/src/wallet/Slp.ts +26 -22
  403. package/src/wallet/Util.ts +9 -20
  404. package/src/wallet/Wif.test.ts +20 -21
  405. package/src/wallet/Wif.ts +534 -99
  406. package/src/wallet/bcmr-v1.schema.ts +639 -0
  407. package/src/wallet/createWallet.test.ts +1 -0
  408. package/src/wallet/createWallet.ts +4 -4
  409. package/src/wallet/interface.ts +9 -6
  410. package/src/wallet/model.ts +190 -19
  411. package/src/webhook/Webhook.ts +7 -3
  412. package/src/webhook/WebhookBch.ts +7 -7
  413. package/src/webhook/WebhookSlp.test.ts +2 -2
  414. package/src/webhook/WebhookSlp.ts +6 -6
  415. package/src/webhook/WebhookWorker.ts +2 -2
  416. package/src/webhook/index.ts +5 -5
  417. package/tsconfig.browser.json +0 -3
  418. package/tsconfig.json +17 -5
  419. package/{webpack.config.js → webpack.config.cjs} +46 -14
  420. package/dist/main/chain.d.ts +0 -3
  421. package/dist/main/chain.js +0 -7
  422. package/dist/main/chain.js.map +0 -1
  423. package/dist/main/cli.d.ts +0 -1
  424. package/dist/main/cli.js +0 -35
  425. package/dist/main/cli.js.map +0 -1
  426. package/dist/main/constant.d.ts +0 -5
  427. package/dist/main/constant.js +0 -27
  428. package/dist/main/constant.js.map +0 -1
  429. package/dist/main/db/ExchangeRateProvider.d.ts +0 -11
  430. package/dist/main/db/ExchangeRateProvider.js +0 -47
  431. package/dist/main/db/ExchangeRateProvider.js.map +0 -1
  432. package/dist/main/db/IndexedDBProvider.d.ts +0 -15
  433. package/dist/main/db/IndexedDBProvider.js +0 -86
  434. package/dist/main/db/IndexedDBProvider.js.map +0 -1
  435. package/dist/main/db/SqlProvider.d.ts +0 -41
  436. package/dist/main/db/SqlProvider.js +0 -217
  437. package/dist/main/db/SqlProvider.js.map +0 -1
  438. package/dist/main/db/StorageProvider.d.ts +0 -52
  439. package/dist/main/db/StorageProvider.js +0 -3
  440. package/dist/main/db/StorageProvider.js.map +0 -1
  441. package/dist/main/db/index.d.ts +0 -3
  442. package/dist/main/db/index.js +0 -11
  443. package/dist/main/db/index.js.map +0 -1
  444. package/dist/main/db/interface.d.ts +0 -22
  445. package/dist/main/db/interface.js +0 -3
  446. package/dist/main/db/interface.js.map +0 -1
  447. package/dist/main/db/util.d.ts +0 -5
  448. package/dist/main/db/util.js +0 -53
  449. package/dist/main/db/util.js.map +0 -1
  450. package/dist/main/enum.d.ts +0 -33
  451. package/dist/main/enum.js +0 -39
  452. package/dist/main/enum.js.map +0 -1
  453. package/dist/main/history/electrumTransformer.d.ts +0 -4
  454. package/dist/main/history/electrumTransformer.js +0 -216
  455. package/dist/main/history/electrumTransformer.js.map +0 -1
  456. package/dist/main/history/interface.d.ts +0 -16
  457. package/dist/main/history/interface.js +0 -3
  458. package/dist/main/history/interface.js.map +0 -1
  459. package/dist/main/index.d.ts +0 -24
  460. package/dist/main/index.js +0 -62
  461. package/dist/main/index.js.map +0 -1
  462. package/dist/main/interface.d.ts +0 -31
  463. package/dist/main/interface.js +0 -12
  464. package/dist/main/interface.js.map +0 -1
  465. package/dist/main/message/index.d.ts +0 -2
  466. package/dist/main/message/index.js +0 -15
  467. package/dist/main/message/index.js.map +0 -1
  468. package/dist/main/message/interface.d.ts +0 -29
  469. package/dist/main/message/interface.js +0 -6
  470. package/dist/main/message/interface.js.map +0 -1
  471. package/dist/main/message/signed.d.ts +0 -33
  472. package/dist/main/message/signed.js +0 -141
  473. package/dist/main/message/signed.js.map +0 -1
  474. package/dist/main/mine/index.d.ts +0 -1
  475. package/dist/main/mine/index.js +0 -14
  476. package/dist/main/mine/index.js.map +0 -1
  477. package/dist/main/mine/mine.d.ts +0 -13
  478. package/dist/main/mine/mine.js +0 -37
  479. package/dist/main/mine/mine.js.map +0 -1
  480. package/dist/main/network/Connection.d.ts +0 -14
  481. package/dist/main/network/Connection.js +0 -71
  482. package/dist/main/network/Connection.js.map +0 -1
  483. package/dist/main/network/ElectrumNetworkProvider.d.ts +0 -49
  484. package/dist/main/network/ElectrumNetworkProvider.js +0 -338
  485. package/dist/main/network/ElectrumNetworkProvider.js.map +0 -1
  486. package/dist/main/network/NetworkProvider.d.ts +0 -107
  487. package/dist/main/network/NetworkProvider.js +0 -3
  488. package/dist/main/network/NetworkProvider.js.map +0 -1
  489. package/dist/main/network/configuration.d.ts +0 -12
  490. package/dist/main/network/configuration.js +0 -79
  491. package/dist/main/network/configuration.js.map +0 -1
  492. package/dist/main/network/constant.d.ts +0 -35
  493. package/dist/main/network/constant.js +0 -55
  494. package/dist/main/network/constant.js.map +0 -1
  495. package/dist/main/network/default.d.ts +0 -7
  496. package/dist/main/network/default.js +0 -107
  497. package/dist/main/network/default.js.map +0 -1
  498. package/dist/main/network/getRelayFeeCache.d.ts +0 -2
  499. package/dist/main/network/getRelayFeeCache.js +0 -27
  500. package/dist/main/network/getRelayFeeCache.js.map +0 -1
  501. package/dist/main/network/index.d.ts +0 -2
  502. package/dist/main/network/index.js +0 -10
  503. package/dist/main/network/index.js.map +0 -1
  504. package/dist/main/network/interface.d.ts +0 -60
  505. package/dist/main/network/interface.js +0 -3
  506. package/dist/main/network/interface.js.map +0 -1
  507. package/dist/main/network/util.d.ts +0 -2
  508. package/dist/main/network/util.js +0 -32
  509. package/dist/main/network/util.js.map +0 -1
  510. package/dist/main/qr/Qr.d.ts +0 -8
  511. package/dist/main/qr/Qr.js +0 -26
  512. package/dist/main/qr/Qr.js.map +0 -1
  513. package/dist/main/qr/interface.d.ts +0 -5
  514. package/dist/main/qr/interface.js +0 -3
  515. package/dist/main/qr/interface.js.map +0 -1
  516. package/dist/main/rate/ExchangeRate.d.ts +0 -19
  517. package/dist/main/rate/ExchangeRate.js +0 -147
  518. package/dist/main/rate/ExchangeRate.js.map +0 -1
  519. package/dist/main/slp/GsppProvider.d.ts +0 -54
  520. package/dist/main/slp/GsppProvider.js +0 -214
  521. package/dist/main/slp/GsppProvider.js.map +0 -1
  522. package/dist/main/slp/SlpDbProvider.d.ts +0 -51
  523. package/dist/main/slp/SlpDbProvider.js +0 -182
  524. package/dist/main/slp/SlpDbProvider.js.map +0 -1
  525. package/dist/main/slp/SlpDbTemplates.d.ts +0 -312
  526. package/dist/main/slp/SlpDbTemplates.js +0 -387
  527. package/dist/main/slp/SlpDbTemplates.js.map +0 -1
  528. package/dist/main/slp/SlpLibAuth.d.ts +0 -217
  529. package/dist/main/slp/SlpLibAuth.js +0 -452
  530. package/dist/main/slp/SlpLibAuth.js.map +0 -1
  531. package/dist/main/slp/SlpProvider.d.ts +0 -23
  532. package/dist/main/slp/SlpProvider.js +0 -39
  533. package/dist/main/slp/SlpProvider.js.map +0 -1
  534. package/dist/main/slp/index.d.ts +0 -5
  535. package/dist/main/slp/index.js +0 -24
  536. package/dist/main/slp/index.js.map +0 -1
  537. package/dist/main/slp/interface.d.ts +0 -113
  538. package/dist/main/slp/interface.js +0 -10
  539. package/dist/main/slp/interface.js.map +0 -1
  540. package/dist/main/test/expect.d.ts +0 -7
  541. package/dist/main/test/expect.js +0 -31
  542. package/dist/main/test/expect.js.map +0 -1
  543. package/dist/main/transaction/Wif.d.ts +0 -42
  544. package/dist/main/transaction/Wif.js +0 -214
  545. package/dist/main/transaction/Wif.js.map +0 -1
  546. package/dist/main/transaction/allocateFee.d.ts +0 -7
  547. package/dist/main/transaction/allocateFee.js +0 -118
  548. package/dist/main/transaction/allocateFee.js.map +0 -1
  549. package/dist/main/util/amountInSatoshi.d.ts +0 -9
  550. package/dist/main/util/amountInSatoshi.js +0 -38
  551. package/dist/main/util/amountInSatoshi.js.map +0 -1
  552. package/dist/main/util/asSendRequestObject.d.ts +0 -2
  553. package/dist/main/util/asSendRequestObject.js +0 -57
  554. package/dist/main/util/asSendRequestObject.js.map +0 -1
  555. package/dist/main/util/balanceObjectFromSatoshi.d.ts +0 -8
  556. package/dist/main/util/balanceObjectFromSatoshi.js +0 -62
  557. package/dist/main/util/balanceObjectFromSatoshi.js.map +0 -1
  558. package/dist/main/util/base64.d.ts +0 -2
  559. package/dist/main/util/base64.js +0 -36
  560. package/dist/main/util/base64.js.map +0 -1
  561. package/dist/main/util/bchaddr.d.ts +0 -1
  562. package/dist/main/util/bchaddr.js +0 -24
  563. package/dist/main/util/bchaddr.js.map +0 -1
  564. package/dist/main/util/browserNotSupported.d.ts +0 -1
  565. package/dist/main/util/browserNotSupported.js +0 -11
  566. package/dist/main/util/browserNotSupported.js.map +0 -1
  567. package/dist/main/util/checkForEmptySeed.d.ts +0 -2
  568. package/dist/main/util/checkForEmptySeed.js +0 -12
  569. package/dist/main/util/checkForEmptySeed.js.map +0 -1
  570. package/dist/main/util/checkWifNetwork.d.ts +0 -2
  571. package/dist/main/util/checkWifNetwork.js +0 -16
  572. package/dist/main/util/checkWifNetwork.js.map +0 -1
  573. package/dist/main/util/convert.d.ts +0 -15
  574. package/dist/main/util/convert.js +0 -24
  575. package/dist/main/util/convert.js.map +0 -1
  576. package/dist/main/util/delay.d.ts +0 -1
  577. package/dist/main/util/delay.js +0 -8
  578. package/dist/main/util/delay.js.map +0 -1
  579. package/dist/main/util/deriveCashaddr.d.ts +0 -2
  580. package/dist/main/util/deriveCashaddr.js +0 -13
  581. package/dist/main/util/deriveCashaddr.js.map +0 -1
  582. package/dist/main/util/deriveLockscript.d.ts +0 -8
  583. package/dist/main/util/deriveLockscript.js +0 -19
  584. package/dist/main/util/deriveLockscript.js.map +0 -1
  585. package/dist/main/util/deriveNetwork.d.ts +0 -1
  586. package/dist/main/util/deriveNetwork.js +0 -23
  587. package/dist/main/util/deriveNetwork.js.map +0 -1
  588. package/dist/main/util/derivePublicKeyHash.d.ts +0 -16
  589. package/dist/main/util/derivePublicKeyHash.js +0 -49
  590. package/dist/main/util/derivePublicKeyHash.js.map +0 -1
  591. package/dist/main/util/eventsource.d.ts +0 -2
  592. package/dist/main/util/eventsource.js +0 -12
  593. package/dist/main/util/eventsource.js.map +0 -1
  594. package/dist/main/util/floor.d.ts +0 -1
  595. package/dist/main/util/floor.js +0 -9
  596. package/dist/main/util/floor.js.map +0 -1
  597. package/dist/main/util/getAddrsByXpubKey.d.ts +0 -22
  598. package/dist/main/util/getAddrsByXpubKey.js +0 -79
  599. package/dist/main/util/getAddrsByXpubKey.js.map +0 -1
  600. package/dist/main/util/getRuntimePlatform.d.ts +0 -6
  601. package/dist/main/util/getRuntimePlatform.js +0 -34
  602. package/dist/main/util/getRuntimePlatform.js.map +0 -1
  603. package/dist/main/util/getUsdRate.d.ts +0 -1
  604. package/dist/main/util/getUsdRate.js +0 -9
  605. package/dist/main/util/getUsdRate.js.map +0 -1
  606. package/dist/main/util/getXPubKey.d.ts +0 -1
  607. package/dist/main/util/getXPubKey.js +0 -26
  608. package/dist/main/util/getXPubKey.js.map +0 -1
  609. package/dist/main/util/hash160.d.ts +0 -8
  610. package/dist/main/util/hash160.js +0 -18
  611. package/dist/main/util/hash160.js.map +0 -1
  612. package/dist/main/util/index.d.ts +0 -21
  613. package/dist/main/util/index.js +0 -72
  614. package/dist/main/util/index.js.map +0 -1
  615. package/dist/main/util/randomBytes.d.ts +0 -1
  616. package/dist/main/util/randomBytes.js +0 -18
  617. package/dist/main/util/randomBytes.js.map +0 -1
  618. package/dist/main/util/randomInt.d.ts +0 -1
  619. package/dist/main/util/randomInt.js +0 -9
  620. package/dist/main/util/randomInt.js.map +0 -1
  621. package/dist/main/util/randomValues.d.ts +0 -1
  622. package/dist/main/util/randomValues.js +0 -15
  623. package/dist/main/util/randomValues.js.map +0 -1
  624. package/dist/main/util/sanitizeAddress.d.ts +0 -1
  625. package/dist/main/util/sanitizeAddress.js +0 -15
  626. package/dist/main/util/sanitizeAddress.js.map +0 -1
  627. package/dist/main/util/sanitizeUnit.d.ts +0 -2
  628. package/dist/main/util/sanitizeUnit.js +0 -13
  629. package/dist/main/util/sanitizeUnit.js.map +0 -1
  630. package/dist/main/util/satoshiToAmount.d.ts +0 -9
  631. package/dist/main/util/satoshiToAmount.js +0 -41
  632. package/dist/main/util/satoshiToAmount.js.map +0 -1
  633. package/dist/main/util/sumSendRequestAmounts.d.ts +0 -2
  634. package/dist/main/util/sumSendRequestAmounts.js +0 -31
  635. package/dist/main/util/sumSendRequestAmounts.js.map +0 -1
  636. package/dist/main/util/sumUtxoValue.d.ts +0 -2
  637. package/dist/main/util/sumUtxoValue.js +0 -17
  638. package/dist/main/util/sumUtxoValue.js.map +0 -1
  639. package/dist/main/wallet/Base.d.ts +0 -202
  640. package/dist/main/wallet/Base.js +0 -438
  641. package/dist/main/wallet/Base.js.map +0 -1
  642. package/dist/main/wallet/Slp.d.ts +0 -430
  643. package/dist/main/wallet/Slp.js +0 -775
  644. package/dist/main/wallet/Slp.js.map +0 -1
  645. package/dist/main/wallet/Util.d.ts +0 -69
  646. package/dist/main/wallet/Util.js +0 -182
  647. package/dist/main/wallet/Util.js.map +0 -1
  648. package/dist/main/wallet/Wif.d.ts +0 -255
  649. package/dist/main/wallet/Wif.js +0 -1067
  650. package/dist/main/wallet/Wif.js.map +0 -1
  651. package/dist/main/wallet/createWallet.d.ts +0 -69
  652. package/dist/main/wallet/createWallet.js +0 -244
  653. package/dist/main/wallet/createWallet.js.map +0 -1
  654. package/dist/main/wallet/enum.d.ts +0 -16
  655. package/dist/main/wallet/enum.js +0 -22
  656. package/dist/main/wallet/enum.js.map +0 -1
  657. package/dist/main/wallet/interface.d.ts +0 -76
  658. package/dist/main/wallet/interface.js +0 -3
  659. package/dist/main/wallet/interface.js.map +0 -1
  660. package/dist/main/wallet/model.d.ts +0 -88
  661. package/dist/main/wallet/model.js +0 -129
  662. package/dist/main/wallet/model.js.map +0 -1
  663. package/dist/main/webhook/Webhook.d.ts +0 -40
  664. package/dist/main/webhook/Webhook.js +0 -82
  665. package/dist/main/webhook/Webhook.js.map +0 -1
  666. package/dist/main/webhook/WebhookBch.d.ts +0 -13
  667. package/dist/main/webhook/WebhookBch.js +0 -148
  668. package/dist/main/webhook/WebhookBch.js.map +0 -1
  669. package/dist/main/webhook/WebhookSlp.d.ts +0 -14
  670. package/dist/main/webhook/WebhookSlp.js +0 -107
  671. package/dist/main/webhook/WebhookSlp.js.map +0 -1
  672. package/dist/main/webhook/WebhookWorker.d.ts +0 -22
  673. package/dist/main/webhook/WebhookWorker.js +0 -100
  674. package/dist/main/webhook/WebhookWorker.js.map +0 -1
  675. package/dist/main/webhook/index.d.ts +0 -5
  676. package/dist/main/webhook/index.js +0 -23
  677. package/dist/main/webhook/index.js.map +0 -1
  678. package/dist/main/webhook/interface.d.ts +0 -8
  679. package/dist/main/webhook/interface.js +0 -3
  680. package/dist/main/webhook/interface.js.map +0 -1
  681. package/dist/mainnet-0.5.9.js +0 -2
  682. package/dist/mainnet-0.5.9.js.LICENSE.txt +0 -48
  683. package/dist/tsconfig.browser.tsbuildinfo +0 -1
  684. package/jest.config.js +0 -23
@@ -1,33 +0,0 @@
1
- import { CashAddressNetworkPrefix } from "@bitauth/libauth";
2
- export declare enum NetworkType {
3
- Mainnet = "mainnet",
4
- Testnet = "testnet",
5
- Regtest = "regtest"
6
- }
7
- export declare enum NetworkEnum {
8
- Mainnet,
9
- Testnet,
10
- Regtest,
11
- Simtest
12
- }
13
- export declare const networkPrefixMap: {
14
- bitcoincash: string;
15
- bchtest: string;
16
- bchreg: string;
17
- };
18
- export declare const prefixFromNetworkMap: {
19
- mainnet: CashAddressNetworkPrefix;
20
- testnet: CashAddressNetworkPrefix;
21
- regtest: CashAddressNetworkPrefix;
22
- };
23
- export declare const UnitEnum: {
24
- BCH: "bch";
25
- USD: "usd";
26
- BIT: "bit";
27
- BITS: "bits";
28
- SAT: "sat";
29
- SATS: "sats";
30
- SATOSHI: "satoshi";
31
- SATOSHIS: "satoshis";
32
- };
33
- export declare type UnitEnum = typeof UnitEnum[keyof typeof UnitEnum];
package/dist/main/enum.js DELETED
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UnitEnum = exports.prefixFromNetworkMap = exports.networkPrefixMap = exports.NetworkEnum = exports.NetworkType = void 0;
4
- const libauth_1 = require("@bitauth/libauth");
5
- var NetworkType;
6
- (function (NetworkType) {
7
- NetworkType["Mainnet"] = "mainnet";
8
- NetworkType["Testnet"] = "testnet";
9
- NetworkType["Regtest"] = "regtest";
10
- })(NetworkType = exports.NetworkType || (exports.NetworkType = {}));
11
- var NetworkEnum;
12
- (function (NetworkEnum) {
13
- NetworkEnum[NetworkEnum["Mainnet"] = "mainnet"] = "Mainnet";
14
- NetworkEnum[NetworkEnum["Testnet"] = "testnet"] = "Testnet";
15
- NetworkEnum[NetworkEnum["Regtest"] = "regtest"] = "Regtest";
16
- NetworkEnum[NetworkEnum["Simtest"] = "simtest"] = "Simtest";
17
- })(NetworkEnum = exports.NetworkEnum || (exports.NetworkEnum = {}));
18
- exports.networkPrefixMap = {
19
- bitcoincash: "mainnet",
20
- bchtest: "testnet",
21
- bchreg: "regtest",
22
- };
23
- exports.prefixFromNetworkMap = {
24
- mainnet: libauth_1.CashAddressNetworkPrefix.mainnet,
25
- testnet: libauth_1.CashAddressNetworkPrefix.testnet,
26
- regtest: libauth_1.CashAddressNetworkPrefix.regtest,
27
- };
28
- const literal = (l) => l;
29
- exports.UnitEnum = {
30
- BCH: literal("bch"),
31
- USD: literal("usd"),
32
- BIT: literal("bit"),
33
- BITS: literal("bits"),
34
- SAT: literal("sat"),
35
- SATS: literal("sats"),
36
- SATOSHI: literal("satoshi"),
37
- SATOSHIS: literal("satoshis"),
38
- };
39
- //# sourceMappingURL=enum.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"enum.js","sourceRoot":"","sources":["../../src/enum.ts"],"names":[],"mappings":";;;AAAA,8CAA4D;AAE5D,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,kCAAmB,CAAA;IACnB,kCAAmB,CAAA;IACnB,kCAAmB,CAAA;AACrB,CAAC,EAJW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAItB;AAED,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,qCAAe,SAAS,aAAA,CAAA;IACxB,qCAAe,SAAS,aAAA,CAAA;IACxB,qCAAe,SAAS,aAAA,CAAA;IACxB,qCAAe,SAAS,aAAA,CAAA;AAC1B,CAAC,EALW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAKtB;AAEY,QAAA,gBAAgB,GAAG;IAC9B,WAAW,EAAE,SAAS;IACtB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,SAAS;CAClB,CAAC;AAEW,QAAA,oBAAoB,GAAG;IAClC,OAAO,EAAE,kCAAwB,CAAC,OAAO;IACzC,OAAO,EAAE,kCAAwB,CAAC,OAAO;IACzC,OAAO,EAAE,kCAAwB,CAAC,OAAO;CAC1C,CAAC;AAEF,MAAM,OAAO,GAAG,CAAmB,CAAI,EAAK,EAAE,CAAC,CAAC,CAAC;AAEpC,QAAA,QAAQ,GAAG;IACtB,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC;IACnB,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC;IACnB,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC;IACnB,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC;IACrB,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC;IACnB,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC;IAC3B,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC;CAC9B,CAAC"}
@@ -1,4 +0,0 @@
1
- import NetworkProvider from "../network/NetworkProvider";
2
- import { TransactionHistoryI, TransactionHistoryItemI } from "./interface";
3
- export declare function getAddressHistory(cashaddr: string, provider: NetworkProvider, unit?: string, start?: number, count?: number, collapseChange?: boolean): Promise<TransactionHistoryI>;
4
- export declare function getDetailedHistory(cashaddr: string, hash: string, height: number, provider: NetworkProvider, collapseChange: boolean): Promise<TransactionHistoryItemI[]>;
@@ -1,216 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDetailedHistory = exports.getAddressHistory = void 0;
4
- const libauth_1 = require("@bitauth/libauth");
5
- const derivePublicKeyHash_1 = require("../util/derivePublicKeyHash");
6
- const convert_1 = require("../util/convert");
7
- const chain_1 = require("../chain");
8
- const floor_1 = require("../util/floor");
9
- async function getAddressHistory(cashaddr, provider, unit = "sat", start = 0, count = 25, collapseChange = true) {
10
- // Get an array of raw transactions as hex
11
- let txnHashes = await provider.getHistory(cashaddr);
12
- // Assume transaction hashes will be served in chronological order
13
- // Slice count in from the end and count to the provided inputs
14
- let len = txnHashes.length;
15
- txnHashes = txnHashes.slice(len - start - count, len - start);
16
- // get the current balance in satoshis
17
- let currentBalance = await provider.getBalance(cashaddr);
18
- // Transform the hex transactions to and array of histroy item array promises.
19
- let txItemPromises = txnHashes.map((tx) => {
20
- return getDetailedHistory(cashaddr, tx.tx_hash, tx.height, provider, collapseChange);
21
- });
22
- // await the history array promises
23
- let items = await Promise.all(txItemPromises);
24
- // flatten the array of responses
25
- let preprocessedTxns = Array.prototype.concat.apply([], items);
26
- // Reverse chronological order (again), so list appear as newest first.
27
- preprocessedTxns = preprocessedTxns.reverse();
28
- // Get the factor to apply the requested unit of measure
29
- let factor = (await (0, convert_1.convert)(chain_1.bchParam.subUnits, "sat", unit)) / chain_1.bchParam.subUnits;
30
- // Apply the unit factor and
31
- let txns = applyBalance(preprocessedTxns, currentBalance, unit, factor);
32
- return {
33
- transactions: txns,
34
- };
35
- }
36
- exports.getAddressHistory = getAddressHistory;
37
- async function getDetailedHistory(cashaddr, hash, height, provider, collapseChange) {
38
- let transactionHex = await provider.getRawTransaction(hash);
39
- collapseChange;
40
- let addressBytecode = (0, libauth_1.cashAddressToLockingBytecode)(cashaddr);
41
- if (typeof addressBytecode === "string")
42
- throw Error(addressBytecode);
43
- let transaction = (0, libauth_1.decodeTransaction)((0, libauth_1.hexToBin)(transactionHex));
44
- if (typeof transaction === "string")
45
- throw Error(transaction);
46
- let r = [];
47
- r.push(...(await getMatchingInputs(transaction, cashaddr, height, hash, provider, collapseChange)));
48
- return r;
49
- }
50
- exports.getDetailedHistory = getDetailedHistory;
51
- async function getMatchingInputs(transaction, cashaddr, height, hash, provider, collapseChange) {
52
- let addressBytecode = (0, libauth_1.cashAddressToLockingBytecode)(cashaddr);
53
- if (typeof addressBytecode === "string")
54
- throw Error(addressBytecode);
55
- let lockingBytecodeHex = (0, libauth_1.binToHex)(addressBytecode.bytecode);
56
- let prefix = (0, derivePublicKeyHash_1.derivePrefix)(cashaddr);
57
- let inputUtxos = await getInputTransactions(transaction, provider);
58
- let fee = getFee(inputUtxos, transaction.outputs, lockingBytecodeHex, collapseChange);
59
- let r = [];
60
- let txIds = [];
61
- for (let input of transaction.inputs) {
62
- let outpoint = inputUtxos[transaction.inputs.indexOf(input)];
63
- // if the utxo of the input matches the address in question
64
- if ((0, libauth_1.binToHex)(outpoint.lockingBytecode) === lockingBytecodeHex) {
65
- for (let output of transaction.outputs) {
66
- let idx = transaction.outputs.indexOf(output);
67
- let from = (0, libauth_1.lockingBytecodeToCashAddress)(outpoint.lockingBytecode, prefix);
68
- // the output was change
69
- if ((0, libauth_1.binToHex)(output.lockingBytecode) === lockingBytecodeHex) {
70
- if (!collapseChange) {
71
- r.push({
72
- from: from,
73
- to: cashaddr,
74
- unit: "sat",
75
- index: idx,
76
- blockheight: height,
77
- txn: `${hash}`,
78
- txId: `${hash}:i:${idx}`,
79
- value: -Number((0, libauth_1.binToBigIntUint64LE)(output.satoshis)),
80
- fee: 0,
81
- });
82
- }
83
- }
84
- else {
85
- if (!txIds.find((str) => str === `${hash}:i:${idx}`)) {
86
- // the utxo was sent to another address
87
- let to = (0, libauth_1.lockingBytecodeToCashAddress)(output.lockingBytecode, prefix);
88
- r.push({
89
- from: from,
90
- to: to,
91
- unit: "sat",
92
- index: idx,
93
- blockheight: height,
94
- txn: `${hash}`,
95
- txId: `${hash}:i:${idx}`,
96
- value: -Number((0, libauth_1.binToBigIntUint64LE)(output.satoshis)),
97
- fee: fee,
98
- });
99
- txIds.push(`${hash}:i:${idx}`);
100
- }
101
- }
102
- }
103
- }
104
- }
105
- // check the transaction outputs for receiving transactions
106
- for (let output of transaction.outputs) {
107
- // the output was a utxo for the address in question
108
- if ((0, libauth_1.binToHex)(output.lockingBytecode) === lockingBytecodeHex) {
109
- // the input was from a single address
110
- if (transaction.inputs.length == 1) {
111
- const input = transaction.inputs[0];
112
- const inHash = (0, libauth_1.binToHex)(input.outpointTransactionHash);
113
- const transactionHex = await provider.getRawTransaction(inHash);
114
- const inTransaction = (0, libauth_1.decodeTransaction)((0, libauth_1.hexToBin)(transactionHex));
115
- if (typeof inTransaction === "string")
116
- throw Error(inTransaction);
117
- let outpoint = inTransaction.outputs[input.outpointIndex];
118
- let from = (0, libauth_1.lockingBytecodeToCashAddress)(outpoint.lockingBytecode, prefix);
119
- // if the utxo was from a different address and change is not being output...
120
- if (from !== cashaddr || !collapseChange) {
121
- r.push({
122
- from: from,
123
- to: cashaddr,
124
- unit: "sat",
125
- index: transaction.outputs.indexOf(output),
126
- blockheight: height,
127
- txn: `${hash}`,
128
- txId: `${hash}:o:${transaction.outputs.indexOf(output)}`,
129
- value: Number((0, libauth_1.binToBigIntUint64LE)(output.satoshis)),
130
- });
131
- }
132
- }
133
- else {
134
- let from = transaction.inputs
135
- .map((i) => `${(0, libauth_1.binToHex)(i.outpointTransactionHash)}:o:${i.outpointIndex}`)
136
- .join(";");
137
- r.push({
138
- from: from,
139
- to: cashaddr,
140
- unit: "sat",
141
- index: transaction.outputs.indexOf(output),
142
- blockheight: height,
143
- txn: `${hash}`,
144
- txId: `${hash}:o:${transaction.outputs.indexOf(output)}`,
145
- value: Number((0, libauth_1.binToBigIntUint64LE)(output.satoshis)),
146
- // incoming transactions pay no fee.
147
- fee: 0,
148
- });
149
- }
150
- }
151
- }
152
- return r;
153
- }
154
- async function getInputTransactions(transaction, provider) {
155
- let inputTransactions = [];
156
- for (let input of transaction.inputs) {
157
- let inHash = (0, libauth_1.binToHex)(input.outpointTransactionHash);
158
- let transactionHex = await provider.getRawTransaction(inHash);
159
- let inTransaction = (0, libauth_1.decodeTransaction)((0, libauth_1.hexToBin)(transactionHex));
160
- if (typeof inTransaction === "string")
161
- throw Error(inTransaction);
162
- inputTransactions.push(inTransaction.outputs[input.outpointIndex]);
163
- }
164
- return inputTransactions;
165
- }
166
- function getFee(inputUtxos, utxos, lockingBytecodeHex, collapseChange) {
167
- let inValues = 0;
168
- for (let outpoint of inputUtxos) {
169
- if ((0, libauth_1.binToHex)(outpoint.lockingBytecode)) {
170
- inValues += Number((0, libauth_1.binToBigIntUint64LE)(outpoint.satoshis));
171
- }
172
- }
173
- const outValues = utxos
174
- .map((utxo) => Number((0, libauth_1.binToBigIntUint64LE)(utxo.satoshis)))
175
- .reduce((a, b) => a + b, 0);
176
- let fee = 0;
177
- if (collapseChange) {
178
- const nonChangeOutputs = utxos
179
- .map((output) => (0, libauth_1.binToHex)(output.lockingBytecode) === lockingBytecodeHex ? 0 : 1)
180
- .reduce((a, b) => a + b, 0);
181
- fee = (0, floor_1.floor)((inValues - outValues) / nonChangeOutputs, 0);
182
- }
183
- else {
184
- fee = (0, floor_1.floor)((inValues - outValues) / utxos.length, 0);
185
- }
186
- return fee;
187
- }
188
- function applyBalance(preprocessedTxns, currentBalance, unit, factor) {
189
- // balance in satoshis
190
- let bal = currentBalance;
191
- let r = [];
192
- for (let txn of preprocessedTxns) {
193
- // set the balance to the current balance in the appropriate unit
194
- txn.balance = bal;
195
- // If fee is not defined, configure it to zero.
196
- txn.fee = txn.fee ? txn.fee : 0;
197
- // update the running balance in satoshis for the next record
198
- // a receiving value is positive, a send is negative
199
- // The sign is reversed in cronological order from the current balance.
200
- bal -= txn.value;
201
- bal += txn.fee;
202
- // transform the value of the transaction
203
- txn.value = txn.value * factor;
204
- txn.fee = txn.fee * factor;
205
- // If unit is usd, round to two decimal places.
206
- if (unit.toLowerCase() == "usd") {
207
- txn.value = (0, floor_1.floor)(txn.value, 2);
208
- txn.fee = (0, floor_1.floor)(txn.fee, 2);
209
- }
210
- // note the unit
211
- txn.unit = unit;
212
- r.push(txn);
213
- }
214
- return r;
215
- }
216
- //# sourceMappingURL=electrumTransformer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"electrumTransformer.js","sourceRoot":"","sources":["../../../src/history/electrumTransformer.ts"],"names":[],"mappings":";;;AAAA,8CAS0B;AAG1B,qEAA2D;AAC3D,6CAA0C;AAC1C,oCAAoC;AACpC,yCAAsC;AAG/B,KAAK,UAAU,iBAAiB,CACrC,QAAgB,EAChB,QAAyB,EACzB,IAAI,GAAG,KAAK,EACZ,KAAK,GAAG,CAAC,EACT,KAAK,GAAG,EAA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,KAAK,CAAC;QACjB,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC;QAEf,yCAAyC;QACzC,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC;QAC/B,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAI,GAAG,MAAM,CAAC;QAE5B,+CAA+C;QAC/C,IAAI,IAAI,CAAC,WAAW,EAAE,IAAI,KAAK,EAAE;YAC/B,GAAG,CAAC,KAAK,GAAG,IAAA,aAAK,EAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAChC,GAAG,CAAC,GAAG,GAAG,IAAA,aAAK,EAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;SAC7B;QAED,gBAAgB;QAChB,GAAG,CAAC,IAAI,GAAG,IAAgB,CAAC;QAE5B,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACb;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -1,16 +0,0 @@
1
- import { UnitEnum } from "../enum";
2
- export interface TransactionHistoryItemI {
3
- to: string;
4
- from: string;
5
- unit: UnitEnum;
6
- index: number;
7
- blockheight: number;
8
- txn: string;
9
- txId: string;
10
- value: number;
11
- fee?: number;
12
- balance?: number;
13
- }
14
- export interface TransactionHistoryI {
15
- transactions: TransactionHistoryItemI[];
16
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=interface.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../src/history/interface.ts"],"names":[],"mappings":""}
@@ -1,24 +0,0 @@
1
- export * from "./db/index";
2
- export * from "./mine/index";
3
- export * from "./slp/index";
4
- export * from "./test/expect";
5
- export * from "./webhook/index";
6
- export * from "./network/index";
7
- export { SignedMessage } from "./message/signed";
8
- export { BaseWallet } from "./wallet/Base";
9
- export * from "./wallet/Wif";
10
- export * from "./wallet/createWallet";
11
- export { NetworkType, UnitEnum } from "./enum";
12
- export { WalletTypeEnum } from "./wallet/enum";
13
- export { SendRequest, UtxoItem } from "./wallet/model";
14
- import * as Mainnet from "./util/index";
15
- export { Mainnet };
16
- import * as CONST from "./constant";
17
- export { CONST };
18
- export { UtxoI } from "./interface";
19
- export { Network } from "./interface";
20
- export { ImageI } from "./qr/interface";
21
- export { SignedMessageResponseI, VerifyMessageResponseI, } from "./message/interface";
22
- export { WalletRequestI, WalletResponseI } from "./wallet/interface";
23
- export * from "./util/bchaddr";
24
- export declare function cube(x: number): number;
@@ -1,62 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
- };
17
- var __importStar = (this && this.__importStar) || function (mod) {
18
- if (mod && mod.__esModule) return mod;
19
- var result = {};
20
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
- __setModuleDefault(result, mod);
22
- return result;
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.cube = exports.Network = exports.CONST = exports.Mainnet = exports.UtxoItem = exports.SendRequest = exports.WalletTypeEnum = exports.UnitEnum = exports.NetworkType = exports.BaseWallet = exports.SignedMessage = void 0;
26
- __exportStar(require("./db/index"), exports);
27
- __exportStar(require("./mine/index"), exports);
28
- __exportStar(require("./slp/index"), exports);
29
- __exportStar(require("./test/expect"), exports);
30
- __exportStar(require("./webhook/index"), exports);
31
- __exportStar(require("./network/index"), exports);
32
- var signed_1 = require("./message/signed");
33
- Object.defineProperty(exports, "SignedMessage", { enumerable: true, get: function () { return signed_1.SignedMessage; } });
34
- var Base_1 = require("./wallet/Base");
35
- Object.defineProperty(exports, "BaseWallet", { enumerable: true, get: function () { return Base_1.BaseWallet; } });
36
- __exportStar(require("./wallet/Wif"), exports);
37
- __exportStar(require("./wallet/createWallet"), exports);
38
- // Enum
39
- var enum_1 = require("./enum");
40
- Object.defineProperty(exports, "NetworkType", { enumerable: true, get: function () { return enum_1.NetworkType; } });
41
- Object.defineProperty(exports, "UnitEnum", { enumerable: true, get: function () { return enum_1.UnitEnum; } });
42
- var enum_2 = require("./wallet/enum");
43
- Object.defineProperty(exports, "WalletTypeEnum", { enumerable: true, get: function () { return enum_2.WalletTypeEnum; } });
44
- // models
45
- var model_1 = require("./wallet/model");
46
- Object.defineProperty(exports, "SendRequest", { enumerable: true, get: function () { return model_1.SendRequest; } });
47
- Object.defineProperty(exports, "UtxoItem", { enumerable: true, get: function () { return model_1.UtxoItem; } });
48
- // utils
49
- const Mainnet = __importStar(require("./util/index"));
50
- exports.Mainnet = Mainnet;
51
- // constants
52
- const CONST = __importStar(require("./constant"));
53
- exports.CONST = CONST;
54
- var interface_1 = require("./interface");
55
- Object.defineProperty(exports, "Network", { enumerable: true, get: function () { return interface_1.Network; } });
56
- // TODO move this up to util (Mainnet) ?
57
- __exportStar(require("./util/bchaddr"), exports);
58
- function cube(x) {
59
- return x * x * x;
60
- }
61
- exports.cube = cube;
62
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,+CAA6B;AAC7B,8CAA4B;AAC5B,gDAA8B;AAC9B,kDAAgC;AAEhC,kDAAgC;AAChC,2CAAiD;AAAxC,uGAAA,aAAa,OAAA;AAEtB,sCAA2C;AAAlC,kGAAA,UAAU,OAAA;AACnB,+CAA6B;AAC7B,wDAAsC;AAEtC,OAAO;AACP,+BAA+C;AAAtC,mGAAA,WAAW,OAAA;AAAE,gGAAA,QAAQ,OAAA;AAC9B,sCAA+C;AAAtC,sGAAA,cAAc,OAAA;AAEvB,SAAS;AACT,wCAAuD;AAA9C,oGAAA,WAAW,OAAA;AAAE,iGAAA,QAAQ,OAAA;AAE9B,QAAQ;AACR,sDAAwC;AAC/B,0BAAO;AAEhB,YAAY;AACZ,kDAAoC;AAC3B,sBAAK;AAId,yCAAsC;AAA7B,oGAAA,OAAO,OAAA;AAQhB,wCAAwC;AACxC,iDAA+B;AAE/B,SAAgB,IAAI,CAAC,CAAS;IAC5B,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACnB,CAAC;AAFD,oBAEC"}
@@ -1,31 +0,0 @@
1
- import { WalletImportFormatType } from "@bitauth/libauth";
2
- export interface PrivateKeyI {
3
- privateKey: Uint8Array;
4
- type: WalletImportFormatType;
5
- }
6
- export declare const Network: {
7
- MAINNET: "mainnet";
8
- TESTNET: "testnet";
9
- REGTEST: "regtest";
10
- };
11
- export declare type Network = typeof Network[keyof typeof Network];
12
- export interface UtxoI {
13
- txid: string;
14
- vout: number;
15
- satoshis: number;
16
- height?: number;
17
- coinbase?: boolean;
18
- }
19
- export interface ElectrumBalanceI {
20
- confirmed: number;
21
- unconfirmed: number;
22
- }
23
- export interface TxI {
24
- tx_hash: string;
25
- height: number;
26
- fee?: number;
27
- }
28
- export interface HeaderI {
29
- height: number;
30
- hex: string;
31
- }
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Network = void 0;
4
- // Weird setup to allow both Enum parameters, as well as literal strings
5
- // https://stackoverflow.com/questions/51433319/typescript-constructor-accept-string-for-enum
6
- const literal = (l) => l;
7
- exports.Network = {
8
- MAINNET: literal("mainnet"),
9
- TESTNET: literal("testnet"),
10
- REGTEST: literal("regtest"),
11
- };
12
- //# sourceMappingURL=interface.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interface.js","sourceRoot":"","sources":["../../src/interface.ts"],"names":[],"mappings":";;;AAOA,wEAAwE;AACxE,6FAA6F;AAC7F,MAAM,OAAO,GAAG,CAAmB,CAAI,EAAK,EAAE,CAAC,CAAC,CAAC;AACpC,QAAA,OAAO,GAAG;IACrB,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC;CAC5B,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from "./interface";
2
- export * from "./signed";
@@ -1,15 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./interface"), exports);
14
- __exportStar(require("./signed"), exports);
15
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/message/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAA4B;AAC5B,2CAAyB"}
@@ -1,29 +0,0 @@
1
- export interface SignedMessageI {
2
- sign(message: string, privateKey: Uint8Array): Promise<SignedMessageResponseI>;
3
- verify(message: string, signature: string, cashaddr: string, publicKey?: Uint8Array): Promise<VerifyMessageResponseI>;
4
- }
5
- export interface SignedMessageRawI {
6
- ecdsa: string;
7
- schnorr: string;
8
- der: string;
9
- }
10
- export interface SignedMessageDetailsI {
11
- recoveryId: number;
12
- compressed: boolean;
13
- messageHash: string;
14
- }
15
- export interface SignedMessageResponseI {
16
- raw?: SignedMessageRawI;
17
- details?: SignedMessageDetailsI;
18
- signature: string;
19
- }
20
- export interface VerifyMessageDetailsI {
21
- signatureType: string;
22
- messageHash: string;
23
- signatureValid: boolean;
24
- publicKeyHashMatch: boolean;
25
- }
26
- export interface VerifyMessageResponseI {
27
- valid: boolean;
28
- details?: VerifyMessageDetailsI;
29
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- // interface EncryptedMessageFunc {
3
- // (message: string, privateKey: string): string;
4
- // }
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- //# sourceMappingURL=interface.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../src/message/interface.ts"],"names":[],"mappings":";AAAA,mCAAmC;AACnC,qDAAqD;AACrD,MAAM"}
@@ -1,33 +0,0 @@
1
- import { SignedMessageI, SignedMessageResponseI, VerifyMessageResponseI } from "./interface";
2
- /**
3
- * hash_magic - Return the hash of the string that has undergone standard formatting
4
- *
5
- * @param {str} string The string to hash
6
- *
7
- * @returns a promise to the hash of the string.
8
- */
9
- export declare function hash_message(str: string): Promise<Uint8Array>;
10
- export declare class SignedMessage implements SignedMessageI {
11
- /**
12
- * sign - Calculate the recoverable signed checksum of a string message.
13
- *
14
- * @param {message} string The
15
- * @param {privateKey} Uint8Array The private key to sign the message with
16
- *
17
- * @returns a promise to signature as a string
18
- */
19
- sign(message: string, privateKey: Uint8Array): Promise<SignedMessageResponseI>;
20
- static sign(message: string, privateKey: Uint8Array): Promise<SignedMessageResponseI>;
21
- /**
22
- * verify - Validate that the message is valid against a given signature
23
- *
24
- * @param {message} string The message to verify as a utf8 string
25
- * @param {signature} string The signature as a base64 encoded string
26
- * @param {cashaddr} string The cashaddr to validate the signature against a recoverable signature.
27
- * @param {publicKey} string If publicKey is not recoverable from the signature type, the publicKey must be passed.
28
- *
29
- * @returns a promise to signature as a string
30
- */
31
- verify(message: string, signature: string, cashaddr?: string, publicKey?: Uint8Array): Promise<VerifyMessageResponseI>;
32
- static verify(message: string, signature: string, cashaddr?: string, publicKey?: Uint8Array): Promise<VerifyMessageResponseI>;
33
- }