mainnet-js 0.5.9 → 1.0.0-rc.3
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/dist/index.html +9 -1
- package/dist/mainnet-1.0.0-rc.3.js +2928 -0
- package/dist/module/chain.d.ts +1 -0
- package/dist/module/chain.d.ts.map +1 -0
- package/dist/module/cli.d.ts +1 -0
- package/dist/module/cli.d.ts.map +1 -0
- package/dist/module/cli.js +2 -2
- package/dist/module/cli.js.map +1 -1
- package/dist/module/constant.d.ts +1 -0
- package/dist/module/constant.d.ts.map +1 -0
- package/dist/module/db/ExchangeRateProvider.d.ts +2 -1
- package/dist/module/db/ExchangeRateProvider.d.ts.map +1 -0
- package/dist/module/db/IndexedDBProvider.d.ts +3 -2
- package/dist/module/db/IndexedDBProvider.d.ts.map +1 -0
- package/dist/module/db/SqlProvider.d.ts +7 -8
- package/dist/module/db/SqlProvider.d.ts.map +1 -0
- package/dist/module/db/SqlProvider.js +10 -8
- package/dist/module/db/SqlProvider.js.map +1 -1
- package/dist/module/db/StorageProvider.d.ts +2 -1
- package/dist/module/db/StorageProvider.d.ts.map +1 -0
- package/dist/module/db/getStorageProvider.d.ts +3 -0
- package/dist/module/db/getStorageProvider.d.ts.map +1 -0
- package/dist/module/db/getStorageProvider.js +19 -0
- package/dist/module/db/getStorageProvider.js.map +1 -0
- package/dist/module/db/index.d.ts +4 -3
- package/dist/module/db/index.d.ts.map +1 -0
- package/dist/module/db/index.js +2 -2
- package/dist/module/db/index.js.map +1 -1
- package/dist/module/db/interface.d.ts +1 -0
- package/dist/module/db/interface.d.ts.map +1 -0
- package/dist/module/db/util.d.ts +2 -3
- package/dist/module/db/util.d.ts.map +1 -0
- package/dist/module/db/util.js +0 -17
- package/dist/module/db/util.js.map +1 -1
- package/dist/module/enum.d.ts +1 -0
- package/dist/module/enum.d.ts.map +1 -0
- package/dist/module/history/electrumTransformer.d.ts +3 -2
- package/dist/module/history/electrumTransformer.d.ts.map +1 -0
- package/dist/module/history/electrumTransformer.js +11 -11
- package/dist/module/history/electrumTransformer.js.map +1 -1
- package/dist/module/history/interface.d.ts +2 -1
- package/dist/module/history/interface.d.ts.map +1 -0
- package/dist/module/index.d.ts +26 -21
- package/dist/module/index.d.ts.map +1 -0
- package/dist/module/index.js +25 -17
- package/dist/module/index.js.map +1 -1
- package/dist/module/interface.d.ts +14 -0
- package/dist/module/interface.d.ts.map +1 -0
- package/dist/module/interface.js +5 -0
- package/dist/module/interface.js.map +1 -1
- package/dist/module/message/index.d.ts +3 -2
- package/dist/module/message/index.d.ts.map +1 -0
- package/dist/module/message/index.js +2 -2
- package/dist/module/message/index.js.map +1 -1
- package/dist/module/message/interface.d.ts +1 -0
- package/dist/module/message/interface.d.ts.map +1 -0
- package/dist/module/message/signed.d.ts +2 -1
- package/dist/module/message/signed.d.ts.map +1 -0
- package/dist/module/message/signed.js +10 -4
- package/dist/module/message/signed.js.map +1 -1
- package/dist/module/mine/index.d.ts +2 -1
- package/dist/module/mine/index.d.ts.map +1 -0
- package/dist/module/mine/index.js +1 -1
- package/dist/module/mine/index.js.map +1 -1
- package/dist/module/mine/mine.d.ts +1 -0
- package/dist/module/mine/mine.d.ts.map +1 -0
- package/dist/module/mine/mine.js +3 -3
- package/dist/module/mine/mine.js.map +1 -1
- package/dist/module/network/Connection.d.ts +3 -2
- package/dist/module/network/Connection.d.ts.map +1 -0
- package/dist/module/network/Connection.js +3 -3
- package/dist/module/network/Connection.js.map +1 -1
- package/dist/module/network/ElectrumNetworkProvider.d.ts +8 -5
- package/dist/module/network/ElectrumNetworkProvider.d.ts.map +1 -0
- package/dist/module/network/ElectrumNetworkProvider.js +59 -13
- package/dist/module/network/ElectrumNetworkProvider.js.map +1 -1
- package/dist/module/network/NetworkProvider.d.ts +2 -1
- package/dist/module/network/NetworkProvider.d.ts.map +1 -0
- package/dist/module/network/configuration.d.ts +8 -10
- package/dist/module/network/configuration.d.ts.map +1 -0
- package/dist/module/network/configuration.js +29 -17
- package/dist/module/network/configuration.js.map +1 -1
- package/dist/module/network/constant.d.ts +1 -0
- package/dist/module/network/constant.d.ts.map +1 -0
- package/dist/module/network/constant.js +8 -4
- package/dist/module/network/constant.js.map +1 -1
- package/dist/module/network/default.d.ts +4 -3
- package/dist/module/network/default.d.ts.map +1 -0
- package/dist/module/network/default.js +7 -7
- package/dist/module/network/default.js.map +1 -1
- package/dist/module/network/getRelayFeeCache.d.ts +2 -1
- package/dist/module/network/getRelayFeeCache.d.ts.map +1 -0
- package/dist/module/network/getRelayFeeCache.js +2 -2
- package/dist/module/network/getRelayFeeCache.js.map +1 -1
- package/dist/module/network/index.d.ts +3 -2
- package/dist/module/network/index.d.ts.map +1 -0
- package/dist/module/network/index.js +2 -2
- package/dist/module/network/index.js.map +1 -1
- package/dist/module/network/interface.d.ts +1 -0
- package/dist/module/network/interface.d.ts.map +1 -0
- package/dist/module/network/util.d.ts +2 -1
- package/dist/module/network/util.d.ts.map +1 -0
- package/dist/module/qr/Qr.d.ts +2 -1
- package/dist/module/qr/Qr.d.ts.map +1 -0
- package/dist/module/qr/Qr.js +2 -2
- package/dist/module/qr/Qr.js.map +1 -1
- package/dist/module/qr/interface.d.ts +1 -0
- package/dist/module/qr/interface.d.ts.map +1 -0
- package/dist/module/rate/ExchangeRate.d.ts +1 -0
- package/dist/module/rate/ExchangeRate.d.ts.map +1 -0
- package/dist/module/rate/ExchangeRate.js +5 -5
- package/dist/module/rate/ExchangeRate.js.map +1 -1
- package/dist/module/slp/GsppProvider.d.ts +4 -3
- package/dist/module/slp/GsppProvider.d.ts.map +1 -0
- package/dist/module/slp/GsppProvider.js +7 -7
- package/dist/module/slp/GsppProvider.js.map +1 -1
- package/dist/module/slp/SlpDbProvider.d.ts +4 -3
- package/dist/module/slp/SlpDbProvider.d.ts.map +1 -0
- package/dist/module/slp/SlpDbProvider.js +8 -8
- package/dist/module/slp/SlpDbProvider.js.map +1 -1
- package/dist/module/slp/SlpDbTemplates.d.ts +1 -0
- package/dist/module/slp/SlpDbTemplates.d.ts.map +1 -0
- package/dist/module/slp/SlpLibAuth.d.ts +7 -14
- package/dist/module/slp/SlpLibAuth.d.ts.map +1 -0
- package/dist/module/slp/SlpLibAuth.js +48 -39
- package/dist/module/slp/SlpLibAuth.js.map +1 -1
- package/dist/module/slp/SlpProvider.d.ts +2 -1
- package/dist/module/slp/SlpProvider.d.ts.map +1 -0
- package/dist/module/slp/SlpProvider.js.map +1 -1
- package/dist/module/slp/index.d.ts +5 -4
- package/dist/module/slp/index.d.ts.map +1 -0
- package/dist/module/slp/index.js +3 -3
- package/dist/module/slp/index.js.map +1 -1
- package/dist/module/slp/interface.d.ts +2 -1
- package/dist/module/slp/interface.d.ts.map +1 -0
- package/dist/module/test/axios.d.ts +3 -0
- package/dist/module/test/axios.d.ts.map +1 -0
- package/dist/module/test/axios.js +35 -0
- package/dist/module/test/axios.js.map +1 -0
- package/dist/module/test/expect.d.ts +6 -1
- package/dist/module/test/expect.d.ts.map +1 -0
- package/dist/module/test/expect.js +22 -1
- package/dist/module/test/expect.js.map +1 -1
- package/dist/module/transaction/Wif.d.ts +19 -16
- package/dist/module/transaction/Wif.d.ts.map +1 -0
- package/dist/module/transaction/Wif.js +152 -55
- package/dist/module/transaction/Wif.js.map +1 -1
- package/dist/module/transaction/allocateFee.d.ts +5 -4
- package/dist/module/transaction/allocateFee.d.ts.map +1 -0
- package/dist/module/transaction/allocateFee.js +11 -8
- package/dist/module/transaction/allocateFee.js.map +1 -1
- package/dist/module/util/amountInSatoshi.d.ts +1 -0
- package/dist/module/util/amountInSatoshi.d.ts.map +1 -0
- package/dist/module/util/amountInSatoshi.js +4 -4
- package/dist/module/util/amountInSatoshi.js.map +1 -1
- package/dist/module/util/asSendRequestObject.d.ts +3 -2
- package/dist/module/util/asSendRequestObject.d.ts.map +1 -0
- package/dist/module/util/asSendRequestObject.js +6 -3
- package/dist/module/util/asSendRequestObject.js.map +1 -1
- package/dist/module/util/balanceObjectFromSatoshi.d.ts +1 -0
- package/dist/module/util/balanceObjectFromSatoshi.d.ts.map +1 -0
- package/dist/module/util/balanceObjectFromSatoshi.js +5 -5
- package/dist/module/util/balanceObjectFromSatoshi.js.map +1 -1
- package/dist/module/util/base64.d.ts +2 -1
- package/dist/module/util/base64.d.ts.map +1 -0
- package/dist/module/util/base64.js +5 -25
- package/dist/module/util/base64.js.map +1 -1
- package/dist/module/util/bchaddr.d.ts +1 -0
- package/dist/module/util/bchaddr.d.ts.map +1 -0
- package/dist/module/util/browserNotSupported.d.ts +1 -0
- package/dist/module/util/browserNotSupported.d.ts.map +1 -0
- package/dist/module/util/browserNotSupported.js +1 -1
- package/dist/module/util/browserNotSupported.js.map +1 -1
- package/dist/module/util/checkForEmptySeed.d.ts +1 -0
- package/dist/module/util/checkForEmptySeed.d.ts.map +1 -0
- package/dist/module/util/checkWifNetwork.d.ts +2 -1
- package/dist/module/util/checkWifNetwork.d.ts.map +1 -0
- package/dist/module/util/checkWifNetwork.js +1 -1
- package/dist/module/util/checkWifNetwork.js.map +1 -1
- package/dist/module/util/convert.d.ts +1 -0
- package/dist/module/util/convert.d.ts.map +1 -0
- package/dist/module/util/convert.js +2 -2
- package/dist/module/util/convert.js.map +1 -1
- package/dist/module/util/delay.d.ts +1 -0
- package/dist/module/util/delay.d.ts.map +1 -0
- package/dist/module/util/deriveCashaddr.d.ts +6 -1
- package/dist/module/util/deriveCashaddr.d.ts.map +1 -0
- package/dist/module/util/deriveCashaddr.js +85 -6
- package/dist/module/util/deriveCashaddr.js.map +1 -1
- package/dist/module/util/deriveLockscript.d.ts +1 -0
- package/dist/module/util/deriveLockscript.d.ts.map +1 -0
- package/dist/module/util/deriveNetwork.d.ts +1 -0
- package/dist/module/util/deriveNetwork.d.ts.map +1 -0
- package/dist/module/util/deriveNetwork.js +2 -2
- package/dist/module/util/deriveNetwork.js.map +1 -1
- package/dist/module/util/derivePublicKeyHash.d.ts +3 -1
- package/dist/module/util/derivePublicKeyHash.d.ts.map +1 -0
- package/dist/module/util/derivePublicKeyHash.js +1 -1
- package/dist/module/util/derivePublicKeyHash.js.map +1 -1
- package/dist/module/util/eventsource.d.ts +1 -0
- package/dist/module/util/eventsource.d.ts.map +1 -0
- package/dist/module/util/eventsource.js +3 -2
- package/dist/module/util/eventsource.js.map +1 -1
- package/dist/module/util/floor.d.ts +1 -0
- package/dist/module/util/floor.d.ts.map +1 -0
- package/dist/module/util/getAddrsByXpubKey.d.ts +8 -8
- package/dist/module/util/getAddrsByXpubKey.d.ts.map +1 -0
- package/dist/module/util/getAddrsByXpubKey.js +17 -21
- package/dist/module/util/getAddrsByXpubKey.js.map +1 -1
- package/dist/module/util/getRuntimePlatform.d.ts +1 -0
- package/dist/module/util/getRuntimePlatform.d.ts.map +1 -0
- package/dist/module/util/getUsdRate.d.ts +1 -0
- package/dist/module/util/getUsdRate.d.ts.map +1 -0
- package/dist/module/util/getUsdRate.js +1 -1
- package/dist/module/util/getUsdRate.js.map +1 -1
- package/dist/module/util/getXPubKey.d.ts +2 -1
- package/dist/module/util/getXPubKey.d.ts.map +1 -0
- package/dist/module/util/getXPubKey.js +6 -7
- package/dist/module/util/getXPubKey.js.map +1 -1
- package/dist/module/util/hash160.d.ts +2 -1
- package/dist/module/util/hash160.d.ts.map +1 -0
- package/dist/module/util/hash160.js +2 -4
- package/dist/module/util/hash160.js.map +1 -1
- package/dist/module/util/index.d.ts +21 -20
- package/dist/module/util/index.d.ts.map +1 -0
- package/dist/module/util/index.js +20 -20
- package/dist/module/util/index.js.map +1 -1
- package/dist/module/util/randomBytes.d.ts +3 -1
- package/dist/module/util/randomBytes.d.ts.map +1 -0
- package/dist/module/util/randomBytes.js +2 -3
- package/dist/module/util/randomBytes.js.map +1 -1
- package/dist/module/util/randomInt.d.ts +1 -0
- package/dist/module/util/randomInt.d.ts.map +1 -0
- package/dist/module/util/randomValues.d.ts +1 -0
- package/dist/module/util/randomValues.d.ts.map +1 -0
- package/dist/module/util/randomValues.js +7 -7
- package/dist/module/util/randomValues.js.map +1 -1
- package/dist/module/util/sanitizeAddress.d.ts +1 -0
- package/dist/module/util/sanitizeAddress.d.ts.map +1 -0
- package/dist/module/util/sanitizeAddress.js +1 -1
- package/dist/module/util/sanitizeAddress.js.map +1 -1
- package/dist/module/util/sanitizeUnit.d.ts +2 -1
- package/dist/module/util/sanitizeUnit.d.ts.map +1 -0
- package/dist/module/util/satoshiToAmount.d.ts +1 -0
- package/dist/module/util/satoshiToAmount.d.ts.map +1 -0
- package/dist/module/util/satoshiToAmount.js +4 -4
- package/dist/module/util/satoshiToAmount.js.map +1 -1
- package/dist/module/util/sumSendRequestAmounts.d.ts +3 -2
- package/dist/module/util/sumSendRequestAmounts.d.ts.map +1 -0
- package/dist/module/util/sumSendRequestAmounts.js +5 -2
- package/dist/module/util/sumSendRequestAmounts.js.map +1 -1
- package/dist/module/util/sumUtxoValue.d.ts +4 -2
- package/dist/module/util/sumUtxoValue.d.ts.map +1 -0
- package/dist/module/util/sumUtxoValue.js +17 -3
- package/dist/module/util/sumUtxoValue.js.map +1 -1
- package/dist/module/util/transaction.d.ts +2 -0
- package/dist/module/util/transaction.d.ts.map +1 -0
- package/dist/module/util/transaction.js +7 -0
- package/dist/module/util/transaction.js.map +1 -0
- package/dist/module/wallet/Base.d.ts +8 -7
- package/dist/module/wallet/Base.d.ts.map +1 -0
- package/dist/module/wallet/Base.js +7 -7
- package/dist/module/wallet/Base.js.map +1 -1
- package/dist/module/wallet/Bcmr.d.ts +88 -0
- package/dist/module/wallet/Bcmr.d.ts.map +1 -0
- package/dist/module/wallet/Bcmr.js +281 -0
- package/dist/module/wallet/Bcmr.js.map +1 -0
- package/dist/module/wallet/Slp.d.ts +6 -5
- package/dist/module/wallet/Slp.d.ts.map +1 -0
- package/dist/module/wallet/Slp.js +15 -15
- package/dist/module/wallet/Slp.js.map +1 -1
- package/dist/module/wallet/Util.d.ts +3 -2
- package/dist/module/wallet/Util.d.ts.map +1 -0
- package/dist/module/wallet/Util.js +9 -14
- package/dist/module/wallet/Util.js.map +1 -1
- package/dist/module/wallet/Wif.d.ts +124 -20
- package/dist/module/wallet/Wif.d.ts.map +1 -0
- package/dist/module/wallet/Wif.js +406 -74
- package/dist/module/wallet/Wif.js.map +1 -1
- package/dist/module/wallet/bcmr-v1.schema.d.ts +623 -0
- package/dist/module/wallet/bcmr-v1.schema.d.ts.map +1 -0
- package/dist/module/wallet/bcmr-v1.schema.js +2 -0
- package/dist/module/wallet/bcmr-v1.schema.js.map +1 -0
- package/dist/module/wallet/createWallet.d.ts +3 -2
- package/dist/module/wallet/createWallet.d.ts.map +1 -0
- package/dist/module/wallet/createWallet.js +3 -3
- package/dist/module/wallet/createWallet.js.map +1 -1
- package/dist/module/wallet/enum.d.ts +1 -0
- package/dist/module/wallet/enum.d.ts.map +1 -0
- package/dist/module/wallet/interface.d.ts +10 -6
- package/dist/module/wallet/interface.d.ts.map +1 -0
- package/dist/module/wallet/model.d.ts +81 -5
- package/dist/module/wallet/model.d.ts.map +1 -0
- package/dist/module/wallet/model.js +102 -17
- package/dist/module/wallet/model.js.map +1 -1
- package/dist/module/webhook/Webhook.d.ts +3 -2
- package/dist/module/webhook/Webhook.d.ts.map +1 -0
- package/dist/module/webhook/Webhook.js +4 -1
- package/dist/module/webhook/Webhook.js.map +1 -1
- package/dist/module/webhook/WebhookBch.d.ts +4 -3
- package/dist/module/webhook/WebhookBch.d.ts.map +1 -0
- package/dist/module/webhook/WebhookBch.js +4 -4
- package/dist/module/webhook/WebhookBch.js.map +1 -1
- package/dist/module/webhook/WebhookSlp.d.ts +5 -4
- package/dist/module/webhook/WebhookSlp.d.ts.map +1 -0
- package/dist/module/webhook/WebhookSlp.js +4 -4
- package/dist/module/webhook/WebhookSlp.js.map +1 -1
- package/dist/module/webhook/WebhookWorker.d.ts +3 -2
- package/dist/module/webhook/WebhookWorker.d.ts.map +1 -0
- package/dist/module/webhook/WebhookWorker.js +1 -1
- package/dist/module/webhook/WebhookWorker.js.map +1 -1
- package/dist/module/webhook/index.d.ts +6 -5
- package/dist/module/webhook/index.d.ts.map +1 -0
- package/dist/module/webhook/index.js +5 -5
- package/dist/module/webhook/index.js.map +1 -1
- package/dist/module/webhook/interface.d.ts +1 -0
- package/dist/module/webhook/interface.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/polyfill/{bip39.browser.js → bip39.browser.cjs} +1 -0
- package/polyfill/{util.js → util.cjs} +0 -0
- package/src/Wallet.test.headless.js +6 -6
- package/src/cli.ts +3 -3
- package/src/db/ExchangeRateProvider.ts +1 -1
- package/src/db/IndexedDBProvider.test.ts +0 -1
- package/src/db/IndexedDBProvider.ts +2 -2
- package/src/db/SqlProvider.ts +14 -12
- package/src/db/StorageProvider.ts +1 -1
- package/src/db/getStorageProvider.ts +20 -0
- package/src/db/index.ts +3 -3
- package/src/db/util.ts +1 -20
- package/src/history/electrumTransformer.ts +13 -14
- package/src/history/interface.ts +1 -1
- package/src/index.ts +29 -21
- package/src/interface.ts +15 -0
- package/src/message/index.ts +2 -2
- package/src/message/signed.test.ts +4 -4
- package/src/message/signed.ts +23 -6
- package/src/mine/index.ts +1 -1
- package/src/mine/mine.ts +3 -3
- package/src/network/Connection.ts +5 -5
- package/src/network/ElectrumNetworkProvider.ts +85 -20
- package/src/network/NetworkProvider.ts +1 -1
- package/src/network/configuration.test.ts +33 -8
- package/src/network/configuration.ts +33 -18
- package/src/network/constant.ts +9 -4
- package/src/network/default.ts +13 -10
- package/src/network/getRelayFeeCache.ts +3 -3
- package/src/network/index.ts +6 -2
- package/src/network/util.ts +1 -1
- package/src/qr/Qr.ts +3 -3
- package/src/rate/ExchangeRate.ts +14 -15
- package/src/slp/GsppProvider.test.ts +2 -2
- package/src/slp/GsppProvider.ts +11 -8
- package/src/slp/SlpDbProvider.test.ts +1 -1
- package/src/slp/SlpDbProvider.ts +12 -9
- package/src/slp/SlpLibAuth.test.ts +1 -1
- package/src/slp/SlpLibAuth.ts +52 -42
- package/src/slp/SlpProvider.ts +6 -1
- package/src/slp/index.ts +4 -4
- package/src/slp/interface.ts +1 -1
- package/src/test/axios.ts +47 -0
- package/src/test/expect.ts +27 -2
- package/src/transaction/Wif.ts +203 -77
- package/src/transaction/allocateFee.ts +32 -14
- package/src/util/amountInSatoshi.ts +4 -4
- package/src/util/asSendRequestObject.ts +42 -30
- package/src/util/balanceObjectFromSatoshi.ts +5 -5
- package/src/util/base64.ts +5 -24
- package/src/util/browserNotSupported.ts +1 -1
- package/src/util/checkWifNetwork.ts +1 -1
- package/src/util/convert.ts +2 -2
- package/src/util/deriveCashaddr.test.ts +43 -0
- package/src/util/deriveCashaddr.ts +123 -7
- package/src/util/deriveNetwork.ts +2 -2
- package/src/util/derivePublicKeyHash.test.ts +3 -0
- package/src/util/derivePublicKeyHash.ts +18 -5
- package/src/util/eventsource.ts +4 -2
- package/src/util/getAddrsByXpubKey.test.ts +5 -5
- package/src/util/getAddrsByXpubKey.ts +23 -28
- package/src/util/getUsdRate.ts +1 -1
- package/src/util/getXPubKey.ts +5 -7
- package/src/util/hash160.test.ts +2 -2
- package/src/util/hash160.ts +2 -4
- package/src/util/index.ts +26 -20
- package/src/util/randomBytes.ts +2 -3
- package/src/util/randomValues.ts +8 -8
- package/src/util/sanitizeAddress.ts +1 -1
- package/src/util/sanitizeUnit.ts +1 -1
- package/src/util/satoshiToAmount.ts +4 -4
- package/src/util/sumSendRequestAmounts.ts +10 -4
- package/src/util/sumUtxoValue.ts +19 -7
- package/src/util/transaction.ts +10 -0
- package/src/wallet/Base.ts +11 -11
- package/src/wallet/Bcmr.test.headless.js +353 -0
- package/src/wallet/Bcmr.test.ts +610 -0
- package/src/wallet/Bcmr.ts +390 -0
- package/src/wallet/Cashtokens.test.headless.js +467 -0
- package/src/wallet/Cashtokens.test.ts +475 -0
- package/src/wallet/Slp.test.headless.js +6 -8
- package/src/wallet/Slp.test.ts +2 -2
- package/src/wallet/Slp.ts +26 -22
- package/src/wallet/Util.ts +9 -20
- package/src/wallet/Wif.test.ts +20 -21
- package/src/wallet/Wif.ts +534 -99
- package/src/wallet/bcmr-v1.schema.ts +639 -0
- package/src/wallet/createWallet.test.ts +1 -0
- package/src/wallet/createWallet.ts +4 -4
- package/src/wallet/interface.ts +9 -6
- package/src/wallet/model.ts +190 -19
- package/src/webhook/Webhook.ts +7 -3
- package/src/webhook/WebhookBch.ts +7 -7
- package/src/webhook/WebhookSlp.test.ts +2 -2
- package/src/webhook/WebhookSlp.ts +6 -6
- package/src/webhook/WebhookWorker.ts +2 -2
- package/src/webhook/index.ts +5 -5
- package/tsconfig.browser.json +0 -3
- package/tsconfig.json +17 -5
- package/{webpack.config.js → webpack.config.cjs} +46 -14
- package/dist/main/chain.d.ts +0 -3
- package/dist/main/chain.js +0 -7
- package/dist/main/chain.js.map +0 -1
- package/dist/main/cli.d.ts +0 -1
- package/dist/main/cli.js +0 -35
- package/dist/main/cli.js.map +0 -1
- package/dist/main/constant.d.ts +0 -5
- package/dist/main/constant.js +0 -27
- package/dist/main/constant.js.map +0 -1
- package/dist/main/db/ExchangeRateProvider.d.ts +0 -11
- package/dist/main/db/ExchangeRateProvider.js +0 -47
- package/dist/main/db/ExchangeRateProvider.js.map +0 -1
- package/dist/main/db/IndexedDBProvider.d.ts +0 -15
- package/dist/main/db/IndexedDBProvider.js +0 -86
- package/dist/main/db/IndexedDBProvider.js.map +0 -1
- package/dist/main/db/SqlProvider.d.ts +0 -41
- package/dist/main/db/SqlProvider.js +0 -217
- package/dist/main/db/SqlProvider.js.map +0 -1
- package/dist/main/db/StorageProvider.d.ts +0 -52
- package/dist/main/db/StorageProvider.js +0 -3
- package/dist/main/db/StorageProvider.js.map +0 -1
- package/dist/main/db/index.d.ts +0 -3
- package/dist/main/db/index.js +0 -11
- package/dist/main/db/index.js.map +0 -1
- package/dist/main/db/interface.d.ts +0 -22
- package/dist/main/db/interface.js +0 -3
- package/dist/main/db/interface.js.map +0 -1
- package/dist/main/db/util.d.ts +0 -5
- package/dist/main/db/util.js +0 -53
- package/dist/main/db/util.js.map +0 -1
- package/dist/main/enum.d.ts +0 -33
- package/dist/main/enum.js +0 -39
- package/dist/main/enum.js.map +0 -1
- package/dist/main/history/electrumTransformer.d.ts +0 -4
- package/dist/main/history/electrumTransformer.js +0 -216
- package/dist/main/history/electrumTransformer.js.map +0 -1
- package/dist/main/history/interface.d.ts +0 -16
- package/dist/main/history/interface.js +0 -3
- package/dist/main/history/interface.js.map +0 -1
- package/dist/main/index.d.ts +0 -24
- package/dist/main/index.js +0 -62
- package/dist/main/index.js.map +0 -1
- package/dist/main/interface.d.ts +0 -31
- package/dist/main/interface.js +0 -12
- package/dist/main/interface.js.map +0 -1
- package/dist/main/message/index.d.ts +0 -2
- package/dist/main/message/index.js +0 -15
- package/dist/main/message/index.js.map +0 -1
- package/dist/main/message/interface.d.ts +0 -29
- package/dist/main/message/interface.js +0 -6
- package/dist/main/message/interface.js.map +0 -1
- package/dist/main/message/signed.d.ts +0 -33
- package/dist/main/message/signed.js +0 -141
- package/dist/main/message/signed.js.map +0 -1
- package/dist/main/mine/index.d.ts +0 -1
- package/dist/main/mine/index.js +0 -14
- package/dist/main/mine/index.js.map +0 -1
- package/dist/main/mine/mine.d.ts +0 -13
- package/dist/main/mine/mine.js +0 -37
- package/dist/main/mine/mine.js.map +0 -1
- package/dist/main/network/Connection.d.ts +0 -14
- package/dist/main/network/Connection.js +0 -71
- package/dist/main/network/Connection.js.map +0 -1
- package/dist/main/network/ElectrumNetworkProvider.d.ts +0 -49
- package/dist/main/network/ElectrumNetworkProvider.js +0 -338
- package/dist/main/network/ElectrumNetworkProvider.js.map +0 -1
- package/dist/main/network/NetworkProvider.d.ts +0 -107
- package/dist/main/network/NetworkProvider.js +0 -3
- package/dist/main/network/NetworkProvider.js.map +0 -1
- package/dist/main/network/configuration.d.ts +0 -12
- package/dist/main/network/configuration.js +0 -79
- package/dist/main/network/configuration.js.map +0 -1
- package/dist/main/network/constant.d.ts +0 -35
- package/dist/main/network/constant.js +0 -55
- package/dist/main/network/constant.js.map +0 -1
- package/dist/main/network/default.d.ts +0 -7
- package/dist/main/network/default.js +0 -107
- package/dist/main/network/default.js.map +0 -1
- package/dist/main/network/getRelayFeeCache.d.ts +0 -2
- package/dist/main/network/getRelayFeeCache.js +0 -27
- package/dist/main/network/getRelayFeeCache.js.map +0 -1
- package/dist/main/network/index.d.ts +0 -2
- package/dist/main/network/index.js +0 -10
- package/dist/main/network/index.js.map +0 -1
- package/dist/main/network/interface.d.ts +0 -60
- package/dist/main/network/interface.js +0 -3
- package/dist/main/network/interface.js.map +0 -1
- package/dist/main/network/util.d.ts +0 -2
- package/dist/main/network/util.js +0 -32
- package/dist/main/network/util.js.map +0 -1
- package/dist/main/qr/Qr.d.ts +0 -8
- package/dist/main/qr/Qr.js +0 -26
- package/dist/main/qr/Qr.js.map +0 -1
- package/dist/main/qr/interface.d.ts +0 -5
- package/dist/main/qr/interface.js +0 -3
- package/dist/main/qr/interface.js.map +0 -1
- package/dist/main/rate/ExchangeRate.d.ts +0 -19
- package/dist/main/rate/ExchangeRate.js +0 -147
- package/dist/main/rate/ExchangeRate.js.map +0 -1
- package/dist/main/slp/GsppProvider.d.ts +0 -54
- package/dist/main/slp/GsppProvider.js +0 -214
- package/dist/main/slp/GsppProvider.js.map +0 -1
- package/dist/main/slp/SlpDbProvider.d.ts +0 -51
- package/dist/main/slp/SlpDbProvider.js +0 -182
- package/dist/main/slp/SlpDbProvider.js.map +0 -1
- package/dist/main/slp/SlpDbTemplates.d.ts +0 -312
- package/dist/main/slp/SlpDbTemplates.js +0 -387
- package/dist/main/slp/SlpDbTemplates.js.map +0 -1
- package/dist/main/slp/SlpLibAuth.d.ts +0 -217
- package/dist/main/slp/SlpLibAuth.js +0 -452
- package/dist/main/slp/SlpLibAuth.js.map +0 -1
- package/dist/main/slp/SlpProvider.d.ts +0 -23
- package/dist/main/slp/SlpProvider.js +0 -39
- package/dist/main/slp/SlpProvider.js.map +0 -1
- package/dist/main/slp/index.d.ts +0 -5
- package/dist/main/slp/index.js +0 -24
- package/dist/main/slp/index.js.map +0 -1
- package/dist/main/slp/interface.d.ts +0 -113
- package/dist/main/slp/interface.js +0 -10
- package/dist/main/slp/interface.js.map +0 -1
- package/dist/main/test/expect.d.ts +0 -7
- package/dist/main/test/expect.js +0 -31
- package/dist/main/test/expect.js.map +0 -1
- package/dist/main/transaction/Wif.d.ts +0 -42
- package/dist/main/transaction/Wif.js +0 -214
- package/dist/main/transaction/Wif.js.map +0 -1
- package/dist/main/transaction/allocateFee.d.ts +0 -7
- package/dist/main/transaction/allocateFee.js +0 -118
- package/dist/main/transaction/allocateFee.js.map +0 -1
- package/dist/main/util/amountInSatoshi.d.ts +0 -9
- package/dist/main/util/amountInSatoshi.js +0 -38
- package/dist/main/util/amountInSatoshi.js.map +0 -1
- package/dist/main/util/asSendRequestObject.d.ts +0 -2
- package/dist/main/util/asSendRequestObject.js +0 -57
- package/dist/main/util/asSendRequestObject.js.map +0 -1
- package/dist/main/util/balanceObjectFromSatoshi.d.ts +0 -8
- package/dist/main/util/balanceObjectFromSatoshi.js +0 -62
- package/dist/main/util/balanceObjectFromSatoshi.js.map +0 -1
- package/dist/main/util/base64.d.ts +0 -2
- package/dist/main/util/base64.js +0 -36
- package/dist/main/util/base64.js.map +0 -1
- package/dist/main/util/bchaddr.d.ts +0 -1
- package/dist/main/util/bchaddr.js +0 -24
- package/dist/main/util/bchaddr.js.map +0 -1
- package/dist/main/util/browserNotSupported.d.ts +0 -1
- package/dist/main/util/browserNotSupported.js +0 -11
- package/dist/main/util/browserNotSupported.js.map +0 -1
- package/dist/main/util/checkForEmptySeed.d.ts +0 -2
- package/dist/main/util/checkForEmptySeed.js +0 -12
- package/dist/main/util/checkForEmptySeed.js.map +0 -1
- package/dist/main/util/checkWifNetwork.d.ts +0 -2
- package/dist/main/util/checkWifNetwork.js +0 -16
- package/dist/main/util/checkWifNetwork.js.map +0 -1
- package/dist/main/util/convert.d.ts +0 -15
- package/dist/main/util/convert.js +0 -24
- package/dist/main/util/convert.js.map +0 -1
- package/dist/main/util/delay.d.ts +0 -1
- package/dist/main/util/delay.js +0 -8
- package/dist/main/util/delay.js.map +0 -1
- package/dist/main/util/deriveCashaddr.d.ts +0 -2
- package/dist/main/util/deriveCashaddr.js +0 -13
- package/dist/main/util/deriveCashaddr.js.map +0 -1
- package/dist/main/util/deriveLockscript.d.ts +0 -8
- package/dist/main/util/deriveLockscript.js +0 -19
- package/dist/main/util/deriveLockscript.js.map +0 -1
- package/dist/main/util/deriveNetwork.d.ts +0 -1
- package/dist/main/util/deriveNetwork.js +0 -23
- package/dist/main/util/deriveNetwork.js.map +0 -1
- package/dist/main/util/derivePublicKeyHash.d.ts +0 -16
- package/dist/main/util/derivePublicKeyHash.js +0 -49
- package/dist/main/util/derivePublicKeyHash.js.map +0 -1
- package/dist/main/util/eventsource.d.ts +0 -2
- package/dist/main/util/eventsource.js +0 -12
- package/dist/main/util/eventsource.js.map +0 -1
- package/dist/main/util/floor.d.ts +0 -1
- package/dist/main/util/floor.js +0 -9
- package/dist/main/util/floor.js.map +0 -1
- package/dist/main/util/getAddrsByXpubKey.d.ts +0 -22
- package/dist/main/util/getAddrsByXpubKey.js +0 -79
- package/dist/main/util/getAddrsByXpubKey.js.map +0 -1
- package/dist/main/util/getRuntimePlatform.d.ts +0 -6
- package/dist/main/util/getRuntimePlatform.js +0 -34
- package/dist/main/util/getRuntimePlatform.js.map +0 -1
- package/dist/main/util/getUsdRate.d.ts +0 -1
- package/dist/main/util/getUsdRate.js +0 -9
- package/dist/main/util/getUsdRate.js.map +0 -1
- package/dist/main/util/getXPubKey.d.ts +0 -1
- package/dist/main/util/getXPubKey.js +0 -26
- package/dist/main/util/getXPubKey.js.map +0 -1
- package/dist/main/util/hash160.d.ts +0 -8
- package/dist/main/util/hash160.js +0 -18
- package/dist/main/util/hash160.js.map +0 -1
- package/dist/main/util/index.d.ts +0 -21
- package/dist/main/util/index.js +0 -72
- package/dist/main/util/index.js.map +0 -1
- package/dist/main/util/randomBytes.d.ts +0 -1
- package/dist/main/util/randomBytes.js +0 -18
- package/dist/main/util/randomBytes.js.map +0 -1
- package/dist/main/util/randomInt.d.ts +0 -1
- package/dist/main/util/randomInt.js +0 -9
- package/dist/main/util/randomInt.js.map +0 -1
- package/dist/main/util/randomValues.d.ts +0 -1
- package/dist/main/util/randomValues.js +0 -15
- package/dist/main/util/randomValues.js.map +0 -1
- package/dist/main/util/sanitizeAddress.d.ts +0 -1
- package/dist/main/util/sanitizeAddress.js +0 -15
- package/dist/main/util/sanitizeAddress.js.map +0 -1
- package/dist/main/util/sanitizeUnit.d.ts +0 -2
- package/dist/main/util/sanitizeUnit.js +0 -13
- package/dist/main/util/sanitizeUnit.js.map +0 -1
- package/dist/main/util/satoshiToAmount.d.ts +0 -9
- package/dist/main/util/satoshiToAmount.js +0 -41
- package/dist/main/util/satoshiToAmount.js.map +0 -1
- package/dist/main/util/sumSendRequestAmounts.d.ts +0 -2
- package/dist/main/util/sumSendRequestAmounts.js +0 -31
- package/dist/main/util/sumSendRequestAmounts.js.map +0 -1
- package/dist/main/util/sumUtxoValue.d.ts +0 -2
- package/dist/main/util/sumUtxoValue.js +0 -17
- package/dist/main/util/sumUtxoValue.js.map +0 -1
- package/dist/main/wallet/Base.d.ts +0 -202
- package/dist/main/wallet/Base.js +0 -438
- package/dist/main/wallet/Base.js.map +0 -1
- package/dist/main/wallet/Slp.d.ts +0 -430
- package/dist/main/wallet/Slp.js +0 -775
- package/dist/main/wallet/Slp.js.map +0 -1
- package/dist/main/wallet/Util.d.ts +0 -69
- package/dist/main/wallet/Util.js +0 -182
- package/dist/main/wallet/Util.js.map +0 -1
- package/dist/main/wallet/Wif.d.ts +0 -255
- package/dist/main/wallet/Wif.js +0 -1067
- package/dist/main/wallet/Wif.js.map +0 -1
- package/dist/main/wallet/createWallet.d.ts +0 -69
- package/dist/main/wallet/createWallet.js +0 -244
- package/dist/main/wallet/createWallet.js.map +0 -1
- package/dist/main/wallet/enum.d.ts +0 -16
- package/dist/main/wallet/enum.js +0 -22
- package/dist/main/wallet/enum.js.map +0 -1
- package/dist/main/wallet/interface.d.ts +0 -76
- package/dist/main/wallet/interface.js +0 -3
- package/dist/main/wallet/interface.js.map +0 -1
- package/dist/main/wallet/model.d.ts +0 -88
- package/dist/main/wallet/model.js +0 -129
- package/dist/main/wallet/model.js.map +0 -1
- package/dist/main/webhook/Webhook.d.ts +0 -40
- package/dist/main/webhook/Webhook.js +0 -82
- package/dist/main/webhook/Webhook.js.map +0 -1
- package/dist/main/webhook/WebhookBch.d.ts +0 -13
- package/dist/main/webhook/WebhookBch.js +0 -148
- package/dist/main/webhook/WebhookBch.js.map +0 -1
- package/dist/main/webhook/WebhookSlp.d.ts +0 -14
- package/dist/main/webhook/WebhookSlp.js +0 -107
- package/dist/main/webhook/WebhookSlp.js.map +0 -1
- package/dist/main/webhook/WebhookWorker.d.ts +0 -22
- package/dist/main/webhook/WebhookWorker.js +0 -100
- package/dist/main/webhook/WebhookWorker.js.map +0 -1
- package/dist/main/webhook/index.d.ts +0 -5
- package/dist/main/webhook/index.js +0 -23
- package/dist/main/webhook/index.js.map +0 -1
- package/dist/main/webhook/interface.d.ts +0 -8
- package/dist/main/webhook/interface.js +0 -3
- package/dist/main/webhook/interface.js.map +0 -1
- package/dist/mainnet-0.5.9.js +0 -2
- package/dist/mainnet-0.5.9.js.LICENSE.txt +0 -48
- package/dist/tsconfig.browser.tsbuildinfo +0 -1
- package/jest.config.js +0 -23
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Helper function to convert an address to a public key hash
|
|
3
|
-
*
|
|
4
|
-
* @param address Address to convert to a hash
|
|
5
|
-
*
|
|
6
|
-
* @returns a public key hash corresponding to the passed address
|
|
7
|
-
*/
|
|
8
|
-
export declare function derivePublicKeyHash(address: string): Uint8Array;
|
|
9
|
-
/**
|
|
10
|
-
* Helper function to convert an address prefix
|
|
11
|
-
*
|
|
12
|
-
* @param address Address with or without prefix
|
|
13
|
-
*
|
|
14
|
-
* @returns the address prefix
|
|
15
|
-
*/
|
|
16
|
-
export declare function derivePrefix(address: string): string;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.derivePrefix = exports.derivePublicKeyHash = void 0;
|
|
4
|
-
const libauth_1 = require("@bitauth/libauth");
|
|
5
|
-
/**
|
|
6
|
-
* Helper function to convert an address to a public key hash
|
|
7
|
-
*
|
|
8
|
-
* @param address Address to convert to a hash
|
|
9
|
-
*
|
|
10
|
-
* @returns a public key hash corresponding to the passed address
|
|
11
|
-
*/
|
|
12
|
-
function derivePublicKeyHash(address) {
|
|
13
|
-
let result;
|
|
14
|
-
// If the address has a prefix decode it as is
|
|
15
|
-
if (address.includes(":")) {
|
|
16
|
-
result = (0, libauth_1.decodeCashAddressFormat)(address);
|
|
17
|
-
}
|
|
18
|
-
// otherwise, derive the network from the address without prefix
|
|
19
|
-
else {
|
|
20
|
-
result = (0, libauth_1.decodeCashAddressFormatWithoutPrefix)(address);
|
|
21
|
-
}
|
|
22
|
-
if (typeof result === "string")
|
|
23
|
-
throw new Error(result);
|
|
24
|
-
// return the public key hash
|
|
25
|
-
return result.hash;
|
|
26
|
-
}
|
|
27
|
-
exports.derivePublicKeyHash = derivePublicKeyHash;
|
|
28
|
-
/**
|
|
29
|
-
* Helper function to convert an address prefix
|
|
30
|
-
*
|
|
31
|
-
* @param address Address with or without prefix
|
|
32
|
-
*
|
|
33
|
-
* @returns the address prefix
|
|
34
|
-
*/
|
|
35
|
-
function derivePrefix(address) {
|
|
36
|
-
let result;
|
|
37
|
-
if (address.includes(":")) {
|
|
38
|
-
result = (0, libauth_1.decodeCashAddressFormat)(address);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
result = (0, libauth_1.decodeCashAddressFormatWithoutPrefix)(address);
|
|
42
|
-
}
|
|
43
|
-
if (typeof result === "string")
|
|
44
|
-
throw new Error(result);
|
|
45
|
-
// TODO pass the network in and check it or raise Error
|
|
46
|
-
return result.prefix;
|
|
47
|
-
}
|
|
48
|
-
exports.derivePrefix = derivePrefix;
|
|
49
|
-
//# sourceMappingURL=derivePublicKeyHash.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"derivePublicKeyHash.js","sourceRoot":"","sources":["../../../src/util/derivePublicKeyHash.ts"],"names":[],"mappings":";;;AAAA,8CAG0B;AAE1B;;;;;;GAMG;AACH,SAAgB,mBAAmB,CAAC,OAAe;IACjD,IAAI,MAAM,CAAC;IAEX,8CAA8C;IAC9C,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACzB,MAAM,GAAG,IAAA,iCAAuB,EAAC,OAAO,CAAC,CAAC;KAC3C;IACD,gEAAgE;SAC3D;QACH,MAAM,GAAG,IAAA,8CAAoC,EAAC,OAAO,CAAC,CAAC;KACxD;IAED,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;IAExD,6BAA6B;IAC7B,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC;AAhBD,kDAgBC;AAED;;;;;;GAMG;AACH,SAAgB,YAAY,CAAC,OAAe;IAC1C,IAAI,MAAM,CAAC;IAEX,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACzB,MAAM,GAAG,IAAA,iCAAuB,EAAC,OAAO,CAAC,CAAC;KAC3C;SAAM;QACL,MAAM,GAAG,IAAA,8CAAoC,EAAC,OAAO,CAAC,CAAC;KACxD;IAED,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;IAExD,uDAAuD;IACvD,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC;AAbD,oCAaC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getRuntimePlatform_1 = require("./getRuntimePlatform");
|
|
4
|
-
let EventSource;
|
|
5
|
-
if ((0, getRuntimePlatform_1.getRuntimePlatform)() != "node") {
|
|
6
|
-
EventSource = globalThis.EventSource;
|
|
7
|
-
}
|
|
8
|
-
else {
|
|
9
|
-
EventSource = eval("require")("eventsource/");
|
|
10
|
-
}
|
|
11
|
-
exports.default = EventSource;
|
|
12
|
-
//# sourceMappingURL=eventsource.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eventsource.js","sourceRoot":"","sources":["../../../src/util/eventsource.ts"],"names":[],"mappings":";;AAAA,6DAA0D;AAE1D,IAAI,WAAW,CAAC;AAChB,IAAI,IAAA,uCAAkB,GAAE,IAAI,MAAM,EAAE;IAClC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC;CACtC;KAAM;IACL,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC,CAAC;CAC/C;AAED,kBAAe,WAAW,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function floor(value: any, precision: any): number;
|
package/dist/main/util/floor.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.floor = void 0;
|
|
4
|
-
function floor(value, precision) {
|
|
5
|
-
var multiplier = Math.pow(10, precision || 0);
|
|
6
|
-
return Math.floor(value * multiplier) / multiplier;
|
|
7
|
-
}
|
|
8
|
-
exports.floor = floor;
|
|
9
|
-
//# sourceMappingURL=floor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"floor.js","sourceRoot":"","sources":["../../../src/util/floor.ts"],"names":[],"mappings":";;;AAAA,SAAgB,KAAK,CAAC,KAAK,EAAE,SAAS;IACpC,IAAI,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,IAAI,CAAC,CAAC,CAAC;IAC9C,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,UAAU,CAAC;AACrD,CAAC;AAHD,sBAGC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { HdKeyNetwork } from "@bitauth/libauth";
|
|
2
|
-
export declare function getAddrsByXpubKey(xpub: string, path: string, count: number): Promise<[unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown]>;
|
|
3
|
-
export declare function getAddrsByXpubKeyObject(obj: any): Promise<[unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown]>;
|
|
4
|
-
export declare function derivePublicNodeCashaddr(xpub: any, index: number, path?: string): Promise<any>;
|
|
5
|
-
export declare function getXpubKeyInfo(hdPublicKey: any): Promise<{
|
|
6
|
-
version: HdKeyNetwork;
|
|
7
|
-
depth: number;
|
|
8
|
-
parentFingerprint: string;
|
|
9
|
-
childNumber: number;
|
|
10
|
-
chain: string;
|
|
11
|
-
data: string;
|
|
12
|
-
fingerprint: string;
|
|
13
|
-
}>;
|
|
14
|
-
export declare function getXpubKeyInfoObject(obj: any): Promise<{
|
|
15
|
-
version: HdKeyNetwork;
|
|
16
|
-
depth: number;
|
|
17
|
-
parentFingerprint: string;
|
|
18
|
-
childNumber: number;
|
|
19
|
-
chain: string;
|
|
20
|
-
data: string;
|
|
21
|
-
fingerprint: string;
|
|
22
|
-
}>;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getXpubKeyInfoObject = exports.getXpubKeyInfo = exports.derivePublicNodeCashaddr = exports.getAddrsByXpubKeyObject = exports.getAddrsByXpubKey = void 0;
|
|
4
|
-
const libauth_1 = require("@bitauth/libauth");
|
|
5
|
-
const hash160_1 = require("./hash160");
|
|
6
|
-
async function getAddrsByXpubKey(xpub, path, count) {
|
|
7
|
-
let pathComponents = path.split("/");
|
|
8
|
-
let rootStr = pathComponents.shift();
|
|
9
|
-
let root;
|
|
10
|
-
if (rootStr === "M" || rootStr === "m") {
|
|
11
|
-
rootStr = pathComponents.shift();
|
|
12
|
-
}
|
|
13
|
-
root = parseInt(rootStr);
|
|
14
|
-
let result = [];
|
|
15
|
-
const start = parseInt(pathComponents.pop());
|
|
16
|
-
const end = start + count;
|
|
17
|
-
for (let curr = start; curr < end; curr++) {
|
|
18
|
-
let childPath = ["M", root, ...pathComponents, curr].join("/");
|
|
19
|
-
result.push(derivePublicNodeCashaddr(xpub, root, childPath));
|
|
20
|
-
}
|
|
21
|
-
return await Promise.all(result).then((result) => {
|
|
22
|
-
return result;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
exports.getAddrsByXpubKey = getAddrsByXpubKey;
|
|
26
|
-
async function getAddrsByXpubKeyObject(obj) {
|
|
27
|
-
return await getAddrsByXpubKey(obj.xpubkey, obj.path, obj.count);
|
|
28
|
-
}
|
|
29
|
-
exports.getAddrsByXpubKeyObject = getAddrsByXpubKeyObject;
|
|
30
|
-
async function derivePublicNodeCashaddr(xpub, index, path) {
|
|
31
|
-
const crypto = await (0, libauth_1.instantiateBIP32Crypto)();
|
|
32
|
-
const publicParent = await (0, libauth_1.decodeHdPublicKey)(crypto, xpub);
|
|
33
|
-
if (typeof publicParent === "string") {
|
|
34
|
-
throw new Error(publicParent);
|
|
35
|
-
}
|
|
36
|
-
let prefix = publicParent.network === "mainnet" ? "bitcoincash" : "bchtest";
|
|
37
|
-
let node = await (0, libauth_1.deriveHdPublicNodeChild)(crypto, publicParent.node, index);
|
|
38
|
-
if (typeof node === "string") {
|
|
39
|
-
throw new Error(node);
|
|
40
|
-
}
|
|
41
|
-
let cashaddr;
|
|
42
|
-
if (typeof path === "string") {
|
|
43
|
-
if (path[0] !== "M") {
|
|
44
|
-
throw Error("use M for public path derivation");
|
|
45
|
-
}
|
|
46
|
-
let childNode = (0, libauth_1.deriveHdPath)(crypto, publicParent.node, path);
|
|
47
|
-
if (typeof childNode === "string") {
|
|
48
|
-
throw new Error(childNode);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
let childPkh = await (0, hash160_1.hash160)(childNode.publicKey);
|
|
52
|
-
cashaddr = (0, libauth_1.encodeCashAddress)(prefix, 0, childPkh);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return cashaddr;
|
|
56
|
-
}
|
|
57
|
-
exports.derivePublicNodeCashaddr = derivePublicNodeCashaddr;
|
|
58
|
-
async function getXpubKeyInfo(hdPublicKey) {
|
|
59
|
-
const crypto = await (0, libauth_1.instantiateBIP32Crypto)();
|
|
60
|
-
let node = (0, libauth_1.decodeHdPublicKey)(crypto, hdPublicKey);
|
|
61
|
-
if (typeof node === "string") {
|
|
62
|
-
throw new Error(node);
|
|
63
|
-
}
|
|
64
|
-
return {
|
|
65
|
-
version: node.network,
|
|
66
|
-
depth: node.node.depth,
|
|
67
|
-
parentFingerprint: (0, libauth_1.binToHex)(node.node.parentFingerprint),
|
|
68
|
-
childNumber: node.node.childIndex,
|
|
69
|
-
chain: (0, libauth_1.binToHex)(node.node.chainCode),
|
|
70
|
-
data: (0, libauth_1.binToHex)(node.node.publicKey),
|
|
71
|
-
fingerprint: (0, libauth_1.binToHex)((await (0, hash160_1.hash160)(node.node.publicKey)).slice(0, 4)),
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
exports.getXpubKeyInfo = getXpubKeyInfo;
|
|
75
|
-
async function getXpubKeyInfoObject(obj) {
|
|
76
|
-
return await getXpubKeyInfo(obj.xpubkey);
|
|
77
|
-
}
|
|
78
|
-
exports.getXpubKeyInfoObject = getXpubKeyInfoObject;
|
|
79
|
-
//# sourceMappingURL=getAddrsByXpubKey.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getAddrsByXpubKey.js","sourceRoot":"","sources":["../../../src/util/getAddrsByXpubKey.ts"],"names":[],"mappings":";;;AAAA,8CAU0B;AAG1B,uCAAoC;AAE7B,KAAK,UAAU,iBAAiB,CACrC,IAAY,EACZ,IAAY,EACZ,KAAa;IAEb,IAAI,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrC,IAAI,OAAO,GAAG,cAAc,CAAC,KAAK,EAAG,CAAC;IACtC,IAAI,IAAY,CAAC;IACjB,IAAI,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK,GAAG,EAAE;QACtC,OAAO,GAAG,cAAc,CAAC,KAAK,EAAG,CAAC;KACnC;IACD,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzB,IAAI,MAAM,GAAQ,EAAE,CAAC;IAErB,MAAM,KAAK,GAAG,QAAQ,CAAC,cAAc,CAAC,GAAG,EAAG,CAAC,CAAC;IAC9C,MAAM,GAAG,GAAG,KAAK,GAAG,KAAK,CAAC;IAC1B,KAAK,IAAI,IAAI,GAAG,KAAK,EAAE,IAAI,GAAG,GAAG,EAAE,IAAI,EAAE,EAAE;QACzC,IAAI,SAAS,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,cAAc,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/D,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;KAC9D;IACD,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;QAC/C,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC;AAvBD,8CAuBC;AAEM,KAAK,UAAU,uBAAuB,CAAC,GAAG;IAC/C,OAAO,MAAM,iBAAiB,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;AACnE,CAAC;AAFD,0DAEC;AAEM,KAAK,UAAU,wBAAwB,CAC5C,IAAI,EACJ,KAAa,EACb,IAAa;IAEb,MAAM,MAAM,GAAG,MAAM,IAAA,gCAAsB,GAAE,CAAC;IAC9C,MAAM,YAAY,GAAG,MAAM,IAAA,2BAAiB,EAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAE3D,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE;QACpC,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;KAC/B;IACD,IAAI,MAAM,GAAG,YAAY,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC;IAE5E,IAAI,IAAI,GAAG,MAAM,IAAA,iCAAuB,EAAC,MAAM,EAAE,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC3E,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC;KACvB;IAED,IAAI,QAAQ,CAAC;IACb,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;YACnB,MAAM,KAAK,CAAC,kCAAkC,CAAC,CAAC;SACjD;QACD,IAAI,SAAS,GAAG,IAAA,sBAAY,EAAC,MAAM,EAAE,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC9D,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;YACjC,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC;SAC5B;aAAM;YACL,IAAI,QAAQ,GAAG,MAAM,IAAA,iBAAO,EAAC,SAAS,CAAC,SAAS,CAAC,CAAC;YAClD,QAAQ,GAAG,IAAA,2BAAiB,EAAC,MAAM,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;SACnD;KACF;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAhCD,4DAgCC;AAEM,KAAK,UAAU,cAAc,CAAC,WAAW;IAC9C,MAAM,MAAM,GAAG,MAAM,IAAA,gCAAsB,GAAE,CAAC;IAC9C,IAAI,IAAI,GAAG,IAAA,2BAAiB,EAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAClD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC;KACvB;IACD,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK;QACtB,iBAAiB,EAAE,IAAA,kBAAQ,EAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC;QACxD,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU;QACjC,KAAK,EAAE,IAAA,kBAAQ,EAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;QACpC,IAAI,EAAE,IAAA,kBAAQ,EAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;QACnC,WAAW,EAAE,IAAA,kBAAQ,EAAC,CAAC,MAAM,IAAA,iBAAO,EAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KACxE,CAAC;AACJ,CAAC;AAfD,wCAeC;AAEM,KAAK,UAAU,oBAAoB,CAAC,GAAG;IAC5C,OAAO,MAAM,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC3C,CAAC;AAFD,oDAEC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRuntimePlatform = exports.RuntimePlatform = void 0;
|
|
4
|
-
var RuntimePlatform;
|
|
5
|
-
(function (RuntimePlatform) {
|
|
6
|
-
RuntimePlatform["node"] = "node";
|
|
7
|
-
RuntimePlatform["browser"] = "browser";
|
|
8
|
-
RuntimePlatform["webworker"] = "webworker";
|
|
9
|
-
})(RuntimePlatform = exports.RuntimePlatform || (exports.RuntimePlatform = {}));
|
|
10
|
-
function getRuntimePlatform() {
|
|
11
|
-
// https://github.com/foo123/asynchronous.js/blob/master/asynchronous.js
|
|
12
|
-
if ("undefined" !== typeof global &&
|
|
13
|
-
("[object global]" === toString.call(global) ||
|
|
14
|
-
"[object Object]" === toString.call(global))) {
|
|
15
|
-
return RuntimePlatform.node;
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
// if (
|
|
19
|
-
// "undefined" !== typeof WorkerGlobalScope &&
|
|
20
|
-
// "function" === typeof importScripts &&
|
|
21
|
-
// navigator instanceof WorkerNavigator
|
|
22
|
-
// ) {
|
|
23
|
-
// return RuntimePlatform.webworker;
|
|
24
|
-
// } else
|
|
25
|
-
if ("undefined" !== typeof navigator && "undefined" !== typeof document) {
|
|
26
|
-
return RuntimePlatform.browser;
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
throw Error("Could not determine runtime platform");
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.getRuntimePlatform = getRuntimePlatform;
|
|
34
|
-
//# sourceMappingURL=getRuntimePlatform.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getRuntimePlatform.js","sourceRoot":"","sources":["../../../src/util/getRuntimePlatform.ts"],"names":[],"mappings":";;;AAAA,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,gCAAa,CAAA;IACb,sCAAmB,CAAA;IACnB,0CAAuB,CAAA;AACzB,CAAC,EAJW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAI1B;AAED,SAAgB,kBAAkB;IAChC,wEAAwE;IACxE,IACE,WAAW,KAAK,OAAO,MAAM;QAC7B,CAAC,iBAAiB,KAAK,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;YAC1C,iBAAiB,KAAK,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAC9C;QACA,OAAO,eAAe,CAAC,IAAI,CAAC;KAC7B;SAAM;QACL,OAAO;QACP,gDAAgD;QAChD,2CAA2C;QAC3C,yCAAyC;QACzC,MAAM;QACN,sCAAsC;QACtC,SAAS;QACT,IAAI,WAAW,KAAK,OAAO,SAAS,IAAI,WAAW,KAAK,OAAO,QAAQ,EAAE;YACvE,OAAO,eAAe,CAAC,OAAO,CAAC;SAChC;aAAM;YACL,MAAM,KAAK,CAAC,sCAAsC,CAAC,CAAC;SACrD;KACF;AACH,CAAC;AAtBD,gDAsBC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getUsdRate(): Promise<number>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getUsdRate = void 0;
|
|
4
|
-
const ExchangeRate_1 = require("../rate/ExchangeRate");
|
|
5
|
-
function getUsdRate() {
|
|
6
|
-
return ExchangeRate_1.ExchangeRate.get("usd");
|
|
7
|
-
}
|
|
8
|
-
exports.getUsdRate = getUsdRate;
|
|
9
|
-
//# sourceMappingURL=getUsdRate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getUsdRate.js","sourceRoot":"","sources":["../../../src/util/getUsdRate.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AAEpD,SAAgB,UAAU;IACxB,OAAO,2BAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC;AAFD,gCAEC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getXPubKey(seed: Uint8Array | string, derivationPath: string, network: string): Promise<string>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getXPubKey = void 0;
|
|
4
|
-
const libauth_1 = require("@bitauth/libauth");
|
|
5
|
-
async function getXPubKey(seed, derivationPath, network) {
|
|
6
|
-
if (typeof seed === "string") {
|
|
7
|
-
seed = (0, libauth_1.hexToBin)(seed);
|
|
8
|
-
}
|
|
9
|
-
const crypto = await (0, libauth_1.instantiateBIP32Crypto)();
|
|
10
|
-
let hdNode = (0, libauth_1.deriveHdPrivateNodeFromSeed)(crypto, seed);
|
|
11
|
-
if (!hdNode.valid) {
|
|
12
|
-
throw Error("Invalid private key derived from mnemonic seed");
|
|
13
|
-
}
|
|
14
|
-
let node = (0, libauth_1.deriveHdPath)(crypto, hdNode, derivationPath);
|
|
15
|
-
if (typeof node === "string") {
|
|
16
|
-
throw node;
|
|
17
|
-
}
|
|
18
|
-
let parentPublicNode = (0, libauth_1.deriveHdPublicNode)(crypto, node);
|
|
19
|
-
let xPubKey = (0, libauth_1.encodeHdPublicKey)(crypto, {
|
|
20
|
-
network: network,
|
|
21
|
-
node: parentPublicNode,
|
|
22
|
-
});
|
|
23
|
-
return xPubKey;
|
|
24
|
-
}
|
|
25
|
-
exports.getXPubKey = getXPubKey;
|
|
26
|
-
//# sourceMappingURL=getXPubKey.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getXPubKey.js","sourceRoot":"","sources":["../../../src/util/getXPubKey.ts"],"names":[],"mappings":";;;AAAA,8CAQ0B;AAEnB,KAAK,UAAU,UAAU,CAC9B,IAAyB,EACzB,cAAsB,EACtB,OAAe;IAEf,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,IAAI,GAAG,IAAA,kBAAQ,EAAC,IAAI,CAAC,CAAC;KACvB;IACD,MAAM,MAAM,GAAG,MAAM,IAAA,gCAAsB,GAAE,CAAC;IAC9C,IAAI,MAAM,GAAG,IAAA,qCAA2B,EAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACvD,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE;QACjB,MAAM,KAAK,CAAC,gDAAgD,CAAC,CAAC;KAC/D;IAED,IAAI,IAAI,GAAG,IAAA,sBAAY,EAAC,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC;IACxD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,MAAM,IAAI,CAAC;KACZ;IACD,IAAI,gBAAgB,GAAG,IAAA,4BAAkB,EAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAExD,IAAI,OAAO,GAAG,IAAA,2BAAiB,EAAC,MAAM,EAAE;QACtC,OAAO,EAAE,OAAuB;QAChC,IAAI,EAAE,gBAAgB;KACvB,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC;AAzBD,gCAyBC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* hash160 - Calculate the sha256, ripemd160 hash of a value
|
|
3
|
-
*
|
|
4
|
-
* @param {message} Uint8Array value to hash as a binary array
|
|
5
|
-
*
|
|
6
|
-
* @returns a promise to the hash160 value of the input
|
|
7
|
-
*/
|
|
8
|
-
export declare function hash160(message: Uint8Array): Promise<Uint8Array>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hash160 = void 0;
|
|
4
|
-
const libauth_1 = require("@bitauth/libauth");
|
|
5
|
-
/**
|
|
6
|
-
* hash160 - Calculate the sha256, ripemd160 hash of a value
|
|
7
|
-
*
|
|
8
|
-
* @param {message} Uint8Array value to hash as a binary array
|
|
9
|
-
*
|
|
10
|
-
* @returns a promise to the hash160 value of the input
|
|
11
|
-
*/
|
|
12
|
-
async function hash160(message) {
|
|
13
|
-
const ripemd160 = await (0, libauth_1.instantiateRipemd160)();
|
|
14
|
-
const sha256 = await (0, libauth_1.instantiateSha256)();
|
|
15
|
-
return ripemd160.hash(sha256.hash(message));
|
|
16
|
-
}
|
|
17
|
-
exports.hash160 = hash160;
|
|
18
|
-
//# sourceMappingURL=hash160.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hash160.js","sourceRoot":"","sources":["../../../src/util/hash160.ts"],"names":[],"mappings":";;;AAAA,8CAA2E;AAE3E;;;;;;GAMG;AACI,KAAK,UAAU,OAAO,CAAC,OAAmB;IAC/C,MAAM,SAAS,GAAG,MAAM,IAAA,8BAAoB,GAAE,CAAC;IAC/C,MAAM,MAAM,GAAG,MAAM,IAAA,2BAAiB,GAAE,CAAC;IACzC,OAAO,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;AAC9C,CAAC;AAJD,0BAIC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export { amountInSatoshi } from "./amountInSatoshi";
|
|
2
|
-
export { asSendRequestObject } from "./asSendRequestObject";
|
|
3
|
-
export { atob, btoa } from "./base64";
|
|
4
|
-
export { binToHex, hexToBin } from "@bitauth/libauth";
|
|
5
|
-
export { convert, convertObject } from "./convert";
|
|
6
|
-
export { delay } from "./delay";
|
|
7
|
-
export { derivedNetwork } from "./deriveNetwork";
|
|
8
|
-
export { derivePublicKeyHash } from "./derivePublicKeyHash";
|
|
9
|
-
export { getAddrsByXpubKey, getAddrsByXpubKeyObject, getXpubKeyInfo, getXpubKeyInfoObject, } from "../util/getAddrsByXpubKey";
|
|
10
|
-
export { getRuntimePlatform, RuntimePlatform } from "./getRuntimePlatform";
|
|
11
|
-
export { getUsdRate } from "./getUsdRate";
|
|
12
|
-
export { hash160 } from "./hash160";
|
|
13
|
-
export { ExchangeRate } from "../rate/ExchangeRate";
|
|
14
|
-
export { sanitizeAddress } from "./sanitizeAddress";
|
|
15
|
-
export { sanitizeUnit } from "./sanitizeUnit";
|
|
16
|
-
export { getRandomInt } from "./randomInt";
|
|
17
|
-
export { getXPubKey } from "../util/getXPubKey";
|
|
18
|
-
import * as randomValues from "./randomValues";
|
|
19
|
-
export { randomValues };
|
|
20
|
-
export { sumUtxoValue } from "./sumUtxoValue";
|
|
21
|
-
export { BalanceResponse, balanceFromSatoshi, balanceResponseFromSatoshi, } from "./balanceObjectFromSatoshi";
|
package/dist/main/util/index.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.balanceResponseFromSatoshi = exports.balanceFromSatoshi = exports.BalanceResponse = exports.sumUtxoValue = exports.randomValues = exports.getXPubKey = exports.getRandomInt = exports.sanitizeUnit = exports.sanitizeAddress = exports.ExchangeRate = exports.hash160 = exports.getUsdRate = exports.RuntimePlatform = exports.getRuntimePlatform = exports.getXpubKeyInfoObject = exports.getXpubKeyInfo = exports.getAddrsByXpubKeyObject = exports.getAddrsByXpubKey = exports.derivePublicKeyHash = exports.derivedNetwork = exports.delay = exports.convertObject = exports.convert = exports.hexToBin = exports.binToHex = exports.btoa = exports.atob = exports.asSendRequestObject = exports.amountInSatoshi = void 0;
|
|
23
|
-
var amountInSatoshi_1 = require("./amountInSatoshi");
|
|
24
|
-
Object.defineProperty(exports, "amountInSatoshi", { enumerable: true, get: function () { return amountInSatoshi_1.amountInSatoshi; } });
|
|
25
|
-
var asSendRequestObject_1 = require("./asSendRequestObject");
|
|
26
|
-
Object.defineProperty(exports, "asSendRequestObject", { enumerable: true, get: function () { return asSendRequestObject_1.asSendRequestObject; } });
|
|
27
|
-
var base64_1 = require("./base64");
|
|
28
|
-
Object.defineProperty(exports, "atob", { enumerable: true, get: function () { return base64_1.atob; } });
|
|
29
|
-
Object.defineProperty(exports, "btoa", { enumerable: true, get: function () { return base64_1.btoa; } });
|
|
30
|
-
var libauth_1 = require("@bitauth/libauth");
|
|
31
|
-
Object.defineProperty(exports, "binToHex", { enumerable: true, get: function () { return libauth_1.binToHex; } });
|
|
32
|
-
Object.defineProperty(exports, "hexToBin", { enumerable: true, get: function () { return libauth_1.hexToBin; } });
|
|
33
|
-
var convert_1 = require("./convert");
|
|
34
|
-
Object.defineProperty(exports, "convert", { enumerable: true, get: function () { return convert_1.convert; } });
|
|
35
|
-
Object.defineProperty(exports, "convertObject", { enumerable: true, get: function () { return convert_1.convertObject; } });
|
|
36
|
-
var delay_1 = require("./delay");
|
|
37
|
-
Object.defineProperty(exports, "delay", { enumerable: true, get: function () { return delay_1.delay; } });
|
|
38
|
-
var deriveNetwork_1 = require("./deriveNetwork");
|
|
39
|
-
Object.defineProperty(exports, "derivedNetwork", { enumerable: true, get: function () { return deriveNetwork_1.derivedNetwork; } });
|
|
40
|
-
var derivePublicKeyHash_1 = require("./derivePublicKeyHash");
|
|
41
|
-
Object.defineProperty(exports, "derivePublicKeyHash", { enumerable: true, get: function () { return derivePublicKeyHash_1.derivePublicKeyHash; } });
|
|
42
|
-
var getAddrsByXpubKey_1 = require("../util/getAddrsByXpubKey");
|
|
43
|
-
Object.defineProperty(exports, "getAddrsByXpubKey", { enumerable: true, get: function () { return getAddrsByXpubKey_1.getAddrsByXpubKey; } });
|
|
44
|
-
Object.defineProperty(exports, "getAddrsByXpubKeyObject", { enumerable: true, get: function () { return getAddrsByXpubKey_1.getAddrsByXpubKeyObject; } });
|
|
45
|
-
Object.defineProperty(exports, "getXpubKeyInfo", { enumerable: true, get: function () { return getAddrsByXpubKey_1.getXpubKeyInfo; } });
|
|
46
|
-
Object.defineProperty(exports, "getXpubKeyInfoObject", { enumerable: true, get: function () { return getAddrsByXpubKey_1.getXpubKeyInfoObject; } });
|
|
47
|
-
var getRuntimePlatform_1 = require("./getRuntimePlatform");
|
|
48
|
-
Object.defineProperty(exports, "getRuntimePlatform", { enumerable: true, get: function () { return getRuntimePlatform_1.getRuntimePlatform; } });
|
|
49
|
-
Object.defineProperty(exports, "RuntimePlatform", { enumerable: true, get: function () { return getRuntimePlatform_1.RuntimePlatform; } });
|
|
50
|
-
var getUsdRate_1 = require("./getUsdRate");
|
|
51
|
-
Object.defineProperty(exports, "getUsdRate", { enumerable: true, get: function () { return getUsdRate_1.getUsdRate; } });
|
|
52
|
-
var hash160_1 = require("./hash160");
|
|
53
|
-
Object.defineProperty(exports, "hash160", { enumerable: true, get: function () { return hash160_1.hash160; } });
|
|
54
|
-
var ExchangeRate_1 = require("../rate/ExchangeRate");
|
|
55
|
-
Object.defineProperty(exports, "ExchangeRate", { enumerable: true, get: function () { return ExchangeRate_1.ExchangeRate; } });
|
|
56
|
-
var sanitizeAddress_1 = require("./sanitizeAddress");
|
|
57
|
-
Object.defineProperty(exports, "sanitizeAddress", { enumerable: true, get: function () { return sanitizeAddress_1.sanitizeAddress; } });
|
|
58
|
-
var sanitizeUnit_1 = require("./sanitizeUnit");
|
|
59
|
-
Object.defineProperty(exports, "sanitizeUnit", { enumerable: true, get: function () { return sanitizeUnit_1.sanitizeUnit; } });
|
|
60
|
-
var randomInt_1 = require("./randomInt");
|
|
61
|
-
Object.defineProperty(exports, "getRandomInt", { enumerable: true, get: function () { return randomInt_1.getRandomInt; } });
|
|
62
|
-
var getXPubKey_1 = require("../util/getXPubKey");
|
|
63
|
-
Object.defineProperty(exports, "getXPubKey", { enumerable: true, get: function () { return getXPubKey_1.getXPubKey; } });
|
|
64
|
-
const randomValues = __importStar(require("./randomValues"));
|
|
65
|
-
exports.randomValues = randomValues;
|
|
66
|
-
var sumUtxoValue_1 = require("./sumUtxoValue");
|
|
67
|
-
Object.defineProperty(exports, "sumUtxoValue", { enumerable: true, get: function () { return sumUtxoValue_1.sumUtxoValue; } });
|
|
68
|
-
var balanceObjectFromSatoshi_1 = require("./balanceObjectFromSatoshi");
|
|
69
|
-
Object.defineProperty(exports, "BalanceResponse", { enumerable: true, get: function () { return balanceObjectFromSatoshi_1.BalanceResponse; } });
|
|
70
|
-
Object.defineProperty(exports, "balanceFromSatoshi", { enumerable: true, get: function () { return balanceObjectFromSatoshi_1.balanceFromSatoshi; } });
|
|
71
|
-
Object.defineProperty(exports, "balanceResponseFromSatoshi", { enumerable: true, get: function () { return balanceObjectFromSatoshi_1.balanceResponseFromSatoshi; } });
|
|
72
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/util/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAC5B,mCAAsC;AAA7B,8FAAA,IAAI,OAAA;AAAE,8FAAA,IAAI,OAAA;AACnB,4CAAsD;AAA7C,mGAAA,QAAQ,OAAA;AAAE,mGAAA,QAAQ,OAAA;AAC3B,qCAAmD;AAA1C,kGAAA,OAAO,OAAA;AAAE,wGAAA,aAAa,OAAA;AAC/B,iCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,iDAAiD;AAAxC,+GAAA,cAAc,OAAA;AACvB,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAC5B,+DAKmC;AAJjC,sHAAA,iBAAiB,OAAA;AACjB,4HAAA,uBAAuB,OAAA;AACvB,mHAAA,cAAc,OAAA;AACd,yHAAA,oBAAoB,OAAA;AAEtB,2DAA2E;AAAlE,wHAAA,kBAAkB,OAAA;AAAE,qHAAA,eAAe,OAAA;AAC5C,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,qDAAoD;AAA3C,4GAAA,YAAY,OAAA;AACrB,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,yCAA2C;AAAlC,yGAAA,YAAY,OAAA;AACrB,iDAAgD;AAAvC,wGAAA,UAAU,OAAA;AACnB,6DAA+C;AACtC,oCAAY;AACrB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,uEAIoC;AAHlC,2HAAA,eAAe,OAAA;AACf,8HAAA,kBAAkB,OAAA;AAClB,sIAAA,0BAA0B,OAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function generateRandomBytes(len?: number): any;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateRandomBytes = void 0;
|
|
4
|
-
const getRuntimePlatform_1 = require("./getRuntimePlatform");
|
|
5
|
-
function generateRandomBytes(len = 32) {
|
|
6
|
-
// nodejs
|
|
7
|
-
if ((0, getRuntimePlatform_1.getRuntimePlatform)() === "node") {
|
|
8
|
-
//
|
|
9
|
-
const crypto = eval("require")("crypto");
|
|
10
|
-
return crypto.randomBytes(len);
|
|
11
|
-
}
|
|
12
|
-
// window, webworkers, service workers
|
|
13
|
-
else {
|
|
14
|
-
return window.crypto.getRandomValues(new Uint8Array(len));
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.generateRandomBytes = generateRandomBytes;
|
|
18
|
-
//# sourceMappingURL=randomBytes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"randomBytes.js","sourceRoot":"","sources":["../../../src/util/randomBytes.ts"],"names":[],"mappings":";;;AAAA,6DAA0D;AAE1D,SAAgB,mBAAmB,CAAC,GAAG,GAAG,EAAE;IAC1C,SAAS;IACT,IAAI,IAAA,uCAAkB,GAAE,KAAK,MAAM,EAAE;QACnC,EAAE;QACF,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC;QACzC,OAAO,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;KAChC;IACD,sCAAsC;SACjC;QACH,OAAO,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;KAC3D;AACH,CAAC;AAXD,kDAWC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getRandomInt(max: number): number;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRandomInt = void 0;
|
|
4
|
-
// Simple function to get a random integer
|
|
5
|
-
function getRandomInt(max) {
|
|
6
|
-
return Math.floor(Math.random() * Math.floor(max));
|
|
7
|
-
}
|
|
8
|
-
exports.getRandomInt = getRandomInt;
|
|
9
|
-
//# sourceMappingURL=randomInt.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"randomInt.js","sourceRoot":"","sources":["../../../src/util/randomInt.ts"],"names":[],"mappings":";;;AAAA,0CAA0C;AAC1C,SAAgB,YAAY,CAAC,GAAW;IACtC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AACrD,CAAC;AAFD,oCAEC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getRuntimePlatform_1 = require("./getRuntimePlatform");
|
|
4
|
-
if ((0, getRuntimePlatform_1.getRuntimePlatform)() === "node") {
|
|
5
|
-
if (!globalThis.crypto || !globalThis.crypto.getRandomValues) {
|
|
6
|
-
const crypto = require("crypto");
|
|
7
|
-
globalThis.crypto = crypto;
|
|
8
|
-
globalThis.crypto.getRandomValues = (buf) => {
|
|
9
|
-
const bytes = crypto.randomBytes(buf.length);
|
|
10
|
-
buf.set(bytes);
|
|
11
|
-
return buf;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=randomValues.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"randomValues.js","sourceRoot":"","sources":["../../../src/util/randomValues.ts"],"names":[],"mappings":";;AAAA,6DAA0D;AAE1D,IAAI,IAAA,uCAAkB,GAAE,KAAK,MAAM,EAAE;IACnC,IAAI,CAAC,UAAU,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,eAAe,EAAE;QAC5D,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QACjC,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC;QAC1B,UAAU,CAAC,MAAc,CAAC,eAAe,GAAG,CAAC,GAAe,EAAE,EAAE;YAC/D,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC7C,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACf,OAAO,GAAG,CAAC;QACb,CAAC,CAAC;KACH;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function sanitizeAddress(address: string): string;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sanitizeAddress = void 0;
|
|
4
|
-
const derivePublicKeyHash_1 = require("./derivePublicKeyHash");
|
|
5
|
-
// Assure address is prefixed.
|
|
6
|
-
function sanitizeAddress(address) {
|
|
7
|
-
if (address.includes(":")) {
|
|
8
|
-
return address;
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
return `${(0, derivePublicKeyHash_1.derivePrefix)(address)}:${address}`;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.sanitizeAddress = sanitizeAddress;
|
|
15
|
-
//# sourceMappingURL=sanitizeAddress.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sanitizeAddress.js","sourceRoot":"","sources":["../../../src/util/sanitizeAddress.ts"],"names":[],"mappings":";;;AAAA,+DAAqD;AAErD,8BAA8B;AAC9B,SAAgB,eAAe,CAAC,OAAe;IAC7C,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACzB,OAAO,OAAO,CAAC;KAChB;SAAM;QACL,OAAO,GAAG,IAAA,kCAAY,EAAC,OAAO,CAAC,IAAI,OAAO,EAAE,CAAC;KAC9C;AACH,CAAC;AAND,0CAMC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sanitizeUnit = void 0;
|
|
4
|
-
function sanitizeUnit(rawUnit) {
|
|
5
|
-
if (rawUnit) {
|
|
6
|
-
return rawUnit.toLocaleLowerCase();
|
|
7
|
-
}
|
|
8
|
-
else {
|
|
9
|
-
throw Error("Attempted to sanitize a unit of value, but the unit was undefined.");
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
exports.sanitizeUnit = sanitizeUnit;
|
|
13
|
-
//# sourceMappingURL=sanitizeUnit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sanitizeUnit.js","sourceRoot":"","sources":["../../../src/util/sanitizeUnit.ts"],"names":[],"mappings":";;;AAEA,SAAgB,YAAY,CAAC,OAAY;IACvC,IAAI,OAAO,EAAE;QACX,OAAO,OAAO,CAAC,iBAAiB,EAAc,CAAC;KAChD;SAAM;QACL,MAAM,KAAK,CACT,oEAAoE,CACrE,CAAC;KACH;AACH,CAAC;AARD,oCAQC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* converts given value and unit from satoshi
|
|
3
|
-
*
|
|
4
|
-
* @param {value} number some value in satoshi
|
|
5
|
-
* @param {rawUnit} any the target unit
|
|
6
|
-
*
|
|
7
|
-
* @returns a promise to the value in the unit of account given by rawUnit
|
|
8
|
-
*/
|
|
9
|
-
export declare function satoshiToAmount(value: number, rawUnit: any): Promise<number>;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.satoshiToAmount = void 0;
|
|
4
|
-
const chain_1 = require("../chain");
|
|
5
|
-
const enum_1 = require("../enum");
|
|
6
|
-
const ExchangeRate_1 = require("../rate/ExchangeRate");
|
|
7
|
-
const sanitizeUnit_1 = require("../util/sanitizeUnit");
|
|
8
|
-
/**
|
|
9
|
-
* converts given value and unit from satoshi
|
|
10
|
-
*
|
|
11
|
-
* @param {value} number some value in satoshi
|
|
12
|
-
* @param {rawUnit} any the target unit
|
|
13
|
-
*
|
|
14
|
-
* @returns a promise to the value in the unit of account given by rawUnit
|
|
15
|
-
*/
|
|
16
|
-
async function satoshiToAmount(value, rawUnit) {
|
|
17
|
-
const unit = (0, sanitizeUnit_1.sanitizeUnit)(rawUnit);
|
|
18
|
-
switch (unit) {
|
|
19
|
-
case enum_1.UnitEnum.BCH:
|
|
20
|
-
return value / chain_1.bchParam.subUnits;
|
|
21
|
-
case enum_1.UnitEnum.SATOSHI:
|
|
22
|
-
return value;
|
|
23
|
-
case enum_1.UnitEnum.SAT:
|
|
24
|
-
return value;
|
|
25
|
-
case enum_1.UnitEnum.SATS:
|
|
26
|
-
return value;
|
|
27
|
-
case enum_1.UnitEnum.SATOSHIS:
|
|
28
|
-
return value;
|
|
29
|
-
case enum_1.UnitEnum.USD:
|
|
30
|
-
let USD_over_BCH = await ExchangeRate_1.ExchangeRate.get("usd");
|
|
31
|
-
let SAT_over_BCH = chain_1.bchParam.subUnits;
|
|
32
|
-
// truncate dollar amounts to fixed precision (2),
|
|
33
|
-
// then return the fixed value string as a float.
|
|
34
|
-
let dollarValue = Number(value * (USD_over_BCH / SAT_over_BCH)).toFixed(2);
|
|
35
|
-
return Number.parseFloat(dollarValue);
|
|
36
|
-
default:
|
|
37
|
-
throw Error("Unit of value not defined");
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.satoshiToAmount = satoshiToAmount;
|
|
41
|
-
//# sourceMappingURL=satoshiToAmount.js.map
|