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
package/src/network/default.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { default as ElectrumNetworkProvider } from "./ElectrumNetworkProvider";
|
|
1
|
+
import { default as ElectrumNetworkProvider } from "./ElectrumNetworkProvider.js";
|
|
2
2
|
import { ElectrumCluster, ElectrumClient } from "electrum-cash";
|
|
3
|
-
import { default as NetworkProvider } from "./NetworkProvider";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import {
|
|
3
|
+
import { default as NetworkProvider } from "./NetworkProvider.js";
|
|
4
|
+
import {
|
|
5
|
+
getConfidence,
|
|
6
|
+
getDefaultServers,
|
|
7
|
+
getUserAgent,
|
|
8
|
+
} from "./configuration.js";
|
|
9
|
+
import { parseElectrumUrl } from "./util.js";
|
|
10
|
+
import { ElectrumHostParams, ElectrumClusterParams } from "./interface.js";
|
|
11
|
+
import { Network } from "../interface.js";
|
|
12
|
+
import { networkTickerMap, clusterParams } from "./constant.js";
|
|
13
|
+
import { ELECTRUM_CASH_PROTOCOL_VERSION } from "./constant.js";
|
|
10
14
|
|
|
11
15
|
export function setGlobalProvider(
|
|
12
16
|
network: Network,
|
|
@@ -50,8 +54,7 @@ export function getNetworkProvider(
|
|
|
50
54
|
manualConnectionManagement = manualConnectionManagement
|
|
51
55
|
? manualConnectionManagement
|
|
52
56
|
: false;
|
|
53
|
-
servers = servers ? servers :
|
|
54
|
-
|
|
57
|
+
servers = servers ? servers : getDefaultServers(network);
|
|
55
58
|
// If the user has passed a single string, assume a single client connection
|
|
56
59
|
if (typeof servers === "string") {
|
|
57
60
|
servers = [servers as string];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { bchParam } from "../chain";
|
|
2
|
-
import { networkTickerMap } from "./constant";
|
|
3
|
-
import { default as NetworkProvider } from "./NetworkProvider";
|
|
1
|
+
import { bchParam } from "../chain.js";
|
|
2
|
+
import { networkTickerMap } from "./constant.js";
|
|
3
|
+
import { default as NetworkProvider } from "./NetworkProvider.js";
|
|
4
4
|
|
|
5
5
|
export async function getRelayFeeCache(provider: NetworkProvider) {
|
|
6
6
|
let relayFeePerKbInCoins;
|
package/src/network/index.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
export { getNetworkProvider } from "./default";
|
|
2
|
-
export {
|
|
1
|
+
export { getNetworkProvider } from "./default.js";
|
|
2
|
+
export {
|
|
3
|
+
Connection,
|
|
4
|
+
initProviders,
|
|
5
|
+
disconnectProviders,
|
|
6
|
+
} from "./Connection.js";
|
package/src/network/util.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ElectrumTransport, TransportScheme } from "electrum-cash";
|
|
2
|
-
import { ElectrumHostParams } from "./interface";
|
|
2
|
+
import { ElectrumHostParams } from "./interface.js";
|
|
3
3
|
|
|
4
4
|
export function parseElectrumUrl(givenUrl: string): ElectrumHostParams {
|
|
5
5
|
let url = new URL(givenUrl);
|
package/src/qr/Qr.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import { ImageI } from "./interface";
|
|
3
|
-
import { btoa } from "../util/base64";
|
|
1
|
+
import QRCode from "qrcode-svg";
|
|
2
|
+
import { ImageI } from "./interface.js";
|
|
3
|
+
import { btoa } from "../util/base64.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* qrAddress returns a qr code for a given cashaddress as raw utf-8 svg
|
package/src/rate/ExchangeRate.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { EXCHANGE_RATE_TTL } from "../constant";
|
|
1
|
+
import { EXCHANGE_RATE_TTL } from "../constant.js";
|
|
2
2
|
import {
|
|
3
3
|
RuntimePlatform,
|
|
4
4
|
getRuntimePlatform,
|
|
5
|
-
} from "../util/getRuntimePlatform";
|
|
6
|
-
import ExchangeRateProvider from "../db/ExchangeRateProvider";
|
|
7
|
-
import { indexedDbIsAvailable } from "../db/util";
|
|
8
|
-
|
|
9
|
-
const axios = require("axios").default;
|
|
5
|
+
} from "../util/getRuntimePlatform.js";
|
|
6
|
+
import ExchangeRateProvider from "../db/ExchangeRateProvider.js";
|
|
7
|
+
import { indexedDbIsAvailable } from "../db/util.js";
|
|
8
|
+
import axios from "axios";
|
|
10
9
|
|
|
11
10
|
export class ExchangeRate {
|
|
12
11
|
symbol: string;
|
|
@@ -27,20 +26,20 @@ export class ExchangeRate {
|
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
static setupAxiosMock(mockUrl, responseData) {
|
|
30
|
-
if (!axios.interceptors.mocks) {
|
|
31
|
-
axios.interceptors.mocks = {};
|
|
29
|
+
if (!(axios.interceptors as any).mocks) {
|
|
30
|
+
(axios.interceptors as any).mocks = {};
|
|
32
31
|
|
|
33
32
|
// install our interceptors
|
|
34
|
-
axios.interceptors.request.use((config) => {
|
|
33
|
+
(axios.interceptors as any).request.use((config) => {
|
|
35
34
|
const url = config.url!;
|
|
36
35
|
|
|
37
|
-
if (axios.interceptors.mocks[url]) {
|
|
36
|
+
if ((axios.interceptors as any).mocks[url]) {
|
|
38
37
|
// if we have set up a mocked response for this url, cancel the actual request with a cancelToken containing our mocked data
|
|
39
|
-
const mockedResponse = axios.interceptors.mocks[url];
|
|
38
|
+
const mockedResponse = (axios.interceptors as any).mocks[url];
|
|
40
39
|
return {
|
|
41
40
|
...config,
|
|
42
41
|
cancelToken: new axios.CancelToken((cancel) =>
|
|
43
|
-
cancel({ status: 200, data: mockedResponse })
|
|
42
|
+
cancel({ status: 200, data: mockedResponse } as any)
|
|
44
43
|
),
|
|
45
44
|
};
|
|
46
45
|
}
|
|
@@ -49,7 +48,7 @@ export class ExchangeRate {
|
|
|
49
48
|
return config;
|
|
50
49
|
});
|
|
51
50
|
|
|
52
|
-
axios.interceptors.response.use(
|
|
51
|
+
(axios.interceptors as any).response.use(
|
|
53
52
|
function (response) {
|
|
54
53
|
return response;
|
|
55
54
|
},
|
|
@@ -65,11 +64,11 @@ export class ExchangeRate {
|
|
|
65
64
|
);
|
|
66
65
|
}
|
|
67
66
|
|
|
68
|
-
axios.interceptors.mocks[mockUrl] = responseData;
|
|
67
|
+
(axios.interceptors as any).mocks[mockUrl] = responseData;
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
static removeAxiosMock(mockUrl) {
|
|
72
|
-
delete (axios.interceptors.mocks || {})[mockUrl];
|
|
71
|
+
delete ((axios.interceptors as any).mocks || {})[mockUrl];
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
toString() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Network, RegTestWallet, toCashAddress } from "..";
|
|
2
2
|
import { GsppProvider } from "./GsppProvider";
|
|
3
3
|
import { base64ToBin, binToBase64, binToHex, hexToBin } from "@bitauth/libauth";
|
|
4
|
-
|
|
4
|
+
import cashaddrjs from "cashaddrjs";
|
|
5
5
|
|
|
6
6
|
const rotate = function (str) {
|
|
7
7
|
return str
|
|
@@ -21,7 +21,7 @@ const addressToScriptpubkey = (address) => {
|
|
|
21
21
|
).toString("base64");
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
describe("Gspp Provider tests", () => {
|
|
24
|
+
describe.skip("Gspp Provider tests", () => {
|
|
25
25
|
// other GsppProvider tests are covered in the Slp.test.ts integration test suite
|
|
26
26
|
|
|
27
27
|
test("Test graphsearch methods", async () => {
|
package/src/slp/GsppProvider.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Network, TxI } from "../interface";
|
|
1
|
+
import { Network, TxI } from "../interface.js";
|
|
2
2
|
import {
|
|
3
3
|
GsppTx,
|
|
4
4
|
SlpTokenBalance,
|
|
5
5
|
SlpTokenInfo,
|
|
6
6
|
SlpTxI,
|
|
7
7
|
SlpUtxoI,
|
|
8
|
-
} from "./interface";
|
|
8
|
+
} from "./interface.js";
|
|
9
9
|
import BigNumber from "bignumber.js";
|
|
10
10
|
import {
|
|
11
11
|
SlpCancelWatchFn,
|
|
@@ -13,13 +13,16 @@ import {
|
|
|
13
13
|
SlpWatchBalanceCallback,
|
|
14
14
|
SlpWatchTransactionCallback,
|
|
15
15
|
_emptyTokenBalance,
|
|
16
|
-
} from "./SlpProvider";
|
|
16
|
+
} from "./SlpProvider.js";
|
|
17
17
|
import axios from "axios";
|
|
18
|
-
import { btoa } from "../util/base64";
|
|
18
|
+
import { btoa } from "../util/base64.js";
|
|
19
19
|
|
|
20
|
-
//import EventSource from "../../polyfill/eventsource";
|
|
21
|
-
import EventSource from "../util/eventsource";
|
|
22
|
-
import {
|
|
20
|
+
//import EventSource from "../../polyfill/eventsource.js";
|
|
21
|
+
import EventSource from "../util/eventsource.js";
|
|
22
|
+
import {
|
|
23
|
+
getRuntimePlatform,
|
|
24
|
+
RuntimePlatform,
|
|
25
|
+
} from "../util/getRuntimePlatform.js";
|
|
23
26
|
|
|
24
27
|
export class GsppProvider implements SlpProvider {
|
|
25
28
|
public static defaultServers = {
|
|
@@ -42,7 +45,7 @@ export class GsppProvider implements SlpProvider {
|
|
|
42
45
|
public caching: boolean = false;
|
|
43
46
|
|
|
44
47
|
constructor(public network: Network = Network.MAINNET) {
|
|
45
|
-
if (
|
|
48
|
+
if (getRuntimePlatform() === RuntimePlatform.node) {
|
|
46
49
|
if (process.env.GSPP_MAINNET_DATA)
|
|
47
50
|
this.servers.mainnet.dataSource = process.env.GSPP_MAINNET_DATA;
|
|
48
51
|
if (process.env.GSPP_MAINNET_EVENTS)
|
|
@@ -3,7 +3,7 @@ import { disconnectProviders, initProviders } from "../network";
|
|
|
3
3
|
import { SlpDbProvider } from "./SlpDbProvider";
|
|
4
4
|
import axios from "axios";
|
|
5
5
|
|
|
6
|
-
describe("Slp tests", () => {
|
|
6
|
+
describe.skip("Slp tests", () => {
|
|
7
7
|
beforeAll(async () => {
|
|
8
8
|
await initProviders([Network.MAINNET]);
|
|
9
9
|
});
|
package/src/slp/SlpDbProvider.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Network, TxI } from "../interface";
|
|
1
|
+
import { Network, TxI } from "../interface.js";
|
|
2
2
|
import {
|
|
3
3
|
SlpDbResponse,
|
|
4
4
|
SlpDbTx,
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
SlpTokenInfo,
|
|
7
7
|
SlpTxI,
|
|
8
8
|
SlpUtxoI,
|
|
9
|
-
} from "./interface";
|
|
9
|
+
} from "./interface.js";
|
|
10
10
|
import {
|
|
11
11
|
SlpAllUtxosTemplate,
|
|
12
12
|
SlpAddressTransactionHistoryTemplate,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
SlpAllTokenBalancesTemplate,
|
|
18
18
|
SlpTokenBalanceTemplate,
|
|
19
19
|
SlpAllOutpointsTemplate,
|
|
20
|
-
} from "./SlpDbTemplates";
|
|
20
|
+
} from "./SlpDbTemplates.js";
|
|
21
21
|
import BigNumber from "bignumber.js";
|
|
22
22
|
import {
|
|
23
23
|
SlpCancelWatchFn,
|
|
@@ -28,14 +28,17 @@ import {
|
|
|
28
28
|
_convertSlpTokenInfo,
|
|
29
29
|
_convertUtxoBigNumbers,
|
|
30
30
|
_emptyTokenBalance,
|
|
31
|
-
} from "./SlpProvider";
|
|
31
|
+
} from "./SlpProvider.js";
|
|
32
32
|
import axios from "axios";
|
|
33
|
-
import { btoa } from "../util/base64";
|
|
33
|
+
import { btoa } from "../util/base64.js";
|
|
34
34
|
|
|
35
|
-
//import EventSource from "../../polyfill/eventsource";
|
|
36
|
-
import EventSource from "../util/eventsource";
|
|
35
|
+
//import EventSource from "../../polyfill/eventsource.js";
|
|
36
|
+
import EventSource from "../util/eventsource.js";
|
|
37
37
|
|
|
38
|
-
import {
|
|
38
|
+
import {
|
|
39
|
+
getRuntimePlatform,
|
|
40
|
+
RuntimePlatform,
|
|
41
|
+
} from "../util/getRuntimePlatform.js";
|
|
39
42
|
|
|
40
43
|
export class SlpDbProvider implements SlpProvider {
|
|
41
44
|
public static defaultServers = {
|
|
@@ -58,7 +61,7 @@ export class SlpDbProvider implements SlpProvider {
|
|
|
58
61
|
public caching: boolean = false;
|
|
59
62
|
|
|
60
63
|
constructor(public network: Network = Network.MAINNET) {
|
|
61
|
-
if (
|
|
64
|
+
if (getRuntimePlatform() === RuntimePlatform.node) {
|
|
62
65
|
if (process.env.SLPDB_MAINNET_DATA)
|
|
63
66
|
this.servers.mainnet.dataSource = process.env.SLPDB_MAINNET_DATA;
|
|
64
67
|
if (process.env.SLPDB_MAINNET_EVENTS)
|
|
@@ -15,7 +15,7 @@ import { RegTestWallet } from "../wallet/Wif";
|
|
|
15
15
|
import { SlpUtxoI } from "./interface";
|
|
16
16
|
import BigNumber from "bignumber.js";
|
|
17
17
|
|
|
18
|
-
test("Test SLP genesis txo bytecode per SLP Spec", async () => {
|
|
18
|
+
test.skip("Test SLP genesis txo bytecode per SLP Spec", async () => {
|
|
19
19
|
const wallet = await RegTestWallet.newRandom();
|
|
20
20
|
|
|
21
21
|
const genesisOptions: SlpGenesisOptions = {
|
package/src/slp/SlpLibAuth.ts
CHANGED
|
@@ -3,24 +3,25 @@ import {
|
|
|
3
3
|
bigIntToBinUint64LE,
|
|
4
4
|
binToHex,
|
|
5
5
|
hexToBin,
|
|
6
|
+
importAuthenticationTemplate,
|
|
7
|
+
Output,
|
|
6
8
|
utf8ToBin,
|
|
7
|
-
validateAuthenticationTemplate,
|
|
8
9
|
} from "@bitauth/libauth";
|
|
9
10
|
import { parseSLP } from "slp-parser";
|
|
10
11
|
|
|
11
|
-
import { SendRequest } from "../wallet/model";
|
|
12
|
+
import { SendRequest } from "../wallet/model.js";
|
|
12
13
|
import {
|
|
13
14
|
SlpGenesisOptions,
|
|
14
15
|
SlpMintOptions,
|
|
15
16
|
SlpSendRequest,
|
|
16
17
|
SlpTokenType,
|
|
17
18
|
SlpUtxoI,
|
|
18
|
-
} from "../slp/interface";
|
|
19
|
+
} from "../slp/interface.js";
|
|
19
20
|
|
|
20
21
|
import BigNumber from "bignumber.js";
|
|
21
|
-
import { DUST_UTXO_THRESHOLD } from "../constant";
|
|
22
|
-
import { UnitEnum } from "../enum";
|
|
23
|
-
import { isValidAddress, toCashAddress } from "../util/bchaddr";
|
|
22
|
+
import { DUST_UTXO_THRESHOLD } from "../constant.js";
|
|
23
|
+
import { UnitEnum } from "../enum.js";
|
|
24
|
+
import { isValidAddress, toCashAddress } from "../util/bchaddr.js";
|
|
24
25
|
|
|
25
26
|
export const bigIntToBinUint64BE = (value) => {
|
|
26
27
|
return bigIntToBinUint64LE(value).reverse();
|
|
@@ -83,7 +84,7 @@ export const SlpGetGenesisOutputs = async (options: SlpGenesisOptions) => {
|
|
|
83
84
|
})
|
|
84
85
|
);
|
|
85
86
|
|
|
86
|
-
const template =
|
|
87
|
+
const template = importAuthenticationTemplate(SlpTxoTemplate);
|
|
87
88
|
if (typeof template === "string") {
|
|
88
89
|
throw new Error("Transaction template error");
|
|
89
90
|
}
|
|
@@ -95,19 +96,22 @@ export const SlpGetGenesisOutputs = async (options: SlpGenesisOptions) => {
|
|
|
95
96
|
|
|
96
97
|
const batonVout = options.endBaton ? [0x4c, 0x00] : [0x01, 0x02];
|
|
97
98
|
|
|
98
|
-
let genesisTxoBytecode = compiler.generateBytecode(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
99
|
+
let genesisTxoBytecode = compiler.generateBytecode({
|
|
100
|
+
scriptId: "genesis_lock",
|
|
101
|
+
data: {
|
|
102
|
+
bytecode: {
|
|
103
|
+
g_token_type: Uint8Array.from([...[0x01], ...[options.type]]),
|
|
104
|
+
g_token_ticker: stringToBin(options.ticker),
|
|
105
|
+
g_token_name: stringToBin(options.name),
|
|
106
|
+
g_token_document_url: stringToBin(options.documentUrl),
|
|
107
|
+
g_token_document_hash: stringToBin(options.documentHash, true),
|
|
108
|
+
g_decimals: Uint8Array.from([...[0x01], ...[options.decimals]]),
|
|
109
|
+
g_mint_baton_vout: Uint8Array.from(batonVout),
|
|
110
|
+
g_initial_token_mint_quantity: Uint8Array.from([
|
|
111
|
+
...[0x08],
|
|
112
|
+
...bigIntToBinUint64BE(rawTokenAmount),
|
|
113
|
+
]),
|
|
114
|
+
},
|
|
111
115
|
},
|
|
112
116
|
});
|
|
113
117
|
if (!genesisTxoBytecode.success) {
|
|
@@ -118,8 +122,8 @@ export const SlpGetGenesisOutputs = async (options: SlpGenesisOptions) => {
|
|
|
118
122
|
SlpOutputs: [
|
|
119
123
|
{
|
|
120
124
|
lockingBytecode: genesisTxoBytecode.bytecode,
|
|
121
|
-
|
|
122
|
-
},
|
|
125
|
+
valueSatoshis: 0n,
|
|
126
|
+
} as Output,
|
|
123
127
|
],
|
|
124
128
|
FundingSlpUtxos: [],
|
|
125
129
|
BchSendRequests: bchSendRequests,
|
|
@@ -160,7 +164,7 @@ export const SlpGetMintOutputs = async (
|
|
|
160
164
|
})
|
|
161
165
|
);
|
|
162
166
|
|
|
163
|
-
const template =
|
|
167
|
+
const template = importAuthenticationTemplate(SlpTxoTemplate);
|
|
164
168
|
if (typeof template === "string") {
|
|
165
169
|
throw new Error("Transaction template error");
|
|
166
170
|
}
|
|
@@ -170,15 +174,18 @@ export const SlpGetMintOutputs = async (
|
|
|
170
174
|
|
|
171
175
|
const batonVout = options.endBaton ? [0x4c, 0x00] : [0x01, 0x02];
|
|
172
176
|
|
|
173
|
-
let mintTxoBytecode = compiler.generateBytecode(
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
177
|
+
let mintTxoBytecode = compiler.generateBytecode({
|
|
178
|
+
scriptId: "mint_lock",
|
|
179
|
+
data: {
|
|
180
|
+
bytecode: {
|
|
181
|
+
m_token_type: Uint8Array.from([...[0x01], ...[tokenType]]),
|
|
182
|
+
m_token_id: hexToBin(options.tokenId),
|
|
183
|
+
m_mint_baton_vout: Uint8Array.from(batonVout),
|
|
184
|
+
m_additional_token_quantity: Uint8Array.from([
|
|
185
|
+
...[0x08],
|
|
186
|
+
...bigIntToBinUint64BE(BigInt(amount.toString())),
|
|
187
|
+
]),
|
|
188
|
+
},
|
|
182
189
|
},
|
|
183
190
|
});
|
|
184
191
|
if (!mintTxoBytecode.success) {
|
|
@@ -189,8 +196,8 @@ export const SlpGetMintOutputs = async (
|
|
|
189
196
|
SlpOutputs: [
|
|
190
197
|
{
|
|
191
198
|
lockingBytecode: mintTxoBytecode.bytecode,
|
|
192
|
-
|
|
193
|
-
},
|
|
199
|
+
valueSatoshis: 0n,
|
|
200
|
+
} as Output,
|
|
194
201
|
],
|
|
195
202
|
FundingSlpUtxos: slpBatonUtxos,
|
|
196
203
|
BchSendRequests: bchSendRequests,
|
|
@@ -249,7 +256,7 @@ export const SlpGetSendOutputs = async (
|
|
|
249
256
|
}
|
|
250
257
|
}
|
|
251
258
|
|
|
252
|
-
const template =
|
|
259
|
+
const template = importAuthenticationTemplate(SlpTxoTemplate);
|
|
253
260
|
if (typeof template === "string") {
|
|
254
261
|
throw new Error("Transaction template error");
|
|
255
262
|
}
|
|
@@ -286,11 +293,14 @@ export const SlpGetSendOutputs = async (
|
|
|
286
293
|
]);
|
|
287
294
|
}
|
|
288
295
|
|
|
289
|
-
let sendTxoBytecode = compiler.generateBytecode(
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
296
|
+
let sendTxoBytecode = compiler.generateBytecode({
|
|
297
|
+
scriptId: "send_lock",
|
|
298
|
+
data: {
|
|
299
|
+
bytecode: {
|
|
300
|
+
s_token_type: Uint8Array.from([...[0x01], ...[tokenType]]),
|
|
301
|
+
s_token_id: hexToBin(tokenId!),
|
|
302
|
+
s_token_output_quantities: result,
|
|
303
|
+
},
|
|
294
304
|
},
|
|
295
305
|
});
|
|
296
306
|
if (!sendTxoBytecode.success) {
|
|
@@ -304,8 +314,8 @@ export const SlpGetSendOutputs = async (
|
|
|
304
314
|
SlpOutputs: [
|
|
305
315
|
{
|
|
306
316
|
lockingBytecode: sendTxoBytecode.bytecode,
|
|
307
|
-
|
|
308
|
-
},
|
|
317
|
+
valueSatoshis: 0n,
|
|
318
|
+
} as Output,
|
|
309
319
|
],
|
|
310
320
|
FundingSlpUtxos: fundingSlpUtxos,
|
|
311
321
|
BchSendRequests: bchSendRequests,
|
package/src/slp/SlpProvider.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
SlpTokenBalance,
|
|
3
|
+
SlpTokenInfo,
|
|
4
|
+
SlpTxI,
|
|
5
|
+
SlpUtxoI,
|
|
6
|
+
} from "./interface.js";
|
|
2
7
|
import BigNumber from "bignumber.js";
|
|
3
8
|
|
|
4
9
|
export type SlpWatchTransactionCallback = (tx: SlpTxI) => void;
|
package/src/slp/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { SlpDbProvider } from "./SlpDbProvider";
|
|
2
|
-
export { GsppProvider } from "./GsppProvider";
|
|
3
|
-
export { SlpProvider } from "./SlpProvider";
|
|
1
|
+
export { SlpDbProvider } from "./SlpDbProvider.js";
|
|
2
|
+
export { GsppProvider } from "./GsppProvider.js";
|
|
3
|
+
export { SlpProvider } from "./SlpProvider.js";
|
|
4
4
|
export { default as BigNumber } from "bignumber.js";
|
|
5
5
|
|
|
6
|
-
export * from "./interface";
|
|
6
|
+
export * from "./interface.js";
|
package/src/slp/interface.ts
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
|
|
3
|
+
export function setupAxiosMock(mockUrl, responseData) {
|
|
4
|
+
if (!(axios.interceptors as any).mocks) {
|
|
5
|
+
(axios.interceptors as any).mocks = {};
|
|
6
|
+
|
|
7
|
+
// install our interceptors
|
|
8
|
+
(axios.interceptors as any).request.use((config) => {
|
|
9
|
+
const url = config.url!;
|
|
10
|
+
|
|
11
|
+
if ((axios.interceptors as any).mocks[url]) {
|
|
12
|
+
// if we have set up a mocked response for this url, cancel the actual request with a cancelToken containing our mocked data
|
|
13
|
+
const mockedResponse = (axios.interceptors as any).mocks[url];
|
|
14
|
+
return {
|
|
15
|
+
...config,
|
|
16
|
+
cancelToken: new axios.CancelToken((cancel) =>
|
|
17
|
+
cancel({ status: 200, data: mockedResponse } as any)
|
|
18
|
+
),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// otherwise proceed with usual request
|
|
23
|
+
return config;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
(axios.interceptors as any).response.use(
|
|
27
|
+
function (response) {
|
|
28
|
+
return response;
|
|
29
|
+
},
|
|
30
|
+
function (error: any) {
|
|
31
|
+
// resolve response with our mocked data
|
|
32
|
+
if (axios.isCancel(error)) {
|
|
33
|
+
return Promise.resolve(error.message);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// handle all other errors gracefully
|
|
37
|
+
return Promise.reject(error);
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
(axios.interceptors as any).mocks[mockUrl] = responseData;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function removeAxiosMock(mockUrl) {
|
|
46
|
+
delete ((axios.interceptors as any).mocks || {})[mockUrl];
|
|
47
|
+
}
|
package/src/test/expect.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export { delay } from "../util/delay";
|
|
2
|
-
|
|
3
1
|
export function expect(expected) {
|
|
4
2
|
return {
|
|
5
3
|
toBe: function (received) {
|
|
@@ -9,6 +7,13 @@ export function expect(expected) {
|
|
|
9
7
|
);
|
|
10
8
|
}
|
|
11
9
|
},
|
|
10
|
+
toEqual: function (received) {
|
|
11
|
+
if (!(expected === received)) {
|
|
12
|
+
throw new Error(
|
|
13
|
+
`assertion failed: expected ${expected} is not equal to received ${received}`
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
},
|
|
12
17
|
toBeGreaterThan: function (received) {
|
|
13
18
|
if (!(expected > received)) {
|
|
14
19
|
throw new Error(
|
|
@@ -30,5 +35,25 @@ export function expect(expected) {
|
|
|
30
35
|
);
|
|
31
36
|
}
|
|
32
37
|
},
|
|
38
|
+
toContain: function (received) {
|
|
39
|
+
if (!(expected as String).includes(received)) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
`assertion failed: expected ${expected} does not Contain received ${received}`
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
rejects: {
|
|
46
|
+
toThrow: async function (message: string): Promise<void> {
|
|
47
|
+
try {
|
|
48
|
+
await expected;
|
|
49
|
+
} catch (e: any) {
|
|
50
|
+
if (!(e.message as String).includes(message)) {
|
|
51
|
+
throw new Error(
|
|
52
|
+
`assertion failed: expected function to throw with message ${message}, but it did not.`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
},
|
|
33
58
|
};
|
|
34
59
|
}
|