@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.
- package/.eslintrc.js +20 -0
- package/.turbo/turbo-build.log +4 -0
- package/.unimportedrc.json +87 -0
- package/CHANGELOG.md +978 -0
- package/LICENSE.txt +21 -0
- package/jest-global-setup.js +9 -0
- package/jest.config.js +21 -0
- package/jest.integ.config.js +8 -0
- package/lib/bridge/broadcast.d.ts +8 -0
- package/lib/bridge/broadcast.d.ts.map +1 -0
- package/lib/bridge/broadcast.js +16 -0
- package/lib/bridge/broadcast.js.map +1 -0
- package/lib/bridge/buildInitialOperation.d.ts +5 -0
- package/lib/bridge/buildInitialOperation.d.ts.map +1 -0
- package/lib/bridge/buildInitialOperation.js +31 -0
- package/lib/bridge/buildInitialOperation.js.map +1 -0
- package/lib/bridge/buildTransaction.d.ts +16 -0
- package/lib/bridge/buildTransaction.d.ts.map +1 -0
- package/lib/bridge/buildTransaction.js +63 -0
- package/lib/bridge/buildTransaction.js.map +1 -0
- package/lib/bridge/createTransaction.d.ts +4 -0
- package/lib/bridge/createTransaction.d.ts.map +1 -0
- package/lib/bridge/createTransaction.js +15 -0
- package/lib/bridge/createTransaction.js.map +1 -0
- package/lib/bridge/estimateMaxSpendable.d.ts +4 -0
- package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -0
- package/lib/bridge/estimateMaxSpendable.js +19 -0
- package/lib/bridge/estimateMaxSpendable.js.map +1 -0
- package/lib/bridge/getTransactionStatus.d.ts +4 -0
- package/lib/bridge/getTransactionStatus.d.ts.map +1 -0
- package/lib/bridge/getTransactionStatus.js +68 -0
- package/lib/bridge/getTransactionStatus.js.map +1 -0
- package/lib/bridge/index.d.ts +9 -0
- package/lib/bridge/index.d.ts.map +1 -0
- package/lib/bridge/index.js +75 -0
- package/lib/bridge/index.js.map +1 -0
- package/lib/bridge/initAccount.d.ts +2 -0
- package/lib/bridge/initAccount.d.ts.map +1 -0
- package/lib/bridge/initAccount.js +6 -0
- package/lib/bridge/initAccount.js.map +1 -0
- package/lib/bridge/prepareTransaction.d.ts +14 -0
- package/lib/bridge/prepareTransaction.d.ts.map +1 -0
- package/lib/bridge/prepareTransaction.js +46 -0
- package/lib/bridge/prepareTransaction.js.map +1 -0
- package/lib/bridge/signOperation.d.ts +8 -0
- package/lib/bridge/signOperation.d.ts.map +1 -0
- package/lib/bridge/signOperation.js +34 -0
- package/lib/bridge/signOperation.js.map +1 -0
- package/lib/bridge/synchronization.d.ts +4 -0
- package/lib/bridge/synchronization.d.ts.map +1 -0
- package/lib/bridge/synchronization.js +66 -0
- package/lib/bridge/synchronization.js.map +1 -0
- package/lib/config.d.ts +8 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +9 -0
- package/lib/config.js.map +1 -0
- package/lib/deviceTransactionConfig.d.ts +11 -0
- package/lib/deviceTransactionConfig.d.ts.map +1 -0
- package/lib/deviceTransactionConfig.js +32 -0
- package/lib/deviceTransactionConfig.js.map +1 -0
- package/lib/errors.d.ts +8 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +8 -0
- package/lib/errors.js.map +1 -0
- package/lib/hw-getAddress.d.ts +6 -0
- package/lib/hw-getAddress.d.ts.map +1 -0
- package/lib/hw-getAddress.js +14 -0
- package/lib/hw-getAddress.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +18 -0
- package/lib/index.js.map +1 -0
- package/lib/logic/base32.d.ts +30 -0
- package/lib/logic/base32.d.ts.map +1 -0
- package/lib/logic/base32.js +99 -0
- package/lib/logic/base32.js.map +1 -0
- package/lib/logic/bip32.d.ts +9 -0
- package/lib/logic/bip32.d.ts.map +1 -0
- package/lib/logic/bip32.js +23 -0
- package/lib/logic/bip32.js.map +1 -0
- package/lib/logic/getAllTransactions.d.ts +3 -0
- package/lib/logic/getAllTransactions.d.ts.map +1 -0
- package/lib/logic/getAllTransactions.js +19 -0
- package/lib/logic/getAllTransactions.js.map +1 -0
- package/lib/logic/getFeeRate.d.ts +4 -0
- package/lib/logic/getFeeRate.d.ts.map +1 -0
- package/lib/logic/getFeeRate.js +19 -0
- package/lib/logic/getFeeRate.js.map +1 -0
- package/lib/logic/index.d.ts +11 -0
- package/lib/logic/index.d.ts.map +1 -0
- package/lib/logic/index.js +27 -0
- package/lib/logic/index.js.map +1 -0
- package/lib/logic/kaspaAddresses.d.ts +30 -0
- package/lib/logic/kaspaAddresses.d.ts.map +1 -0
- package/lib/logic/kaspaAddresses.js +231 -0
- package/lib/logic/kaspaAddresses.js.map +1 -0
- package/lib/logic/massCalcluation.d.ts +4 -0
- package/lib/logic/massCalcluation.d.ts.map +1 -0
- package/lib/logic/massCalcluation.js +40 -0
- package/lib/logic/massCalcluation.js.map +1 -0
- package/lib/logic/scanAddresses.d.ts +13 -0
- package/lib/logic/scanAddresses.d.ts.map +1 -0
- package/lib/logic/scanAddresses.js +147 -0
- package/lib/logic/scanAddresses.js.map +1 -0
- package/lib/logic/scanOperations.d.ts +3 -0
- package/lib/logic/scanOperations.d.ts.map +1 -0
- package/lib/logic/scanOperations.js +43 -0
- package/lib/logic/scanOperations.js.map +1 -0
- package/lib/logic/scanUtxos.d.ts +8 -0
- package/lib/logic/scanUtxos.d.ts.map +1 -0
- package/lib/logic/scanUtxos.js +39 -0
- package/lib/logic/scanUtxos.js.map +1 -0
- package/lib/logic/tests/bip32.test.d.ts +2 -0
- package/lib/logic/tests/bip32.test.d.ts.map +1 -0
- package/lib/logic/tests/bip32.test.js +64 -0
- package/lib/logic/tests/bip32.test.js.map +1 -0
- package/lib/logic/tests/getFeeRate.test.d.ts +2 -0
- package/lib/logic/tests/getFeeRate.test.d.ts.map +1 -0
- package/lib/logic/tests/getFeeRate.test.js +57 -0
- package/lib/logic/tests/getFeeRate.test.js.map +1 -0
- package/lib/logic/tests/kaspaAddresses.test.d.ts +2 -0
- package/lib/logic/tests/kaspaAddresses.test.d.ts.map +1 -0
- package/lib/logic/tests/kaspaAddresses.test.js +172 -0
- package/lib/logic/tests/kaspaAddresses.test.js.map +1 -0
- package/lib/logic/tests/massCalcluation.test.d.ts +2 -0
- package/lib/logic/tests/massCalcluation.test.d.ts.map +1 -0
- package/lib/logic/tests/massCalcluation.test.js +27 -0
- package/lib/logic/tests/massCalcluation.test.js.map +1 -0
- package/lib/logic/tests/scanAddresses.integ.test.d.ts +2 -0
- package/lib/logic/tests/scanAddresses.integ.test.d.ts.map +1 -0
- package/lib/logic/tests/scanAddresses.integ.test.js +18 -0
- package/lib/logic/tests/scanAddresses.integ.test.js.map +1 -0
- package/lib/logic/tests/scanOperations.integ.test.d.ts +2 -0
- package/lib/logic/tests/scanOperations.integ.test.d.ts.map +1 -0
- package/lib/logic/tests/scanOperations.integ.test.js +254 -0
- package/lib/logic/tests/scanOperations.integ.test.js.map +1 -0
- package/lib/logic/tests/scanOperations.test.d.ts +2 -0
- package/lib/logic/tests/scanOperations.test.d.ts.map +1 -0
- package/lib/logic/tests/scanOperations.test.js +184 -0
- package/lib/logic/tests/scanOperations.test.js.map +1 -0
- package/lib/logic/tests/scanUtxos.integ.test.d.ts +2 -0
- package/lib/logic/tests/scanUtxos.integ.test.d.ts.map +1 -0
- package/lib/logic/tests/scanUtxos.integ.test.js +13 -0
- package/lib/logic/tests/scanUtxos.integ.test.js.map +1 -0
- package/lib/logic/tests/scanUtxos.test.d.ts +2 -0
- package/lib/logic/tests/scanUtxos.test.d.ts.map +1 -0
- package/lib/logic/tests/scanUtxos.test.js +167 -0
- package/lib/logic/tests/scanUtxos.test.js.map +1 -0
- package/lib/logic/tests/utxoLib.test.d.ts +2 -0
- package/lib/logic/tests/utxoLib.test.d.ts.map +1 -0
- package/lib/logic/tests/utxoLib.test.js +26 -0
- package/lib/logic/tests/utxoLib.test.js.map +1 -0
- package/lib/logic/tests/utxoSelection.test.d.ts +10 -0
- package/lib/logic/tests/utxoSelection.test.d.ts.map +1 -0
- package/lib/logic/tests/utxoSelection.test.js +256 -0
- package/lib/logic/tests/utxoSelection.test.js.map +1 -0
- package/lib/logic/tests/validAddress.test.d.ts +2 -0
- package/lib/logic/tests/validAddress.test.d.ts.map +1 -0
- package/lib/logic/tests/validAddress.test.js +56 -0
- package/lib/logic/tests/validAddress.test.js.map +1 -0
- package/lib/logic/utxos/lib.d.ts +6 -0
- package/lib/logic/utxos/lib.d.ts.map +1 -0
- package/lib/logic/utxos/lib.js +27 -0
- package/lib/logic/utxos/lib.js.map +1 -0
- package/lib/logic/utxos/selection.d.ts +8 -0
- package/lib/logic/utxos/selection.d.ts.map +1 -0
- package/lib/logic/utxos/selection.js +80 -0
- package/lib/logic/utxos/selection.js.map +1 -0
- package/lib/network/config.d.ts +3 -0
- package/lib/network/config.d.ts.map +1 -0
- package/lib/network/config.js +8 -0
- package/lib/network/config.js.map +1 -0
- package/lib/network/getAddressesActive.d.ts +3 -0
- package/lib/network/getAddressesActive.d.ts.map +1 -0
- package/lib/network/getAddressesActive.js +25 -0
- package/lib/network/getAddressesActive.js.map +1 -0
- package/lib/network/getBalancesForAddresses.d.ts +3 -0
- package/lib/network/getBalancesForAddresses.d.ts.map +1 -0
- package/lib/network/getBalancesForAddresses.js +25 -0
- package/lib/network/getBalancesForAddresses.js.map +1 -0
- package/lib/network/getBlockDagInfo.d.ts +3 -0
- package/lib/network/getBlockDagInfo.d.ts.map +1 -0
- package/lib/network/getBlockDagInfo.js +24 -0
- package/lib/network/getBlockDagInfo.js.map +1 -0
- package/lib/network/getFeeEstimate.d.ts +3 -0
- package/lib/network/getFeeEstimate.d.ts.map +1 -0
- package/lib/network/getFeeEstimate.js +23 -0
- package/lib/network/getFeeEstimate.js.map +1 -0
- package/lib/network/getTransactions.d.ts +6 -0
- package/lib/network/getTransactions.d.ts.map +1 -0
- package/lib/network/getTransactions.js +19 -0
- package/lib/network/getTransactions.js.map +1 -0
- package/lib/network/getUtxosForAddresses.d.ts +3 -0
- package/lib/network/getUtxosForAddresses.d.ts.map +1 -0
- package/lib/network/getUtxosForAddresses.js +25 -0
- package/lib/network/getUtxosForAddresses.js.map +1 -0
- package/lib/network/getVirtualChainBlueScore.d.ts +2 -0
- package/lib/network/getVirtualChainBlueScore.d.ts.map +1 -0
- package/lib/network/getVirtualChainBlueScore.js +24 -0
- package/lib/network/getVirtualChainBlueScore.js.map +1 -0
- package/lib/network/index.d.ts +9 -0
- package/lib/network/index.d.ts.map +1 -0
- package/lib/network/index.js +20 -0
- package/lib/network/index.js.map +1 -0
- package/lib/network/submitTransaction.d.ts +3 -0
- package/lib/network/submitTransaction.d.ts.map +1 -0
- package/lib/network/submitTransaction.js +27 -0
- package/lib/network/submitTransaction.js.map +1 -0
- package/lib/network/tests/getAddressesActive.test.d.ts +2 -0
- package/lib/network/tests/getAddressesActive.test.d.ts.map +1 -0
- package/lib/network/tests/getAddressesActive.test.js +65 -0
- package/lib/network/tests/getAddressesActive.test.js.map +1 -0
- package/lib/network/tests/getBalancesForAddresss.test.d.ts +2 -0
- package/lib/network/tests/getBalancesForAddresss.test.d.ts.map +1 -0
- package/lib/network/tests/getBalancesForAddresss.test.js +40 -0
- package/lib/network/tests/getBalancesForAddresss.test.js.map +1 -0
- package/lib/network/tests/getBlockDagInfo.test.d.ts +2 -0
- package/lib/network/tests/getBlockDagInfo.test.d.ts.map +1 -0
- package/lib/network/tests/getBlockDagInfo.test.js +36 -0
- package/lib/network/tests/getBlockDagInfo.test.js.map +1 -0
- package/lib/network/tests/getFeeEstimate.test.d.ts +2 -0
- package/lib/network/tests/getFeeEstimate.test.d.ts.map +1 -0
- package/lib/network/tests/getFeeEstimate.test.js +54 -0
- package/lib/network/tests/getFeeEstimate.test.js.map +1 -0
- package/lib/network/tests/getTransactions.test.d.ts +2 -0
- package/lib/network/tests/getTransactions.test.d.ts.map +1 -0
- package/lib/network/tests/getTransactions.test.js +157 -0
- package/lib/network/tests/getTransactions.test.js.map +1 -0
- package/lib/network/tests/getUtxosForAddress.test.d.ts +2 -0
- package/lib/network/tests/getUtxosForAddress.test.d.ts.map +1 -0
- package/lib/network/tests/getUtxosForAddress.test.js +142 -0
- package/lib/network/tests/getUtxosForAddress.test.js.map +1 -0
- package/lib/network/tests/getVirtualChainBlueScore.test.d.ts +2 -0
- package/lib/network/tests/getVirtualChainBlueScore.test.d.ts.map +1 -0
- package/lib/network/tests/getVirtualChainBlueScore.test.js +27 -0
- package/lib/network/tests/getVirtualChainBlueScore.test.js.map +1 -0
- package/lib/network/tests/submitTransaction.test.d.ts +2 -0
- package/lib/network/tests/submitTransaction.test.d.ts.map +1 -0
- package/lib/network/tests/submitTransaction.test.js +43 -0
- package/lib/network/tests/submitTransaction.test.js.map +1 -0
- package/lib/test/bridgeDatasetTest.d.ts +4 -0
- package/lib/test/bridgeDatasetTest.d.ts.map +1 -0
- package/lib/test/bridgeDatasetTest.js +46 -0
- package/lib/test/bridgeDatasetTest.js.map +1 -0
- package/lib/test/cli.d.ts +16 -0
- package/lib/test/cli.d.ts.map +1 -0
- package/lib/test/cli.js +30 -0
- package/lib/test/cli.js.map +1 -0
- package/lib/test/index.d.ts +2 -0
- package/lib/test/index.d.ts.map +1 -0
- package/lib/test/index.js +18 -0
- package/lib/test/index.js.map +1 -0
- package/lib/transaction.d.ts +16 -0
- package/lib/transaction.d.ts.map +1 -0
- package/lib/transaction.js +66 -0
- package/lib/transaction.js.map +1 -0
- package/lib/types/addresses.d.ts +18 -0
- package/lib/types/addresses.d.ts.map +1 -0
- package/lib/types/addresses.js +3 -0
- package/lib/types/addresses.js.map +1 -0
- package/lib/types/bridge.d.ts +34 -0
- package/lib/types/bridge.d.ts.map +1 -0
- package/lib/types/bridge.js +3 -0
- package/lib/types/bridge.js.map +1 -0
- package/lib/types/errors.d.ts +10 -0
- package/lib/types/errors.d.ts.map +1 -0
- package/lib/types/errors.js +8 -0
- package/lib/types/errors.js.map +1 -0
- package/lib/types/index.d.ts +8 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +18 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/kaspaHwTransaction.d.ts +89 -0
- package/lib/types/kaspaHwTransaction.d.ts.map +1 -0
- package/lib/types/kaspaHwTransaction.js +167 -0
- package/lib/types/kaspaHwTransaction.js.map +1 -0
- package/lib/types/kaspaNetwork.d.ts +22 -0
- package/lib/types/kaspaNetwork.d.ts.map +1 -0
- package/lib/types/kaspaNetwork.js +3 -0
- package/lib/types/kaspaNetwork.js.map +1 -0
- package/lib/types/network.d.ts +91 -0
- package/lib/types/network.d.ts.map +1 -0
- package/lib/types/network.js +3 -0
- package/lib/types/network.js.map +1 -0
- package/lib/types/signer.d.ts +14 -0
- package/lib/types/signer.d.ts.map +1 -0
- package/lib/types/signer.js +3 -0
- package/lib/types/signer.js.map +1 -0
- package/lib-es/bridge/broadcast.d.ts +8 -0
- package/lib-es/bridge/broadcast.d.ts.map +1 -0
- package/lib-es/bridge/broadcast.js +12 -0
- package/lib-es/bridge/broadcast.js.map +1 -0
- package/lib-es/bridge/buildInitialOperation.d.ts +5 -0
- package/lib-es/bridge/buildInitialOperation.d.ts.map +1 -0
- package/lib-es/bridge/buildInitialOperation.js +27 -0
- package/lib-es/bridge/buildInitialOperation.js.map +1 -0
- package/lib-es/bridge/buildTransaction.d.ts +16 -0
- package/lib-es/bridge/buildTransaction.d.ts.map +1 -0
- package/lib-es/bridge/buildTransaction.js +59 -0
- package/lib-es/bridge/buildTransaction.js.map +1 -0
- package/lib-es/bridge/createTransaction.d.ts +4 -0
- package/lib-es/bridge/createTransaction.d.ts.map +1 -0
- package/lib-es/bridge/createTransaction.js +11 -0
- package/lib-es/bridge/createTransaction.js.map +1 -0
- package/lib-es/bridge/estimateMaxSpendable.d.ts +4 -0
- package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -0
- package/lib-es/bridge/estimateMaxSpendable.js +15 -0
- package/lib-es/bridge/estimateMaxSpendable.js.map +1 -0
- package/lib-es/bridge/getTransactionStatus.d.ts +4 -0
- package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -0
- package/lib-es/bridge/getTransactionStatus.js +66 -0
- package/lib-es/bridge/getTransactionStatus.js.map +1 -0
- package/lib-es/bridge/index.d.ts +9 -0
- package/lib-es/bridge/index.d.ts.map +1 -0
- package/lib-es/bridge/index.js +68 -0
- package/lib-es/bridge/index.js.map +1 -0
- package/lib-es/bridge/initAccount.d.ts +2 -0
- package/lib-es/bridge/initAccount.d.ts.map +1 -0
- package/lib-es/bridge/initAccount.js +2 -0
- package/lib-es/bridge/initAccount.js.map +1 -0
- package/lib-es/bridge/prepareTransaction.d.ts +14 -0
- package/lib-es/bridge/prepareTransaction.d.ts.map +1 -0
- package/lib-es/bridge/prepareTransaction.js +39 -0
- package/lib-es/bridge/prepareTransaction.js.map +1 -0
- package/lib-es/bridge/signOperation.d.ts +8 -0
- package/lib-es/bridge/signOperation.d.ts.map +1 -0
- package/lib-es/bridge/signOperation.js +27 -0
- package/lib-es/bridge/signOperation.js.map +1 -0
- package/lib-es/bridge/synchronization.d.ts +4 -0
- package/lib-es/bridge/synchronization.d.ts.map +1 -0
- package/lib-es/bridge/synchronization.js +62 -0
- package/lib-es/bridge/synchronization.js.map +1 -0
- package/lib-es/config.d.ts +8 -0
- package/lib-es/config.d.ts.map +1 -0
- package/lib-es/config.js +4 -0
- package/lib-es/config.js.map +1 -0
- package/lib-es/deviceTransactionConfig.d.ts +11 -0
- package/lib-es/deviceTransactionConfig.d.ts.map +1 -0
- package/lib-es/deviceTransactionConfig.js +30 -0
- package/lib-es/deviceTransactionConfig.js.map +1 -0
- package/lib-es/errors.d.ts +8 -0
- package/lib-es/errors.d.ts.map +1 -0
- package/lib-es/errors.js +5 -0
- package/lib-es/errors.js.map +1 -0
- package/lib-es/hw-getAddress.d.ts +6 -0
- package/lib-es/hw-getAddress.d.ts.map +1 -0
- package/lib-es/hw-getAddress.js +12 -0
- package/lib-es/hw-getAddress.js.map +1 -0
- package/lib-es/index.d.ts +2 -0
- package/lib-es/index.d.ts.map +1 -0
- package/lib-es/index.js +2 -0
- package/lib-es/index.js.map +1 -0
- package/lib-es/logic/base32.d.ts +30 -0
- package/lib-es/logic/base32.d.ts.map +1 -0
- package/lib-es/logic/base32.js +95 -0
- package/lib-es/logic/base32.js.map +1 -0
- package/lib-es/logic/bip32.d.ts +9 -0
- package/lib-es/logic/bip32.d.ts.map +1 -0
- package/lib-es/logic/bip32.js +17 -0
- package/lib-es/logic/bip32.js.map +1 -0
- package/lib-es/logic/getAllTransactions.d.ts +3 -0
- package/lib-es/logic/getAllTransactions.d.ts.map +1 -0
- package/lib-es/logic/getAllTransactions.js +15 -0
- package/lib-es/logic/getAllTransactions.js.map +1 -0
- package/lib-es/logic/getFeeRate.d.ts +4 -0
- package/lib-es/logic/getFeeRate.d.ts.map +1 -0
- package/lib-es/logic/getFeeRate.js +15 -0
- package/lib-es/logic/getFeeRate.js.map +1 -0
- package/lib-es/logic/index.d.ts +11 -0
- package/lib-es/logic/index.d.ts.map +1 -0
- package/lib-es/logic/index.js +11 -0
- package/lib-es/logic/index.js.map +1 -0
- package/lib-es/logic/kaspaAddresses.d.ts +30 -0
- package/lib-es/logic/kaspaAddresses.d.ts.map +1 -0
- package/lib-es/logic/kaspaAddresses.js +219 -0
- package/lib-es/logic/kaspaAddresses.js.map +1 -0
- package/lib-es/logic/massCalcluation.d.ts +4 -0
- package/lib-es/logic/massCalcluation.d.ts.map +1 -0
- package/lib-es/logic/massCalcluation.js +35 -0
- package/lib-es/logic/massCalcluation.js.map +1 -0
- package/lib-es/logic/scanAddresses.d.ts +13 -0
- package/lib-es/logic/scanAddresses.d.ts.map +1 -0
- package/lib-es/logic/scanAddresses.js +140 -0
- package/lib-es/logic/scanAddresses.js.map +1 -0
- package/lib-es/logic/scanOperations.d.ts +3 -0
- package/lib-es/logic/scanOperations.d.ts.map +1 -0
- package/lib-es/logic/scanOperations.js +39 -0
- package/lib-es/logic/scanOperations.js.map +1 -0
- package/lib-es/logic/scanUtxos.d.ts +8 -0
- package/lib-es/logic/scanUtxos.d.ts.map +1 -0
- package/lib-es/logic/scanUtxos.js +35 -0
- package/lib-es/logic/scanUtxos.js.map +1 -0
- package/lib-es/logic/tests/bip32.test.d.ts +2 -0
- package/lib-es/logic/tests/bip32.test.d.ts.map +1 -0
- package/lib-es/logic/tests/bip32.test.js +59 -0
- package/lib-es/logic/tests/bip32.test.js.map +1 -0
- package/lib-es/logic/tests/getFeeRate.test.d.ts +2 -0
- package/lib-es/logic/tests/getFeeRate.test.d.ts.map +1 -0
- package/lib-es/logic/tests/getFeeRate.test.js +55 -0
- package/lib-es/logic/tests/getFeeRate.test.js.map +1 -0
- package/lib-es/logic/tests/kaspaAddresses.test.d.ts +2 -0
- package/lib-es/logic/tests/kaspaAddresses.test.d.ts.map +1 -0
- package/lib-es/logic/tests/kaspaAddresses.test.js +170 -0
- package/lib-es/logic/tests/kaspaAddresses.test.js.map +1 -0
- package/lib-es/logic/tests/massCalcluation.test.d.ts +2 -0
- package/lib-es/logic/tests/massCalcluation.test.d.ts.map +1 -0
- package/lib-es/logic/tests/massCalcluation.test.js +22 -0
- package/lib-es/logic/tests/massCalcluation.test.js.map +1 -0
- package/lib-es/logic/tests/scanAddresses.integ.test.d.ts +2 -0
- package/lib-es/logic/tests/scanAddresses.integ.test.d.ts.map +1 -0
- package/lib-es/logic/tests/scanAddresses.integ.test.js +16 -0
- package/lib-es/logic/tests/scanAddresses.integ.test.js.map +1 -0
- package/lib-es/logic/tests/scanOperations.integ.test.d.ts +2 -0
- package/lib-es/logic/tests/scanOperations.integ.test.d.ts.map +1 -0
- package/lib-es/logic/tests/scanOperations.integ.test.js +249 -0
- package/lib-es/logic/tests/scanOperations.integ.test.js.map +1 -0
- package/lib-es/logic/tests/scanOperations.test.d.ts +2 -0
- package/lib-es/logic/tests/scanOperations.test.d.ts.map +1 -0
- package/lib-es/logic/tests/scanOperations.test.js +156 -0
- package/lib-es/logic/tests/scanOperations.test.js.map +1 -0
- package/lib-es/logic/tests/scanUtxos.integ.test.d.ts +2 -0
- package/lib-es/logic/tests/scanUtxos.integ.test.d.ts.map +1 -0
- package/lib-es/logic/tests/scanUtxos.integ.test.js +11 -0
- package/lib-es/logic/tests/scanUtxos.integ.test.js.map +1 -0
- package/lib-es/logic/tests/scanUtxos.test.d.ts +2 -0
- package/lib-es/logic/tests/scanUtxos.test.d.ts.map +1 -0
- package/lib-es/logic/tests/scanUtxos.test.js +139 -0
- package/lib-es/logic/tests/scanUtxos.test.js.map +1 -0
- package/lib-es/logic/tests/utxoLib.test.d.ts +2 -0
- package/lib-es/logic/tests/utxoLib.test.d.ts.map +1 -0
- package/lib-es/logic/tests/utxoLib.test.js +24 -0
- package/lib-es/logic/tests/utxoLib.test.js.map +1 -0
- package/lib-es/logic/tests/utxoSelection.test.d.ts +10 -0
- package/lib-es/logic/tests/utxoSelection.test.d.ts.map +1 -0
- package/lib-es/logic/tests/utxoSelection.test.js +229 -0
- package/lib-es/logic/tests/utxoSelection.test.js.map +1 -0
- package/lib-es/logic/tests/validAddress.test.d.ts +2 -0
- package/lib-es/logic/tests/validAddress.test.d.ts.map +1 -0
- package/lib-es/logic/tests/validAddress.test.js +54 -0
- package/lib-es/logic/tests/validAddress.test.js.map +1 -0
- package/lib-es/logic/utxos/lib.d.ts +6 -0
- package/lib-es/logic/utxos/lib.d.ts.map +1 -0
- package/lib-es/logic/utxos/lib.js +21 -0
- package/lib-es/logic/utxos/lib.js.map +1 -0
- package/lib-es/logic/utxos/selection.d.ts +8 -0
- package/lib-es/logic/utxos/selection.d.ts.map +1 -0
- package/lib-es/logic/utxos/selection.js +76 -0
- package/lib-es/logic/utxos/selection.js.map +1 -0
- package/lib-es/network/config.d.ts +3 -0
- package/lib-es/network/config.d.ts.map +1 -0
- package/lib-es/network/config.js +5 -0
- package/lib-es/network/config.js.map +1 -0
- package/lib-es/network/getAddressesActive.d.ts +3 -0
- package/lib-es/network/getAddressesActive.d.ts.map +1 -0
- package/lib-es/network/getAddressesActive.js +21 -0
- package/lib-es/network/getAddressesActive.js.map +1 -0
- package/lib-es/network/getBalancesForAddresses.d.ts +3 -0
- package/lib-es/network/getBalancesForAddresses.d.ts.map +1 -0
- package/lib-es/network/getBalancesForAddresses.js +21 -0
- package/lib-es/network/getBalancesForAddresses.js.map +1 -0
- package/lib-es/network/getBlockDagInfo.d.ts +3 -0
- package/lib-es/network/getBlockDagInfo.d.ts.map +1 -0
- package/lib-es/network/getBlockDagInfo.js +20 -0
- package/lib-es/network/getBlockDagInfo.js.map +1 -0
- package/lib-es/network/getFeeEstimate.d.ts +3 -0
- package/lib-es/network/getFeeEstimate.d.ts.map +1 -0
- package/lib-es/network/getFeeEstimate.js +19 -0
- package/lib-es/network/getFeeEstimate.js.map +1 -0
- package/lib-es/network/getTransactions.d.ts +6 -0
- package/lib-es/network/getTransactions.d.ts.map +1 -0
- package/lib-es/network/getTransactions.js +15 -0
- package/lib-es/network/getTransactions.js.map +1 -0
- package/lib-es/network/getUtxosForAddresses.d.ts +3 -0
- package/lib-es/network/getUtxosForAddresses.d.ts.map +1 -0
- package/lib-es/network/getUtxosForAddresses.js +21 -0
- package/lib-es/network/getUtxosForAddresses.js.map +1 -0
- package/lib-es/network/getVirtualChainBlueScore.d.ts +2 -0
- package/lib-es/network/getVirtualChainBlueScore.d.ts.map +1 -0
- package/lib-es/network/getVirtualChainBlueScore.js +20 -0
- package/lib-es/network/getVirtualChainBlueScore.js.map +1 -0
- package/lib-es/network/index.d.ts +9 -0
- package/lib-es/network/index.d.ts.map +1 -0
- package/lib-es/network/index.js +9 -0
- package/lib-es/network/index.js.map +1 -0
- package/lib-es/network/submitTransaction.d.ts +3 -0
- package/lib-es/network/submitTransaction.d.ts.map +1 -0
- package/lib-es/network/submitTransaction.js +23 -0
- package/lib-es/network/submitTransaction.js.map +1 -0
- package/lib-es/network/tests/getAddressesActive.test.d.ts +2 -0
- package/lib-es/network/tests/getAddressesActive.test.d.ts.map +1 -0
- package/lib-es/network/tests/getAddressesActive.test.js +63 -0
- package/lib-es/network/tests/getAddressesActive.test.js.map +1 -0
- package/lib-es/network/tests/getBalancesForAddresss.test.d.ts +2 -0
- package/lib-es/network/tests/getBalancesForAddresss.test.d.ts.map +1 -0
- package/lib-es/network/tests/getBalancesForAddresss.test.js +38 -0
- package/lib-es/network/tests/getBalancesForAddresss.test.js.map +1 -0
- package/lib-es/network/tests/getBlockDagInfo.test.d.ts +2 -0
- package/lib-es/network/tests/getBlockDagInfo.test.d.ts.map +1 -0
- package/lib-es/network/tests/getBlockDagInfo.test.js +34 -0
- package/lib-es/network/tests/getBlockDagInfo.test.js.map +1 -0
- package/lib-es/network/tests/getFeeEstimate.test.d.ts +2 -0
- package/lib-es/network/tests/getFeeEstimate.test.d.ts.map +1 -0
- package/lib-es/network/tests/getFeeEstimate.test.js +52 -0
- package/lib-es/network/tests/getFeeEstimate.test.js.map +1 -0
- package/lib-es/network/tests/getTransactions.test.d.ts +2 -0
- package/lib-es/network/tests/getTransactions.test.d.ts.map +1 -0
- package/lib-es/network/tests/getTransactions.test.js +155 -0
- package/lib-es/network/tests/getTransactions.test.js.map +1 -0
- package/lib-es/network/tests/getUtxosForAddress.test.d.ts +2 -0
- package/lib-es/network/tests/getUtxosForAddress.test.d.ts.map +1 -0
- package/lib-es/network/tests/getUtxosForAddress.test.js +140 -0
- package/lib-es/network/tests/getUtxosForAddress.test.js.map +1 -0
- package/lib-es/network/tests/getVirtualChainBlueScore.test.d.ts +2 -0
- package/lib-es/network/tests/getVirtualChainBlueScore.test.d.ts.map +1 -0
- package/lib-es/network/tests/getVirtualChainBlueScore.test.js +25 -0
- package/lib-es/network/tests/getVirtualChainBlueScore.test.js.map +1 -0
- package/lib-es/network/tests/submitTransaction.test.d.ts +2 -0
- package/lib-es/network/tests/submitTransaction.test.d.ts.map +1 -0
- package/lib-es/network/tests/submitTransaction.test.js +41 -0
- package/lib-es/network/tests/submitTransaction.test.js.map +1 -0
- package/lib-es/test/bridgeDatasetTest.d.ts +4 -0
- package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -0
- package/lib-es/test/bridgeDatasetTest.js +43 -0
- package/lib-es/test/bridgeDatasetTest.js.map +1 -0
- package/lib-es/test/cli.d.ts +16 -0
- package/lib-es/test/cli.d.ts.map +1 -0
- package/lib-es/test/cli.js +25 -0
- package/lib-es/test/cli.js.map +1 -0
- package/lib-es/test/index.d.ts +2 -0
- package/lib-es/test/index.d.ts.map +1 -0
- package/lib-es/test/index.js +2 -0
- package/lib-es/test/index.js.map +1 -0
- package/lib-es/transaction.d.ts +16 -0
- package/lib-es/transaction.d.ts.map +1 -0
- package/lib-es/transaction.js +59 -0
- package/lib-es/transaction.js.map +1 -0
- package/lib-es/types/addresses.d.ts +18 -0
- package/lib-es/types/addresses.d.ts.map +1 -0
- package/lib-es/types/addresses.js +2 -0
- package/lib-es/types/addresses.js.map +1 -0
- package/lib-es/types/bridge.d.ts +34 -0
- package/lib-es/types/bridge.d.ts.map +1 -0
- package/lib-es/types/bridge.js +2 -0
- package/lib-es/types/bridge.js.map +1 -0
- package/lib-es/types/errors.d.ts +10 -0
- package/lib-es/types/errors.d.ts.map +1 -0
- package/lib-es/types/errors.js +5 -0
- package/lib-es/types/errors.js.map +1 -0
- package/lib-es/types/index.d.ts +8 -0
- package/lib-es/types/index.d.ts.map +1 -0
- package/lib-es/types/index.js +2 -0
- package/lib-es/types/index.js.map +1 -0
- package/lib-es/types/kaspaHwTransaction.d.ts +89 -0
- package/lib-es/types/kaspaHwTransaction.d.ts.map +1 -0
- package/lib-es/types/kaspaHwTransaction.js +160 -0
- package/lib-es/types/kaspaHwTransaction.js.map +1 -0
- package/lib-es/types/kaspaNetwork.d.ts +22 -0
- package/lib-es/types/kaspaNetwork.d.ts.map +1 -0
- package/lib-es/types/kaspaNetwork.js +2 -0
- package/lib-es/types/kaspaNetwork.js.map +1 -0
- package/lib-es/types/network.d.ts +91 -0
- package/lib-es/types/network.d.ts.map +1 -0
- package/lib-es/types/network.js +2 -0
- package/lib-es/types/network.js.map +1 -0
- package/lib-es/types/signer.d.ts +14 -0
- package/lib-es/types/signer.d.ts.map +1 -0
- package/lib-es/types/signer.js +2 -0
- package/lib-es/types/signer.js.map +1 -0
- package/package.json +138 -0
- package/src/bridge/broadcast.ts +14 -0
- package/src/bridge/buildInitialOperation.ts +38 -0
- package/src/bridge/buildTransaction.ts +80 -0
- package/src/bridge/createTransaction.ts +13 -0
- package/src/bridge/estimateMaxSpendable.ts +23 -0
- package/src/bridge/getTransactionStatus.ts +116 -0
- package/src/bridge/index.ts +106 -0
- package/src/bridge/initAccount.ts +1 -0
- package/src/bridge/prepareTransaction.ts +48 -0
- package/src/bridge/signOperation.ts +43 -0
- package/src/bridge/synchronization.ts +80 -0
- package/src/config.ts +7 -0
- package/src/deviceTransactionConfig.ts +44 -0
- package/src/errors.ts +6 -0
- package/src/hw-getAddress.ts +17 -0
- package/src/index.ts +1 -0
- package/src/logic/base32.ts +100 -0
- package/src/logic/bip32.ts +21 -0
- package/src/logic/getAllTransactions.ts +22 -0
- package/src/logic/getFeeRate.ts +20 -0
- package/src/logic/index.ts +10 -0
- package/src/logic/kaspaAddresses.ts +274 -0
- package/src/logic/massCalcluation.ts +50 -0
- package/src/logic/scanAddresses.ts +173 -0
- package/src/logic/scanOperations.ts +59 -0
- package/src/logic/scanUtxos.ts +44 -0
- package/src/logic/tests/bip32.test.ts +78 -0
- package/src/logic/tests/getFeeRate.test.ts +64 -0
- package/src/logic/tests/kaspaAddresses.test.ts +278 -0
- package/src/logic/tests/massCalcluation.test.ts +37 -0
- package/src/logic/tests/scanAddresses.integ.test.ts +27 -0
- package/src/logic/tests/scanOperations.integ.test.ts +271 -0
- package/src/logic/tests/scanOperations.test.ts +191 -0
- package/src/logic/tests/scanUtxos.integ.test.ts +14 -0
- package/src/logic/tests/scanUtxos.test.ts +153 -0
- package/src/logic/tests/utxoLib.test.ts +29 -0
- package/src/logic/tests/utxoSelection.test.ts +290 -0
- package/src/logic/tests/validAddress.test.ts +55 -0
- package/src/logic/utxos/lib.ts +40 -0
- package/src/logic/utxos/selection.ts +100 -0
- package/src/network/config.ts +6 -0
- package/src/network/getAddressesActive.ts +27 -0
- package/src/network/getBalancesForAddresses.ts +27 -0
- package/src/network/getBlockDagInfo.ts +22 -0
- package/src/network/getFeeEstimate.ts +21 -0
- package/src/network/getTransactions.ts +25 -0
- package/src/network/getUtxosForAddresses.ts +23 -0
- package/src/network/getVirtualChainBlueScore.ts +21 -0
- package/src/network/index.ts +8 -0
- package/src/network/submitTransaction.ts +27 -0
- package/src/network/tests/getAddressesActive.test.ts +77 -0
- package/src/network/tests/getBalancesForAddresss.test.ts +44 -0
- package/src/network/tests/getBlockDagInfo.test.ts +40 -0
- package/src/network/tests/getFeeEstimate.test.ts +57 -0
- package/src/network/tests/getTransactions.test.ts +173 -0
- package/src/network/tests/getUtxosForAddress.test.ts +159 -0
- package/src/network/tests/getVirtualChainBlueScore.test.ts +29 -0
- package/src/network/tests/submitTransaction.test.ts +53 -0
- package/src/test/bridgeDatasetTest.ts +47 -0
- package/src/test/cli.ts +33 -0
- package/src/test/index.ts +1 -0
- package/src/transaction.ts +84 -0
- package/src/types/addresses.ts +19 -0
- package/src/types/bridge.ts +43 -0
- package/src/types/errors.ts +7 -0
- package/src/types/index.ts +7 -0
- package/src/types/kaspaHwTransaction.ts +234 -0
- package/src/types/kaspaNetwork.ts +21 -0
- package/src/types/network.ts +101 -0
- package/src/types/signer.ts +22 -0
- 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
|
+
};
|
package/src/test/cli.ts
ADDED
|
@@ -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,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
|
+
}
|