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
|
@@ -0,0 +1,610 @@
|
|
|
1
|
+
import { disconnectProviders, initProviders } from "../network/Connection.js";
|
|
2
|
+
import { setupAxiosMock, removeAxiosMock } from "../test/axios.js";
|
|
3
|
+
import { BCMR } from "./Bcmr.js";
|
|
4
|
+
import { Registry } from "./bcmr-v1.schema.js";
|
|
5
|
+
import { RegTestWallet } from "./Wif";
|
|
6
|
+
import { OpReturnData, SendRequest } from "./model";
|
|
7
|
+
import { binToHex, hexToBin, sha256, utf8ToBin } from "@bitauth/libauth";
|
|
8
|
+
import { mine } from "../mine";
|
|
9
|
+
import { Network } from "../interface";
|
|
10
|
+
|
|
11
|
+
beforeAll(async () => {
|
|
12
|
+
await initProviders();
|
|
13
|
+
});
|
|
14
|
+
afterAll(async () => {
|
|
15
|
+
await disconnectProviders();
|
|
16
|
+
});
|
|
17
|
+
afterEach(async () => {
|
|
18
|
+
BCMR.resetRegistries();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe(`Test BCMR support`, () => {
|
|
22
|
+
const registry: Registry = {
|
|
23
|
+
version: { major: 1, minor: 0, patch: 0 },
|
|
24
|
+
latestRevision: Date.toString(),
|
|
25
|
+
registryIdentity: {
|
|
26
|
+
name: "Test token registry",
|
|
27
|
+
time: { begin: Date.now() },
|
|
28
|
+
token: {
|
|
29
|
+
category:
|
|
30
|
+
"0000000000000000000000000000000000000000000000000000000000000000",
|
|
31
|
+
symbol: "TOK",
|
|
32
|
+
decimals: 8,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const registryContent = JSON.stringify(registry, null, 2);
|
|
38
|
+
const registryContentHashBin = sha256.hash(utf8ToBin(registryContent));
|
|
39
|
+
const registryContentHash = binToHex(registryContentHashBin);
|
|
40
|
+
const registryContentHashBinBitcoinByteOrder = registryContentHashBin
|
|
41
|
+
.slice()
|
|
42
|
+
.reverse();
|
|
43
|
+
|
|
44
|
+
test("Add metadata registry and get token info", async () => {
|
|
45
|
+
expect(
|
|
46
|
+
BCMR.getTokenInfo(
|
|
47
|
+
"0000000000000000000000000000000000000000000000000000000000000000"
|
|
48
|
+
)
|
|
49
|
+
).toBe(undefined);
|
|
50
|
+
BCMR.addMetadataRegistry(registry);
|
|
51
|
+
const tokenInfo = BCMR.getTokenInfo(
|
|
52
|
+
"0000000000000000000000000000000000000000000000000000000000000000"
|
|
53
|
+
);
|
|
54
|
+
expect(tokenInfo?.token?.symbol).toBe("TOK");
|
|
55
|
+
expect(tokenInfo?.token?.decimals).toBe(8);
|
|
56
|
+
|
|
57
|
+
// check adding the same registry does not produce a duplicate
|
|
58
|
+
expect(BCMR.metadataRegistries.length).toBe(1);
|
|
59
|
+
BCMR.addMetadataRegistry(registry);
|
|
60
|
+
expect(BCMR.metadataRegistries.length).toBe(1);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test("Add metadata from uri and get token info", async () => {
|
|
64
|
+
setupAxiosMock(
|
|
65
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry.json",
|
|
66
|
+
registry
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
expect(
|
|
70
|
+
BCMR.getTokenInfo(
|
|
71
|
+
"0000000000000000000000000000000000000000000000000000000000000000"
|
|
72
|
+
)
|
|
73
|
+
).toBe(undefined);
|
|
74
|
+
await BCMR.addMetadataRegistryFromUri(
|
|
75
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry.json"
|
|
76
|
+
);
|
|
77
|
+
const tokenInfo = BCMR.getTokenInfo(
|
|
78
|
+
"0000000000000000000000000000000000000000000000000000000000000000"
|
|
79
|
+
);
|
|
80
|
+
expect(tokenInfo?.token?.symbol).toBe("TOK");
|
|
81
|
+
expect(tokenInfo?.token?.decimals).toBe(8);
|
|
82
|
+
|
|
83
|
+
// check adding the same registry does not produce a duplicate
|
|
84
|
+
expect(BCMR.metadataRegistries.length).toBe(1);
|
|
85
|
+
await BCMR.addMetadataRegistryFromUri(
|
|
86
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry.json"
|
|
87
|
+
);
|
|
88
|
+
expect(BCMR.metadataRegistries.length).toBe(1);
|
|
89
|
+
|
|
90
|
+
removeAxiosMock(
|
|
91
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry.json"
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test("Add metadata from uri with contenthash and get token info", async () => {
|
|
96
|
+
setupAxiosMock(
|
|
97
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry.json",
|
|
98
|
+
registryContent
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
expect(
|
|
102
|
+
BCMR.getTokenInfo(
|
|
103
|
+
"0000000000000000000000000000000000000000000000000000000000000000"
|
|
104
|
+
)
|
|
105
|
+
).toBe(undefined);
|
|
106
|
+
await expect(
|
|
107
|
+
BCMR.addMetadataRegistryFromUri(
|
|
108
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry.json",
|
|
109
|
+
"00"
|
|
110
|
+
)
|
|
111
|
+
).rejects.toThrow("mismatch");
|
|
112
|
+
await BCMR.addMetadataRegistryFromUri(
|
|
113
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry.json",
|
|
114
|
+
registryContentHash
|
|
115
|
+
);
|
|
116
|
+
const tokenInfo = BCMR.getTokenInfo(
|
|
117
|
+
"0000000000000000000000000000000000000000000000000000000000000000"
|
|
118
|
+
);
|
|
119
|
+
expect(tokenInfo?.token?.symbol).toBe("TOK");
|
|
120
|
+
expect(tokenInfo?.token?.decimals).toBe(8);
|
|
121
|
+
|
|
122
|
+
removeAxiosMock(
|
|
123
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry.json"
|
|
124
|
+
);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test("Auth chain: invalid transaction", async () => {
|
|
128
|
+
await expect(
|
|
129
|
+
BCMR.buildAuthChain({
|
|
130
|
+
transactionHash:
|
|
131
|
+
"0000000000000000000000000000000000000000000000000000000000000000",
|
|
132
|
+
})
|
|
133
|
+
).rejects.toThrow("Could not decode transaction");
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test("Auth chain: no BCMR", async () => {
|
|
137
|
+
const alice = await RegTestWallet.fromId(
|
|
138
|
+
`wif:regtest:${process.env.PRIVATE_WIF!}`
|
|
139
|
+
);
|
|
140
|
+
const bob = await RegTestWallet.newRandom();
|
|
141
|
+
|
|
142
|
+
const chunks = ["Hello"];
|
|
143
|
+
const opreturnData = OpReturnData.fromArray(chunks);
|
|
144
|
+
|
|
145
|
+
const response = await alice.send([
|
|
146
|
+
new SendRequest({ cashaddr: bob.cashaddr!, value: 1000, unit: "sat" }),
|
|
147
|
+
opreturnData,
|
|
148
|
+
]);
|
|
149
|
+
await expect(
|
|
150
|
+
BCMR.buildAuthChain({
|
|
151
|
+
transactionHash: response.txId!,
|
|
152
|
+
network: Network.REGTEST,
|
|
153
|
+
})
|
|
154
|
+
).rejects.toThrow("No BCMR OP_RETURN outputs found in the transaction");
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test("Auth chain: BCMR, no hash", async () => {
|
|
158
|
+
const alice = await RegTestWallet.fromId(
|
|
159
|
+
`wif:regtest:${process.env.PRIVATE_WIF!}`
|
|
160
|
+
);
|
|
161
|
+
const bob = await RegTestWallet.newRandom();
|
|
162
|
+
|
|
163
|
+
const chunks = ["BCMR"];
|
|
164
|
+
const opreturnData = OpReturnData.fromArray(chunks);
|
|
165
|
+
|
|
166
|
+
const response = await alice.send([
|
|
167
|
+
new SendRequest({ cashaddr: bob.cashaddr!, value: 1000, unit: "sat" }),
|
|
168
|
+
opreturnData,
|
|
169
|
+
]);
|
|
170
|
+
await expect(
|
|
171
|
+
BCMR.buildAuthChain({
|
|
172
|
+
transactionHash: response.txId!,
|
|
173
|
+
network: Network.REGTEST,
|
|
174
|
+
})
|
|
175
|
+
).rejects.toThrow("Malformed BCMR output");
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
test("Auth chain: BCMR, ipfs hash", async () => {
|
|
179
|
+
const alice = await RegTestWallet.fromId(
|
|
180
|
+
`wif:regtest:${process.env.PRIVATE_WIF!}`
|
|
181
|
+
);
|
|
182
|
+
const bob = await RegTestWallet.newRandom();
|
|
183
|
+
|
|
184
|
+
const chunks = ["BCMR", "QmbWrG5Asp5iGmUwQHogSJGRX26zuRnuLWPytZfiL75sZv"];
|
|
185
|
+
const opreturnData = OpReturnData.fromArray(chunks);
|
|
186
|
+
|
|
187
|
+
const response = await alice.send([
|
|
188
|
+
new SendRequest({ cashaddr: bob.cashaddr!, value: 1000, unit: "sat" }),
|
|
189
|
+
opreturnData,
|
|
190
|
+
]);
|
|
191
|
+
const chain = await BCMR.buildAuthChain({
|
|
192
|
+
transactionHash: response.txId!,
|
|
193
|
+
network: Network.REGTEST,
|
|
194
|
+
});
|
|
195
|
+
expect(chain.length).toBe(1);
|
|
196
|
+
expect(chain[0].contentHash).toBe(
|
|
197
|
+
"516d62577247354173703569476d557751486f67534a47525832367a75526e754c575079745a66694c3735735a76"
|
|
198
|
+
);
|
|
199
|
+
expect(chain[0].uri).toBe(
|
|
200
|
+
"https://dweb.link/ipfs/QmbWrG5Asp5iGmUwQHogSJGRX26zuRnuLWPytZfiL75sZv"
|
|
201
|
+
);
|
|
202
|
+
expect(chain[0].txHash).toBe(response.txId);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
test("Auth chain: BCMR, sha256 content hash, uri", async () => {
|
|
206
|
+
const alice = await RegTestWallet.fromId(
|
|
207
|
+
`wif:regtest:${process.env.PRIVATE_WIF!}`
|
|
208
|
+
);
|
|
209
|
+
const bob = await RegTestWallet.newRandom();
|
|
210
|
+
|
|
211
|
+
const contentHashBin = sha256.hash(utf8ToBin("registry_contents"));
|
|
212
|
+
const chunks = [
|
|
213
|
+
"BCMR",
|
|
214
|
+
contentHashBin.slice().reverse(),
|
|
215
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry.json",
|
|
216
|
+
];
|
|
217
|
+
const opreturnData = OpReturnData.fromArray(chunks);
|
|
218
|
+
|
|
219
|
+
const response = await alice.send([
|
|
220
|
+
new SendRequest({ cashaddr: bob.cashaddr!, value: 1000, unit: "sat" }),
|
|
221
|
+
opreturnData,
|
|
222
|
+
]);
|
|
223
|
+
const chain = await BCMR.buildAuthChain({
|
|
224
|
+
transactionHash: response.txId!,
|
|
225
|
+
network: Network.REGTEST,
|
|
226
|
+
});
|
|
227
|
+
expect(chain.length).toBe(1);
|
|
228
|
+
expect(chain[0].contentHash).toBe(binToHex(contentHashBin));
|
|
229
|
+
expect(chain[0].uri).toBe(
|
|
230
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry.json"
|
|
231
|
+
);
|
|
232
|
+
expect(chain[0].txHash).toBe(response.txId);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
test("Auth chain: BCMR, sha256 content hash, uri and another chunk", async () => {
|
|
236
|
+
const alice = await RegTestWallet.fromId(
|
|
237
|
+
`wif:regtest:${process.env.PRIVATE_WIF!}`
|
|
238
|
+
);
|
|
239
|
+
const bob = await RegTestWallet.newRandom();
|
|
240
|
+
|
|
241
|
+
const chunks = [
|
|
242
|
+
"BCMR",
|
|
243
|
+
sha256.hash(utf8ToBin("registry_contents")),
|
|
244
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry.json",
|
|
245
|
+
"something else",
|
|
246
|
+
];
|
|
247
|
+
const opreturnData = OpReturnData.fromArray(chunks);
|
|
248
|
+
const response = await alice.send([
|
|
249
|
+
new SendRequest({ cashaddr: bob.cashaddr!, value: 1000, unit: "sat" }),
|
|
250
|
+
opreturnData,
|
|
251
|
+
]);
|
|
252
|
+
await expect(
|
|
253
|
+
BCMR.buildAuthChain({
|
|
254
|
+
transactionHash: response.txId!,
|
|
255
|
+
network: Network.REGTEST,
|
|
256
|
+
})
|
|
257
|
+
).rejects.toThrow("Malformed BCMR output");
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
test("Auth chain: all OP_PUSDHDATA encodings", async () => {
|
|
261
|
+
const alice = await RegTestWallet.fromId(
|
|
262
|
+
`wif:regtest:${process.env.PRIVATE_WIF!}`
|
|
263
|
+
);
|
|
264
|
+
const bob = await RegTestWallet.newRandom();
|
|
265
|
+
|
|
266
|
+
const opreturnData = OpReturnData.fromUint8Array(
|
|
267
|
+
hexToBin(
|
|
268
|
+
"6a0442434d524c20e073b89a80c77c533ad364692db15df01adb9df404592f608d2c0cdd8960ed0e4d440068747470733a2f2f6d61696e6e65742e636173682f2e77656c6c2d6b6e6f776e2f626974636f696e2d636173682d6d657461646174612d72656769737472792e6a736f6e"
|
|
269
|
+
)
|
|
270
|
+
);
|
|
271
|
+
const response = await alice.send([
|
|
272
|
+
new SendRequest({ cashaddr: bob.cashaddr!, value: 1000, unit: "sat" }),
|
|
273
|
+
opreturnData,
|
|
274
|
+
]);
|
|
275
|
+
await BCMR.buildAuthChain({
|
|
276
|
+
transactionHash: response.txId!,
|
|
277
|
+
network: Network.REGTEST,
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
test("Auth chain with 1 element, add resolved registry", async () => {
|
|
282
|
+
const alice = await RegTestWallet.fromId(
|
|
283
|
+
`wif:regtest:${process.env.PRIVATE_WIF!}`
|
|
284
|
+
);
|
|
285
|
+
const bob = await RegTestWallet.newRandom();
|
|
286
|
+
|
|
287
|
+
let chunks = [
|
|
288
|
+
"BCMR",
|
|
289
|
+
registryContentHashBinBitcoinByteOrder,
|
|
290
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry.json",
|
|
291
|
+
];
|
|
292
|
+
const opreturnData = OpReturnData.fromArray(chunks);
|
|
293
|
+
const response = await alice.send([
|
|
294
|
+
new SendRequest({ cashaddr: bob.cashaddr!, value: 10000, unit: "sat" }),
|
|
295
|
+
opreturnData,
|
|
296
|
+
]);
|
|
297
|
+
|
|
298
|
+
setupAxiosMock(
|
|
299
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry.json",
|
|
300
|
+
registry
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
expect(
|
|
304
|
+
BCMR.getTokenInfo(
|
|
305
|
+
"0000000000000000000000000000000000000000000000000000000000000000"
|
|
306
|
+
)
|
|
307
|
+
).toBe(undefined);
|
|
308
|
+
const chain = await BCMR.addMetadataRegistryAuthChain({
|
|
309
|
+
transactionHash: response.txId!,
|
|
310
|
+
network: Network.REGTEST,
|
|
311
|
+
});
|
|
312
|
+
expect(chain.length).toBe(1);
|
|
313
|
+
expect(chain[0].txHash).toBe(response.txId!);
|
|
314
|
+
expect(chain[0].uri).toBe(
|
|
315
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry.json"
|
|
316
|
+
);
|
|
317
|
+
|
|
318
|
+
const tokenInfo = BCMR.getTokenInfo(
|
|
319
|
+
"0000000000000000000000000000000000000000000000000000000000000000"
|
|
320
|
+
);
|
|
321
|
+
expect(tokenInfo?.token?.symbol).toBe("TOK");
|
|
322
|
+
expect(tokenInfo?.token?.decimals).toBe(8);
|
|
323
|
+
|
|
324
|
+
// check adding the same registry does not produce a duplicate
|
|
325
|
+
expect(BCMR.metadataRegistries.length).toBe(1);
|
|
326
|
+
const otherChain = await BCMR.addMetadataRegistryAuthChain({
|
|
327
|
+
transactionHash: response.txId!,
|
|
328
|
+
network: Network.REGTEST,
|
|
329
|
+
});
|
|
330
|
+
expect(otherChain.length).toBe(1);
|
|
331
|
+
expect(BCMR.metadataRegistries.length).toBe(1);
|
|
332
|
+
|
|
333
|
+
removeAxiosMock(
|
|
334
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry.json"
|
|
335
|
+
);
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
test("Auth chain with 3 elements", async () => {
|
|
339
|
+
// tests autchchain of 3 elements with all possible confirmed and unfonfirmed transaction chains
|
|
340
|
+
// Also change of autchchain holding address is asessed
|
|
341
|
+
for (const [index, mineCombo] of [
|
|
342
|
+
[0, 0, 0],
|
|
343
|
+
[0, 0, 1],
|
|
344
|
+
[0, 1, 0],
|
|
345
|
+
[0, 1, 1],
|
|
346
|
+
[1, 0, 0],
|
|
347
|
+
[1, 0, 1],
|
|
348
|
+
[1, 1, 0],
|
|
349
|
+
[1, 1, 1],
|
|
350
|
+
].entries()) {
|
|
351
|
+
const alice = await RegTestWallet.fromId(
|
|
352
|
+
`wif:regtest:${process.env.PRIVATE_WIF!}`
|
|
353
|
+
);
|
|
354
|
+
const bob = await RegTestWallet.newRandom();
|
|
355
|
+
const charlie = await RegTestWallet.newRandom();
|
|
356
|
+
|
|
357
|
+
let chunks = [
|
|
358
|
+
"BCMR",
|
|
359
|
+
registryContentHashBinBitcoinByteOrder,
|
|
360
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry.json",
|
|
361
|
+
];
|
|
362
|
+
const opreturnData = OpReturnData.fromArray(chunks);
|
|
363
|
+
const response = await alice.send([
|
|
364
|
+
new SendRequest({ cashaddr: bob.cashaddr!, value: 10000, unit: "sat" }),
|
|
365
|
+
opreturnData,
|
|
366
|
+
]);
|
|
367
|
+
if (mineCombo[0]) await mine({ cashaddr: alice.cashaddr!, blocks: 1 });
|
|
368
|
+
|
|
369
|
+
chunks[2] =
|
|
370
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v2.json";
|
|
371
|
+
const opreturnData2 = OpReturnData.fromArray(chunks);
|
|
372
|
+
const response2 = await bob.send([
|
|
373
|
+
new SendRequest({ cashaddr: bob.cashaddr!, value: 9500, unit: "sat" }),
|
|
374
|
+
opreturnData2,
|
|
375
|
+
]);
|
|
376
|
+
if (mineCombo[1]) await mine({ cashaddr: alice.cashaddr!, blocks: 1 });
|
|
377
|
+
|
|
378
|
+
chunks[2] =
|
|
379
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v3.json";
|
|
380
|
+
const opreturnData3 = OpReturnData.fromArray(chunks);
|
|
381
|
+
const response3 = await bob.send([
|
|
382
|
+
new SendRequest({
|
|
383
|
+
cashaddr: charlie.cashaddr!,
|
|
384
|
+
value: 9000,
|
|
385
|
+
unit: "sat",
|
|
386
|
+
}),
|
|
387
|
+
opreturnData3,
|
|
388
|
+
]);
|
|
389
|
+
if (mineCombo[2]) await mine({ cashaddr: alice.cashaddr!, blocks: 1 });
|
|
390
|
+
|
|
391
|
+
const chain = await BCMR.buildAuthChain({
|
|
392
|
+
transactionHash: response.txId!,
|
|
393
|
+
network: Network.REGTEST,
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
expect(chain.length).toBe(3);
|
|
397
|
+
expect(chain[0].txHash).toBe(response.txId!);
|
|
398
|
+
expect(chain[0].uri).toBe(
|
|
399
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry.json"
|
|
400
|
+
);
|
|
401
|
+
|
|
402
|
+
expect(chain[1].txHash).toBe(response2.txId!);
|
|
403
|
+
expect(chain[1].uri).toBe(
|
|
404
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v2.json"
|
|
405
|
+
);
|
|
406
|
+
|
|
407
|
+
expect(chain[2].txHash).toBe(response3.txId!);
|
|
408
|
+
expect(chain[2].uri).toBe(
|
|
409
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v3.json"
|
|
410
|
+
);
|
|
411
|
+
|
|
412
|
+
// extra checks for resolving chains not from head
|
|
413
|
+
if (index === 0) {
|
|
414
|
+
const noFollow = await BCMR.buildAuthChain({
|
|
415
|
+
transactionHash: response2.txId!,
|
|
416
|
+
network: Network.REGTEST,
|
|
417
|
+
followToHead: false,
|
|
418
|
+
});
|
|
419
|
+
expect(noFollow.length).toBe(1);
|
|
420
|
+
expect(noFollow[0].txHash).toBe(response2.txId!);
|
|
421
|
+
expect(noFollow[0].uri).toBe(
|
|
422
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v2.json"
|
|
423
|
+
);
|
|
424
|
+
|
|
425
|
+
const follow = await BCMR.buildAuthChain({
|
|
426
|
+
transactionHash: response2.txId!,
|
|
427
|
+
network: Network.REGTEST,
|
|
428
|
+
followToHead: true,
|
|
429
|
+
});
|
|
430
|
+
expect(follow.length).toBe(2);
|
|
431
|
+
|
|
432
|
+
expect(follow[0].txHash).toBe(response2.txId!);
|
|
433
|
+
expect(follow[0].uri).toBe(
|
|
434
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v2.json"
|
|
435
|
+
);
|
|
436
|
+
|
|
437
|
+
expect(follow[1].txHash).toBe(response3.txId!);
|
|
438
|
+
expect(follow[1].uri).toBe(
|
|
439
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v3.json"
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
test("Authchain tail resolution info in registry acceleration path", async () => {
|
|
446
|
+
const alice = await RegTestWallet.fromId(
|
|
447
|
+
`wif:regtest:${process.env.PRIVATE_WIF!}`
|
|
448
|
+
);
|
|
449
|
+
const bob = await RegTestWallet.newRandom();
|
|
450
|
+
|
|
451
|
+
const registry_v1 = { ...registry };
|
|
452
|
+
registry_v1.extensions = { authchain: [] };
|
|
453
|
+
const contentHash_v1 = sha256
|
|
454
|
+
.hash(utf8ToBin(JSON.stringify(registry_v1, null, 2)))
|
|
455
|
+
.reverse();
|
|
456
|
+
setupAxiosMock(
|
|
457
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v1.json",
|
|
458
|
+
JSON.stringify(registry_v1, null, 2)
|
|
459
|
+
);
|
|
460
|
+
let chunks = [
|
|
461
|
+
"BCMR",
|
|
462
|
+
contentHash_v1,
|
|
463
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v1.json",
|
|
464
|
+
];
|
|
465
|
+
const opreturnData = OpReturnData.fromArray(chunks);
|
|
466
|
+
const response = await alice.send([
|
|
467
|
+
new SendRequest({ cashaddr: bob.cashaddr!, value: 10000, unit: "sat" }),
|
|
468
|
+
opreturnData,
|
|
469
|
+
]);
|
|
470
|
+
|
|
471
|
+
const registry_v2 = { ...registry };
|
|
472
|
+
registry_v2.extensions = {
|
|
473
|
+
authchain: [await bob.provider!.getRawTransaction(response.txId)],
|
|
474
|
+
};
|
|
475
|
+
const contentHash_v2 = sha256
|
|
476
|
+
.hash(utf8ToBin(JSON.stringify(registry_v2, null, 2)))
|
|
477
|
+
.reverse();
|
|
478
|
+
setupAxiosMock(
|
|
479
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v2.json",
|
|
480
|
+
JSON.stringify(registry_v2, null, 2)
|
|
481
|
+
);
|
|
482
|
+
chunks = [
|
|
483
|
+
"BCMR",
|
|
484
|
+
contentHash_v2,
|
|
485
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v2.json",
|
|
486
|
+
];
|
|
487
|
+
const opreturnData2 = OpReturnData.fromArray(chunks);
|
|
488
|
+
const response2 = await bob.send([
|
|
489
|
+
new SendRequest({ cashaddr: bob.cashaddr!, value: 9500, unit: "sat" }),
|
|
490
|
+
opreturnData2,
|
|
491
|
+
]);
|
|
492
|
+
|
|
493
|
+
const registry_v3 = { ...registry };
|
|
494
|
+
registry_v3.extensions = {
|
|
495
|
+
authchain: [
|
|
496
|
+
await bob.provider!.getRawTransaction(response.txId),
|
|
497
|
+
await bob.provider!.getRawTransaction(response2.txId),
|
|
498
|
+
],
|
|
499
|
+
};
|
|
500
|
+
const contentHash_v3 = sha256
|
|
501
|
+
.hash(utf8ToBin(JSON.stringify(registry_v3, null, 2)))
|
|
502
|
+
.reverse();
|
|
503
|
+
setupAxiosMock(
|
|
504
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v3.json",
|
|
505
|
+
JSON.stringify(registry_v3, null, 2)
|
|
506
|
+
);
|
|
507
|
+
chunks = [
|
|
508
|
+
"BCMR",
|
|
509
|
+
contentHash_v3,
|
|
510
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v3.json",
|
|
511
|
+
];
|
|
512
|
+
const opreturnData3 = OpReturnData.fromArray(chunks);
|
|
513
|
+
const response3 = await bob.send([
|
|
514
|
+
new SendRequest({ cashaddr: bob.cashaddr!, value: 9000, unit: "sat" }),
|
|
515
|
+
opreturnData3,
|
|
516
|
+
]);
|
|
517
|
+
|
|
518
|
+
const registry_v4 = { ...registry };
|
|
519
|
+
registry_v4.extensions = {};
|
|
520
|
+
const contentHash_v4 = sha256
|
|
521
|
+
.hash(utf8ToBin(JSON.stringify(registry_v4, null, 2)))
|
|
522
|
+
.reverse();
|
|
523
|
+
setupAxiosMock(
|
|
524
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v4.json",
|
|
525
|
+
JSON.stringify(registry_v4, null, 2)
|
|
526
|
+
);
|
|
527
|
+
chunks = [
|
|
528
|
+
"BCMR",
|
|
529
|
+
contentHash_v4,
|
|
530
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v4.json",
|
|
531
|
+
];
|
|
532
|
+
const opreturnData4 = OpReturnData.fromArray(chunks);
|
|
533
|
+
const response4 = await bob.send([
|
|
534
|
+
new SendRequest({ cashaddr: bob.cashaddr!, value: 8500, unit: "sat" }),
|
|
535
|
+
opreturnData4,
|
|
536
|
+
]);
|
|
537
|
+
|
|
538
|
+
let chain = await BCMR.buildAuthChain({
|
|
539
|
+
transactionHash: response.txId!,
|
|
540
|
+
network: Network.REGTEST,
|
|
541
|
+
});
|
|
542
|
+
expect(chain.length).toBe(4);
|
|
543
|
+
|
|
544
|
+
chain = await BCMR.buildAuthChain({
|
|
545
|
+
transactionHash: response.txId!,
|
|
546
|
+
network: Network.REGTEST,
|
|
547
|
+
followToHead: false,
|
|
548
|
+
});
|
|
549
|
+
expect(chain.length).toBe(1);
|
|
550
|
+
|
|
551
|
+
// tail acceleration available, do not follow head
|
|
552
|
+
chain = await BCMR.buildAuthChain({
|
|
553
|
+
transactionHash: response3.txId!,
|
|
554
|
+
network: Network.REGTEST,
|
|
555
|
+
followToHead: false,
|
|
556
|
+
resolveBase: true,
|
|
557
|
+
});
|
|
558
|
+
expect(chain.length).toBe(3);
|
|
559
|
+
|
|
560
|
+
// resolve single element
|
|
561
|
+
chain = await BCMR.buildAuthChain({
|
|
562
|
+
transactionHash: response3.txId!,
|
|
563
|
+
network: Network.REGTEST,
|
|
564
|
+
followToHead: false,
|
|
565
|
+
resolveBase: false,
|
|
566
|
+
});
|
|
567
|
+
expect(chain.length).toBe(1);
|
|
568
|
+
|
|
569
|
+
// no acceleration available, will scan network
|
|
570
|
+
chain = await BCMR.buildAuthChain({
|
|
571
|
+
transactionHash: response4.txId!,
|
|
572
|
+
network: Network.REGTEST,
|
|
573
|
+
resolveBase: true,
|
|
574
|
+
});
|
|
575
|
+
expect(chain.length).toBe(4);
|
|
576
|
+
|
|
577
|
+
expect(chain[0].txHash).toBe(response.txId!);
|
|
578
|
+
expect(chain[0].uri).toBe(
|
|
579
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v1.json"
|
|
580
|
+
);
|
|
581
|
+
|
|
582
|
+
expect(chain[1].txHash).toBe(response2.txId!);
|
|
583
|
+
expect(chain[1].uri).toBe(
|
|
584
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v2.json"
|
|
585
|
+
);
|
|
586
|
+
|
|
587
|
+
expect(chain[2].txHash).toBe(response3.txId!);
|
|
588
|
+
expect(chain[2].uri).toBe(
|
|
589
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v3.json"
|
|
590
|
+
);
|
|
591
|
+
|
|
592
|
+
expect(chain[3].txHash).toBe(response4.txId!);
|
|
593
|
+
expect(chain[3].uri).toBe(
|
|
594
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v4.json"
|
|
595
|
+
);
|
|
596
|
+
|
|
597
|
+
removeAxiosMock(
|
|
598
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v1.json"
|
|
599
|
+
);
|
|
600
|
+
removeAxiosMock(
|
|
601
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v2.json"
|
|
602
|
+
);
|
|
603
|
+
removeAxiosMock(
|
|
604
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v3.json"
|
|
605
|
+
);
|
|
606
|
+
removeAxiosMock(
|
|
607
|
+
"https://mainnet.cash/.well-known/bitcoin-cash-metadata-registry_v4.json"
|
|
608
|
+
);
|
|
609
|
+
});
|
|
610
|
+
});
|