@ledgerhq/coin-kaspa 1.1.0-nightly.0

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 (640) hide show
  1. package/.eslintrc.js +20 -0
  2. package/.turbo/turbo-build.log +4 -0
  3. package/.unimportedrc.json +87 -0
  4. package/CHANGELOG.md +978 -0
  5. package/LICENSE.txt +21 -0
  6. package/jest-global-setup.js +9 -0
  7. package/jest.config.js +21 -0
  8. package/jest.integ.config.js +8 -0
  9. package/lib/bridge/broadcast.d.ts +8 -0
  10. package/lib/bridge/broadcast.d.ts.map +1 -0
  11. package/lib/bridge/broadcast.js +16 -0
  12. package/lib/bridge/broadcast.js.map +1 -0
  13. package/lib/bridge/buildInitialOperation.d.ts +5 -0
  14. package/lib/bridge/buildInitialOperation.d.ts.map +1 -0
  15. package/lib/bridge/buildInitialOperation.js +31 -0
  16. package/lib/bridge/buildInitialOperation.js.map +1 -0
  17. package/lib/bridge/buildTransaction.d.ts +16 -0
  18. package/lib/bridge/buildTransaction.d.ts.map +1 -0
  19. package/lib/bridge/buildTransaction.js +63 -0
  20. package/lib/bridge/buildTransaction.js.map +1 -0
  21. package/lib/bridge/createTransaction.d.ts +4 -0
  22. package/lib/bridge/createTransaction.d.ts.map +1 -0
  23. package/lib/bridge/createTransaction.js +15 -0
  24. package/lib/bridge/createTransaction.js.map +1 -0
  25. package/lib/bridge/estimateMaxSpendable.d.ts +4 -0
  26. package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -0
  27. package/lib/bridge/estimateMaxSpendable.js +19 -0
  28. package/lib/bridge/estimateMaxSpendable.js.map +1 -0
  29. package/lib/bridge/getTransactionStatus.d.ts +4 -0
  30. package/lib/bridge/getTransactionStatus.d.ts.map +1 -0
  31. package/lib/bridge/getTransactionStatus.js +68 -0
  32. package/lib/bridge/getTransactionStatus.js.map +1 -0
  33. package/lib/bridge/index.d.ts +9 -0
  34. package/lib/bridge/index.d.ts.map +1 -0
  35. package/lib/bridge/index.js +75 -0
  36. package/lib/bridge/index.js.map +1 -0
  37. package/lib/bridge/initAccount.d.ts +2 -0
  38. package/lib/bridge/initAccount.d.ts.map +1 -0
  39. package/lib/bridge/initAccount.js +6 -0
  40. package/lib/bridge/initAccount.js.map +1 -0
  41. package/lib/bridge/prepareTransaction.d.ts +14 -0
  42. package/lib/bridge/prepareTransaction.d.ts.map +1 -0
  43. package/lib/bridge/prepareTransaction.js +46 -0
  44. package/lib/bridge/prepareTransaction.js.map +1 -0
  45. package/lib/bridge/signOperation.d.ts +8 -0
  46. package/lib/bridge/signOperation.d.ts.map +1 -0
  47. package/lib/bridge/signOperation.js +34 -0
  48. package/lib/bridge/signOperation.js.map +1 -0
  49. package/lib/bridge/synchronization.d.ts +4 -0
  50. package/lib/bridge/synchronization.d.ts.map +1 -0
  51. package/lib/bridge/synchronization.js +66 -0
  52. package/lib/bridge/synchronization.js.map +1 -0
  53. package/lib/config.d.ts +8 -0
  54. package/lib/config.d.ts.map +1 -0
  55. package/lib/config.js +9 -0
  56. package/lib/config.js.map +1 -0
  57. package/lib/deviceTransactionConfig.d.ts +11 -0
  58. package/lib/deviceTransactionConfig.d.ts.map +1 -0
  59. package/lib/deviceTransactionConfig.js +32 -0
  60. package/lib/deviceTransactionConfig.js.map +1 -0
  61. package/lib/errors.d.ts +8 -0
  62. package/lib/errors.d.ts.map +1 -0
  63. package/lib/errors.js +8 -0
  64. package/lib/errors.js.map +1 -0
  65. package/lib/hw-getAddress.d.ts +6 -0
  66. package/lib/hw-getAddress.d.ts.map +1 -0
  67. package/lib/hw-getAddress.js +14 -0
  68. package/lib/hw-getAddress.js.map +1 -0
  69. package/lib/index.d.ts +2 -0
  70. package/lib/index.d.ts.map +1 -0
  71. package/lib/index.js +18 -0
  72. package/lib/index.js.map +1 -0
  73. package/lib/logic/base32.d.ts +30 -0
  74. package/lib/logic/base32.d.ts.map +1 -0
  75. package/lib/logic/base32.js +99 -0
  76. package/lib/logic/base32.js.map +1 -0
  77. package/lib/logic/bip32.d.ts +9 -0
  78. package/lib/logic/bip32.d.ts.map +1 -0
  79. package/lib/logic/bip32.js +23 -0
  80. package/lib/logic/bip32.js.map +1 -0
  81. package/lib/logic/getAllTransactions.d.ts +3 -0
  82. package/lib/logic/getAllTransactions.d.ts.map +1 -0
  83. package/lib/logic/getAllTransactions.js +19 -0
  84. package/lib/logic/getAllTransactions.js.map +1 -0
  85. package/lib/logic/getFeeRate.d.ts +4 -0
  86. package/lib/logic/getFeeRate.d.ts.map +1 -0
  87. package/lib/logic/getFeeRate.js +19 -0
  88. package/lib/logic/getFeeRate.js.map +1 -0
  89. package/lib/logic/index.d.ts +11 -0
  90. package/lib/logic/index.d.ts.map +1 -0
  91. package/lib/logic/index.js +27 -0
  92. package/lib/logic/index.js.map +1 -0
  93. package/lib/logic/kaspaAddresses.d.ts +30 -0
  94. package/lib/logic/kaspaAddresses.d.ts.map +1 -0
  95. package/lib/logic/kaspaAddresses.js +231 -0
  96. package/lib/logic/kaspaAddresses.js.map +1 -0
  97. package/lib/logic/massCalcluation.d.ts +4 -0
  98. package/lib/logic/massCalcluation.d.ts.map +1 -0
  99. package/lib/logic/massCalcluation.js +40 -0
  100. package/lib/logic/massCalcluation.js.map +1 -0
  101. package/lib/logic/scanAddresses.d.ts +13 -0
  102. package/lib/logic/scanAddresses.d.ts.map +1 -0
  103. package/lib/logic/scanAddresses.js +147 -0
  104. package/lib/logic/scanAddresses.js.map +1 -0
  105. package/lib/logic/scanOperations.d.ts +3 -0
  106. package/lib/logic/scanOperations.d.ts.map +1 -0
  107. package/lib/logic/scanOperations.js +43 -0
  108. package/lib/logic/scanOperations.js.map +1 -0
  109. package/lib/logic/scanUtxos.d.ts +8 -0
  110. package/lib/logic/scanUtxos.d.ts.map +1 -0
  111. package/lib/logic/scanUtxos.js +39 -0
  112. package/lib/logic/scanUtxos.js.map +1 -0
  113. package/lib/logic/tests/bip32.test.d.ts +2 -0
  114. package/lib/logic/tests/bip32.test.d.ts.map +1 -0
  115. package/lib/logic/tests/bip32.test.js +64 -0
  116. package/lib/logic/tests/bip32.test.js.map +1 -0
  117. package/lib/logic/tests/getFeeRate.test.d.ts +2 -0
  118. package/lib/logic/tests/getFeeRate.test.d.ts.map +1 -0
  119. package/lib/logic/tests/getFeeRate.test.js +57 -0
  120. package/lib/logic/tests/getFeeRate.test.js.map +1 -0
  121. package/lib/logic/tests/kaspaAddresses.test.d.ts +2 -0
  122. package/lib/logic/tests/kaspaAddresses.test.d.ts.map +1 -0
  123. package/lib/logic/tests/kaspaAddresses.test.js +172 -0
  124. package/lib/logic/tests/kaspaAddresses.test.js.map +1 -0
  125. package/lib/logic/tests/massCalcluation.test.d.ts +2 -0
  126. package/lib/logic/tests/massCalcluation.test.d.ts.map +1 -0
  127. package/lib/logic/tests/massCalcluation.test.js +27 -0
  128. package/lib/logic/tests/massCalcluation.test.js.map +1 -0
  129. package/lib/logic/tests/scanAddresses.integ.test.d.ts +2 -0
  130. package/lib/logic/tests/scanAddresses.integ.test.d.ts.map +1 -0
  131. package/lib/logic/tests/scanAddresses.integ.test.js +18 -0
  132. package/lib/logic/tests/scanAddresses.integ.test.js.map +1 -0
  133. package/lib/logic/tests/scanOperations.integ.test.d.ts +2 -0
  134. package/lib/logic/tests/scanOperations.integ.test.d.ts.map +1 -0
  135. package/lib/logic/tests/scanOperations.integ.test.js +254 -0
  136. package/lib/logic/tests/scanOperations.integ.test.js.map +1 -0
  137. package/lib/logic/tests/scanOperations.test.d.ts +2 -0
  138. package/lib/logic/tests/scanOperations.test.d.ts.map +1 -0
  139. package/lib/logic/tests/scanOperations.test.js +184 -0
  140. package/lib/logic/tests/scanOperations.test.js.map +1 -0
  141. package/lib/logic/tests/scanUtxos.integ.test.d.ts +2 -0
  142. package/lib/logic/tests/scanUtxos.integ.test.d.ts.map +1 -0
  143. package/lib/logic/tests/scanUtxos.integ.test.js +13 -0
  144. package/lib/logic/tests/scanUtxos.integ.test.js.map +1 -0
  145. package/lib/logic/tests/scanUtxos.test.d.ts +2 -0
  146. package/lib/logic/tests/scanUtxos.test.d.ts.map +1 -0
  147. package/lib/logic/tests/scanUtxos.test.js +167 -0
  148. package/lib/logic/tests/scanUtxos.test.js.map +1 -0
  149. package/lib/logic/tests/utxoLib.test.d.ts +2 -0
  150. package/lib/logic/tests/utxoLib.test.d.ts.map +1 -0
  151. package/lib/logic/tests/utxoLib.test.js +26 -0
  152. package/lib/logic/tests/utxoLib.test.js.map +1 -0
  153. package/lib/logic/tests/utxoSelection.test.d.ts +10 -0
  154. package/lib/logic/tests/utxoSelection.test.d.ts.map +1 -0
  155. package/lib/logic/tests/utxoSelection.test.js +256 -0
  156. package/lib/logic/tests/utxoSelection.test.js.map +1 -0
  157. package/lib/logic/tests/validAddress.test.d.ts +2 -0
  158. package/lib/logic/tests/validAddress.test.d.ts.map +1 -0
  159. package/lib/logic/tests/validAddress.test.js +56 -0
  160. package/lib/logic/tests/validAddress.test.js.map +1 -0
  161. package/lib/logic/utxos/lib.d.ts +6 -0
  162. package/lib/logic/utxos/lib.d.ts.map +1 -0
  163. package/lib/logic/utxos/lib.js +27 -0
  164. package/lib/logic/utxos/lib.js.map +1 -0
  165. package/lib/logic/utxos/selection.d.ts +8 -0
  166. package/lib/logic/utxos/selection.d.ts.map +1 -0
  167. package/lib/logic/utxos/selection.js +80 -0
  168. package/lib/logic/utxos/selection.js.map +1 -0
  169. package/lib/network/config.d.ts +3 -0
  170. package/lib/network/config.d.ts.map +1 -0
  171. package/lib/network/config.js +8 -0
  172. package/lib/network/config.js.map +1 -0
  173. package/lib/network/getAddressesActive.d.ts +3 -0
  174. package/lib/network/getAddressesActive.d.ts.map +1 -0
  175. package/lib/network/getAddressesActive.js +25 -0
  176. package/lib/network/getAddressesActive.js.map +1 -0
  177. package/lib/network/getBalancesForAddresses.d.ts +3 -0
  178. package/lib/network/getBalancesForAddresses.d.ts.map +1 -0
  179. package/lib/network/getBalancesForAddresses.js +25 -0
  180. package/lib/network/getBalancesForAddresses.js.map +1 -0
  181. package/lib/network/getBlockDagInfo.d.ts +3 -0
  182. package/lib/network/getBlockDagInfo.d.ts.map +1 -0
  183. package/lib/network/getBlockDagInfo.js +24 -0
  184. package/lib/network/getBlockDagInfo.js.map +1 -0
  185. package/lib/network/getFeeEstimate.d.ts +3 -0
  186. package/lib/network/getFeeEstimate.d.ts.map +1 -0
  187. package/lib/network/getFeeEstimate.js +23 -0
  188. package/lib/network/getFeeEstimate.js.map +1 -0
  189. package/lib/network/getTransactions.d.ts +6 -0
  190. package/lib/network/getTransactions.d.ts.map +1 -0
  191. package/lib/network/getTransactions.js +19 -0
  192. package/lib/network/getTransactions.js.map +1 -0
  193. package/lib/network/getUtxosForAddresses.d.ts +3 -0
  194. package/lib/network/getUtxosForAddresses.d.ts.map +1 -0
  195. package/lib/network/getUtxosForAddresses.js +25 -0
  196. package/lib/network/getUtxosForAddresses.js.map +1 -0
  197. package/lib/network/getVirtualChainBlueScore.d.ts +2 -0
  198. package/lib/network/getVirtualChainBlueScore.d.ts.map +1 -0
  199. package/lib/network/getVirtualChainBlueScore.js +24 -0
  200. package/lib/network/getVirtualChainBlueScore.js.map +1 -0
  201. package/lib/network/index.d.ts +9 -0
  202. package/lib/network/index.d.ts.map +1 -0
  203. package/lib/network/index.js +20 -0
  204. package/lib/network/index.js.map +1 -0
  205. package/lib/network/submitTransaction.d.ts +3 -0
  206. package/lib/network/submitTransaction.d.ts.map +1 -0
  207. package/lib/network/submitTransaction.js +27 -0
  208. package/lib/network/submitTransaction.js.map +1 -0
  209. package/lib/network/tests/getAddressesActive.test.d.ts +2 -0
  210. package/lib/network/tests/getAddressesActive.test.d.ts.map +1 -0
  211. package/lib/network/tests/getAddressesActive.test.js +65 -0
  212. package/lib/network/tests/getAddressesActive.test.js.map +1 -0
  213. package/lib/network/tests/getBalancesForAddresss.test.d.ts +2 -0
  214. package/lib/network/tests/getBalancesForAddresss.test.d.ts.map +1 -0
  215. package/lib/network/tests/getBalancesForAddresss.test.js +40 -0
  216. package/lib/network/tests/getBalancesForAddresss.test.js.map +1 -0
  217. package/lib/network/tests/getBlockDagInfo.test.d.ts +2 -0
  218. package/lib/network/tests/getBlockDagInfo.test.d.ts.map +1 -0
  219. package/lib/network/tests/getBlockDagInfo.test.js +36 -0
  220. package/lib/network/tests/getBlockDagInfo.test.js.map +1 -0
  221. package/lib/network/tests/getFeeEstimate.test.d.ts +2 -0
  222. package/lib/network/tests/getFeeEstimate.test.d.ts.map +1 -0
  223. package/lib/network/tests/getFeeEstimate.test.js +54 -0
  224. package/lib/network/tests/getFeeEstimate.test.js.map +1 -0
  225. package/lib/network/tests/getTransactions.test.d.ts +2 -0
  226. package/lib/network/tests/getTransactions.test.d.ts.map +1 -0
  227. package/lib/network/tests/getTransactions.test.js +157 -0
  228. package/lib/network/tests/getTransactions.test.js.map +1 -0
  229. package/lib/network/tests/getUtxosForAddress.test.d.ts +2 -0
  230. package/lib/network/tests/getUtxosForAddress.test.d.ts.map +1 -0
  231. package/lib/network/tests/getUtxosForAddress.test.js +142 -0
  232. package/lib/network/tests/getUtxosForAddress.test.js.map +1 -0
  233. package/lib/network/tests/getVirtualChainBlueScore.test.d.ts +2 -0
  234. package/lib/network/tests/getVirtualChainBlueScore.test.d.ts.map +1 -0
  235. package/lib/network/tests/getVirtualChainBlueScore.test.js +27 -0
  236. package/lib/network/tests/getVirtualChainBlueScore.test.js.map +1 -0
  237. package/lib/network/tests/submitTransaction.test.d.ts +2 -0
  238. package/lib/network/tests/submitTransaction.test.d.ts.map +1 -0
  239. package/lib/network/tests/submitTransaction.test.js +43 -0
  240. package/lib/network/tests/submitTransaction.test.js.map +1 -0
  241. package/lib/test/bridgeDatasetTest.d.ts +4 -0
  242. package/lib/test/bridgeDatasetTest.d.ts.map +1 -0
  243. package/lib/test/bridgeDatasetTest.js +46 -0
  244. package/lib/test/bridgeDatasetTest.js.map +1 -0
  245. package/lib/test/cli.d.ts +16 -0
  246. package/lib/test/cli.d.ts.map +1 -0
  247. package/lib/test/cli.js +30 -0
  248. package/lib/test/cli.js.map +1 -0
  249. package/lib/test/index.d.ts +2 -0
  250. package/lib/test/index.d.ts.map +1 -0
  251. package/lib/test/index.js +18 -0
  252. package/lib/test/index.js.map +1 -0
  253. package/lib/transaction.d.ts +16 -0
  254. package/lib/transaction.d.ts.map +1 -0
  255. package/lib/transaction.js +66 -0
  256. package/lib/transaction.js.map +1 -0
  257. package/lib/types/addresses.d.ts +18 -0
  258. package/lib/types/addresses.d.ts.map +1 -0
  259. package/lib/types/addresses.js +3 -0
  260. package/lib/types/addresses.js.map +1 -0
  261. package/lib/types/bridge.d.ts +34 -0
  262. package/lib/types/bridge.d.ts.map +1 -0
  263. package/lib/types/bridge.js +3 -0
  264. package/lib/types/bridge.js.map +1 -0
  265. package/lib/types/errors.d.ts +10 -0
  266. package/lib/types/errors.d.ts.map +1 -0
  267. package/lib/types/errors.js +8 -0
  268. package/lib/types/errors.js.map +1 -0
  269. package/lib/types/index.d.ts +8 -0
  270. package/lib/types/index.d.ts.map +1 -0
  271. package/lib/types/index.js +18 -0
  272. package/lib/types/index.js.map +1 -0
  273. package/lib/types/kaspaHwTransaction.d.ts +89 -0
  274. package/lib/types/kaspaHwTransaction.d.ts.map +1 -0
  275. package/lib/types/kaspaHwTransaction.js +167 -0
  276. package/lib/types/kaspaHwTransaction.js.map +1 -0
  277. package/lib/types/kaspaNetwork.d.ts +22 -0
  278. package/lib/types/kaspaNetwork.d.ts.map +1 -0
  279. package/lib/types/kaspaNetwork.js +3 -0
  280. package/lib/types/kaspaNetwork.js.map +1 -0
  281. package/lib/types/network.d.ts +91 -0
  282. package/lib/types/network.d.ts.map +1 -0
  283. package/lib/types/network.js +3 -0
  284. package/lib/types/network.js.map +1 -0
  285. package/lib/types/signer.d.ts +14 -0
  286. package/lib/types/signer.d.ts.map +1 -0
  287. package/lib/types/signer.js +3 -0
  288. package/lib/types/signer.js.map +1 -0
  289. package/lib-es/bridge/broadcast.d.ts +8 -0
  290. package/lib-es/bridge/broadcast.d.ts.map +1 -0
  291. package/lib-es/bridge/broadcast.js +12 -0
  292. package/lib-es/bridge/broadcast.js.map +1 -0
  293. package/lib-es/bridge/buildInitialOperation.d.ts +5 -0
  294. package/lib-es/bridge/buildInitialOperation.d.ts.map +1 -0
  295. package/lib-es/bridge/buildInitialOperation.js +27 -0
  296. package/lib-es/bridge/buildInitialOperation.js.map +1 -0
  297. package/lib-es/bridge/buildTransaction.d.ts +16 -0
  298. package/lib-es/bridge/buildTransaction.d.ts.map +1 -0
  299. package/lib-es/bridge/buildTransaction.js +59 -0
  300. package/lib-es/bridge/buildTransaction.js.map +1 -0
  301. package/lib-es/bridge/createTransaction.d.ts +4 -0
  302. package/lib-es/bridge/createTransaction.d.ts.map +1 -0
  303. package/lib-es/bridge/createTransaction.js +11 -0
  304. package/lib-es/bridge/createTransaction.js.map +1 -0
  305. package/lib-es/bridge/estimateMaxSpendable.d.ts +4 -0
  306. package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -0
  307. package/lib-es/bridge/estimateMaxSpendable.js +15 -0
  308. package/lib-es/bridge/estimateMaxSpendable.js.map +1 -0
  309. package/lib-es/bridge/getTransactionStatus.d.ts +4 -0
  310. package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -0
  311. package/lib-es/bridge/getTransactionStatus.js +66 -0
  312. package/lib-es/bridge/getTransactionStatus.js.map +1 -0
  313. package/lib-es/bridge/index.d.ts +9 -0
  314. package/lib-es/bridge/index.d.ts.map +1 -0
  315. package/lib-es/bridge/index.js +68 -0
  316. package/lib-es/bridge/index.js.map +1 -0
  317. package/lib-es/bridge/initAccount.d.ts +2 -0
  318. package/lib-es/bridge/initAccount.d.ts.map +1 -0
  319. package/lib-es/bridge/initAccount.js +2 -0
  320. package/lib-es/bridge/initAccount.js.map +1 -0
  321. package/lib-es/bridge/prepareTransaction.d.ts +14 -0
  322. package/lib-es/bridge/prepareTransaction.d.ts.map +1 -0
  323. package/lib-es/bridge/prepareTransaction.js +39 -0
  324. package/lib-es/bridge/prepareTransaction.js.map +1 -0
  325. package/lib-es/bridge/signOperation.d.ts +8 -0
  326. package/lib-es/bridge/signOperation.d.ts.map +1 -0
  327. package/lib-es/bridge/signOperation.js +27 -0
  328. package/lib-es/bridge/signOperation.js.map +1 -0
  329. package/lib-es/bridge/synchronization.d.ts +4 -0
  330. package/lib-es/bridge/synchronization.d.ts.map +1 -0
  331. package/lib-es/bridge/synchronization.js +62 -0
  332. package/lib-es/bridge/synchronization.js.map +1 -0
  333. package/lib-es/config.d.ts +8 -0
  334. package/lib-es/config.d.ts.map +1 -0
  335. package/lib-es/config.js +4 -0
  336. package/lib-es/config.js.map +1 -0
  337. package/lib-es/deviceTransactionConfig.d.ts +11 -0
  338. package/lib-es/deviceTransactionConfig.d.ts.map +1 -0
  339. package/lib-es/deviceTransactionConfig.js +30 -0
  340. package/lib-es/deviceTransactionConfig.js.map +1 -0
  341. package/lib-es/errors.d.ts +8 -0
  342. package/lib-es/errors.d.ts.map +1 -0
  343. package/lib-es/errors.js +5 -0
  344. package/lib-es/errors.js.map +1 -0
  345. package/lib-es/hw-getAddress.d.ts +6 -0
  346. package/lib-es/hw-getAddress.d.ts.map +1 -0
  347. package/lib-es/hw-getAddress.js +12 -0
  348. package/lib-es/hw-getAddress.js.map +1 -0
  349. package/lib-es/index.d.ts +2 -0
  350. package/lib-es/index.d.ts.map +1 -0
  351. package/lib-es/index.js +2 -0
  352. package/lib-es/index.js.map +1 -0
  353. package/lib-es/logic/base32.d.ts +30 -0
  354. package/lib-es/logic/base32.d.ts.map +1 -0
  355. package/lib-es/logic/base32.js +95 -0
  356. package/lib-es/logic/base32.js.map +1 -0
  357. package/lib-es/logic/bip32.d.ts +9 -0
  358. package/lib-es/logic/bip32.d.ts.map +1 -0
  359. package/lib-es/logic/bip32.js +17 -0
  360. package/lib-es/logic/bip32.js.map +1 -0
  361. package/lib-es/logic/getAllTransactions.d.ts +3 -0
  362. package/lib-es/logic/getAllTransactions.d.ts.map +1 -0
  363. package/lib-es/logic/getAllTransactions.js +15 -0
  364. package/lib-es/logic/getAllTransactions.js.map +1 -0
  365. package/lib-es/logic/getFeeRate.d.ts +4 -0
  366. package/lib-es/logic/getFeeRate.d.ts.map +1 -0
  367. package/lib-es/logic/getFeeRate.js +15 -0
  368. package/lib-es/logic/getFeeRate.js.map +1 -0
  369. package/lib-es/logic/index.d.ts +11 -0
  370. package/lib-es/logic/index.d.ts.map +1 -0
  371. package/lib-es/logic/index.js +11 -0
  372. package/lib-es/logic/index.js.map +1 -0
  373. package/lib-es/logic/kaspaAddresses.d.ts +30 -0
  374. package/lib-es/logic/kaspaAddresses.d.ts.map +1 -0
  375. package/lib-es/logic/kaspaAddresses.js +219 -0
  376. package/lib-es/logic/kaspaAddresses.js.map +1 -0
  377. package/lib-es/logic/massCalcluation.d.ts +4 -0
  378. package/lib-es/logic/massCalcluation.d.ts.map +1 -0
  379. package/lib-es/logic/massCalcluation.js +35 -0
  380. package/lib-es/logic/massCalcluation.js.map +1 -0
  381. package/lib-es/logic/scanAddresses.d.ts +13 -0
  382. package/lib-es/logic/scanAddresses.d.ts.map +1 -0
  383. package/lib-es/logic/scanAddresses.js +140 -0
  384. package/lib-es/logic/scanAddresses.js.map +1 -0
  385. package/lib-es/logic/scanOperations.d.ts +3 -0
  386. package/lib-es/logic/scanOperations.d.ts.map +1 -0
  387. package/lib-es/logic/scanOperations.js +39 -0
  388. package/lib-es/logic/scanOperations.js.map +1 -0
  389. package/lib-es/logic/scanUtxos.d.ts +8 -0
  390. package/lib-es/logic/scanUtxos.d.ts.map +1 -0
  391. package/lib-es/logic/scanUtxos.js +35 -0
  392. package/lib-es/logic/scanUtxos.js.map +1 -0
  393. package/lib-es/logic/tests/bip32.test.d.ts +2 -0
  394. package/lib-es/logic/tests/bip32.test.d.ts.map +1 -0
  395. package/lib-es/logic/tests/bip32.test.js +59 -0
  396. package/lib-es/logic/tests/bip32.test.js.map +1 -0
  397. package/lib-es/logic/tests/getFeeRate.test.d.ts +2 -0
  398. package/lib-es/logic/tests/getFeeRate.test.d.ts.map +1 -0
  399. package/lib-es/logic/tests/getFeeRate.test.js +55 -0
  400. package/lib-es/logic/tests/getFeeRate.test.js.map +1 -0
  401. package/lib-es/logic/tests/kaspaAddresses.test.d.ts +2 -0
  402. package/lib-es/logic/tests/kaspaAddresses.test.d.ts.map +1 -0
  403. package/lib-es/logic/tests/kaspaAddresses.test.js +170 -0
  404. package/lib-es/logic/tests/kaspaAddresses.test.js.map +1 -0
  405. package/lib-es/logic/tests/massCalcluation.test.d.ts +2 -0
  406. package/lib-es/logic/tests/massCalcluation.test.d.ts.map +1 -0
  407. package/lib-es/logic/tests/massCalcluation.test.js +22 -0
  408. package/lib-es/logic/tests/massCalcluation.test.js.map +1 -0
  409. package/lib-es/logic/tests/scanAddresses.integ.test.d.ts +2 -0
  410. package/lib-es/logic/tests/scanAddresses.integ.test.d.ts.map +1 -0
  411. package/lib-es/logic/tests/scanAddresses.integ.test.js +16 -0
  412. package/lib-es/logic/tests/scanAddresses.integ.test.js.map +1 -0
  413. package/lib-es/logic/tests/scanOperations.integ.test.d.ts +2 -0
  414. package/lib-es/logic/tests/scanOperations.integ.test.d.ts.map +1 -0
  415. package/lib-es/logic/tests/scanOperations.integ.test.js +249 -0
  416. package/lib-es/logic/tests/scanOperations.integ.test.js.map +1 -0
  417. package/lib-es/logic/tests/scanOperations.test.d.ts +2 -0
  418. package/lib-es/logic/tests/scanOperations.test.d.ts.map +1 -0
  419. package/lib-es/logic/tests/scanOperations.test.js +156 -0
  420. package/lib-es/logic/tests/scanOperations.test.js.map +1 -0
  421. package/lib-es/logic/tests/scanUtxos.integ.test.d.ts +2 -0
  422. package/lib-es/logic/tests/scanUtxos.integ.test.d.ts.map +1 -0
  423. package/lib-es/logic/tests/scanUtxos.integ.test.js +11 -0
  424. package/lib-es/logic/tests/scanUtxos.integ.test.js.map +1 -0
  425. package/lib-es/logic/tests/scanUtxos.test.d.ts +2 -0
  426. package/lib-es/logic/tests/scanUtxos.test.d.ts.map +1 -0
  427. package/lib-es/logic/tests/scanUtxos.test.js +139 -0
  428. package/lib-es/logic/tests/scanUtxos.test.js.map +1 -0
  429. package/lib-es/logic/tests/utxoLib.test.d.ts +2 -0
  430. package/lib-es/logic/tests/utxoLib.test.d.ts.map +1 -0
  431. package/lib-es/logic/tests/utxoLib.test.js +24 -0
  432. package/lib-es/logic/tests/utxoLib.test.js.map +1 -0
  433. package/lib-es/logic/tests/utxoSelection.test.d.ts +10 -0
  434. package/lib-es/logic/tests/utxoSelection.test.d.ts.map +1 -0
  435. package/lib-es/logic/tests/utxoSelection.test.js +229 -0
  436. package/lib-es/logic/tests/utxoSelection.test.js.map +1 -0
  437. package/lib-es/logic/tests/validAddress.test.d.ts +2 -0
  438. package/lib-es/logic/tests/validAddress.test.d.ts.map +1 -0
  439. package/lib-es/logic/tests/validAddress.test.js +54 -0
  440. package/lib-es/logic/tests/validAddress.test.js.map +1 -0
  441. package/lib-es/logic/utxos/lib.d.ts +6 -0
  442. package/lib-es/logic/utxos/lib.d.ts.map +1 -0
  443. package/lib-es/logic/utxos/lib.js +21 -0
  444. package/lib-es/logic/utxos/lib.js.map +1 -0
  445. package/lib-es/logic/utxos/selection.d.ts +8 -0
  446. package/lib-es/logic/utxos/selection.d.ts.map +1 -0
  447. package/lib-es/logic/utxos/selection.js +76 -0
  448. package/lib-es/logic/utxos/selection.js.map +1 -0
  449. package/lib-es/network/config.d.ts +3 -0
  450. package/lib-es/network/config.d.ts.map +1 -0
  451. package/lib-es/network/config.js +5 -0
  452. package/lib-es/network/config.js.map +1 -0
  453. package/lib-es/network/getAddressesActive.d.ts +3 -0
  454. package/lib-es/network/getAddressesActive.d.ts.map +1 -0
  455. package/lib-es/network/getAddressesActive.js +21 -0
  456. package/lib-es/network/getAddressesActive.js.map +1 -0
  457. package/lib-es/network/getBalancesForAddresses.d.ts +3 -0
  458. package/lib-es/network/getBalancesForAddresses.d.ts.map +1 -0
  459. package/lib-es/network/getBalancesForAddresses.js +21 -0
  460. package/lib-es/network/getBalancesForAddresses.js.map +1 -0
  461. package/lib-es/network/getBlockDagInfo.d.ts +3 -0
  462. package/lib-es/network/getBlockDagInfo.d.ts.map +1 -0
  463. package/lib-es/network/getBlockDagInfo.js +20 -0
  464. package/lib-es/network/getBlockDagInfo.js.map +1 -0
  465. package/lib-es/network/getFeeEstimate.d.ts +3 -0
  466. package/lib-es/network/getFeeEstimate.d.ts.map +1 -0
  467. package/lib-es/network/getFeeEstimate.js +19 -0
  468. package/lib-es/network/getFeeEstimate.js.map +1 -0
  469. package/lib-es/network/getTransactions.d.ts +6 -0
  470. package/lib-es/network/getTransactions.d.ts.map +1 -0
  471. package/lib-es/network/getTransactions.js +15 -0
  472. package/lib-es/network/getTransactions.js.map +1 -0
  473. package/lib-es/network/getUtxosForAddresses.d.ts +3 -0
  474. package/lib-es/network/getUtxosForAddresses.d.ts.map +1 -0
  475. package/lib-es/network/getUtxosForAddresses.js +21 -0
  476. package/lib-es/network/getUtxosForAddresses.js.map +1 -0
  477. package/lib-es/network/getVirtualChainBlueScore.d.ts +2 -0
  478. package/lib-es/network/getVirtualChainBlueScore.d.ts.map +1 -0
  479. package/lib-es/network/getVirtualChainBlueScore.js +20 -0
  480. package/lib-es/network/getVirtualChainBlueScore.js.map +1 -0
  481. package/lib-es/network/index.d.ts +9 -0
  482. package/lib-es/network/index.d.ts.map +1 -0
  483. package/lib-es/network/index.js +9 -0
  484. package/lib-es/network/index.js.map +1 -0
  485. package/lib-es/network/submitTransaction.d.ts +3 -0
  486. package/lib-es/network/submitTransaction.d.ts.map +1 -0
  487. package/lib-es/network/submitTransaction.js +23 -0
  488. package/lib-es/network/submitTransaction.js.map +1 -0
  489. package/lib-es/network/tests/getAddressesActive.test.d.ts +2 -0
  490. package/lib-es/network/tests/getAddressesActive.test.d.ts.map +1 -0
  491. package/lib-es/network/tests/getAddressesActive.test.js +63 -0
  492. package/lib-es/network/tests/getAddressesActive.test.js.map +1 -0
  493. package/lib-es/network/tests/getBalancesForAddresss.test.d.ts +2 -0
  494. package/lib-es/network/tests/getBalancesForAddresss.test.d.ts.map +1 -0
  495. package/lib-es/network/tests/getBalancesForAddresss.test.js +38 -0
  496. package/lib-es/network/tests/getBalancesForAddresss.test.js.map +1 -0
  497. package/lib-es/network/tests/getBlockDagInfo.test.d.ts +2 -0
  498. package/lib-es/network/tests/getBlockDagInfo.test.d.ts.map +1 -0
  499. package/lib-es/network/tests/getBlockDagInfo.test.js +34 -0
  500. package/lib-es/network/tests/getBlockDagInfo.test.js.map +1 -0
  501. package/lib-es/network/tests/getFeeEstimate.test.d.ts +2 -0
  502. package/lib-es/network/tests/getFeeEstimate.test.d.ts.map +1 -0
  503. package/lib-es/network/tests/getFeeEstimate.test.js +52 -0
  504. package/lib-es/network/tests/getFeeEstimate.test.js.map +1 -0
  505. package/lib-es/network/tests/getTransactions.test.d.ts +2 -0
  506. package/lib-es/network/tests/getTransactions.test.d.ts.map +1 -0
  507. package/lib-es/network/tests/getTransactions.test.js +155 -0
  508. package/lib-es/network/tests/getTransactions.test.js.map +1 -0
  509. package/lib-es/network/tests/getUtxosForAddress.test.d.ts +2 -0
  510. package/lib-es/network/tests/getUtxosForAddress.test.d.ts.map +1 -0
  511. package/lib-es/network/tests/getUtxosForAddress.test.js +140 -0
  512. package/lib-es/network/tests/getUtxosForAddress.test.js.map +1 -0
  513. package/lib-es/network/tests/getVirtualChainBlueScore.test.d.ts +2 -0
  514. package/lib-es/network/tests/getVirtualChainBlueScore.test.d.ts.map +1 -0
  515. package/lib-es/network/tests/getVirtualChainBlueScore.test.js +25 -0
  516. package/lib-es/network/tests/getVirtualChainBlueScore.test.js.map +1 -0
  517. package/lib-es/network/tests/submitTransaction.test.d.ts +2 -0
  518. package/lib-es/network/tests/submitTransaction.test.d.ts.map +1 -0
  519. package/lib-es/network/tests/submitTransaction.test.js +41 -0
  520. package/lib-es/network/tests/submitTransaction.test.js.map +1 -0
  521. package/lib-es/test/bridgeDatasetTest.d.ts +4 -0
  522. package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -0
  523. package/lib-es/test/bridgeDatasetTest.js +43 -0
  524. package/lib-es/test/bridgeDatasetTest.js.map +1 -0
  525. package/lib-es/test/cli.d.ts +16 -0
  526. package/lib-es/test/cli.d.ts.map +1 -0
  527. package/lib-es/test/cli.js +25 -0
  528. package/lib-es/test/cli.js.map +1 -0
  529. package/lib-es/test/index.d.ts +2 -0
  530. package/lib-es/test/index.d.ts.map +1 -0
  531. package/lib-es/test/index.js +2 -0
  532. package/lib-es/test/index.js.map +1 -0
  533. package/lib-es/transaction.d.ts +16 -0
  534. package/lib-es/transaction.d.ts.map +1 -0
  535. package/lib-es/transaction.js +59 -0
  536. package/lib-es/transaction.js.map +1 -0
  537. package/lib-es/types/addresses.d.ts +18 -0
  538. package/lib-es/types/addresses.d.ts.map +1 -0
  539. package/lib-es/types/addresses.js +2 -0
  540. package/lib-es/types/addresses.js.map +1 -0
  541. package/lib-es/types/bridge.d.ts +34 -0
  542. package/lib-es/types/bridge.d.ts.map +1 -0
  543. package/lib-es/types/bridge.js +2 -0
  544. package/lib-es/types/bridge.js.map +1 -0
  545. package/lib-es/types/errors.d.ts +10 -0
  546. package/lib-es/types/errors.d.ts.map +1 -0
  547. package/lib-es/types/errors.js +5 -0
  548. package/lib-es/types/errors.js.map +1 -0
  549. package/lib-es/types/index.d.ts +8 -0
  550. package/lib-es/types/index.d.ts.map +1 -0
  551. package/lib-es/types/index.js +2 -0
  552. package/lib-es/types/index.js.map +1 -0
  553. package/lib-es/types/kaspaHwTransaction.d.ts +89 -0
  554. package/lib-es/types/kaspaHwTransaction.d.ts.map +1 -0
  555. package/lib-es/types/kaspaHwTransaction.js +160 -0
  556. package/lib-es/types/kaspaHwTransaction.js.map +1 -0
  557. package/lib-es/types/kaspaNetwork.d.ts +22 -0
  558. package/lib-es/types/kaspaNetwork.d.ts.map +1 -0
  559. package/lib-es/types/kaspaNetwork.js +2 -0
  560. package/lib-es/types/kaspaNetwork.js.map +1 -0
  561. package/lib-es/types/network.d.ts +91 -0
  562. package/lib-es/types/network.d.ts.map +1 -0
  563. package/lib-es/types/network.js +2 -0
  564. package/lib-es/types/network.js.map +1 -0
  565. package/lib-es/types/signer.d.ts +14 -0
  566. package/lib-es/types/signer.d.ts.map +1 -0
  567. package/lib-es/types/signer.js +2 -0
  568. package/lib-es/types/signer.js.map +1 -0
  569. package/package.json +138 -0
  570. package/src/bridge/broadcast.ts +14 -0
  571. package/src/bridge/buildInitialOperation.ts +38 -0
  572. package/src/bridge/buildTransaction.ts +80 -0
  573. package/src/bridge/createTransaction.ts +13 -0
  574. package/src/bridge/estimateMaxSpendable.ts +23 -0
  575. package/src/bridge/getTransactionStatus.ts +116 -0
  576. package/src/bridge/index.ts +106 -0
  577. package/src/bridge/initAccount.ts +1 -0
  578. package/src/bridge/prepareTransaction.ts +48 -0
  579. package/src/bridge/signOperation.ts +43 -0
  580. package/src/bridge/synchronization.ts +80 -0
  581. package/src/config.ts +7 -0
  582. package/src/deviceTransactionConfig.ts +44 -0
  583. package/src/errors.ts +6 -0
  584. package/src/hw-getAddress.ts +17 -0
  585. package/src/index.ts +1 -0
  586. package/src/logic/base32.ts +100 -0
  587. package/src/logic/bip32.ts +21 -0
  588. package/src/logic/getAllTransactions.ts +22 -0
  589. package/src/logic/getFeeRate.ts +20 -0
  590. package/src/logic/index.ts +10 -0
  591. package/src/logic/kaspaAddresses.ts +274 -0
  592. package/src/logic/massCalcluation.ts +50 -0
  593. package/src/logic/scanAddresses.ts +173 -0
  594. package/src/logic/scanOperations.ts +59 -0
  595. package/src/logic/scanUtxos.ts +44 -0
  596. package/src/logic/tests/bip32.test.ts +78 -0
  597. package/src/logic/tests/getFeeRate.test.ts +64 -0
  598. package/src/logic/tests/kaspaAddresses.test.ts +278 -0
  599. package/src/logic/tests/massCalcluation.test.ts +37 -0
  600. package/src/logic/tests/scanAddresses.integ.test.ts +27 -0
  601. package/src/logic/tests/scanOperations.integ.test.ts +271 -0
  602. package/src/logic/tests/scanOperations.test.ts +191 -0
  603. package/src/logic/tests/scanUtxos.integ.test.ts +14 -0
  604. package/src/logic/tests/scanUtxos.test.ts +153 -0
  605. package/src/logic/tests/utxoLib.test.ts +29 -0
  606. package/src/logic/tests/utxoSelection.test.ts +290 -0
  607. package/src/logic/tests/validAddress.test.ts +55 -0
  608. package/src/logic/utxos/lib.ts +40 -0
  609. package/src/logic/utxos/selection.ts +100 -0
  610. package/src/network/config.ts +6 -0
  611. package/src/network/getAddressesActive.ts +27 -0
  612. package/src/network/getBalancesForAddresses.ts +27 -0
  613. package/src/network/getBlockDagInfo.ts +22 -0
  614. package/src/network/getFeeEstimate.ts +21 -0
  615. package/src/network/getTransactions.ts +25 -0
  616. package/src/network/getUtxosForAddresses.ts +23 -0
  617. package/src/network/getVirtualChainBlueScore.ts +21 -0
  618. package/src/network/index.ts +8 -0
  619. package/src/network/submitTransaction.ts +27 -0
  620. package/src/network/tests/getAddressesActive.test.ts +77 -0
  621. package/src/network/tests/getBalancesForAddresss.test.ts +44 -0
  622. package/src/network/tests/getBlockDagInfo.test.ts +40 -0
  623. package/src/network/tests/getFeeEstimate.test.ts +57 -0
  624. package/src/network/tests/getTransactions.test.ts +173 -0
  625. package/src/network/tests/getUtxosForAddress.test.ts +159 -0
  626. package/src/network/tests/getVirtualChainBlueScore.test.ts +29 -0
  627. package/src/network/tests/submitTransaction.test.ts +53 -0
  628. package/src/test/bridgeDatasetTest.ts +47 -0
  629. package/src/test/cli.ts +33 -0
  630. package/src/test/index.ts +1 -0
  631. package/src/transaction.ts +84 -0
  632. package/src/types/addresses.ts +19 -0
  633. package/src/types/bridge.ts +43 -0
  634. package/src/types/errors.ts +7 -0
  635. package/src/types/index.ts +7 -0
  636. package/src/types/kaspaHwTransaction.ts +234 -0
  637. package/src/types/kaspaNetwork.ts +21 -0
  638. package/src/types/network.ts +101 -0
  639. package/src/types/signer.ts +22 -0
  640. package/tsconfig.json +13 -0
