mainnet-js 0.5.8 → 1.0.0-rc.1
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.1.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 +16 -14
- 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/Wallet.test.ts +69 -1
- 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.test.ts +1 -2
- package/src/history/electrumTransformer.ts +19 -18
- 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 -214
- 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.8.js +0 -2
- package/dist/mainnet-0.5.8.js.LICENSE.txt +0 -48
- package/dist/tsconfig.browser.tsbuildinfo +0 -1
- package/jest.config.js +0 -23
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SlpDbTemplates.js","sourceRoot":"","sources":["../../../src/slp/SlpDbTemplates.ts"],"names":[],"mappings":";;;AAAA,+EAA+E;AAC/E,kBAAkB;AACX,MAAM,mBAAmB,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,CAAC;IACrD,GAAG,EAAE,CAAC;IACN,GAAG,EAAE;QACD,IAAI,EAAE,CAAC,GAAG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BAAkB;AACX,MAAM,qBAAqB,GAAG,CAAC,OAAe,EAAE,OAAgB,EAAE,EAAE;IACzE,IAAI,CAAC,GAAG;QACN,GAAG,EAAE,CAAC;QACN,GAAG,EAAE;YACD,IAAI,EAAE,CAAC,GAAG,CAAC;YACX,WAAW,EAAE;gBACT;oBACI,QAAQ,EAAE;wBACN,0BAA0B,EAAE,OAAO;wBACnC,yBAAyB,EAAE,eAAe;qBAC7C;iBACJ;gBACD;oBACI,SAAS,EAAE,mBAAmB;iBACjC;gBACD;oBACI,QAAQ,EAAE;wBACN,0BAA0B,EAAE,OAAO;wBACnC,yBAAyB,EAAE,eAAe;qBAC7C;iBACJ;gBACD;oBACI,UAAU,EAAE;wBACR,UAAU,EAAE,CAAC;qBAChB;iBACJ;gBACD;oBACE,SAAS,EAAE;wBACT,MAAM,EAAE,QAAQ;wBAChB,YAAY,EAAE,6BAA6B;wBAC3C,cAAc,EAAE,yBAAyB;wBACzC,IAAI,EAAE,OAAO;qBACd;iBACF;aACJ;SACJ;QACD,GAAG,EAAE;YACH,GAAG,EAAE,6SAA6S;SACnT;KACF,CAAA;IAED,IAAI,OAAO,EAAE;QACV,CAAC,CAAC,GAAG,CAAC,CAAC,WAAW,CAAY,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,6BAA6B,CAAC,GAAG,OAAO,CAAC;KACvF;IAED,2CAA2C;IAC3C,OAAO,CAAC,CAAC;AACX,CAAC,CAAA;AA/CY,QAAA,qBAAqB,yBA+CjC"}
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
import { SendRequest } from "../wallet/model";
|
|
2
|
-
import { SlpGenesisOptions, SlpMintOptions, SlpSendRequest, SlpUtxoI } from "../slp/interface";
|
|
3
|
-
export declare const bigIntToBinUint64BE: (value: any) => Uint8Array;
|
|
4
|
-
export declare const SlpGetGenesisOutputs: (options: SlpGenesisOptions) => Promise<{
|
|
5
|
-
SlpOutputs: {
|
|
6
|
-
lockingBytecode: Uint8Array;
|
|
7
|
-
satoshis: Uint8Array;
|
|
8
|
-
}[];
|
|
9
|
-
FundingSlpUtxos: never[];
|
|
10
|
-
BchSendRequests: SendRequest[];
|
|
11
|
-
}>;
|
|
12
|
-
export declare const SlpGetMintOutputs: (options: SlpMintOptions, slpBatonUtxos: SlpUtxoI[]) => Promise<{
|
|
13
|
-
SlpOutputs: {
|
|
14
|
-
lockingBytecode: Uint8Array;
|
|
15
|
-
satoshis: Uint8Array;
|
|
16
|
-
}[];
|
|
17
|
-
FundingSlpUtxos: SlpUtxoI[];
|
|
18
|
-
BchSendRequests: SendRequest[];
|
|
19
|
-
}>;
|
|
20
|
-
export declare const SlpGetSendOutputs: (changeSlpaddr: string, slpUtxos: SlpUtxoI[], sendRequests: SlpSendRequest[]) => Promise<{
|
|
21
|
-
SlpOutputs: {
|
|
22
|
-
lockingBytecode: Uint8Array;
|
|
23
|
-
satoshis: Uint8Array;
|
|
24
|
-
}[];
|
|
25
|
-
FundingSlpUtxos: SlpUtxoI[];
|
|
26
|
-
BchSendRequests: SendRequest[];
|
|
27
|
-
}>;
|
|
28
|
-
export declare const SlpTxoTemplate: {
|
|
29
|
-
$schema: string;
|
|
30
|
-
description: string;
|
|
31
|
-
name: string;
|
|
32
|
-
entities: {
|
|
33
|
-
genesis_variables: {
|
|
34
|
-
description: string;
|
|
35
|
-
name: string;
|
|
36
|
-
scripts: string[];
|
|
37
|
-
variables: {
|
|
38
|
-
g_token_type: {
|
|
39
|
-
description: string;
|
|
40
|
-
name: string;
|
|
41
|
-
type: string;
|
|
42
|
-
};
|
|
43
|
-
g_token_ticker: {
|
|
44
|
-
description: string;
|
|
45
|
-
name: string;
|
|
46
|
-
type: string;
|
|
47
|
-
};
|
|
48
|
-
g_token_name: {
|
|
49
|
-
description: string;
|
|
50
|
-
name: string;
|
|
51
|
-
type: string;
|
|
52
|
-
};
|
|
53
|
-
g_token_document_url: {
|
|
54
|
-
description: string;
|
|
55
|
-
name: string;
|
|
56
|
-
type: string;
|
|
57
|
-
};
|
|
58
|
-
g_token_document_hash: {
|
|
59
|
-
description: string;
|
|
60
|
-
name: string;
|
|
61
|
-
type: string;
|
|
62
|
-
};
|
|
63
|
-
g_decimals: {
|
|
64
|
-
description: string;
|
|
65
|
-
name: string;
|
|
66
|
-
type: string;
|
|
67
|
-
};
|
|
68
|
-
g_mint_baton_vout: {
|
|
69
|
-
description: string;
|
|
70
|
-
name: string;
|
|
71
|
-
type: string;
|
|
72
|
-
};
|
|
73
|
-
g_initial_token_mint_quantity: {
|
|
74
|
-
description: string;
|
|
75
|
-
name: string;
|
|
76
|
-
type: string;
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
send_variables: {
|
|
81
|
-
description: string;
|
|
82
|
-
name: string;
|
|
83
|
-
scripts: string[];
|
|
84
|
-
variables: {
|
|
85
|
-
s_token_type: {
|
|
86
|
-
description: string;
|
|
87
|
-
name: string;
|
|
88
|
-
type: string;
|
|
89
|
-
};
|
|
90
|
-
s_token_id: {
|
|
91
|
-
description: string;
|
|
92
|
-
name: string;
|
|
93
|
-
type: string;
|
|
94
|
-
};
|
|
95
|
-
s_token_output_quantities: {
|
|
96
|
-
description: string;
|
|
97
|
-
name: string;
|
|
98
|
-
type: string;
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
|
-
mint_variables: {
|
|
103
|
-
description: string;
|
|
104
|
-
name: string;
|
|
105
|
-
scripts: string[];
|
|
106
|
-
variables: {
|
|
107
|
-
m_token_type: {
|
|
108
|
-
description: string;
|
|
109
|
-
name: string;
|
|
110
|
-
type: string;
|
|
111
|
-
};
|
|
112
|
-
m_token_id: {
|
|
113
|
-
description: string;
|
|
114
|
-
name: string;
|
|
115
|
-
type: string;
|
|
116
|
-
};
|
|
117
|
-
m_mint_baton_vout: {
|
|
118
|
-
description: string;
|
|
119
|
-
name: string;
|
|
120
|
-
type: string;
|
|
121
|
-
};
|
|
122
|
-
m_additional_token_quantity: {
|
|
123
|
-
description: string;
|
|
124
|
-
name: string;
|
|
125
|
-
type: string;
|
|
126
|
-
};
|
|
127
|
-
};
|
|
128
|
-
};
|
|
129
|
-
};
|
|
130
|
-
scenarios: {
|
|
131
|
-
genesis: {
|
|
132
|
-
data: {
|
|
133
|
-
bytecode: {
|
|
134
|
-
g_token_type: string;
|
|
135
|
-
g_token_ticker: string;
|
|
136
|
-
g_token_name: string;
|
|
137
|
-
g_token_document_url: string;
|
|
138
|
-
g_token_document_hash: string;
|
|
139
|
-
g_decimals: string;
|
|
140
|
-
g_mint_baton_vout: string;
|
|
141
|
-
g_initial_token_mint_quantity: string;
|
|
142
|
-
};
|
|
143
|
-
};
|
|
144
|
-
description: string;
|
|
145
|
-
name: string;
|
|
146
|
-
transaction: {
|
|
147
|
-
locktime: number;
|
|
148
|
-
};
|
|
149
|
-
};
|
|
150
|
-
send: {
|
|
151
|
-
data: {
|
|
152
|
-
bytecode: {
|
|
153
|
-
s_token_type: string;
|
|
154
|
-
s_token_id: string;
|
|
155
|
-
s_token_output_quantities: string;
|
|
156
|
-
};
|
|
157
|
-
};
|
|
158
|
-
description: string;
|
|
159
|
-
name: string;
|
|
160
|
-
transaction: {
|
|
161
|
-
locktime: number;
|
|
162
|
-
};
|
|
163
|
-
};
|
|
164
|
-
mint: {
|
|
165
|
-
data: {
|
|
166
|
-
bytecode: {
|
|
167
|
-
m_token_type: string;
|
|
168
|
-
m_token_id: string;
|
|
169
|
-
m_mint_baton_vout: string;
|
|
170
|
-
m_additional_token_quantity: string;
|
|
171
|
-
};
|
|
172
|
-
};
|
|
173
|
-
description: string;
|
|
174
|
-
name: string;
|
|
175
|
-
transaction: {
|
|
176
|
-
locktime: number;
|
|
177
|
-
};
|
|
178
|
-
};
|
|
179
|
-
};
|
|
180
|
-
scripts: {
|
|
181
|
-
genesis_unlock: {
|
|
182
|
-
fails: string[];
|
|
183
|
-
name: string;
|
|
184
|
-
script: string;
|
|
185
|
-
unlocks: string;
|
|
186
|
-
};
|
|
187
|
-
send_unlock: {
|
|
188
|
-
fails: string[];
|
|
189
|
-
name: string;
|
|
190
|
-
script: string;
|
|
191
|
-
unlocks: string;
|
|
192
|
-
};
|
|
193
|
-
mint_unlock: {
|
|
194
|
-
fails: string[];
|
|
195
|
-
name: string;
|
|
196
|
-
script: string;
|
|
197
|
-
unlocks: string;
|
|
198
|
-
};
|
|
199
|
-
genesis_lock: {
|
|
200
|
-
lockingType: string;
|
|
201
|
-
name: string;
|
|
202
|
-
script: string;
|
|
203
|
-
};
|
|
204
|
-
send_lock: {
|
|
205
|
-
lockingType: string;
|
|
206
|
-
name: string;
|
|
207
|
-
script: string;
|
|
208
|
-
};
|
|
209
|
-
mint_lock: {
|
|
210
|
-
lockingType: string;
|
|
211
|
-
name: string;
|
|
212
|
-
script: string;
|
|
213
|
-
};
|
|
214
|
-
};
|
|
215
|
-
supported: string[];
|
|
216
|
-
version: number;
|
|
217
|
-
};
|
|
@@ -1,452 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SlpTxoTemplate = exports.SlpGetSendOutputs = exports.SlpGetMintOutputs = exports.SlpGetGenesisOutputs = exports.bigIntToBinUint64BE = void 0;
|
|
7
|
-
const libauth_1 = require("@bitauth/libauth");
|
|
8
|
-
const slp_parser_1 = require("slp-parser");
|
|
9
|
-
const model_1 = require("../wallet/model");
|
|
10
|
-
const interface_1 = require("../slp/interface");
|
|
11
|
-
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
12
|
-
const constant_1 = require("../constant");
|
|
13
|
-
const enum_1 = require("../enum");
|
|
14
|
-
const bchaddr_1 = require("../util/bchaddr");
|
|
15
|
-
const bigIntToBinUint64BE = (value) => {
|
|
16
|
-
return (0, libauth_1.bigIntToBinUint64LE)(value).reverse();
|
|
17
|
-
};
|
|
18
|
-
exports.bigIntToBinUint64BE = bigIntToBinUint64BE;
|
|
19
|
-
const stringToBin = (value, hex = false) => {
|
|
20
|
-
if (!value)
|
|
21
|
-
return Uint8Array.from([0x4c, 0x00]);
|
|
22
|
-
if (hex)
|
|
23
|
-
return Uint8Array.from([...[value.length / 2], ...(0, libauth_1.hexToBin)(value)]);
|
|
24
|
-
const length = new TextEncoder().encode(value).length;
|
|
25
|
-
return Uint8Array.from([...[length], ...(0, libauth_1.utf8ToBin)(value)]);
|
|
26
|
-
};
|
|
27
|
-
const supportedTokenTypes = [
|
|
28
|
-
interface_1.SlpTokenType.Type1,
|
|
29
|
-
interface_1.SlpTokenType.NftParent,
|
|
30
|
-
interface_1.SlpTokenType.NftChild,
|
|
31
|
-
];
|
|
32
|
-
const SlpGetGenesisOutputs = async (options) => {
|
|
33
|
-
if (!(0, bchaddr_1.isValidAddress)(options.tokenReceiverSlpAddr)) {
|
|
34
|
-
throw new Error(`Invalid tokenReceiverSlpAddr ${options.tokenReceiverSlpAddr}`);
|
|
35
|
-
}
|
|
36
|
-
if (!(0, bchaddr_1.isValidAddress)(options.batonReceiverSlpAddr)) {
|
|
37
|
-
throw new Error(`Invalid batonReceiverSlpAddr ${options.batonReceiverSlpAddr}`);
|
|
38
|
-
}
|
|
39
|
-
if (!options.type) {
|
|
40
|
-
options.type = interface_1.SlpTokenType.Type1;
|
|
41
|
-
}
|
|
42
|
-
if (!supportedTokenTypes.includes(options.type)) {
|
|
43
|
-
throw new Error(`Unsupported token type ${options.type}`);
|
|
44
|
-
}
|
|
45
|
-
// explicitly convert initial amount to bignumber
|
|
46
|
-
options.initialAmount = new bignumber_js_1.default(options.initialAmount);
|
|
47
|
-
if (options.initialAmount.isLessThanOrEqualTo(0)) {
|
|
48
|
-
throw Error("Initial genesis token amount should be greater than zero");
|
|
49
|
-
}
|
|
50
|
-
if (options.decimals < 0 || options.decimals > 9) {
|
|
51
|
-
throw new Error("Genesis allows decimal places between 0");
|
|
52
|
-
}
|
|
53
|
-
const addrs = options.endBaton
|
|
54
|
-
? [options.tokenReceiverSlpAddr]
|
|
55
|
-
: [options.tokenReceiverSlpAddr, options.batonReceiverSlpAddr];
|
|
56
|
-
const bchSendRequests = addrs.map((val) => new model_1.SendRequest({
|
|
57
|
-
cashaddr: (0, bchaddr_1.toCashAddress)(val),
|
|
58
|
-
value: constant_1.DUST_UTXO_THRESHOLD,
|
|
59
|
-
unit: enum_1.UnitEnum.SAT,
|
|
60
|
-
}));
|
|
61
|
-
const template = (0, libauth_1.validateAuthenticationTemplate)(exports.SlpTxoTemplate);
|
|
62
|
-
if (typeof template === "string") {
|
|
63
|
-
throw new Error("Transaction template error");
|
|
64
|
-
}
|
|
65
|
-
const compiler = await (0, libauth_1.authenticationTemplateToCompilerBCH)(template);
|
|
66
|
-
const rawTokenAmount = BigInt(options.initialAmount.shiftedBy(options.decimals));
|
|
67
|
-
const batonVout = options.endBaton ? [0x4c, 0x00] : [0x01, 0x02];
|
|
68
|
-
let genesisTxoBytecode = compiler.generateBytecode("genesis_lock", {
|
|
69
|
-
bytecode: {
|
|
70
|
-
g_token_type: Uint8Array.from([...[0x01], ...[options.type]]),
|
|
71
|
-
g_token_ticker: stringToBin(options.ticker),
|
|
72
|
-
g_token_name: stringToBin(options.name),
|
|
73
|
-
g_token_document_url: stringToBin(options.documentUrl),
|
|
74
|
-
g_token_document_hash: stringToBin(options.documentHash, true),
|
|
75
|
-
g_decimals: Uint8Array.from([...[0x01], ...[options.decimals]]),
|
|
76
|
-
g_mint_baton_vout: Uint8Array.from(batonVout),
|
|
77
|
-
g_initial_token_mint_quantity: Uint8Array.from([
|
|
78
|
-
...[0x08],
|
|
79
|
-
...(0, exports.bigIntToBinUint64BE)(rawTokenAmount),
|
|
80
|
-
]),
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
if (!genesisTxoBytecode.success) {
|
|
84
|
-
throw new Error(genesisTxoBytecode.errors.map((e) => e.error).join("\n"));
|
|
85
|
-
}
|
|
86
|
-
return {
|
|
87
|
-
SlpOutputs: [
|
|
88
|
-
{
|
|
89
|
-
lockingBytecode: genesisTxoBytecode.bytecode,
|
|
90
|
-
satoshis: (0, libauth_1.bigIntToBinUint64LE)(BigInt(0)),
|
|
91
|
-
},
|
|
92
|
-
],
|
|
93
|
-
FundingSlpUtxos: [],
|
|
94
|
-
BchSendRequests: bchSendRequests,
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
exports.SlpGetGenesisOutputs = SlpGetGenesisOutputs;
|
|
98
|
-
const SlpGetMintOutputs = async (options, slpBatonUtxos) => {
|
|
99
|
-
if (!(0, bchaddr_1.isValidAddress)(options.tokenReceiverSlpAddr)) {
|
|
100
|
-
throw new Error(`Invalid tokenReceiverSlpAddr ${options.tokenReceiverSlpAddr}`);
|
|
101
|
-
}
|
|
102
|
-
if (!(0, bchaddr_1.isValidAddress)(options.batonReceiverSlpAddr)) {
|
|
103
|
-
throw new Error(`Invalid batonReceiverSlpAddr ${options.batonReceiverSlpAddr}`);
|
|
104
|
-
}
|
|
105
|
-
const tokenType = slpBatonUtxos[0].type;
|
|
106
|
-
if (!supportedTokenTypes.includes(tokenType)) {
|
|
107
|
-
throw new Error(`Unsupported token type ${tokenType}`);
|
|
108
|
-
}
|
|
109
|
-
const addrs = options.endBaton
|
|
110
|
-
? [options.tokenReceiverSlpAddr]
|
|
111
|
-
: [options.tokenReceiverSlpAddr, options.batonReceiverSlpAddr];
|
|
112
|
-
const bchSendRequests = addrs.map((val) => new model_1.SendRequest({
|
|
113
|
-
cashaddr: (0, bchaddr_1.toCashAddress)(val),
|
|
114
|
-
value: constant_1.DUST_UTXO_THRESHOLD,
|
|
115
|
-
unit: enum_1.UnitEnum.SAT,
|
|
116
|
-
}));
|
|
117
|
-
const template = (0, libauth_1.validateAuthenticationTemplate)(exports.SlpTxoTemplate);
|
|
118
|
-
if (typeof template === "string") {
|
|
119
|
-
throw new Error("Transaction template error");
|
|
120
|
-
}
|
|
121
|
-
const compiler = await (0, libauth_1.authenticationTemplateToCompilerBCH)(template);
|
|
122
|
-
const decimals = slpBatonUtxos[0].decimals;
|
|
123
|
-
const amount = new bignumber_js_1.default(options.value).shiftedBy(decimals);
|
|
124
|
-
const batonVout = options.endBaton ? [0x4c, 0x00] : [0x01, 0x02];
|
|
125
|
-
let mintTxoBytecode = compiler.generateBytecode("mint_lock", {
|
|
126
|
-
bytecode: {
|
|
127
|
-
m_token_type: Uint8Array.from([...[0x01], ...[tokenType]]),
|
|
128
|
-
m_token_id: (0, libauth_1.hexToBin)(options.tokenId),
|
|
129
|
-
m_mint_baton_vout: Uint8Array.from(batonVout),
|
|
130
|
-
m_additional_token_quantity: Uint8Array.from([
|
|
131
|
-
...[0x08],
|
|
132
|
-
...(0, exports.bigIntToBinUint64BE)(BigInt(amount.toString())),
|
|
133
|
-
]),
|
|
134
|
-
},
|
|
135
|
-
});
|
|
136
|
-
if (!mintTxoBytecode.success) {
|
|
137
|
-
throw new Error(mintTxoBytecode.errors.map((e) => e.error).join("\n"));
|
|
138
|
-
}
|
|
139
|
-
return {
|
|
140
|
-
SlpOutputs: [
|
|
141
|
-
{
|
|
142
|
-
lockingBytecode: mintTxoBytecode.bytecode,
|
|
143
|
-
satoshis: (0, libauth_1.bigIntToBinUint64LE)(BigInt(0)),
|
|
144
|
-
},
|
|
145
|
-
],
|
|
146
|
-
FundingSlpUtxos: slpBatonUtxos,
|
|
147
|
-
BchSendRequests: bchSendRequests,
|
|
148
|
-
};
|
|
149
|
-
};
|
|
150
|
-
exports.SlpGetMintOutputs = SlpGetMintOutputs;
|
|
151
|
-
const SlpGetSendOutputs = async (changeSlpaddr, slpUtxos, sendRequests) => {
|
|
152
|
-
if (!(0, bchaddr_1.isValidAddress)(changeSlpaddr)) {
|
|
153
|
-
throw new Error(`Invalid changeSlpaddr ${changeSlpaddr}`);
|
|
154
|
-
}
|
|
155
|
-
if (!slpUtxos.length) {
|
|
156
|
-
throw new Error("No available tokens to spend");
|
|
157
|
-
}
|
|
158
|
-
const decimals = slpUtxos[0].decimals;
|
|
159
|
-
const tokenId = slpUtxos[0].tokenId;
|
|
160
|
-
const tokenType = slpUtxos[0].type;
|
|
161
|
-
if (!supportedTokenTypes.includes(tokenType)) {
|
|
162
|
-
throw new Error(`Unsupported token type ${tokenType}`);
|
|
163
|
-
}
|
|
164
|
-
// sort inputs in ascending order to eliminate the unnecessary splitting
|
|
165
|
-
// and to prefer the consolidation of small inputs
|
|
166
|
-
slpUtxos = slpUtxos.sort((a, b) => a.value.comparedTo(b.value));
|
|
167
|
-
const slpAvailableAmount = slpUtxos
|
|
168
|
-
.map((val) => new bignumber_js_1.default(val.value))
|
|
169
|
-
.reduce((a, b) => bignumber_js_1.default.sum(a, b), new bignumber_js_1.default(0));
|
|
170
|
-
const slpSpendAmount = sendRequests
|
|
171
|
-
.map((val) => new bignumber_js_1.default(val.value))
|
|
172
|
-
.reduce((a, b) => bignumber_js_1.default.sum(a, b), new bignumber_js_1.default(0));
|
|
173
|
-
if (slpSpendAmount.isLessThanOrEqualTo(0)) {
|
|
174
|
-
throw new Error("Refusing to spend 0 tokens");
|
|
175
|
-
}
|
|
176
|
-
if (slpSpendAmount.isGreaterThan(slpAvailableAmount)) {
|
|
177
|
-
throw new Error("Not enough tokens to spend");
|
|
178
|
-
}
|
|
179
|
-
let fundingSlpUtxos = [];
|
|
180
|
-
let totalInputTokens = new bignumber_js_1.default(0);
|
|
181
|
-
for (let slputxo of slpUtxos) {
|
|
182
|
-
const amountTooLow = totalInputTokens.isLessThan(slpSpendAmount);
|
|
183
|
-
if (amountTooLow) {
|
|
184
|
-
totalInputTokens = totalInputTokens.plus(slputxo.value);
|
|
185
|
-
fundingSlpUtxos.push(slputxo);
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
break;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
const template = (0, libauth_1.validateAuthenticationTemplate)(exports.SlpTxoTemplate);
|
|
192
|
-
if (typeof template === "string") {
|
|
193
|
-
throw new Error("Transaction template error");
|
|
194
|
-
}
|
|
195
|
-
const compiler = await (0, libauth_1.authenticationTemplateToCompilerBCH)(template);
|
|
196
|
-
const change = totalInputTokens.minus(slpSpendAmount);
|
|
197
|
-
let values = sendRequests.map((val) => new bignumber_js_1.default(val.value));
|
|
198
|
-
if (change.isGreaterThan(new bignumber_js_1.default(0))) {
|
|
199
|
-
values.push(change);
|
|
200
|
-
sendRequests.push({
|
|
201
|
-
slpaddr: changeSlpaddr,
|
|
202
|
-
tokenId: tokenId,
|
|
203
|
-
value: new bignumber_js_1.default(0),
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
const bchSendRequests = sendRequests.map((val) => new model_1.SendRequest({
|
|
207
|
-
cashaddr: (0, bchaddr_1.toCashAddress)(val.slpaddr),
|
|
208
|
-
value: constant_1.DUST_UTXO_THRESHOLD,
|
|
209
|
-
unit: enum_1.UnitEnum.SAT,
|
|
210
|
-
}));
|
|
211
|
-
values = values.map((val) => val.shiftedBy(decimals));
|
|
212
|
-
let result = new Uint8Array();
|
|
213
|
-
for (const val of values) {
|
|
214
|
-
result = new Uint8Array([
|
|
215
|
-
...result,
|
|
216
|
-
...[0x08],
|
|
217
|
-
...(0, exports.bigIntToBinUint64BE)(BigInt(val.toString())),
|
|
218
|
-
]);
|
|
219
|
-
}
|
|
220
|
-
let sendTxoBytecode = compiler.generateBytecode("send_lock", {
|
|
221
|
-
bytecode: {
|
|
222
|
-
s_token_type: Uint8Array.from([...[0x01], ...[tokenType]]),
|
|
223
|
-
s_token_id: (0, libauth_1.hexToBin)(tokenId),
|
|
224
|
-
s_token_output_quantities: result,
|
|
225
|
-
},
|
|
226
|
-
});
|
|
227
|
-
if (!sendTxoBytecode.success) {
|
|
228
|
-
throw new Error(sendTxoBytecode.errors.map((e) => e.error).join("\n"));
|
|
229
|
-
}
|
|
230
|
-
// enforce checking
|
|
231
|
-
(0, slp_parser_1.parseSLP)(Buffer.from((0, libauth_1.binToHex)(sendTxoBytecode.bytecode), "hex"));
|
|
232
|
-
return {
|
|
233
|
-
SlpOutputs: [
|
|
234
|
-
{
|
|
235
|
-
lockingBytecode: sendTxoBytecode.bytecode,
|
|
236
|
-
satoshis: (0, libauth_1.bigIntToBinUint64LE)(BigInt(0)),
|
|
237
|
-
},
|
|
238
|
-
],
|
|
239
|
-
FundingSlpUtxos: fundingSlpUtxos,
|
|
240
|
-
BchSendRequests: bchSendRequests,
|
|
241
|
-
};
|
|
242
|
-
};
|
|
243
|
-
exports.SlpGetSendOutputs = SlpGetSendOutputs;
|
|
244
|
-
// prettier-ignore
|
|
245
|
-
exports.SlpTxoTemplate = {
|
|
246
|
-
"$schema": "https://bitauth.com/schemas/authentication-template-v0.schema.json",
|
|
247
|
-
"description": "SLP Token transaction output templates",
|
|
248
|
-
"name": "SLP",
|
|
249
|
-
"entities": {
|
|
250
|
-
"genesis_variables": {
|
|
251
|
-
"description": "Variables used in genesis template.",
|
|
252
|
-
"name": "Genesis_Variables",
|
|
253
|
-
"scripts": [
|
|
254
|
-
"genesis_lock",
|
|
255
|
-
"genesis_unlock"
|
|
256
|
-
],
|
|
257
|
-
"variables": {
|
|
258
|
-
"g_token_type": {
|
|
259
|
-
"description": "1 to 2 byte integer",
|
|
260
|
-
"name": "token_type",
|
|
261
|
-
"type": "AddressData"
|
|
262
|
-
},
|
|
263
|
-
"g_token_ticker": {
|
|
264
|
-
"description": "0 to ∞ bytes, suggested utf-8",
|
|
265
|
-
"name": "token_ticker",
|
|
266
|
-
"type": "AddressData"
|
|
267
|
-
},
|
|
268
|
-
"g_token_name": {
|
|
269
|
-
"description": "0 to ∞ bytes, suggested utf-8",
|
|
270
|
-
"name": "token_name",
|
|
271
|
-
"type": "AddressData"
|
|
272
|
-
},
|
|
273
|
-
"g_token_document_url": {
|
|
274
|
-
"description": "0 to ∞ bytes, suggested ascii",
|
|
275
|
-
"name": "token_document_url",
|
|
276
|
-
"type": "AddressData"
|
|
277
|
-
},
|
|
278
|
-
"g_token_document_hash": {
|
|
279
|
-
"description": "0 bytes or 32 bytes",
|
|
280
|
-
"name": "token_document_hash",
|
|
281
|
-
"type": "AddressData"
|
|
282
|
-
},
|
|
283
|
-
"g_decimals": {
|
|
284
|
-
"description": "1 byte in range 0x00-0x09",
|
|
285
|
-
"name": "decimals",
|
|
286
|
-
"type": "AddressData"
|
|
287
|
-
},
|
|
288
|
-
"g_mint_baton_vout": {
|
|
289
|
-
"description": "0 bytes, or 1 byte in range 0x02-0xff",
|
|
290
|
-
"name": "mint_baton_vout",
|
|
291
|
-
"type": "AddressData"
|
|
292
|
-
},
|
|
293
|
-
"g_initial_token_mint_quantity": {
|
|
294
|
-
"description": "8 byte integer",
|
|
295
|
-
"name": "initial_token_mint_quantity",
|
|
296
|
-
"type": "AddressData"
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
},
|
|
300
|
-
"send_variables": {
|
|
301
|
-
"description": "",
|
|
302
|
-
"name": "Send_Variables",
|
|
303
|
-
"scripts": [
|
|
304
|
-
"send_lock",
|
|
305
|
-
"send_unlock"
|
|
306
|
-
],
|
|
307
|
-
"variables": {
|
|
308
|
-
"s_token_type": {
|
|
309
|
-
"description": "1 to 2 byte integer",
|
|
310
|
-
"name": "token_type",
|
|
311
|
-
"type": "AddressData"
|
|
312
|
-
},
|
|
313
|
-
"s_token_id": {
|
|
314
|
-
"description": "Token Id, genesis transaction hex",
|
|
315
|
-
"name": "Token_Id",
|
|
316
|
-
"type": "AddressData"
|
|
317
|
-
},
|
|
318
|
-
"s_token_output_quantities": {
|
|
319
|
-
"description": "N 8 byte integer token amounts (up to 19). At least one is required. Each one is a push.\nN BCH transaction outputs should be specified",
|
|
320
|
-
"name": "Token Output Quantities",
|
|
321
|
-
"type": "AddressData"
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
},
|
|
325
|
-
"mint_variables": {
|
|
326
|
-
"description": "",
|
|
327
|
-
"name": "Mint_Variables",
|
|
328
|
-
"scripts": [
|
|
329
|
-
"mint_lock",
|
|
330
|
-
"mint_unlock"
|
|
331
|
-
],
|
|
332
|
-
"variables": {
|
|
333
|
-
"m_token_type": {
|
|
334
|
-
"description": "1 to 2 byte integer",
|
|
335
|
-
"name": "token_type",
|
|
336
|
-
"type": "AddressData"
|
|
337
|
-
},
|
|
338
|
-
"m_token_id": {
|
|
339
|
-
"description": "Token Id, genesis transaction hex",
|
|
340
|
-
"name": "Token_Id",
|
|
341
|
-
"type": "AddressData"
|
|
342
|
-
},
|
|
343
|
-
"m_mint_baton_vout": {
|
|
344
|
-
"description": "0 bytes, or 1 byte in range 0x02-0xff",
|
|
345
|
-
"name": "mint_baton_vout",
|
|
346
|
-
"type": "AddressData"
|
|
347
|
-
},
|
|
348
|
-
"m_additional_token_quantity": {
|
|
349
|
-
"description": "Amount of tokens to mint, 8 byte integer",
|
|
350
|
-
"name": "Additinial token quantity",
|
|
351
|
-
"type": "AddressData"
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
},
|
|
356
|
-
"scenarios": {
|
|
357
|
-
"genesis": {
|
|
358
|
-
"data": {
|
|
359
|
-
"bytecode": {
|
|
360
|
-
"g_token_type": "0x01",
|
|
361
|
-
"g_token_ticker": "0x00",
|
|
362
|
-
"g_token_name": "0x00",
|
|
363
|
-
"g_token_document_url": "0x00",
|
|
364
|
-
"g_token_document_hash": "",
|
|
365
|
-
"g_decimals": "0x09",
|
|
366
|
-
"g_mint_baton_vout": "0x02",
|
|
367
|
-
"g_initial_token_mint_quantity": "0x0102030405060708"
|
|
368
|
-
}
|
|
369
|
-
},
|
|
370
|
-
"description": "Genesis",
|
|
371
|
-
"name": "Genesis",
|
|
372
|
-
"transaction": {
|
|
373
|
-
"locktime": 100
|
|
374
|
-
}
|
|
375
|
-
},
|
|
376
|
-
"send": {
|
|
377
|
-
"data": {
|
|
378
|
-
"bytecode": {
|
|
379
|
-
"s_token_type": "0x01",
|
|
380
|
-
"s_token_id": "0x0000000000000000'0000000000000000'0000000000000000'0000000000000000'",
|
|
381
|
-
"s_token_output_quantities": "0x0000000000000000"
|
|
382
|
-
}
|
|
383
|
-
},
|
|
384
|
-
"description": "Send",
|
|
385
|
-
"name": "Send",
|
|
386
|
-
"transaction": {
|
|
387
|
-
"locktime": 100
|
|
388
|
-
}
|
|
389
|
-
},
|
|
390
|
-
"mint": {
|
|
391
|
-
"data": {
|
|
392
|
-
"bytecode": {
|
|
393
|
-
"m_token_type": "0x01",
|
|
394
|
-
"m_token_id": "0x0000000000000000'0000000000000000'0000000000000000'0000000000000000'",
|
|
395
|
-
"m_mint_baton_vout": "0x00",
|
|
396
|
-
"m_additional_token_quantity": "0x0000000000000000"
|
|
397
|
-
}
|
|
398
|
-
},
|
|
399
|
-
"description": "Mint",
|
|
400
|
-
"name": "Mint",
|
|
401
|
-
"transaction": {
|
|
402
|
-
"locktime": 100
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
},
|
|
406
|
-
"scripts": {
|
|
407
|
-
"genesis_unlock": {
|
|
408
|
-
"fails": [
|
|
409
|
-
"genesis"
|
|
410
|
-
],
|
|
411
|
-
"name": "Genesis Unlock",
|
|
412
|
-
"script": "// unlock script is required, so we leave it empty",
|
|
413
|
-
"unlocks": "genesis_lock"
|
|
414
|
-
},
|
|
415
|
-
"send_unlock": {
|
|
416
|
-
"fails": [
|
|
417
|
-
"send"
|
|
418
|
-
],
|
|
419
|
-
"name": "Send Unlock",
|
|
420
|
-
"script": "",
|
|
421
|
-
"unlocks": "send_lock"
|
|
422
|
-
},
|
|
423
|
-
"mint_unlock": {
|
|
424
|
-
"fails": [
|
|
425
|
-
"mint"
|
|
426
|
-
],
|
|
427
|
-
"name": "Mint Unlock",
|
|
428
|
-
"script": "",
|
|
429
|
-
"unlocks": "mint_lock"
|
|
430
|
-
},
|
|
431
|
-
"genesis_lock": {
|
|
432
|
-
"lockingType": "standard",
|
|
433
|
-
"name": "Genesis",
|
|
434
|
-
"script": "OP_RETURN <'SLP'0x00> g_token_type <'GENESIS'> g_token_ticker g_token_name g_token_document_url g_token_document_hash g_decimals g_mint_baton_vout g_initial_token_mint_quantity"
|
|
435
|
-
},
|
|
436
|
-
"send_lock": {
|
|
437
|
-
"lockingType": "standard",
|
|
438
|
-
"name": "Send",
|
|
439
|
-
"script": "OP_RETURN <'SLP'0x00> s_token_type <'SEND'> <s_token_id> s_token_output_quantities"
|
|
440
|
-
},
|
|
441
|
-
"mint_lock": {
|
|
442
|
-
"lockingType": "standard",
|
|
443
|
-
"name": "Mint",
|
|
444
|
-
"script": "OP_RETURN <'SLP'0x00> m_token_type <'MINT'> <m_token_id> m_mint_baton_vout m_additional_token_quantity"
|
|
445
|
-
}
|
|
446
|
-
},
|
|
447
|
-
"supported": [
|
|
448
|
-
"BCH_2020_05"
|
|
449
|
-
],
|
|
450
|
-
"version": 0
|
|
451
|
-
};
|
|
452
|
-
//# sourceMappingURL=SlpLibAuth.js.map
|