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