@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,47 @@
1
+ import { CurrenciesData, DatasetTest } from "@ledgerhq/types-live";
2
+ import { Transaction } from "../types";
3
+
4
+ const kaspa: CurrenciesData<Transaction> = {
5
+ scanAccounts: [
6
+ {
7
+ name: "kaspa seed 1",
8
+ apdus: `
9
+ => e00500000d038000002c8001b20780000000
10
+ <= 41049d8002c08041d975ab58491c09cf8ced7b388a114ab2f5df73f2534d4d74d17ab8913b3cb3056bad63141cb63fb92e44401b691dee069dbdb2119861c18cc01b204340fcc305ab72e752cd347f4b6271ffe21da098d4f2a4749826857dda7a55769000
11
+ => e00500000d038000002c8001b20780000001
12
+ <= 4104751b5ebd4a9d2a0a25d5c37cab4814a95335b8945cfcaa6a4138de418f581bb1d0d02f22081b3cda223a51e18a63ebdffd64803e0988b68a91802738a5a9f901206d4a2b989a82b5fb160f0151ea5d046451a291a0748f3038ecdc63d637cce00b9000
13
+ `,
14
+ },
15
+ ],
16
+ accounts: [
17
+ {
18
+ FIXME_tests: ["pendingOperations are cleaned up"],
19
+ raw: {
20
+ id: "js:2:kaspa:41049d8002c08041d975ab58491c09cf8ced7b388a114ab2f5df73f2534d4d74d17ab8913b3cb3056bad63141cb63fb92e44401b691dee069dbdb2119861c18cc01b204340fcc305ab72e752cd347f4b6271ffe21da098d4f2a4749826857dda7a5576:",
21
+ seedIdentifier:
22
+ "41049d8002c08041d975ab58491c09cf8ced7b388a114ab2f5df73f2534d4d74d17ab8913b3cb3056bad63141cb63fb92e44401b691dee069dbdb2119861c18cc01b204340fcc305ab72e752cd347f4b6271ffe21da098d4f2a4749826857dda7a5576",
23
+ derivationMode: "",
24
+ currencyId: "kaspa",
25
+ pendingOperations: [],
26
+ xpub: "41049d8002c08041d975ab58491c09cf8ced7b388a114ab2f5df73f2534d4d74d17ab8913b3cb3056bad63141cb63fb92e44401b691dee069dbdb2119861c18cc01b204340fcc305ab72e752cd347f4b6271ffe21da098d4f2a4749826857dda7a5576",
27
+ lastSyncDate: "",
28
+ index: 0,
29
+ blockHeight: 194187965,
30
+ balance: "13370000",
31
+ spendableBalance: "13370000",
32
+ operations: [],
33
+ operationsCount: 1,
34
+ freshAddress: "kaspa:qz49rpg0q6ywewxkwl76757ya79v6j556hcmrcy7mk9d36ewgp80cdrwlct2h",
35
+ freshAddressPath: "44'/111111'/0'/0/1",
36
+ used: true,
37
+ },
38
+ },
39
+ ],
40
+ };
41
+
42
+ export const dataset: DatasetTest<Transaction> = {
43
+ implementations: ["js"],
44
+ currencies: {
45
+ kaspa,
46
+ },
47
+ };
@@ -0,0 +1,33 @@
1
+ import flatMap from "lodash/flatMap";
2
+ import type { AccountLike } from "@ledgerhq/types-live";
3
+ import { Transaction } from "../types/bridge";
4
+
5
+ const options = [
6
+ {
7
+ name: "mode",
8
+ type: String,
9
+ desc: "mode of transaction: send",
10
+ },
11
+ ];
12
+
13
+ function inferTransactions(
14
+ transactions: Array<{ account: AccountLike; transaction: Transaction }>,
15
+ opts: Record<string, any>,
16
+ ): Transaction[] {
17
+ return flatMap(transactions, ({ transaction }) => {
18
+ if (transaction.family !== "kaspa") {
19
+ throw new Error("transaction is not of type Kaspa");
20
+ }
21
+
22
+ return {
23
+ ...transaction,
24
+ family: "kaspa",
25
+ mode: opts.mode || "send",
26
+ };
27
+ });
28
+ }
29
+
30
+ export default {
31
+ options,
32
+ inferTransactions,
33
+ };
@@ -0,0 +1 @@
1
+ export * from "./bridgeDatasetTest";
@@ -0,0 +1,84 @@
1
+ import { KaspaAccount, Transaction, TransactionRaw, TransactionStatus } from "./types";
2
+
3
+ import {
4
+ fromTransactionCommonRaw,
5
+ fromTransactionStatusRawCommon as fromTransactionStatusRaw,
6
+ toTransactionCommonRaw,
7
+ toTransactionStatusRawCommon as toTransactionStatusRaw,
8
+ } from "@ledgerhq/coin-framework/serialization";
9
+
10
+ import { getAccountCurrency } from "@ledgerhq/coin-framework/account/index";
11
+ import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies/index";
12
+ import type { Account } from "@ledgerhq/types-live";
13
+ import { formatTransactionStatus as formatTransactionStatusCommon } from "@ledgerhq/coin-framework/formatters";
14
+ import { BigNumber } from "bignumber.js";
15
+
16
+ export const formatTransactionStatus = (
17
+ t: Transaction,
18
+ ts: TransactionStatus,
19
+ mainAccount: KaspaAccount,
20
+ ): string => {
21
+ let str = "";
22
+
23
+ str += formatTransactionStatusCommon(t, ts, mainAccount);
24
+
25
+ return str;
26
+ };
27
+
28
+ export const formatTransaction = (
29
+ { amount, recipient, useAllAmount, subAccountId }: Transaction,
30
+ mainAccount: Account,
31
+ ): string => {
32
+ const account =
33
+ (subAccountId && (mainAccount.subAccounts || []).find(a => a.id === subAccountId)) ||
34
+ mainAccount;
35
+ return `
36
+ ${
37
+ useAllAmount
38
+ ? "MAX"
39
+ : amount.isZero()
40
+ ? ""
41
+ : " " +
42
+ formatCurrencyUnit(getAccountCurrency(account).units[0], amount, {
43
+ showCode: true,
44
+ disableRounding: true,
45
+ })
46
+ }${recipient ? `\nTO ${recipient}` : ""}`;
47
+ };
48
+
49
+ export const fromTransactionRaw = (tr: TransactionRaw): Transaction => {
50
+ const common = fromTransactionCommonRaw(tr);
51
+ return {
52
+ ...common,
53
+ family: tr.family,
54
+ networkInfo: tr.networkInfo.map(x => ({
55
+ ...x,
56
+ amount: BigNumber(x.amount),
57
+ })),
58
+ feesStrategy: tr.feesStrategy,
59
+ customFeeRate: tr.customFeeRate ? BigNumber(tr.customFeeRate) : undefined,
60
+ };
61
+ };
62
+
63
+ export const toTransactionRaw = (t: Transaction): TransactionRaw => {
64
+ const common = toTransactionCommonRaw(t);
65
+ return {
66
+ ...common,
67
+ family: t.family,
68
+ networkInfo: t.networkInfo.map(x => ({
69
+ ...x,
70
+ amount: x.amount.toString(),
71
+ })),
72
+ feesStrategy: t.feesStrategy,
73
+ customFeeRate: t.customFeeRate?.toString(),
74
+ };
75
+ };
76
+
77
+ export default {
78
+ formatTransaction,
79
+ fromTransactionRaw,
80
+ toTransactionRaw,
81
+ fromTransactionStatusRaw,
82
+ toTransactionStatusRaw,
83
+ formatTransactionStatus,
84
+ };
@@ -0,0 +1,19 @@
1
+ import { BigNumber } from "bignumber.js";
2
+
3
+ export type AccountAddress = {
4
+ type: number;
5
+ index: number;
6
+ address: string;
7
+ balance: BigNumber;
8
+ active: boolean;
9
+ timestamp: number | null;
10
+ };
11
+
12
+ export type AccountAddresses = {
13
+ usedReceiveAddresses: AccountAddress[];
14
+ usedChangeAddresses: AccountAddress[];
15
+ nextChangeAddress: AccountAddress;
16
+ nextReceiveAddress: AccountAddress;
17
+ totalBalance: BigNumber;
18
+ spendableBalance: BigNumber;
19
+ };
@@ -0,0 +1,43 @@
1
+ import type {
2
+ Account,
3
+ TransactionCommon,
4
+ TransactionCommonRaw,
5
+ TransactionStatusCommon,
6
+ TransactionStatusCommonRaw,
7
+ } from "@ledgerhq/types-live";
8
+ import { BigNumber } from "bignumber.js";
9
+
10
+ export type KaspaAccount = Account & {
11
+ xpub: string;
12
+ lastSyncTimestamp: number;
13
+ activeAddressCount: number; // good to approximate the fee
14
+ nextChangeAddress: string;
15
+ nextChangeAddressType: number;
16
+ nextChangeAddressIndex: number;
17
+ nextReceiveAddress: string;
18
+ nextReceiveAddressType: number;
19
+ nextReceiveAddressIndex: number;
20
+ };
21
+
22
+ export type Transaction = TransactionCommon & {
23
+ family: "kaspa";
24
+ networkInfo: {
25
+ label: string;
26
+ amount: BigNumber;
27
+ estimatedSeconds: number;
28
+ }[];
29
+ customFeeRate?: BigNumber | undefined;
30
+ };
31
+
32
+ export type TransactionRaw = TransactionCommonRaw & {
33
+ family: "kaspa";
34
+ networkInfo: {
35
+ label: string;
36
+ amount: string;
37
+ estimatedSeconds: number;
38
+ }[];
39
+ customFeeRate?: string | undefined;
40
+ };
41
+
42
+ export type TransactionStatus = TransactionStatusCommon;
43
+ export type TransactionStatusRaw = TransactionStatusCommonRaw;
@@ -0,0 +1,7 @@
1
+ import { createCustomErrorClass } from "@ledgerhq/errors";
2
+
3
+ export const NotEnoughFeeError = createCustomErrorClass("NotEnoughFeeError");
4
+
5
+ export const TransactionMassExceededError = createCustomErrorClass("TransactionMassExceededError");
6
+
7
+ export const EmptyRecipientError = createCustomErrorClass("EmptyRecipientError");
@@ -0,0 +1,7 @@
1
+ export type * from "./bridge";
2
+ export type * from "./errors";
3
+ export type * from "./kaspaNetwork";
4
+ export type * from "./network";
5
+ export type * from "./addresses";
6
+ export * from "./kaspaHwTransaction";
7
+ export type * from "./signer";
@@ -0,0 +1,234 @@
1
+ type TransactionApiJSON = {
2
+ transaction: {
3
+ version: number;
4
+ inputs: TransactionInputApiJSON[];
5
+ outputs: TransactionOutputApiJSON[];
6
+ lockTime: number;
7
+ subnetworkId: string;
8
+ };
9
+ };
10
+
11
+ export class KaspaHwTransaction {
12
+ inputs: KaspaHwTransactionInput[];
13
+ outputs: KaspaHwTransactionOutput[];
14
+ version: number;
15
+ changeAddressType: number;
16
+ changeAddressIndex: number;
17
+ account: number;
18
+ fee: number;
19
+
20
+ constructor(txData: {
21
+ inputs: KaspaHwTransactionInput[];
22
+ outputs: KaspaHwTransactionOutput[];
23
+ version: number;
24
+ fee?: number;
25
+ changeAddressType?: number;
26
+ changeAddressIndex?: number;
27
+ account?: number;
28
+ }) {
29
+ /**
30
+ * @type {TransactionInput[]}
31
+ */
32
+ this.inputs = txData.inputs;
33
+ /**
34
+ * @type {TransactionOutput[]}
35
+ */
36
+ this.outputs = txData.outputs;
37
+ /**
38
+ * @type {int}
39
+ */
40
+ this.version = txData.version;
41
+
42
+ this.changeAddressType = txData.changeAddressType ?? 0;
43
+ this.changeAddressIndex = txData.changeAddressIndex ?? 0;
44
+ this.account = txData.account ?? 0x80000000;
45
+ this.fee = txData.fee || 0;
46
+
47
+ if (!(this.changeAddressType === 0 || this.changeAddressType === 1)) {
48
+ throw new Error(`changeAddressType must be 0 or 1 if set`);
49
+ }
50
+
51
+ if (this.account < 0x80000000 || this.account > 0xffffffff) {
52
+ throw new Error("account must be between 0x80000000 and 0xFFFFFFFF");
53
+ }
54
+
55
+ if (this.changeAddressIndex < 0x00000000 || this.changeAddressIndex > 0xffffffff) {
56
+ throw new Error(`changeAddressIndex must be between 0x00000000 and 0xFFFFFFFF`);
57
+ }
58
+ }
59
+
60
+ serialize(): Buffer {
61
+ const versionBuf = Buffer.alloc(2);
62
+ versionBuf.writeUInt16BE(this.version);
63
+
64
+ const outputLenBuf = Buffer.alloc(1);
65
+ outputLenBuf.writeUInt8(this.outputs.length);
66
+
67
+ const inputLenBuf = Buffer.alloc(1);
68
+ inputLenBuf.writeUInt8(this.inputs.length);
69
+
70
+ const changeAddressTypeBuf = Buffer.alloc(1);
71
+ changeAddressTypeBuf.writeUInt8(this.changeAddressType);
72
+
73
+ const changeAddressIndexBuf = Buffer.alloc(4);
74
+ changeAddressIndexBuf.writeUInt32BE(this.changeAddressIndex);
75
+
76
+ const accountBuf = Buffer.alloc(4);
77
+ accountBuf.writeUInt32BE(this.account);
78
+
79
+ return Buffer.concat([
80
+ versionBuf,
81
+ outputLenBuf,
82
+ inputLenBuf,
83
+ changeAddressTypeBuf,
84
+ changeAddressIndexBuf,
85
+ accountBuf,
86
+ ]);
87
+ }
88
+
89
+ /**
90
+ * Convert this transaction to a JSON object that api.kaspa.org will accept
91
+ */
92
+ toApiJSON(): TransactionApiJSON {
93
+ return {
94
+ transaction: {
95
+ version: this.version,
96
+ inputs: this.inputs.map(i => i.toApiJSON()),
97
+ outputs: this.outputs.map(o => o.toApiJSON()),
98
+ lockTime: 0,
99
+ subnetworkId: "0000000000000000000000000000000000000000",
100
+ },
101
+ };
102
+ }
103
+ }
104
+
105
+ type TransactionInputApiJSON = {
106
+ previousOutpoint: {
107
+ transactionId: string;
108
+ index: number;
109
+ };
110
+ signatureScript: string | null;
111
+ sequence: number;
112
+ sigOpCount: number;
113
+ };
114
+
115
+ export class KaspaHwTransactionInput {
116
+ signature?: string | null;
117
+ sighash?: string | null;
118
+ value: number;
119
+ prevTxId: string;
120
+ outpointIndex: number;
121
+ addressType: number;
122
+ addressIndex: number;
123
+ address: string;
124
+
125
+ constructor(inputData: {
126
+ value: number;
127
+ prevTxId: string;
128
+ outpointIndex: number;
129
+ addressType: number;
130
+ addressIndex: number;
131
+ address: string;
132
+ }) {
133
+ this.value = inputData.value;
134
+ this.prevTxId = inputData.prevTxId;
135
+ this.outpointIndex = inputData.outpointIndex;
136
+ this.addressType = inputData.addressType;
137
+ this.addressIndex = inputData.addressIndex;
138
+ this.signature = null;
139
+ this.sighash = null;
140
+ this.address = inputData.address;
141
+ }
142
+
143
+ serialize(): Buffer {
144
+ const valueBuf = Buffer.from(toBigEndianHex(this.value), "hex");
145
+
146
+ const addressTypeBuf = Buffer.alloc(1);
147
+ addressTypeBuf.writeUInt8(this.addressType);
148
+
149
+ const addressIndexBuf = Buffer.alloc(4);
150
+ addressIndexBuf.writeUInt32BE(this.addressIndex);
151
+
152
+ const outpointIndexBuf = Buffer.alloc(1);
153
+ outpointIndexBuf.writeUInt8(this.outpointIndex);
154
+
155
+ return Buffer.concat([
156
+ valueBuf,
157
+ Buffer.from(this.prevTxId, "hex"),
158
+ addressTypeBuf,
159
+ addressIndexBuf,
160
+ outpointIndexBuf,
161
+ ]);
162
+ }
163
+
164
+ /**
165
+ *
166
+ * @param {string} signature
167
+ */
168
+ setSignature(signature: string): void {
169
+ this.signature = signature;
170
+ }
171
+
172
+ setSighash(sighash: string): void {
173
+ this.sighash = sighash;
174
+ }
175
+
176
+ toApiJSON(): TransactionInputApiJSON {
177
+ return {
178
+ previousOutpoint: {
179
+ transactionId: this.prevTxId,
180
+ index: this.outpointIndex,
181
+ },
182
+ signatureScript: this.signature ? `41${this.signature}01` : null,
183
+ sequence: 0,
184
+ sigOpCount: 1,
185
+ };
186
+ }
187
+ }
188
+
189
+ type TransactionOutputApiJSON = {
190
+ amount: number;
191
+ scriptPublicKey: {
192
+ version: number;
193
+ scriptPublicKey: string;
194
+ };
195
+ };
196
+
197
+ export class KaspaHwTransactionOutput {
198
+ value: number;
199
+ scriptPublicKey: string;
200
+
201
+ constructor(outputData: { value: number; scriptPublicKey: string }) {
202
+ if (!outputData.value || outputData.value < 0 || outputData.value > 0xffffffffffffffffn) {
203
+ throw new Error(
204
+ "value must be set to a value greater than 0 and less than 0xFFFFFFFFFFFFFFFF",
205
+ );
206
+ }
207
+ this.value = outputData.value;
208
+
209
+ // Only then do we care about the script public key
210
+ this.scriptPublicKey = outputData.scriptPublicKey;
211
+ }
212
+
213
+ serialize(): Buffer {
214
+ const valueBuf: Buffer = Buffer.from(toBigEndianHex(this.value), "hex");
215
+ return Buffer.concat([valueBuf, Buffer.from(this.scriptPublicKey, "hex")]);
216
+ }
217
+
218
+ toApiJSON(): TransactionOutputApiJSON {
219
+ return {
220
+ amount: this.value,
221
+ scriptPublicKey: {
222
+ version: 0,
223
+ scriptPublicKey: this.scriptPublicKey,
224
+ },
225
+ };
226
+ }
227
+ }
228
+
229
+ export function toBigEndianHex(numberToConvert: number) {
230
+ let baseStr = "0000000000000000";
231
+ baseStr += numberToConvert.toString(16);
232
+
233
+ return baseStr.substring(baseStr.length - 16, baseStr.length);
234
+ }
@@ -0,0 +1,21 @@
1
+ import type { BigNumber } from "bignumber.js";
2
+
3
+ type KaspaOutpoint = {
4
+ transactionId: string;
5
+ index: number;
6
+ };
7
+ export type KaspaUtxo = {
8
+ address: string;
9
+ accountType: number;
10
+ accountIndex: number;
11
+ outpoint: KaspaOutpoint;
12
+ utxoEntry: {
13
+ amount: BigNumber;
14
+ scriptPublicKey: {
15
+ version: number;
16
+ scriptPublicKey: string;
17
+ };
18
+ blockDaaScore: string;
19
+ isCoinbase: boolean;
20
+ };
21
+ };
@@ -0,0 +1,101 @@
1
+ import { BigNumber } from "bignumber.js";
2
+
3
+ export type ApiResponseSubmitTransaction = {
4
+ txId: string;
5
+ };
6
+
7
+ export type ApiResponseBlockDagInfo = {
8
+ networkName: string;
9
+ blockCount: string;
10
+ headerCount: string;
11
+ tipHashes: string[];
12
+ difficulty: number;
13
+ pastMedianTime: string;
14
+ virtualParentHashes: string[];
15
+ pruningPointHash: string;
16
+ virtualDaaScore: string;
17
+ };
18
+
19
+ export type ApiResponseAddressActive = {
20
+ address: string;
21
+ active: boolean;
22
+ lastTxBlockTime: number;
23
+ };
24
+
25
+ export type ApiResponseBalance = {
26
+ address: string;
27
+ balance: number;
28
+ };
29
+
30
+ export type ApiResponseFeeEstimate = {
31
+ priorityBucket: {
32
+ feerate: number;
33
+ estimatedSeconds: number;
34
+ };
35
+ normalBuckets: Array<{
36
+ feerate: number;
37
+ estimatedSeconds: number;
38
+ }>;
39
+ lowBuckets: Array<{
40
+ feerate: number;
41
+ estimatedSeconds: number;
42
+ }>;
43
+ };
44
+
45
+ type Outpoint = {
46
+ transactionId: string;
47
+ index: number;
48
+ };
49
+
50
+ type ScriptPublicKey = {
51
+ scriptPublicKey: string;
52
+ };
53
+
54
+ type UtxoEntry = {
55
+ amount: BigNumber;
56
+ scriptPublicKey: ScriptPublicKey;
57
+ blockDaaScore: string;
58
+ isCoinbase: boolean;
59
+ };
60
+
61
+ export type ApiResponseUtxo = {
62
+ address: string;
63
+ outpoint: Outpoint;
64
+ utxoEntry: UtxoEntry;
65
+ };
66
+
67
+ export type ApiResponseTransaction = {
68
+ subnetwork_id: string;
69
+ transaction_id: string;
70
+ hash: string;
71
+ mass: string;
72
+ block_hash: string[];
73
+ block_time: number;
74
+ is_accepted: boolean;
75
+ accepting_block_hash: string;
76
+ accepting_block_blue_score: number;
77
+ inputs: Input[];
78
+ outputs: Output[];
79
+ };
80
+
81
+ type Input = {
82
+ transaction_id: string;
83
+ index: number;
84
+ previous_outpoint_hash: string;
85
+ previous_outpoint_index: string;
86
+ previous_outpoint_resolved: Output;
87
+ previous_outpoint_address: string;
88
+ previous_outpoint_amount: number;
89
+ signature_script: string;
90
+ sig_op_count: string;
91
+ };
92
+
93
+ type Output = {
94
+ transaction_id: string;
95
+ index: number;
96
+ amount: number;
97
+ script_public_key: string;
98
+ script_public_key_address: string;
99
+ script_public_key_type: string;
100
+ accepting_block_hash: string;
101
+ };
@@ -0,0 +1,22 @@
1
+ import { KaspaHwTransaction } from "./index";
2
+
3
+ export type KaspaAddress = {
4
+ address: string;
5
+ publicKey: string;
6
+ };
7
+ export type KaspaSignature = {
8
+ signature: string;
9
+ };
10
+
11
+ export interface KaspaSigner {
12
+ getAddress(path: string, display?: boolean): Promise<KaspaAddress>;
13
+
14
+ signMessage(
15
+ message: string,
16
+ addressType?: 0 | 1,
17
+ addressIndex?: number,
18
+ account?: number,
19
+ ): Promise<KaspaSignature>;
20
+
21
+ signTransaction(transaction: KaspaHwTransaction): Promise<void>;
22
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "../../../tsconfig.base",
3
+ "compilerOptions": {
4
+ "declaration": true,
5
+ "declarationMap": true,
6
+ "downlevelIteration": true,
7
+ "lib": ["es2020", "dom"],
8
+ "outDir": "lib",
9
+ "rootDir": "src",
10
+ "module": "NodeNext"
11
+ },
12
+ "include": ["src/**/*"]
13
+ }