@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,106 @@
1
+ import {
2
+ getSerializedAddressParameters,
3
+ makeAccountBridgeReceive,
4
+ makeScanAccounts,
5
+ makeSync,
6
+ } from "@ledgerhq/coin-framework/bridge/jsHelpers";
7
+ import { SignerContext } from "@ledgerhq/coin-framework/signer";
8
+ import { AccountBridge, CurrencyBridge, DerivationMode } from "@ledgerhq/types-live";
9
+ import getAddressWrapper, { GetAddressFn } from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
10
+
11
+ import type { KaspaAccount, Transaction, TransactionStatus } from "../types";
12
+ import { KaspaSigner } from "../types";
13
+
14
+ import { estimateMaxSpendable } from "./estimateMaxSpendable";
15
+ import getTransactionStatus from "./getTransactionStatus";
16
+ import { getAccountShape } from "./synchronization";
17
+ import { prepareTransaction } from "./prepareTransaction";
18
+ import { createTransaction } from "./createTransaction";
19
+ import { updateTransaction } from "@ledgerhq/coin-framework/bridge/jsHelpers";
20
+ import { broadcast } from "./broadcast";
21
+ import { initAccount } from "./initAccount";
22
+ import resolver from "../hw-getAddress";
23
+ import { buildSignOperation } from "./signOperation";
24
+ import { Result, runDerivationScheme } from "@ledgerhq/coin-framework/derivation";
25
+ import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
26
+
27
+ function buildCurrencyBridge(signerContext: SignerContext<KaspaSigner>): CurrencyBridge {
28
+ const getAddress = resolver(signerContext);
29
+
30
+ const scanAccounts = makeScanAccounts({
31
+ getAccountShape,
32
+ getAddressFn: getAddressWrapper(getAddress),
33
+ buildIterateResult: kaspaIterateResultBuilder(getAddress),
34
+ });
35
+
36
+ return {
37
+ preload: async () => Promise.resolve({}),
38
+ hydrate: () => {},
39
+ scanAccounts,
40
+ };
41
+ }
42
+
43
+ const kaspaIterateResultBuilder = (getAddressFn: GetAddressFn) => () =>
44
+ Promise.resolve(
45
+ async ({
46
+ index,
47
+ derivationsCache,
48
+ derivationScheme,
49
+ derivationMode,
50
+ currency,
51
+ deviceId,
52
+ }: {
53
+ index: number | string;
54
+ derivationsCache: Record<string, Result>;
55
+ derivationScheme: string;
56
+ derivationMode: DerivationMode;
57
+ currency: CryptoCurrency;
58
+ deviceId: string;
59
+ }): Promise<Result | null> => {
60
+ const accountPath = derivationScheme.split("/").slice(0, 3).join("/");
61
+ const freshAddressPath = runDerivationScheme(accountPath, currency, {
62
+ account: index,
63
+ });
64
+ let res = derivationsCache[freshAddressPath];
65
+ if (!res) {
66
+ res = await getAddressWrapper(getAddressFn)(deviceId, {
67
+ currency,
68
+ path: freshAddressPath,
69
+ derivationMode,
70
+ });
71
+ derivationsCache[freshAddressPath] = res;
72
+ }
73
+ return res as Result;
74
+ },
75
+ );
76
+
77
+ function buildAccountBridge(
78
+ signerContext: SignerContext<KaspaSigner>,
79
+ ): AccountBridge<Transaction, KaspaAccount, TransactionStatus> {
80
+ const getAddress = resolver(signerContext);
81
+
82
+ const sync = makeSync({ getAccountShape });
83
+ const receive = makeAccountBridgeReceive(getAddressWrapper(getAddress));
84
+ const signOperation = buildSignOperation(signerContext);
85
+
86
+ return {
87
+ getSerializedAddressParameters,
88
+ createTransaction,
89
+ updateTransaction,
90
+ prepareTransaction,
91
+ getTransactionStatus,
92
+ sync,
93
+ receive,
94
+ initAccount,
95
+ signOperation,
96
+ broadcast,
97
+ estimateMaxSpendable,
98
+ };
99
+ }
100
+
101
+ export function createBridges(signerContext: SignerContext<KaspaSigner>) {
102
+ return {
103
+ currencyBridge: buildCurrencyBridge(signerContext),
104
+ accountBridge: buildAccountBridge(signerContext),
105
+ };
106
+ }
@@ -0,0 +1 @@
1
+ export function initAccount(): void {}
@@ -0,0 +1,48 @@
1
+ import { ApiResponseFeeEstimate, KaspaAccount, Transaction } from "../types";
2
+ import { getFeeEstimate } from "../network";
3
+ import BigNumber from "bignumber.js";
4
+
5
+ /**
6
+ * Prepares a transaction by calculating and setting its fee based on the specified fee strategy.
7
+ *
8
+ * @param {KaspaAccount} account - The account for which the transaction is being prepared.
9
+ * @param {Transaction} transaction - The transaction object that needs to be prepared.
10
+ *
11
+ * @returns {Promise<Transaction>} The prepared transaction with the appropriate fees set.
12
+ *
13
+ * @throws Will throw an error if the fee strategy type is unknown.
14
+ */
15
+ export const prepareTransaction = async (account: KaspaAccount, transaction: Transaction) => {
16
+ const fees: ApiResponseFeeEstimate = await getFeeEstimate();
17
+
18
+ transaction.networkInfo = [
19
+ {
20
+ label: "slow",
21
+ amount: BigNumber(fees.lowBuckets[0]?.feerate || 1),
22
+ estimatedSeconds: fees.lowBuckets[0]?.estimatedSeconds,
23
+ },
24
+ {
25
+ label: "medium",
26
+ amount: BigNumber(fees.normalBuckets[0]?.feerate || 1),
27
+ estimatedSeconds: fees.normalBuckets[0]?.estimatedSeconds,
28
+ },
29
+ {
30
+ label: "fast",
31
+ amount: BigNumber(fees.priorityBucket.feerate),
32
+ estimatedSeconds: fees.priorityBucket.estimatedSeconds,
33
+ },
34
+ ];
35
+
36
+ if (
37
+ transaction.networkInfo.every(
38
+ info => info.estimatedSeconds === transaction.networkInfo[0].estimatedSeconds,
39
+ ) &&
40
+ transaction.feesStrategy !== "custom"
41
+ ) {
42
+ transaction.feesStrategy = "fast";
43
+ }
44
+
45
+ return transaction;
46
+ };
47
+
48
+ export default prepareTransaction;
@@ -0,0 +1,43 @@
1
+ import { Observable } from "rxjs";
2
+ import type { AccountBridge, SignOperationEvent } from "@ledgerhq/types-live";
3
+
4
+ import { buildTransaction } from "./buildTransaction";
5
+ import { KaspaAccount, KaspaSigner, Transaction } from "../types";
6
+ import { SignerContext } from "@ledgerhq/coin-framework/signer";
7
+ import buildInitialOperation from "./buildInitialOperation";
8
+
9
+ /**
10
+ * Sign Transaction with Ledger hardware
11
+ */
12
+ export const buildSignOperation =
13
+ (
14
+ signerContext: SignerContext<KaspaSigner>,
15
+ ): AccountBridge<Transaction, KaspaAccount>["signOperation"] =>
16
+ ({ account, deviceId, transaction }): Observable<SignOperationEvent> =>
17
+ new Observable(o => {
18
+ async function main() {
19
+ o.next({
20
+ type: "device-signature-requested",
21
+ });
22
+
23
+ const tx = await buildTransaction(account, transaction);
24
+
25
+ // Sign by device
26
+ await signerContext(deviceId, signer => signer.signTransaction(tx));
27
+
28
+ o.next({ type: "device-signature-granted" });
29
+ const operation = buildInitialOperation(account, tx);
30
+ o.next({
31
+ type: "signed",
32
+ signedOperation: {
33
+ operation,
34
+ signature: JSON.stringify(tx.toApiJSON()),
35
+ },
36
+ });
37
+ }
38
+
39
+ main().then(
40
+ () => o.complete(),
41
+ e => o.error(e),
42
+ );
43
+ });
@@ -0,0 +1,80 @@
1
+ import { decodeAccountId, encodeAccountId } from "@ledgerhq/coin-framework/account/index";
2
+ import { GetAccountShape, mergeOps } from "@ledgerhq/coin-framework/bridge/jsHelpers";
3
+ import { AccountAddresses, KaspaAccount } from "../types";
4
+ import { Operation } from "@ledgerhq/types-live";
5
+ import { parseExtendedPublicKey, scanAddresses, scanOperations } from "../logic";
6
+ import { getBlockDagInfo, getVirtualChainBlueScore } from "../network";
7
+
8
+ export const getAccountShape: GetAccountShape<KaspaAccount> = async info => {
9
+ const { initialAccount, index, rest } = info;
10
+
11
+ const xpub =
12
+ rest?.publicKey || (initialAccount && decodeAccountId(initialAccount.id).xpubOrAddress);
13
+
14
+ // // Needed for incremental synchronisation
15
+ const accountId = encodeAccountId({
16
+ type: "js",
17
+ version: "2",
18
+ currencyId: "kaspa",
19
+ xpubOrAddress: xpub,
20
+ derivationMode: "",
21
+ });
22
+
23
+ const { compressedPublicKey, chainCode } = parseExtendedPublicKey(Buffer.from(xpub, "hex"));
24
+
25
+ const accountAddresses: AccountAddresses = await scanAddresses(compressedPublicKey, chainCode, 0);
26
+
27
+ const oldOperations = initialAccount?.operations || [];
28
+
29
+ // Fetch new operations
30
+ // Timestamp with 60s buffer to make sure there's no gap
31
+ let scanOperationsAfter: number = 1; // begin with after=1 for correct TX fetching
32
+ if (initialAccount?.lastSyncTimestamp) {
33
+ // as older blocks with valid transactions can be added into the BlockDAG up to an hour later,
34
+ // we have to set the rescan timestamp to around 2 hours earlier than the last tip's timestamp.
35
+ scanOperationsAfter = initialAccount.lastSyncTimestamp - 60 * 60 * 2 * 1000; // milliseconds timestamp
36
+ scanOperationsAfter = Math.max(scanOperationsAfter, 1); // actually it can't really be lower than 1.
37
+ }
38
+
39
+ const usedAddresses: string[] = [
40
+ ...accountAddresses.usedReceiveAddresses
41
+ .filter(addr => addr.timestamp! > scanOperationsAfter)
42
+ .map(addr => addr.address),
43
+ ...accountAddresses.usedChangeAddresses
44
+ .filter(addr => addr.timestamp! > scanOperationsAfter)
45
+ .map(addr => addr.address),
46
+ ];
47
+
48
+ const allOperations: Operation[] = await scanOperations(
49
+ usedAddresses,
50
+ accountId,
51
+ scanOperationsAfter,
52
+ );
53
+ const operations = mergeOps(oldOperations, allOperations);
54
+
55
+ const activeAddressCount: number =
56
+ accountAddresses.usedReceiveAddresses.filter(address => address.balance.gt(0)).length +
57
+ accountAddresses.usedChangeAddresses.filter(address => address.balance.gt(0)).length;
58
+
59
+ return {
60
+ id: accountId,
61
+ xpub: xpub,
62
+ lastSyncTimestamp: Number.parseInt((await getBlockDagInfo()).pastMedianTime || "1"),
63
+ index,
64
+ blockHeight: await getVirtualChainBlueScore(),
65
+ balance: accountAddresses.totalBalance,
66
+ spendableBalance: accountAddresses.spendableBalance,
67
+ operations,
68
+ operationsCount: operations.length,
69
+ nextChangeAddressIndex: accountAddresses.nextChangeAddress.index,
70
+ nextChangeAddressType: accountAddresses.nextChangeAddress.type,
71
+ nextChangeAddress: accountAddresses.nextChangeAddress.address,
72
+ nextReceiveAddressIndex: accountAddresses.nextReceiveAddress.index,
73
+ nextReceiveAddressType: accountAddresses.nextReceiveAddress.type,
74
+ nextReceiveAddress: accountAddresses.nextReceiveAddress.address,
75
+ activeAddressCount: activeAddressCount,
76
+ freshAddress: accountAddresses.nextReceiveAddress.address,
77
+ freshAddressPath: `44'/111111'/${index}'/${accountAddresses.nextReceiveAddress.type}/${accountAddresses.nextReceiveAddress.index}`,
78
+ used: operations.length > 0,
79
+ };
80
+ };
package/src/config.ts ADDED
@@ -0,0 +1,7 @@
1
+ import buildConConfig, { type CurrencyConfig } from "@ledgerhq/coin-framework/config";
2
+
3
+ export type KaspaCoinConfig = CurrencyConfig;
4
+
5
+ const coinConfig = buildConConfig<KaspaCoinConfig>();
6
+
7
+ export default coinConfig;
@@ -0,0 +1,44 @@
1
+ import type { Account, AccountLike } from "@ledgerhq/types-live";
2
+ import type { Transaction, TransactionStatus } from "./types";
3
+ import type { CommonDeviceTransactionField as DeviceTransactionField } from "@ledgerhq/coin-framework/transaction/common";
4
+
5
+ function getDeviceTransactionConfig({
6
+ transaction,
7
+ status: { estimatedFees },
8
+ }: {
9
+ account: AccountLike;
10
+ parentAccount?: Account;
11
+ transaction: Transaction;
12
+ status: TransactionStatus;
13
+ }): Array<DeviceTransactionField> {
14
+ const fields: Array<DeviceTransactionField> = [];
15
+
16
+ if (transaction.useAllAmount) {
17
+ fields.push({
18
+ type: "text",
19
+ label: "Method",
20
+ value: "Transfer All",
21
+ });
22
+ } else {
23
+ fields.push({
24
+ type: "text",
25
+ label: "Method",
26
+ value: "Transfer",
27
+ });
28
+ fields.push({
29
+ type: "amount",
30
+ label: "Amount",
31
+ });
32
+ }
33
+
34
+ if (!estimatedFees.isZero()) {
35
+ fields.push({
36
+ type: "fees",
37
+ label: "Fees",
38
+ });
39
+ }
40
+
41
+ return fields;
42
+ }
43
+
44
+ export default getDeviceTransactionConfig;
package/src/errors.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { createCustomErrorClass } from "@ledgerhq/errors";
2
+
3
+ export const UnsupportedDerivation = createCustomErrorClass("UnsupportedDerivation");
4
+
5
+ /** When a coin-module has no CoinConfig setted */
6
+ export const MissingCoinConfig = createCustomErrorClass("MissingCoinConfig");
@@ -0,0 +1,17 @@
1
+ import { GetAddressFn } from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
2
+ import { SignerContext } from "@ledgerhq/coin-framework/signer";
3
+ import { GetAddressOptions } from "@ledgerhq/coin-framework/derivation";
4
+ import { KaspaSigner } from "./types";
5
+
6
+ const resolver = (signerContext: SignerContext<KaspaSigner>): GetAddressFn => {
7
+ return async (deviceId: string, { path, verify }: GetAddressOptions) => {
8
+ const r = await signerContext(deviceId, signer => signer.getAddress(path, verify || false));
9
+ return {
10
+ address: r.address,
11
+ publicKey: r.publicKey,
12
+ path,
13
+ };
14
+ };
15
+ };
16
+
17
+ export default resolver;
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./types";
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ /***
3
+ * https://github.com/bitcoincashjs/cashaddr
4
+ * Copyright (c) 2018 Matias Alejo Garcia
5
+ * Copyright (c) 2017 Emilio Almansi
6
+ * Distributed under the MIT software license, see the accompanying
7
+ * file LICENSE or http://www.opensource.org/licenses/mit-license.php.
8
+ */
9
+
10
+ /***
11
+ * Charset containing the 32 symbols used in the base32 encoding.
12
+ */
13
+ export const CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
14
+
15
+ /***
16
+ * Inverted index mapping each symbol into its index within the charset.
17
+ */
18
+ const CHARSET_INVERSE_INDEX = {
19
+ q: 0,
20
+ p: 1,
21
+ z: 2,
22
+ r: 3,
23
+ y: 4,
24
+ 9: 5,
25
+ x: 6,
26
+ 8: 7,
27
+ g: 8,
28
+ f: 9,
29
+ 2: 10,
30
+ t: 11,
31
+ v: 12,
32
+ d: 13,
33
+ w: 14,
34
+ 0: 15,
35
+ s: 16,
36
+ 3: 17,
37
+ j: 18,
38
+ n: 19,
39
+ 5: 20,
40
+ 4: 21,
41
+ k: 22,
42
+ h: 23,
43
+ c: 24,
44
+ e: 25,
45
+ 6: 26,
46
+ m: 27,
47
+ u: 28,
48
+ a: 29,
49
+ 7: 30,
50
+ l: 31,
51
+ };
52
+
53
+ /***
54
+ * Encodes the given array of 5-bit integers as a base32-encoded string.
55
+ *
56
+ * @param {Array} data Array of integers between 0 and 31 inclusive.
57
+ */
58
+ export function encode(data: number[]) {
59
+ if (!(data instanceof Array)) {
60
+ throw new Error("Must be Array");
61
+ }
62
+ let base32 = "";
63
+ for (let i = 0; i < data.length; i++) {
64
+ const value = data[i];
65
+ if (!(0 <= value && value < 32)) {
66
+ throw new Error("value " + value);
67
+ }
68
+ base32 += CHARSET[value];
69
+ }
70
+ return base32;
71
+ }
72
+
73
+ /***
74
+ * Decodes the given base32-encoded string into an array of 5-bit integers.
75
+ *
76
+ * @param {string} base32
77
+ */
78
+ export function decode(base32: string) {
79
+ if (typeof base32 !== "string") {
80
+ throw new Error("Must be base32-encoded string");
81
+ }
82
+ const data = [];
83
+ for (let i = 0; i < base32.length; i++) {
84
+ const value = base32[i];
85
+ if (!(value in CHARSET_INVERSE_INDEX)) {
86
+ throw new Error("value " + value);
87
+ }
88
+ // @ts-expect-error: ignore array of any
89
+ data.push(CHARSET_INVERSE_INDEX[value]);
90
+ }
91
+ return data;
92
+ }
93
+
94
+ const base32 = {
95
+ encode,
96
+ decode,
97
+ CHARSET,
98
+ };
99
+
100
+ export default base32;
@@ -0,0 +1,21 @@
1
+ import ecc from "@bitcoinerlab/secp256k1";
2
+ import BIP32Factory, { BIP32API, BIP32Interface } from "bip32";
3
+ import { publicKeyToAddress } from "./kaspaAddresses";
4
+
5
+ const bip32: BIP32API = BIP32Factory(ecc);
6
+
7
+ export default class KaspaBIP32 {
8
+ rootNode: BIP32Interface;
9
+
10
+ constructor(compressedPublicKey: Buffer, chainCode: Buffer) {
11
+ this.rootNode = bip32.fromPublicKey(compressedPublicKey, chainCode);
12
+ }
13
+
14
+ getAddress(type: number = 0, index: number = 0) {
15
+ const child = this.rootNode.derivePath(`${type}/${index}`);
16
+
17
+ // child.publicKey is a compressed public key
18
+ const publicKeyBuffer: Buffer = Buffer.from(child.publicKey.subarray(1, 33));
19
+ return publicKeyToAddress(publicKeyBuffer, false);
20
+ }
21
+ }
@@ -0,0 +1,22 @@
1
+ import { getTransactions } from "../network";
2
+ import { ApiResponseTransaction } from "../types";
3
+
4
+ export const getAllTransactions = async (
5
+ addr: string,
6
+ afterValue: number,
7
+ ): Promise<ApiResponseTransaction[]> => {
8
+ if (afterValue === 0) {
9
+ afterValue = 1;
10
+ }
11
+
12
+ let allTransactions: ApiResponseTransaction[] = [];
13
+
14
+ let nextPageAfter: string | null = afterValue.toString();
15
+ while (nextPageAfter) {
16
+ const response = await getTransactions(addr, parseInt(nextPageAfter));
17
+ allTransactions = allTransactions.concat(response.transactions);
18
+ nextPageAfter = response.nextPageAfter;
19
+ }
20
+
21
+ return allTransactions;
22
+ };
@@ -0,0 +1,20 @@
1
+ import { Transaction } from "../types";
2
+ import { BigNumber } from "bignumber.js";
3
+
4
+ export const getFeeRate = (transaction: Transaction | null | undefined): BigNumber => {
5
+ if (!transaction) {
6
+ return BigNumber(0);
7
+ }
8
+ if (transaction.feesStrategy === "custom") {
9
+ return transaction.customFeeRate || BigNumber(0);
10
+ }
11
+ const filteredNetworkInfo = transaction.networkInfo.filter(
12
+ ni => ni.label === transaction.feesStrategy,
13
+ );
14
+
15
+ if (filteredNetworkInfo.length === 0) {
16
+ throw new Error("Invalid fee strategy provided");
17
+ }
18
+
19
+ return filteredNetworkInfo[0].amount;
20
+ };
@@ -0,0 +1,10 @@
1
+ export * from "./scanAddresses";
2
+ export * from "./scanUtxos";
3
+ export * from "./scanOperations";
4
+ export * from "./kaspaAddresses";
5
+ export * from "./massCalcluation";
6
+ export * from "./base32";
7
+ export * from "./bip32";
8
+ export * from "./utxos/lib";
9
+ export * from "./utxos/selection";
10
+ export * from "./getFeeRate";