@@ -0,0 +1,274 @@
1
+ import base32 from "./base32";
2
+
3
+ export enum ScriptTypeVersion {
4
+ SCHNORR = 0,
5
+ ECDSA = 1,
6
+ P2SH = 8,
7
+ }
8
+
9
+ type ParsedExtendedPublicKey = {
10
+ chainCode: Buffer;
11
+ compressedPublicKey: Buffer;
12
+ uncompressedPublicKey: Buffer;
13
+ };
14
+
15
+ export function addressToPublicKey(address: string): { version: number; publicKey: number[] } {
16
+ const addrPart = address.split(":")[1];
17
+ const payload = convertBits(base32.decode(addrPart), 5, 8);
18
+
19
+ switch (payload[0]) {
20
+ // for 0 and 8
21
+ case 0:
22
+ case 8:
23
+ return { version: payload[0], publicKey: payload.slice(1, 33) };
24
+ case 1:
25
+ // for ECDSA it's one byte more
26
+ return { version: payload[0], publicKey: payload.slice(1, 34) };
27
+ default:
28
+ throw new Error("Unable to translate address to ScriptPublicKey");
29
+ }
30
+ }
31
+
32
+ export function publicKeyToAddress(
33
+ hashBuffer: Buffer,
34
+ stripPrefix: boolean = false,
35
+ scriptTypeVersion: ScriptTypeVersion = ScriptTypeVersion.SCHNORR,
36
+ ): string {
37
+ const eight0: number[] = [0, 0, 0, 0, 0, 0, 0, 0];
38
+ const prefixData: number[] = prefixToArray("kaspa").concat([0]);
39
+ const versionByte: number = scriptTypeVersion;
40
+
41
+ const arr: number[] = Array.from(hashBuffer);
42
+ const payloadData: number[] = convertBits([versionByte, ...arr], 8, 5);
43
+ const checksumData: number[] = [...prefixData, ...payloadData, ...eight0];
44
+ const payload: number[] = [...payloadData, ...checksumToArray(polymod(checksumData))];
45
+
46
+ if (stripPrefix) {
47
+ return base32.encode(payload);
48
+ } else {
49
+ return `kaspa:${base32.encode(payload)}`;
50
+ }
51
+ }
52
+
53
+ export function addressToScriptPublicKey(address: string): string {
54
+ const { version, publicKey } = addressToPublicKey(address);
55
+
56
+ switch (version) {
57
+ case 0:
58
+ return "20" + numArrayToHexString(publicKey) + "ac";
59
+ case 1:
60
+ return "21" + numArrayToHexString(publicKey) + "ab";
61
+ case 8:
62
+ return "aa20" + numArrayToHexString(publicKey) + "87";
63
+ default:
64
+ throw new Error("Address could not be translated to script public key");
65
+ }
66
+ }
67
+
68
+ /**
69
+ * Converts a script public key to a corresponding address.
70
+ *
71
+ * @param {string} scriptPublicKey - The script public key to be converted.
72
+ * @param {boolean} [stripPrefix=false] - Optional flag to determine if the prefix should be stripped from the resulting address.
73
+ * @return {string} The address derived from the provided script public key.
74
+ */
75
+ export function scriptPublicKeyToAddress(scriptPublicKey: string, stripPrefix?: boolean): string {
76
+ // determine version of script public key
77
+ const version = determineVersionFromScriptPublicKey(scriptPublicKey);
78
+ const publicKey = Buffer.from(
79
+ scriptPublicKey.slice(version == ScriptTypeVersion.P2SH ? 4 : 2, -2),
80
+ "hex",
81
+ ); // Remove the prefix and suffix
82
+ return publicKeyToAddress(publicKey, stripPrefix, version);
83
+ }
84
+
85
+ export function isValidKaspaAddress(address: string): boolean {
86
+ // Kaspa addresses typically start with 'kaspa:' and are followed by a hexadecimal string
87
+ const kaspaAddressRegex = new RegExp(`^kaspa:([${base32.CHARSET}]{61}|[${base32.CHARSET}]{63})$`);
88
+
89
+ // Check if the address matches the Kaspa format
90
+ if (!kaspaAddressRegex.test(address)) {
91
+ return false;
92
+ }
93
+
94
+ // do a round-trip to publickey and back - checks the checksum and all the functionality
95
+ try {
96
+ const extractedPublicKey = addressToPublicKey(address);
97
+ const roundtripAddress: string = publicKeyToAddress(
98
+ Buffer.from(extractedPublicKey.publicKey),
99
+ false,
100
+ extractedPublicKey.version,
101
+ );
102
+
103
+ if (address !== roundtripAddress) {
104
+ // checksum not valid
105
+ return false;
106
+ }
107
+ } catch (e) {
108
+ // Unable to translate address to ScriptPublicKey
109
+ return false;
110
+ }
111
+
112
+ return true;
113
+ }
114
+
115
+ export function parseExtendedPublicKey(extendedPublicKey: Buffer): ParsedExtendedPublicKey {
116
+ /**
117
+ * Converts a full public key to an xPublicKey.
118
+ *
119
+ * @param {Buffer} fullPublicKey - The complete public key buffer which includes the chain code.
120
+ * @returns {Buffer} The xPublicKey obtained by processing the full public key.
121
+ *
122
+ * The xPublicKey consists of a single byte y-coordinate parity followed by the first 32 bytes of the x coordinate.
123
+ */
124
+ // Validate the length of the extended public key
125
+ if (extendedPublicKey.length !== 99) {
126
+ throw new Error("Invalid extended public key length. Expected length is 99 bytes.");
127
+ }
128
+ // Index 0 is always 0x41 = (65) the length of the following full public key
129
+ // Index 66 is always 0x20 = (32) the length of the following chain code
130
+ const chainCode = Buffer.from(extendedPublicKey.subarray(67, 67 + 32));
131
+ // x-coord is index [2, 34),
132
+ // y-coord is index [34, 66)
133
+ const yCoordParity = extendedPublicKey[65] % 2;
134
+
135
+ return {
136
+ chainCode,
137
+ compressedPublicKey: Buffer.from([yCoordParity + 2, ...extendedPublicKey.subarray(2, 34)]),
138
+ uncompressedPublicKey: Buffer.from(extendedPublicKey.subarray(1, 1 + 65)),
139
+ };
140
+ }
141
+
142
+ function convertBits(data: number[], from: number, to: number, strict: boolean = false): number[] {
143
+ const result: number[] = [];
144
+ let accumulator = 0;
145
+ let bits = 0;
146
+ const mask = (1 << to) - 1;
147
+
148
+ for (let i = 0; i < data.length; i++) {
149
+ const value = data[i];
150
+ if (value < 0 || value >> from !== 0) {
151
+ throw new Error(`Invalid argument: value = ${value}`);
152
+ }
153
+
154
+ accumulator = (accumulator << from) | value;
155
+ bits += from;
156
+ while (bits >= to) {
157
+ bits -= to;
158
+ result.push((accumulator >> bits) & mask);
159
+ }
160
+ }
161
+
162
+ if (!strict) {
163
+ if (bits > 0) {
164
+ result.push((accumulator << (to - bits)) & mask);
165
+ }
166
+ } else {
167
+ if (bits > 0 && ((accumulator << (to - bits)) & mask) !== 0) {
168
+ throw new Error("Conversion requires padding but strict mode was used");
169
+ }
170
+ }
171
+
172
+ return result;
173
+ }
174
+
175
+ function prefixToArray(prefix: string): number[] {
176
+ const result: number[] = [];
177
+ for (let i = 0; i < prefix.length; i++) {
178
+ result.push(prefix.charCodeAt(i) & 31);
179
+ }
180
+ return result;
181
+ }
182
+
183
+ function polymod(data: number[]): number {
184
+ const GENERATOR1: number[] = [0x98, 0x79, 0xf3, 0xae, 0x1e];
185
+ const GENERATOR2: number[] = [0xf2bc8e61, 0xb76d99e2, 0x3e5fb3c4, 0x2eabe2a8, 0x4f43e470];
186
+
187
+ // Split c into two parts: 8 bits (c0) + 32 bits (c1)
188
+ let c0 = 0;
189
+ let c1 = 1;
190
+ let C: number = 0;
191
+
192
+ for (let j = 0; j < data.length; j++) {
193
+ // Set C to c shifted by 35 bits
194
+ C = c0 >>> 3;
195
+
196
+ // Mask the remaining bits of c0 (8 bits)
197
+ c0 &= 0x07;
198
+
199
+ // Shift c0 as a whole number
200
+ c0 <<= 5;
201
+ c0 |= c1 >>> 27;
202
+
203
+ // Mask the remaining bits of c1 (27 bits)
204
+ c1 &= 0x07ffffff;
205
+
206
+ // Shift c1 and add current data value
207
+ c1 <<= 5;
208
+ c1 ^= data[j];
209
+
210
+ // Perform XOR operations with GENERATOR arrays
211
+ for (let i = 0; i < GENERATOR1.length; ++i) {
212
+ if (C & (1 << i)) {
213
+ c0 ^= GENERATOR1[i];
214
+ c1 ^= GENERATOR2[i];
215
+ }
216
+ }
217
+ }
218
+
219
+ // Final XOR operation on c1
220
+ c1 ^= 1;
221
+
222
+ // Handle negative numbers to ensure it becomes a large positive number
223
+ if (c1 < 0) {
224
+ c1 ^= 1 << 31;
225
+ c1 += (1 << 30) * 2;
226
+ }
227
+
228
+ // Return the final result
229
+ return c0 * (1 << 30) * 4 + c1;
230
+ }
231
+
232
+ function checksumToArray(checksum: number): number[] {
233
+ const result: number[] = [];
234
+ for (let i = 0; i < 8; ++i) {
235
+ result.push(checksum & 31); // Extract the last 5 bits
236
+ checksum = Math.floor(checksum / 32); // Ensure integer division
237
+ }
238
+ return result.reverse();
239
+ }
240
+
241
+ // Function to determine the version based on the scriptPublicKey string
242
+ function determineVersionFromScriptPublicKey(scriptPublicKey: string): ScriptTypeVersion {
243
+ if (
244
+ scriptPublicKey.startsWith("20") &&
245
+ scriptPublicKey.endsWith("ac") &&
246
+ scriptPublicKey.length == 68
247
+ ) {
248
+ return ScriptTypeVersion.SCHNORR;
249
+ } else if (
250
+ scriptPublicKey.startsWith("21") &&
251
+ scriptPublicKey.endsWith("ab") &&
252
+ scriptPublicKey.length === 70
253
+ ) {
254
+ return ScriptTypeVersion.ECDSA;
255
+ } else if (
256
+ scriptPublicKey.startsWith("aa20") &&
257
+ scriptPublicKey.endsWith("87") &&
258
+ scriptPublicKey.length === 70
259
+ ) {
260
+ return ScriptTypeVersion.P2SH;
261
+ }
262
+
263
+ throw new Error("Script public key version could not be determined.");
264
+ }
265
+
266
+ function numArrayToHexString(numArray: number[] = []): string {
267
+ const hexArr = [];
268
+
269
+ for (const num of numArray) {
270
+ hexArr.push(("00" + num.toString(16)).slice(-2));
271
+ }
272
+
273
+ return hexArr.join("");
274
+ }
@@ -0,0 +1,50 @@
1
+ import { BigNumber } from "bignumber.js";
2
+ import { sumBigNumber } from "./utxos/lib";
3
+
4
+ const C: BigNumber = BigNumber(10 ** 12);
5
+
6
+ // if one output is ECDSA, scriptPubKey is one byte longer
7
+ // which ends up in 11g mass ( 1 byte + 10g MASS_PER_SCRIPT_PUB_KEY_BYTE )
8
+ const ADDTIONAL_MASS_FOR_ECDSA_OUTPUT = 11;
9
+
10
+ // note: this is an easy version of computeMass for Ledger only.
11
+ // it has usual inputs with regular Script and one or two outputs
12
+ export function calcComputeMass(
13
+ inputCount: number,
14
+ isChangeAddress: boolean,
15
+ recipientIsECDSA: boolean = false,
16
+ ): number {
17
+ // 506 for one output, 918 for two outputs
18
+ let mass: number = isChangeAddress ? 918 : 506;
19
+
20
+ // per used utxo mass increases by 1118
21
+ mass += inputCount * 1118;
22
+
23
+ // is output address is ECDSA, the mass is 11g higher
24
+ if (recipientIsECDSA) {
25
+ mass += ADDTIONAL_MASS_FOR_ECDSA_OUTPUT;
26
+ }
27
+
28
+ return mass;
29
+ }
30
+
31
+ function _negative_mass(inputs: BigNumber[], outputsNum: number): number {
32
+ const inputsNum = inputs.length;
33
+ if (outputsNum === 1 || inputsNum === 1 || (outputsNum === 2 && inputsNum === 2)) {
34
+ return sumBigNumber(inputs.map(v => C.div(v).integerValue(BigNumber.ROUND_FLOOR))).toNumber();
35
+ }
36
+ return (
37
+ inputsNum *
38
+ C.div(sumBigNumber(inputs).div(BigNumber(inputsNum)).integerValue(BigNumber.ROUND_FLOOR))
39
+ .integerValue(BigNumber.ROUND_FLOOR)
40
+ .toNumber()
41
+ );
42
+ }
43
+
44
+ export function calcStorageMass(inputs: BigNumber[], outputs: BigNumber[]): number {
45
+ const N: number = _negative_mass(inputs, outputs.length);
46
+ const P: number = sumBigNumber(
47
+ outputs.map(v => C.div(v).integerValue(BigNumber.ROUND_FLOOR)),
48
+ ).toNumber();
49
+ return Math.max(P - N, 0);
50
+ }
@@ -0,0 +1,173 @@
1
+ import { BigNumber } from "bignumber.js";
2
+ import { AccountAddress, AccountAddresses } from "../types";
3
+ import KaspaBIP32 from "./bip32";
4
+ import { getAddressesActive, getBalancesForAddresses } from "../network";
5
+
6
+ // Constants to improve clarity
7
+ const RECEIVE_ADDRESS_TYPE = 0;
8
+ const CHANGE_ADDRESS_TYPE = 1;
9
+ const INITIAL_BALANCE = BigNumber(0);
10
+ const GAP_LIMIT = 20;
11
+ const SCAN_BATCH_SIZE = 200;
12
+
13
+ const MAX_TX_INPUTS = 88; // floor (( 100_000 - 918 (def_size with 2 outputs) ) / 1_118 (per_input))
14
+
15
+ /**
16
+ * Scans the addresses for an account and retrieves information such as used addresses and the total balance.
17
+ *
18
+ * @param {Buffer} compressedPublicKey - The compressed public key used for address derivation.
19
+ * @param {Buffer} chainCode - The chain code used for address derivation.
20
+ * @param {number} [startIndex=0] - The starting index for address scanning.
21
+ * @return {Promise<AccountAddresses>} - A promise that resolves to an AccountAddresses object containing used addresses and balance information.
22
+ */
23
+ export async function scanAddresses(
24
+ compressedPublicKey: Buffer,
25
+ chainCode: Buffer,
26
+ startIndex: number,
27
+ ): Promise<AccountAddresses> {
28
+ const kaspaBip32: KaspaBIP32 = new KaspaBIP32(compressedPublicKey, chainCode);
29
+
30
+ const accountAddresses: AccountAddresses = {
31
+ usedReceiveAddresses: [],
32
+ usedChangeAddresses: [],
33
+ nextChangeAddress: {
34
+ type: 0,
35
+ index: 0,
36
+ address: "",
37
+ balance: INITIAL_BALANCE,
38
+ active: false,
39
+ timestamp: null,
40
+ },
41
+ nextReceiveAddress: {
42
+ type: 0,
43
+ index: 0,
44
+ address: "",
45
+ balance: INITIAL_BALANCE,
46
+ active: false,
47
+ timestamp: null,
48
+ },
49
+ totalBalance: BigNumber(0),
50
+ spendableBalance: BigNumber(0),
51
+ };
52
+
53
+ // need to check UTXOs and TX history for the first account addresses
54
+
55
+ // go through receive address and change address
56
+ for (const type of [RECEIVE_ADDRESS_TYPE, CHANGE_ADDRESS_TYPE]) {
57
+ let keepScanning: boolean = true;
58
+
59
+ while (keepScanning) {
60
+ const addresses: AccountAddress[] = [];
61
+ for (let index = startIndex; index < startIndex + SCAN_BATCH_SIZE; index++) {
62
+ const derivedAddress: string = kaspaBip32.getAddress(type, index);
63
+ addresses.push({
64
+ type: type,
65
+ index,
66
+ address: derivedAddress,
67
+ balance: BigNumber(0),
68
+ active: false,
69
+ } as AccountAddress);
70
+ }
71
+
72
+ // fetch address information via API and update object
73
+ await updateAddressesActive(addresses);
74
+
75
+ // update balance
76
+ for (const addr of addresses) {
77
+ accountAddresses.totalBalance = accountAddresses.totalBalance.plus(addr.balance);
78
+ }
79
+
80
+ // Check the last GAP_LIMIT addresses for inactivity ( active = false )
81
+ const lastAddressesToCheck = addresses.slice(-GAP_LIMIT);
82
+
83
+ keepScanning = !lastAddressesToCheck.every(addr => !addr.active);
84
+ if (keepScanning) startIndex += SCAN_BATCH_SIZE;
85
+
86
+ updateAddressesData(addresses, accountAddresses, type, keepScanning);
87
+ }
88
+ }
89
+
90
+ const spendableBalance = [
91
+ ...accountAddresses.usedChangeAddresses,
92
+ ...accountAddresses.usedReceiveAddresses,
93
+ ]
94
+ .sort((a, b) => b.balance.minus(a.balance).toNumber())
95
+ .slice(0, MAX_TX_INPUTS)
96
+ .map(utxo => utxo.balance)
97
+ .reduce((acc, v) => acc.plus(v), BigNumber(0));
98
+
99
+ accountAddresses.spendableBalance = spendableBalance;
100
+
101
+ return accountAddresses;
102
+ }
103
+
104
+ /**
105
+ * Updates the addresses data based on the type and current scanning state.
106
+ * If the type is RECEIVE_ADDRESS_TYPE, it updates the used receive addresses and sets the next receive address.
107
+ * If the type is CHANGE_ADDRESS_TYPE, it updates the used change addresses and sets the next change address.
108
+ *
109
+ * @param {AccountAddress[]} addresses - List of account addresses.
110
+ * @param {AccountAddresses} accountAddresses - Object containing used receive and change addresses and the next addresses.
111
+ * @param {number} type - Type of the addresses being updated. It can be either RECEIVE_ADDRESS_TYPE or CHANGE_ADDRESS_TYPE.
112
+ * @param {boolean} keepScanning - Indicates whether to keep scanning for addresses or not.
113
+ * @return {void}
114
+ */
115
+ function updateAddressesData(
116
+ addresses: AccountAddress[],
117
+ accountAddresses: AccountAddresses,
118
+ type: number,
119
+ keepScanning: boolean,
120
+ ): void {
121
+ if (type === RECEIVE_ADDRESS_TYPE) {
122
+ accountAddresses.usedReceiveAddresses.push(...addresses.filter(addr => addr.active));
123
+
124
+ if (!keepScanning) {
125
+ // last used address + 1
126
+ // + 1 has to be available, as there needs to be a GAP!
127
+ accountAddresses.nextReceiveAddress =
128
+ addresses[
129
+ addresses.indexOf(<AccountAddress>accountAddresses.usedReceiveAddresses.at(-1)) + 1
130
+ ];
131
+ }
132
+ }
133
+ // change address
134
+ if (type === CHANGE_ADDRESS_TYPE) {
135
+ accountAddresses.usedChangeAddresses.push(...addresses.filter(addr => addr.active));
136
+
137
+ if (!keepScanning) {
138
+ // last used address + 1
139
+ // + 1 has to be available, as there needs to be a GAP!
140
+ accountAddresses.nextChangeAddress =
141
+ addresses[
142
+ addresses.indexOf(<AccountAddress>accountAddresses.usedChangeAddresses.at(-1)) + 1
143
+ ];
144
+ }
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Updates the provided array of addresses with their respective balances and active status.
150
+ *
151
+ * @param {AccountAddress[]} addresses - An array of account addresses to be updated.
152
+ * @return {Promise<void>} A promise that resolves when the update operation is complete.
153
+ */
154
+ async function updateAddressesActive(addresses: AccountAddress[]) {
155
+ const balances = await getBalancesForAddresses(addresses.map(addr => addr.address));
156
+ const addressesActive = await getAddressesActive(addresses.map(addr => addr.address));
157
+
158
+ for (const addressBalance of balances) {
159
+ const addressIndex = addresses.findIndex(addr => addr.address === addressBalance.address);
160
+ if (addressBalance.balance > 0) {
161
+ addresses[addressIndex].balance = BigNumber(addressBalance.balance);
162
+ addresses[addressIndex].active = true;
163
+ }
164
+ }
165
+
166
+ for (const addressActive of addressesActive) {
167
+ const addressIndex = addresses.findIndex(addr => addr.address === addressActive.address);
168
+ if (addressActive.active) {
169
+ addresses[addressIndex].active = true;
170
+ addresses[addressIndex].timestamp = addressActive.lastTxBlockTime;
171
+ }
172
+ }
173
+ }
@@ -0,0 +1,59 @@
1
+ import { Operation, OperationType } from "@ledgerhq/types-live";
2
+ import { BigNumber } from "bignumber.js";
3
+ import { getAllTransactions } from "./getAllTransactions";
4
+
5
+ export async function scanOperations(
6
+ addresses: string[],
7
+ accountId: string,
8
+ afterValue: number = 1,
9
+ ): Promise<Operation[]> {
10
+ const operations: Operation[] = [];
11
+
12
+ const fetchedTxs = await Promise.all(
13
+ addresses.map(addr => getAllTransactions(addr, afterValue)),
14
+ ).then(results => results.flat());
15
+
16
+ for (const tx of fetchedTxs) {
17
+ const myInputAmount: BigNumber = tx.inputs.reduce((acc: BigNumber, v): BigNumber => {
18
+ if (addresses.includes(v.previous_outpoint_address)) {
19
+ return acc.plus(BigNumber(v.previous_outpoint_amount));
20
+ }
21
+ return acc;
22
+ }, BigNumber(0));
23
+
24
+ const myOutputAmount: BigNumber = tx.outputs.reduce((acc: BigNumber, v) => {
25
+ if (addresses.includes(v.script_public_key_address)) {
26
+ return acc.plus(BigNumber(v.amount));
27
+ }
28
+ return acc;
29
+ }, BigNumber(0));
30
+
31
+ const totalOutputAmount: BigNumber = tx.outputs.reduce(
32
+ (acc: BigNumber, v) => acc.plus(BigNumber(v.amount)),
33
+ BigNumber(0),
34
+ );
35
+ const totalInputAmount: BigNumber = tx.inputs.reduce(
36
+ (acc: BigNumber, v) => acc.plus(BigNumber(v.previous_outpoint_amount)),
37
+ BigNumber(0),
38
+ );
39
+
40
+ const operationType: OperationType = myOutputAmount.gt(myInputAmount) ? "IN" : "OUT";
41
+
42
+ operations.push({
43
+ id: tx.transaction_id,
44
+ hash: tx.transaction_id,
45
+ type: operationType,
46
+ value: myOutputAmount.minus(myInputAmount).absoluteValue(),
47
+ fee: totalInputAmount.minus(totalOutputAmount),
48
+ senders: tx.inputs.map(inp => inp.previous_outpoint_address),
49
+ recipients: tx.outputs.map(output => output.script_public_key_address),
50
+ blockHeight: tx.accepting_block_blue_score,
51
+ blockHash: tx.block_hash[0],
52
+ accountId: accountId,
53
+ date: new Date(tx.block_time),
54
+ extra: {},
55
+ } as Operation);
56
+ }
57
+
58
+ return operations;
59
+ }
@@ -0,0 +1,44 @@
1
+ import { BigNumber } from "bignumber.js";
2
+ import { AccountAddress, AccountAddresses, KaspaUtxo } from "../types";
3
+ import { getUtxosForAddresses } from "../network";
4
+ import { scanAddresses } from "./scanAddresses";
5
+
6
+ export async function scanUtxos(
7
+ compressedPublicKey: Buffer,
8
+ chainCode: Buffer,
9
+ ): Promise<{ utxos: KaspaUtxo[]; accountAddresses: AccountAddresses }> {
10
+ const accountAddresses: AccountAddresses = await scanAddresses(compressedPublicKey, chainCode, 0);
11
+
12
+ const allUsedAddresses = [
13
+ ...accountAddresses.usedReceiveAddresses,
14
+ ...accountAddresses.usedChangeAddresses,
15
+ ];
16
+
17
+ const utxoResponse = await getUtxosForAddresses(allUsedAddresses.map(addrObj => addrObj.address));
18
+
19
+ const kaspaUtxos = utxoResponse.map(utxo => {
20
+ return {
21
+ ...utxo,
22
+ ...getTypeAndIndexFromAccountAddresses(allUsedAddresses, utxo.address),
23
+ };
24
+ });
25
+
26
+ // Convert utxoEntry.amount to BigNumber
27
+ kaspaUtxos.forEach(utxo => {
28
+ utxo.utxoEntry.amount = BigNumber(utxo.utxoEntry.amount);
29
+ });
30
+
31
+ return {
32
+ utxos: kaspaUtxos as KaspaUtxo[],
33
+ accountAddresses: accountAddresses,
34
+ };
35
+ }
36
+
37
+ function getTypeAndIndexFromAccountAddresses(accountAddreses: AccountAddress[], address: string) {
38
+ const foundAddress = accountAddreses.find(addr => addr.address === address);
39
+ if (foundAddress) {
40
+ return { accountType: foundAddress.type, accountIndex: foundAddress.index };
41
+ } else {
42
+ throw new Error(`Address ${address} not found in addresses set.`);
43
+ }
44
+ }
@@ -0,0 +1,78 @@
1
+ import KaspaBIP32 from "../bip32";
2
+
3
+ describe("KaspaBIP32", () => {
4
+ it("should generate the expected addresses", () => {
5
+ // These addresses were generated from the ledger device, whose public key and chain code
6
+ // for 44'/111111'/0' are:
7
+ // public key (compressed): 035a19ab1842af431d3b4fa88a15b1fe7d7c3f6e26e808124a10dc0523352d462d
8
+ // chain code: 0ba599a9c5bad1106065eab47b48efa070f4b31e9639c9d096f7756b248a6ff4
9
+ const testCases = [
10
+ {
11
+ derivationPath: "44'/111111'/0'/0/0",
12
+ address: "kaspa:qzese5lc37m2a9np8k5gect4l2jj8svyqq392p7aa7mxsqarjg9sjgxr4wvru",
13
+ },
14
+ {
15
+ derivationPath: "44'/111111'/0'/0/1",
16
+ address: "kaspa:qqdpnpjcqmzntn4z4y082t5jjvn7rv2wejfy38ljnjvreyg3d7jwv4uj86vlt",
17
+ },
18
+ {
19
+ derivationPath: "44'/111111'/0'/1/0",
20
+ address: "kaspa:qzvqsl48dyhu7wy8jxklwa9n9gwyprq44xsmylnhzxlmhzarfd6vwrrjuekuw",
21
+ },
22
+ {
23
+ derivationPath: "44'/111111'/0'/1/1",
24
+ address: "kaspa:qza444ye2lt384jl4u9jf8kd2pe4m2yr44nq9u5g5ush8qzlskaauh2mk4ezp",
25
+ },
26
+ ];
27
+
28
+ const compressedPublicKey = Buffer.from(
29
+ "035a19ab1842af431d3b4fa88a15b1fe7d7c3f6e26e808124a10dc0523352d462d",
30
+ "hex",
31
+ );
32
+ const chainCode = Buffer.from(
33
+ "0ba599a9c5bad1106065eab47b48efa070f4b31e9639c9d096f7756b248a6ff4",
34
+ "hex",
35
+ );
36
+ const bip32 = new KaspaBIP32(compressedPublicKey, chainCode);
37
+
38
+ for (const testCase of testCases) {
39
+ const path = testCase.derivationPath.split("/");
40
+ expect(bip32.getAddress(Number(path[3]), Number(path[4]))).toBe(testCase.address);
41
+ }
42
+
43
+ expect(bip32.getAddress()).toBe(
44
+ "kaspa:qzese5lc37m2a9np8k5gect4l2jj8svyqq392p7aa7mxsqarjg9sjgxr4wvru",
45
+ );
46
+ });
47
+ it("result from ledger hw device", () => {
48
+ const testCases = [
49
+ {
50
+ derivationPath: "44'/111111'/1'/0/0",
51
+ address: "kaspa:qzcluxxl05wgr8f3aw2rnwy9jt8cfdv0kucyv4hye7g4eswk5ws7y532cnfua",
52
+ },
53
+ {
54
+ derivationPath: "44'/111111'/1'/0/1",
55
+ address: "kaspa:qp6xh8tsgsd7yhkkk3m37rfqcdmmj4k0ca9ewtfm48p9g5uxdjexgq9h0xrjc",
56
+ },
57
+ {
58
+ derivationPath: "44'/111111'/1'/1/1",
59
+ address: "kaspa:qrzw7k2sxahz67kzs2vdmktvmgjc6tx6j8xas7ltx7utg4uyz83ucpf9mv0xz",
60
+ },
61
+ ];
62
+
63
+ const compressedPublicKey = Buffer.from(
64
+ "02bb257a3f0b6bc2104539be649e6f7fe0b42e38c660500598fb1dc833b7ecbb1a",
65
+ "hex",
66
+ );
67
+ const chainCode = Buffer.from(
68
+ "27a38ef4c76455946be71692ee422b1fc40dc30952a8bf1ce961a534476035c8",
69
+ "hex",
70
+ );
71
+ const bip32 = new KaspaBIP32(compressedPublicKey, chainCode);
72
+
73
+ for (const testCase of testCases) {
74
+ const path = testCase.derivationPath.split("/");
75
+ expect(bip32.getAddress(Number(path[3]), Number(path[4]))).toBe(testCase.address);
76
+ }
77
+ });
78
+ });