crypto-aio 0.0.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +167 -0
- package/README.md +163 -13
- package/dist/adapters/avalanche/address.d.ts +15 -0
- package/dist/adapters/avalanche/address.js +74 -0
- package/dist/adapters/avalanche/address.js.map +1 -0
- package/dist/adapters/avalanche/api.d.ts +100 -0
- package/dist/adapters/avalanche/api.js +381 -0
- package/dist/adapters/avalanche/api.js.map +1 -0
- package/dist/adapters/avalanche/builder.d.ts +13 -0
- package/dist/adapters/avalanche/builder.js +336 -0
- package/dist/adapters/avalanche/builder.js.map +1 -0
- package/dist/adapters/avalanche/cb58.d.ts +7 -0
- package/dist/adapters/avalanche/cb58.js +49 -0
- package/dist/adapters/avalanche/cb58.js.map +1 -0
- package/dist/adapters/avalanche/chains.d.ts +21 -0
- package/dist/adapters/avalanche/chains.js +79 -0
- package/dist/adapters/avalanche/chains.js.map +1 -0
- package/dist/adapters/avalanche/codec.d.ts +94 -0
- package/dist/adapters/avalanche/codec.js +371 -0
- package/dist/adapters/avalanche/codec.js.map +1 -0
- package/dist/adapters/avalanche/context.d.ts +59 -0
- package/dist/adapters/avalanche/context.js +114 -0
- package/dist/adapters/avalanche/context.js.map +1 -0
- package/dist/adapters/avalanche/decode.d.ts +16 -0
- package/dist/adapters/avalanche/decode.js +101 -0
- package/dist/adapters/avalanche/decode.js.map +1 -0
- package/dist/adapters/avalanche/driver.d.ts +22 -0
- package/dist/adapters/avalanche/driver.js +81 -0
- package/dist/adapters/avalanche/driver.js.map +1 -0
- package/dist/adapters/avalanche/errors.d.ts +18 -0
- package/dist/adapters/avalanche/errors.js +61 -0
- package/dist/adapters/avalanche/errors.js.map +1 -0
- package/dist/adapters/avalanche/fees.d.ts +23 -0
- package/dist/adapters/avalanche/fees.js +105 -0
- package/dist/adapters/avalanche/fees.js.map +1 -0
- package/dist/adapters/avalanche/index.d.ts +19 -0
- package/dist/adapters/avalanche/index.js +8 -0
- package/dist/adapters/avalanche/index.js.map +1 -0
- package/dist/adapters/avalanche/network.d.ts +37 -0
- package/dist/adapters/avalanche/network.js +135 -0
- package/dist/adapters/avalanche/network.js.map +1 -0
- package/dist/adapters/avalanche/plugin.d.ts +21 -0
- package/dist/adapters/avalanche/plugin.js +46 -0
- package/dist/adapters/avalanche/plugin.js.map +1 -0
- package/dist/adapters/avalanche/presets.d.ts +6 -0
- package/dist/adapters/avalanche/presets.js +86 -0
- package/dist/adapters/avalanche/presets.js.map +1 -0
- package/dist/adapters/avalanche/proofs.d.ts +41 -0
- package/dist/adapters/avalanche/proofs.js +270 -0
- package/dist/adapters/avalanche/proofs.js.map +1 -0
- package/dist/adapters/avalanche/reader.d.ts +40 -0
- package/dist/adapters/avalanche/reader.js +231 -0
- package/dist/adapters/avalanche/reader.js.map +1 -0
- package/dist/adapters/avalanche/sdk.d.ts +182 -0
- package/dist/adapters/avalanche/sdk.js +21 -0
- package/dist/adapters/avalanche/sdk.js.map +1 -0
- package/dist/adapters/avalanche/types.d.ts +86 -0
- package/dist/{type/common.js → adapters/avalanche/types.js} +1 -1
- package/dist/adapters/avalanche/types.js.map +1 -0
- package/dist/adapters/evm/builder.d.ts +11 -0
- package/dist/adapters/evm/builder.js +386 -0
- package/dist/adapters/evm/builder.js.map +1 -0
- package/dist/adapters/evm/chains.d.ts +6 -0
- package/dist/adapters/evm/chains.js +203 -0
- package/dist/adapters/evm/chains.js.map +1 -0
- package/dist/adapters/evm/client.d.ts +84 -0
- package/dist/adapters/evm/client.js +335 -0
- package/dist/adapters/evm/client.js.map +1 -0
- package/dist/adapters/evm/decode.d.ts +35 -0
- package/dist/adapters/evm/decode.js +175 -0
- package/dist/adapters/evm/decode.js.map +1 -0
- package/dist/adapters/evm/driver.d.ts +8 -0
- package/dist/adapters/evm/driver.js +61 -0
- package/dist/adapters/evm/driver.js.map +1 -0
- package/dist/adapters/evm/errors.d.ts +20 -0
- package/dist/adapters/evm/errors.js +110 -0
- package/dist/adapters/evm/errors.js.map +1 -0
- package/dist/adapters/evm/ethers-client.d.ts +43 -0
- package/dist/adapters/evm/ethers-client.js +139 -0
- package/dist/adapters/evm/ethers-client.js.map +1 -0
- package/dist/adapters/evm/fees.d.ts +103 -0
- package/dist/adapters/evm/fees.js +277 -0
- package/dist/adapters/evm/fees.js.map +1 -0
- package/dist/adapters/evm/index.d.ts +20 -0
- package/dist/adapters/evm/index.js +12 -0
- package/dist/adapters/evm/index.js.map +1 -0
- package/dist/adapters/evm/network.d.ts +65 -0
- package/dist/adapters/evm/network.js +150 -0
- package/dist/adapters/evm/network.js.map +1 -0
- package/dist/adapters/evm/plugin.d.ts +35 -0
- package/dist/adapters/evm/plugin.js +150 -0
- package/dist/adapters/evm/plugin.js.map +1 -0
- package/dist/adapters/evm/presets.d.ts +2 -0
- package/dist/adapters/evm/presets.js +105 -0
- package/dist/adapters/evm/presets.js.map +1 -0
- package/dist/adapters/evm/proofs.d.ts +19 -0
- package/dist/adapters/evm/proofs.js +370 -0
- package/dist/adapters/evm/proofs.js.map +1 -0
- package/dist/adapters/evm/rawtx.d.ts +25 -0
- package/dist/adapters/evm/rawtx.js +176 -0
- package/dist/adapters/evm/rawtx.js.map +1 -0
- package/dist/adapters/evm/reader.d.ts +83 -0
- package/dist/adapters/evm/reader.js +326 -0
- package/dist/adapters/evm/reader.js.map +1 -0
- package/dist/adapters/evm/rpc.d.ts +39 -0
- package/dist/adapters/evm/rpc.js +152 -0
- package/dist/adapters/evm/rpc.js.map +1 -0
- package/dist/adapters/evm/tokens.d.ts +10 -0
- package/dist/adapters/evm/tokens.js +23 -0
- package/dist/adapters/evm/tokens.js.map +1 -0
- package/dist/adapters/evm/types.d.ts +265 -0
- package/dist/{type/account.js → adapters/evm/types.js} +1 -1
- package/dist/adapters/evm/types.js.map +1 -0
- package/dist/adapters/evm/web3-client.d.ts +26 -0
- package/dist/adapters/evm/web3-client.js +176 -0
- package/dist/adapters/evm/web3-client.js.map +1 -0
- package/dist/adapters/solana/builder.d.ts +18 -0
- package/dist/adapters/solana/builder.js +556 -0
- package/dist/adapters/solana/builder.js.map +1 -0
- package/dist/adapters/solana/chains.d.ts +13 -0
- package/dist/adapters/solana/chains.js +37 -0
- package/dist/adapters/solana/chains.js.map +1 -0
- package/dist/adapters/solana/decode.d.ts +111 -0
- package/dist/adapters/solana/decode.js +595 -0
- package/dist/adapters/solana/decode.js.map +1 -0
- package/dist/adapters/solana/driver.d.ts +15 -0
- package/dist/adapters/solana/driver.js +72 -0
- package/dist/adapters/solana/driver.js.map +1 -0
- package/dist/adapters/solana/errors.d.ts +36 -0
- package/dist/adapters/solana/errors.js +154 -0
- package/dist/adapters/solana/errors.js.map +1 -0
- package/dist/adapters/solana/fees.d.ts +77 -0
- package/dist/adapters/solana/fees.js +214 -0
- package/dist/adapters/solana/fees.js.map +1 -0
- package/dist/adapters/solana/heights.d.ts +47 -0
- package/dist/adapters/solana/heights.js +185 -0
- package/dist/adapters/solana/heights.js.map +1 -0
- package/dist/adapters/solana/history.d.ts +10 -0
- package/dist/adapters/solana/history.js +71 -0
- package/dist/adapters/solana/history.js.map +1 -0
- package/dist/adapters/solana/index.d.ts +16 -0
- package/dist/adapters/solana/index.js +9 -0
- package/dist/adapters/solana/index.js.map +1 -0
- package/dist/adapters/solana/keys.d.ts +13 -0
- package/dist/adapters/solana/keys.js +69 -0
- package/dist/adapters/solana/keys.js.map +1 -0
- package/dist/adapters/solana/message.d.ts +15 -0
- package/dist/adapters/solana/message.js +120 -0
- package/dist/adapters/solana/message.js.map +1 -0
- package/dist/adapters/solana/network.d.ts +24 -0
- package/dist/adapters/solana/network.js +95 -0
- package/dist/adapters/solana/network.js.map +1 -0
- package/dist/adapters/solana/plugin.d.ts +18 -0
- package/dist/adapters/solana/plugin.js +44 -0
- package/dist/adapters/solana/plugin.js.map +1 -0
- package/dist/adapters/solana/presets.d.ts +2 -0
- package/dist/adapters/solana/presets.js +77 -0
- package/dist/adapters/solana/presets.js.map +1 -0
- package/dist/adapters/solana/programs.d.ts +44 -0
- package/dist/adapters/solana/programs.js +159 -0
- package/dist/adapters/solana/programs.js.map +1 -0
- package/dist/adapters/solana/proofs.d.ts +56 -0
- package/dist/adapters/solana/proofs.js +540 -0
- package/dist/adapters/solana/proofs.js.map +1 -0
- package/dist/adapters/solana/reader.d.ts +82 -0
- package/dist/adapters/solana/reader.js +326 -0
- package/dist/adapters/solana/reader.js.map +1 -0
- package/dist/adapters/solana/rpc.d.ts +102 -0
- package/dist/adapters/solana/rpc.js +301 -0
- package/dist/adapters/solana/rpc.js.map +1 -0
- package/dist/adapters/solana/tokens.d.ts +7 -0
- package/dist/adapters/solana/tokens.js +19 -0
- package/dist/adapters/solana/tokens.js.map +1 -0
- package/dist/adapters/solana/types.d.ts +124 -0
- package/dist/{type/contract.js → adapters/solana/types.js} +1 -1
- package/dist/adapters/solana/types.js.map +1 -0
- package/dist/adapters/solana/web3.d.ts +5 -0
- package/dist/adapters/solana/web3.js +61 -0
- package/dist/adapters/solana/web3.js.map +1 -0
- package/dist/adapters/solana/wire.d.ts +62 -0
- package/dist/adapters/solana/wire.js +168 -0
- package/dist/adapters/solana/wire.js.map +1 -0
- package/dist/adapters/ton/address.d.ts +43 -0
- package/dist/adapters/ton/address.js +168 -0
- package/dist/adapters/ton/address.js.map +1 -0
- package/dist/adapters/ton/api.d.ts +344 -0
- package/dist/adapters/ton/api.js +942 -0
- package/dist/adapters/ton/api.js.map +1 -0
- package/dist/adapters/ton/builder.d.ts +18 -0
- package/dist/adapters/ton/builder.js +701 -0
- package/dist/adapters/ton/builder.js.map +1 -0
- package/dist/adapters/ton/chains.d.ts +16 -0
- package/dist/adapters/ton/chains.js +39 -0
- package/dist/adapters/ton/chains.js.map +1 -0
- package/dist/adapters/ton/decode.d.ts +43 -0
- package/dist/adapters/ton/decode.js +219 -0
- package/dist/adapters/ton/decode.js.map +1 -0
- package/dist/adapters/ton/driver.d.ts +10 -0
- package/dist/adapters/ton/driver.js +117 -0
- package/dist/adapters/ton/driver.js.map +1 -0
- package/dist/adapters/ton/errors.d.ts +36 -0
- package/dist/adapters/ton/errors.js +89 -0
- package/dist/adapters/ton/errors.js.map +1 -0
- package/dist/adapters/ton/fees.d.ts +28 -0
- package/dist/adapters/ton/fees.js +121 -0
- package/dist/adapters/ton/fees.js.map +1 -0
- package/dist/adapters/ton/index.d.ts +16 -0
- package/dist/adapters/ton/index.js +9 -0
- package/dist/adapters/ton/index.js.map +1 -0
- package/dist/adapters/ton/messages.d.ts +157 -0
- package/dist/adapters/ton/messages.js +397 -0
- package/dist/adapters/ton/messages.js.map +1 -0
- package/dist/adapters/ton/native-client.d.ts +10 -0
- package/dist/adapters/ton/native-client.js +47 -0
- package/dist/adapters/ton/native-client.js.map +1 -0
- package/dist/adapters/ton/network.d.ts +58 -0
- package/dist/adapters/ton/network.js +207 -0
- package/dist/adapters/ton/network.js.map +1 -0
- package/dist/adapters/ton/plugin.d.ts +24 -0
- package/dist/adapters/ton/plugin.js +57 -0
- package/dist/adapters/ton/plugin.js.map +1 -0
- package/dist/adapters/ton/presets.d.ts +6 -0
- package/dist/adapters/ton/presets.js +94 -0
- package/dist/adapters/ton/presets.js.map +1 -0
- package/dist/adapters/ton/proofs.d.ts +66 -0
- package/dist/adapters/ton/proofs.js +755 -0
- package/dist/adapters/ton/proofs.js.map +1 -0
- package/dist/adapters/ton/reader.d.ts +235 -0
- package/dist/adapters/ton/reader.js +976 -0
- package/dist/adapters/ton/reader.js.map +1 -0
- package/dist/adapters/ton/tokens.d.ts +10 -0
- package/dist/adapters/ton/tokens.js +27 -0
- package/dist/adapters/ton/tokens.js.map +1 -0
- package/dist/adapters/ton/trace.d.ts +74 -0
- package/dist/adapters/ton/trace.js +303 -0
- package/dist/adapters/ton/trace.js.map +1 -0
- package/dist/adapters/ton/types.d.ts +105 -0
- package/dist/{type/transact.js → adapters/ton/types.js} +1 -1
- package/dist/adapters/ton/types.js.map +1 -0
- package/dist/adapters/ton/wallets.d.ts +86 -0
- package/dist/adapters/ton/wallets.js +373 -0
- package/dist/adapters/ton/wallets.js.map +1 -0
- package/dist/adapters/tron/abi.d.ts +41 -0
- package/dist/adapters/tron/abi.js +112 -0
- package/dist/adapters/tron/abi.js.map +1 -0
- package/dist/adapters/tron/address.d.ts +20 -0
- package/dist/adapters/tron/address.js +110 -0
- package/dist/adapters/tron/address.js.map +1 -0
- package/dist/adapters/tron/builder.d.ts +12 -0
- package/dist/adapters/tron/builder.js +569 -0
- package/dist/adapters/tron/builder.js.map +1 -0
- package/dist/adapters/tron/chains.d.ts +12 -0
- package/dist/adapters/tron/chains.js +35 -0
- package/dist/adapters/tron/chains.js.map +1 -0
- package/dist/adapters/tron/codec.d.ts +10 -0
- package/dist/adapters/tron/codec.js +322 -0
- package/dist/adapters/tron/codec.js.map +1 -0
- package/dist/adapters/tron/decode.d.ts +52 -0
- package/dist/adapters/tron/decode.js +280 -0
- package/dist/adapters/tron/decode.js.map +1 -0
- package/dist/adapters/tron/driver.d.ts +12 -0
- package/dist/adapters/tron/driver.js +106 -0
- package/dist/adapters/tron/driver.js.map +1 -0
- package/dist/adapters/tron/errors.d.ts +74 -0
- package/dist/adapters/tron/errors.js +261 -0
- package/dist/adapters/tron/errors.js.map +1 -0
- package/dist/adapters/tron/fees.d.ts +49 -0
- package/dist/adapters/tron/fees.js +166 -0
- package/dist/adapters/tron/fees.js.map +1 -0
- package/dist/adapters/tron/http.d.ts +173 -0
- package/dist/adapters/tron/http.js +729 -0
- package/dist/adapters/tron/http.js.map +1 -0
- package/dist/adapters/tron/index.d.ts +16 -0
- package/dist/adapters/tron/index.js +15 -0
- package/dist/adapters/tron/index.js.map +1 -0
- package/dist/adapters/tron/network.d.ts +44 -0
- package/dist/adapters/tron/network.js +163 -0
- package/dist/adapters/tron/network.js.map +1 -0
- package/dist/adapters/tron/plugin.d.ts +17 -0
- package/dist/adapters/tron/plugin.js +39 -0
- package/dist/adapters/tron/plugin.js.map +1 -0
- package/dist/adapters/tron/presets.d.ts +5 -0
- package/dist/adapters/tron/presets.js +68 -0
- package/dist/adapters/tron/presets.js.map +1 -0
- package/dist/adapters/tron/proofs.d.ts +80 -0
- package/dist/adapters/tron/proofs.js +371 -0
- package/dist/adapters/tron/proofs.js.map +1 -0
- package/dist/adapters/tron/protobuf.d.ts +36 -0
- package/dist/adapters/tron/protobuf.js +90 -0
- package/dist/adapters/tron/protobuf.js.map +1 -0
- package/dist/adapters/tron/reader.d.ts +57 -0
- package/dist/adapters/tron/reader.js +220 -0
- package/dist/adapters/tron/reader.js.map +1 -0
- package/dist/adapters/tron/tokens.d.ts +9 -0
- package/dist/adapters/tron/tokens.js +14 -0
- package/dist/adapters/tron/tokens.js.map +1 -0
- package/dist/adapters/tron/types.d.ts +166 -0
- package/dist/adapters/tron/types.js +3 -0
- package/dist/adapters/tron/types.js.map +1 -0
- package/dist/adapters/utxo/address.d.ts +51 -0
- package/dist/adapters/utxo/address.js +341 -0
- package/dist/adapters/utxo/address.js.map +1 -0
- package/dist/adapters/utxo/builder.d.ts +35 -0
- package/dist/adapters/utxo/builder.js +380 -0
- package/dist/adapters/utxo/builder.js.map +1 -0
- package/dist/adapters/utxo/chains.d.ts +17 -0
- package/dist/adapters/utxo/chains.js +100 -0
- package/dist/adapters/utxo/chains.js.map +1 -0
- package/dist/adapters/utxo/codec.d.ts +120 -0
- package/dist/adapters/utxo/codec.js +408 -0
- package/dist/adapters/utxo/codec.js.map +1 -0
- package/dist/adapters/utxo/coinselect.d.ts +48 -0
- package/dist/adapters/utxo/coinselect.js +131 -0
- package/dist/adapters/utxo/coinselect.js.map +1 -0
- package/dist/adapters/utxo/context.d.ts +63 -0
- package/dist/adapters/utxo/context.js +125 -0
- package/dist/adapters/utxo/context.js.map +1 -0
- package/dist/adapters/utxo/decode.d.ts +22 -0
- package/dist/adapters/utxo/decode.js +121 -0
- package/dist/adapters/utxo/decode.js.map +1 -0
- package/dist/adapters/utxo/driver.d.ts +16 -0
- package/dist/adapters/utxo/driver.js +79 -0
- package/dist/adapters/utxo/driver.js.map +1 -0
- package/dist/adapters/utxo/ecc.d.ts +9 -0
- package/dist/adapters/utxo/ecc.js +26 -0
- package/dist/adapters/utxo/ecc.js.map +1 -0
- package/dist/adapters/utxo/errors.d.ts +52 -0
- package/dist/adapters/utxo/errors.js +191 -0
- package/dist/adapters/utxo/errors.js.map +1 -0
- package/dist/adapters/utxo/esplora.d.ts +100 -0
- package/dist/adapters/utxo/esplora.js +498 -0
- package/dist/adapters/utxo/esplora.js.map +1 -0
- package/dist/adapters/utxo/fees.d.ts +41 -0
- package/dist/adapters/utxo/fees.js +125 -0
- package/dist/adapters/utxo/fees.js.map +1 -0
- package/dist/adapters/utxo/index.d.ts +17 -0
- package/dist/adapters/utxo/index.js +8 -0
- package/dist/adapters/utxo/index.js.map +1 -0
- package/dist/adapters/utxo/network.d.ts +50 -0
- package/dist/adapters/utxo/network.js +165 -0
- package/dist/adapters/utxo/network.js.map +1 -0
- package/dist/adapters/utxo/plugin.d.ts +17 -0
- package/dist/adapters/utxo/plugin.js +41 -0
- package/dist/adapters/utxo/plugin.js.map +1 -0
- package/dist/adapters/utxo/presets.d.ts +12 -0
- package/dist/adapters/utxo/presets.js +47 -0
- package/dist/adapters/utxo/presets.js.map +1 -0
- package/dist/adapters/utxo/preview.d.ts +3 -0
- package/dist/adapters/utxo/preview.js +65 -0
- package/dist/adapters/utxo/preview.js.map +1 -0
- package/dist/adapters/utxo/proofs.d.ts +66 -0
- package/dist/adapters/utxo/proofs.js +469 -0
- package/dist/adapters/utxo/proofs.js.map +1 -0
- package/dist/adapters/utxo/rawblock.d.ts +46 -0
- package/dist/adapters/utxo/rawblock.js +159 -0
- package/dist/adapters/utxo/rawblock.js.map +1 -0
- package/dist/adapters/utxo/rawtx.d.ts +73 -0
- package/dist/adapters/utxo/rawtx.js +264 -0
- package/dist/adapters/utxo/rawtx.js.map +1 -0
- package/dist/adapters/utxo/reader.d.ts +36 -0
- package/dist/adapters/utxo/reader.js +265 -0
- package/dist/adapters/utxo/reader.js.map +1 -0
- package/dist/adapters/utxo/sdk.d.ts +18 -0
- package/dist/adapters/utxo/sdk.js +17 -0
- package/dist/adapters/utxo/sdk.js.map +1 -0
- package/dist/adapters/utxo/signed-psbt.d.ts +36 -0
- package/dist/adapters/utxo/signed-psbt.js +428 -0
- package/dist/adapters/utxo/signed-psbt.js.map +1 -0
- package/dist/adapters/utxo/spend.d.ts +59 -0
- package/dist/adapters/utxo/spend.js +230 -0
- package/dist/adapters/utxo/spend.js.map +1 -0
- package/dist/adapters/utxo/types.d.ts +167 -0
- package/dist/adapters/utxo/types.js +3 -0
- package/dist/adapters/utxo/types.js.map +1 -0
- package/dist/core/assets/service.d.ts +18 -0
- package/dist/core/assets/service.js +69 -0
- package/dist/core/assets/service.js.map +1 -0
- package/dist/core/blockchain/default-ref.d.ts +4 -0
- package/dist/core/blockchain/default-ref.js +16 -0
- package/dist/core/blockchain/default-ref.js.map +1 -0
- package/dist/core/blockchain/handle.d.ts +179 -0
- package/dist/core/blockchain/handle.js +579 -0
- package/dist/core/blockchain/handle.js.map +1 -0
- package/dist/core/blockchain/internal.d.ts +19 -0
- package/dist/core/blockchain/internal.js +16 -0
- package/dist/core/blockchain/internal.js.map +1 -0
- package/dist/core/blockchain/mapping.d.ts +22 -0
- package/dist/core/blockchain/mapping.js +136 -0
- package/dist/core/blockchain/mapping.js.map +1 -0
- package/dist/core/config/env.d.ts +8 -0
- package/dist/core/config/env.js +60 -0
- package/dist/core/config/env.js.map +1 -0
- package/dist/core/config/merge.d.ts +26 -0
- package/dist/core/config/merge.js +144 -0
- package/dist/core/config/merge.js.map +1 -0
- package/dist/core/config/resolve.d.ts +12 -0
- package/dist/core/config/resolve.js +251 -0
- package/dist/core/config/resolve.js.map +1 -0
- package/dist/core/config/types.d.ts +180 -0
- package/dist/core/config/types.js +3 -0
- package/dist/core/config/types.js.map +1 -0
- package/dist/core/container/builtins.d.ts +4 -0
- package/dist/core/container/builtins.js +13 -0
- package/dist/core/container/builtins.js.map +1 -0
- package/dist/core/container/container.d.ts +62 -0
- package/dist/core/container/container.js +500 -0
- package/dist/core/container/container.js.map +1 -0
- package/dist/core/container/default.d.ts +15 -0
- package/dist/core/container/default.js +70 -0
- package/dist/core/container/default.js.map +1 -0
- package/dist/core/container/internals.d.ts +54 -0
- package/dist/core/container/internals.js +21 -0
- package/dist/core/container/internals.js.map +1 -0
- package/dist/core/container/pool.d.ts +27 -0
- package/dist/core/container/pool.js +77 -0
- package/dist/core/container/pool.js.map +1 -0
- package/dist/core/driver/types.d.ts +379 -0
- package/dist/core/driver/types.js +3 -0
- package/dist/core/driver/types.js.map +1 -0
- package/dist/core/errors/codes.d.ts +163 -0
- package/dist/core/errors/codes.js +53 -0
- package/dist/core/errors/codes.js.map +1 -0
- package/dist/core/errors/error.d.ts +66 -0
- package/dist/core/errors/error.js +129 -0
- package/dist/core/errors/error.js.map +1 -0
- package/dist/core/events/bus.d.ts +12 -0
- package/dist/core/events/bus.js +46 -0
- package/dist/core/events/bus.js.map +1 -0
- package/dist/core/events/logger.d.ts +13 -0
- package/dist/core/events/logger.js +42 -0
- package/dist/core/events/logger.js.map +1 -0
- package/dist/core/events/types.d.ts +131 -0
- package/dist/core/events/types.js +3 -0
- package/dist/core/events/types.js.map +1 -0
- package/dist/core/lifecycle/engine-rules.d.ts +106 -0
- package/dist/core/lifecycle/engine-rules.js +267 -0
- package/dist/core/lifecycle/engine-rules.js.map +1 -0
- package/dist/core/lifecycle/engine.d.ts +502 -0
- package/dist/core/lifecycle/engine.js +1750 -0
- package/dist/core/lifecycle/engine.js.map +1 -0
- package/dist/core/lifecycle/evaluate.d.ts +19 -0
- package/dist/core/lifecycle/evaluate.js +77 -0
- package/dist/core/lifecycle/evaluate.js.map +1 -0
- package/dist/core/lifecycle/intent.d.ts +11 -0
- package/dist/core/lifecycle/intent.js +88 -0
- package/dist/core/lifecycle/intent.js.map +1 -0
- package/dist/core/lifecycle/monitor.d.ts +138 -0
- package/dist/core/lifecycle/monitor.js +616 -0
- package/dist/core/lifecycle/monitor.js.map +1 -0
- package/dist/core/lifecycle/observations.d.ts +17 -0
- package/dist/core/lifecycle/observations.js +59 -0
- package/dist/core/lifecycle/observations.js.map +1 -0
- package/dist/core/lifecycle/reconcile.d.ts +58 -0
- package/dist/core/lifecycle/reconcile.js +112 -0
- package/dist/core/lifecycle/reconcile.js.map +1 -0
- package/dist/core/lifecycle/views.d.ts +49 -0
- package/dist/core/lifecycle/views.js +57 -0
- package/dist/core/lifecycle/views.js.map +1 -0
- package/dist/core/lifecycle/workers.d.ts +88 -0
- package/dist/core/lifecycle/workers.js +347 -0
- package/dist/core/lifecycle/workers.js.map +1 -0
- package/dist/core/model/address.d.ts +32 -0
- package/dist/core/model/address.js +43 -0
- package/dist/core/model/address.js.map +1 -0
- package/dist/core/model/amount.d.ts +25 -0
- package/dist/core/model/amount.js +102 -0
- package/dist/core/model/amount.js.map +1 -0
- package/dist/core/model/asset.d.ts +28 -0
- package/dist/core/model/asset.js +47 -0
- package/dist/core/model/asset.js.map +1 -0
- package/dist/core/model/capability.d.ts +3 -0
- package/dist/core/model/capability.js +18 -0
- package/dist/core/model/capability.js.map +1 -0
- package/dist/core/model/chain.d.ts +63 -0
- package/dist/core/model/chain.js +8 -0
- package/dist/core/model/chain.js.map +1 -0
- package/dist/core/model/fee.d.ts +36 -0
- package/dist/core/model/fee.js +17 -0
- package/dist/core/model/fee.js.map +1 -0
- package/dist/core/model/ids.d.ts +38 -0
- package/dist/core/model/ids.js +14 -0
- package/dist/core/model/ids.js.map +1 -0
- package/dist/core/model/intent.d.ts +63 -0
- package/dist/core/model/intent.js +81 -0
- package/dist/core/model/intent.js.map +1 -0
- package/dist/core/model/ordering.d.ts +28 -0
- package/dist/core/model/ordering.js +29 -0
- package/dist/core/model/ordering.js.map +1 -0
- package/dist/core/model/transaction.d.ts +123 -0
- package/dist/{type/lib-types.js → core/model/transaction.js} +1 -1
- package/dist/core/model/transaction.js.map +1 -0
- package/dist/core/observe/scanner.d.ts +135 -0
- package/dist/core/observe/scanner.js +358 -0
- package/dist/core/observe/scanner.js.map +1 -0
- package/dist/core/ordering/reservations.d.ts +16 -0
- package/dist/core/ordering/reservations.js +53 -0
- package/dist/core/ordering/reservations.js.map +1 -0
- package/dist/core/ordering/sequence.d.ts +61 -0
- package/dist/core/ordering/sequence.js +155 -0
- package/dist/core/ordering/sequence.js.map +1 -0
- package/dist/core/registry/adapters.d.ts +10 -0
- package/dist/core/registry/adapters.js +56 -0
- package/dist/core/registry/adapters.js.map +1 -0
- package/dist/core/registry/assets.d.ts +18 -0
- package/dist/core/registry/assets.js +90 -0
- package/dist/core/registry/assets.js.map +1 -0
- package/dist/core/registry/chains.d.ts +10 -0
- package/dist/core/registry/chains.js +80 -0
- package/dist/core/registry/chains.js.map +1 -0
- package/dist/core/registry/plugin.d.ts +41 -0
- package/dist/core/registry/plugin.js +109 -0
- package/dist/core/registry/plugin.js.map +1 -0
- package/dist/core/registry/providers.d.ts +31 -0
- package/dist/core/registry/providers.js +43 -0
- package/dist/core/registry/providers.js.map +1 -0
- package/dist/core/registry/schemes.d.ts +30 -0
- package/dist/core/registry/schemes.js +84 -0
- package/dist/core/registry/schemes.js.map +1 -0
- package/dist/core/secret/fragments.d.ts +33 -0
- package/dist/core/secret/fragments.js +110 -0
- package/dist/core/secret/fragments.js.map +1 -0
- package/dist/core/secret/redact.d.ts +10 -0
- package/dist/core/secret/redact.js +110 -0
- package/dist/core/secret/redact.js.map +1 -0
- package/dist/core/secret/secret.d.ts +14 -0
- package/dist/core/secret/secret.js +42 -0
- package/dist/core/secret/secret.js.map +1 -0
- package/dist/core/signing/callback.d.ts +10 -0
- package/dist/core/signing/callback.js +22 -0
- package/dist/core/signing/callback.js.map +1 -0
- package/dist/core/signing/guard.d.ts +18 -0
- package/dist/core/signing/guard.js +72 -0
- package/dist/core/signing/guard.js.map +1 -0
- package/dist/core/signing/hd.d.ts +36 -0
- package/dist/core/signing/hd.js +167 -0
- package/dist/core/signing/hd.js.map +1 -0
- package/dist/core/signing/local.d.ts +48 -0
- package/dist/core/signing/local.js +190 -0
- package/dist/core/signing/local.js.map +1 -0
- package/dist/core/signing/orchestrator.d.ts +40 -0
- package/dist/core/signing/orchestrator.js +300 -0
- package/dist/core/signing/orchestrator.js.map +1 -0
- package/dist/core/signing/types.d.ts +64 -0
- package/dist/core/signing/types.js +3 -0
- package/dist/core/signing/types.js.map +1 -0
- package/dist/core/signing/wallet.d.ts +48 -0
- package/dist/core/signing/wallet.js +161 -0
- package/dist/core/signing/wallet.js.map +1 -0
- package/dist/core/store/clone.d.ts +25 -0
- package/dist/core/store/clone.js +71 -0
- package/dist/core/store/clone.js.map +1 -0
- package/dist/core/store/format.d.ts +20 -0
- package/dist/core/store/format.js +86 -0
- package/dist/core/store/format.js.map +1 -0
- package/dist/core/store/memory.d.ts +38 -0
- package/dist/core/store/memory.js +325 -0
- package/dist/core/store/memory.js.map +1 -0
- package/dist/core/store/types.d.ts +258 -0
- package/dist/core/store/types.js +119 -0
- package/dist/core/store/types.js.map +1 -0
- package/dist/core/transport/backoff.d.ts +8 -0
- package/dist/core/transport/backoff.js +27 -0
- package/dist/core/transport/backoff.js.map +1 -0
- package/dist/core/transport/circuit.d.ts +25 -0
- package/dist/core/transport/circuit.js +61 -0
- package/dist/core/transport/circuit.js.map +1 -0
- package/dist/core/transport/http-transport.d.ts +30 -0
- package/dist/core/transport/http-transport.js +1703 -0
- package/dist/core/transport/http-transport.js.map +1 -0
- package/dist/core/transport/rate-limit.d.ts +27 -0
- package/dist/core/transport/rate-limit.js +78 -0
- package/dist/core/transport/rate-limit.js.map +1 -0
- package/dist/core/transport/stale-view.d.ts +11 -0
- package/dist/core/transport/stale-view.js +17 -0
- package/dist/core/transport/stale-view.js.map +1 -0
- package/dist/core/transport/types.d.ts +159 -0
- package/dist/core/transport/types.js +6 -0
- package/dist/core/transport/types.js.map +1 -0
- package/dist/core/util/bytes.d.ts +9 -0
- package/dist/core/util/bytes.js +40 -0
- package/dist/core/util/bytes.js.map +1 -0
- package/dist/core/util/clock.d.ts +6 -0
- package/dist/core/util/clock.js +26 -0
- package/dist/core/util/clock.js.map +1 -0
- package/dist/core/util/freeze.d.ts +8 -0
- package/dist/core/util/freeze.js +31 -0
- package/dist/core/util/freeze.js.map +1 -0
- package/dist/core/util/json.d.ts +35 -0
- package/dist/core/util/json.js +174 -0
- package/dist/core/util/json.js.map +1 -0
- package/dist/core/util/names.d.ts +27 -0
- package/dist/core/util/names.js +56 -0
- package/dist/core/util/names.js.map +1 -0
- package/dist/index.d.ts +65 -14
- package/dist/index.js +107 -49
- package/dist/index.js.map +1 -1
- package/dist/native.d.ts +21 -0
- package/dist/native.js +44 -0
- package/dist/native.js.map +1 -0
- package/dist/testing/contracts/api.d.ts +12 -0
- package/dist/testing/contracts/api.js +58 -0
- package/dist/testing/contracts/api.js.map +1 -0
- package/dist/testing/contracts/cursors.d.ts +6 -0
- package/dist/testing/contracts/cursors.js +43 -0
- package/dist/testing/contracts/cursors.js.map +1 -0
- package/dist/testing/contracts/locks.d.ts +10 -0
- package/dist/testing/contracts/locks.js +63 -0
- package/dist/testing/contracts/locks.js.map +1 -0
- package/dist/testing/contracts/operations.d.ts +21 -0
- package/dist/testing/contracts/operations.js +737 -0
- package/dist/testing/contracts/operations.js.map +1 -0
- package/dist/testing/contracts/sequences.d.ts +6 -0
- package/dist/testing/contracts/sequences.js +68 -0
- package/dist/testing/contracts/sequences.js.map +1 -0
- package/dist/testing/env.d.ts +68 -0
- package/dist/testing/env.js +105 -0
- package/dist/testing/env.js.map +1 -0
- package/dist/testing/fake-chain.d.ts +118 -0
- package/dist/testing/fake-chain.js +536 -0
- package/dist/testing/fake-chain.js.map +1 -0
- package/dist/testing/fake-clock.d.ts +15 -0
- package/dist/testing/fake-clock.js +86 -0
- package/dist/testing/fake-clock.js.map +1 -0
- package/dist/testing/fake-driver.d.ts +15 -0
- package/dist/testing/fake-driver.js +458 -0
- package/dist/testing/fake-driver.js.map +1 -0
- package/dist/testing/fake-fetch.d.ts +32 -0
- package/dist/testing/fake-fetch.js +81 -0
- package/dist/testing/fake-fetch.js.map +1 -0
- package/dist/testing/fake-plugin.d.ts +30 -0
- package/dist/testing/fake-plugin.js +66 -0
- package/dist/testing/fake-plugin.js.map +1 -0
- package/dist/testing/faulty-store.d.ts +38 -0
- package/dist/testing/faulty-store.js +71 -0
- package/dist/testing/faulty-store.js.map +1 -0
- package/dist/testing/generation.d.ts +60 -0
- package/dist/testing/generation.js +252 -0
- package/dist/testing/generation.js.map +1 -0
- package/dist/testing/index.d.ts +28 -0
- package/dist/testing/index.js +51 -0
- package/dist/testing/index.js.map +1 -0
- package/package.json +198 -45
- package/dist/libs/eth/account.d.ts +0 -9
- package/dist/libs/eth/account.js +0 -58
- package/dist/libs/eth/account.js.map +0 -1
- package/dist/libs/eth/contract.d.ts +0 -7
- package/dist/libs/eth/contract.js +0 -42
- package/dist/libs/eth/contract.js.map +0 -1
- package/dist/libs/eth/index.d.ts +0 -24
- package/dist/libs/eth/index.js +0 -72
- package/dist/libs/eth/index.js.map +0 -1
- package/dist/libs/eth/transact.d.ts +0 -7
- package/dist/libs/eth/transact.js +0 -26
- package/dist/libs/eth/transact.js.map +0 -1
- package/dist/libs/index.d.ts +0 -2
- package/dist/libs/index.js +0 -19
- package/dist/libs/index.js.map +0 -1
- package/dist/libs/trx/account.d.ts +0 -9
- package/dist/libs/trx/account.js +0 -55
- package/dist/libs/trx/account.js.map +0 -1
- package/dist/libs/trx/contract.d.ts +0 -7
- package/dist/libs/trx/contract.js +0 -27
- package/dist/libs/trx/contract.js.map +0 -1
- package/dist/libs/trx/index.d.ts +0 -22
- package/dist/libs/trx/index.js +0 -64
- package/dist/libs/trx/index.js.map +0 -1
- package/dist/libs/trx/transact.d.ts +0 -7
- package/dist/libs/trx/transact.js +0 -26
- package/dist/libs/trx/transact.js.map +0 -1
- package/dist/tool/common.d.ts +0 -28
- package/dist/tool/common.js +0 -33
- package/dist/tool/common.js.map +0 -1
- package/dist/tool/eth-tools.d.ts +0 -3
- package/dist/tool/eth-tools.js +0 -33
- package/dist/tool/eth-tools.js.map +0 -1
- package/dist/tool/index.d.ts +0 -5
- package/dist/tool/index.js +0 -22
- package/dist/tool/index.js.map +0 -1
- package/dist/tool/logging.d.ts +0 -3
- package/dist/tool/logging.js +0 -11
- package/dist/tool/logging.js.map +0 -1
- package/dist/tool/options.d.ts +0 -6
- package/dist/tool/options.js +0 -41
- package/dist/tool/options.js.map +0 -1
- package/dist/tool/trx-tools.d.ts +0 -3
- package/dist/tool/trx-tools.js +0 -20
- package/dist/tool/trx-tools.js.map +0 -1
- package/dist/type/account.d.ts +0 -9
- package/dist/type/account.js.map +0 -1
- package/dist/type/common.d.ts +0 -18
- package/dist/type/common.js.map +0 -1
- package/dist/type/contract.d.ts +0 -10
- package/dist/type/contract.js.map +0 -1
- package/dist/type/index.d.ts +0 -5
- package/dist/type/index.js +0 -22
- package/dist/type/index.js.map +0 -1
- package/dist/type/lib-types.d.ts +0 -9
- package/dist/type/lib-types.js.map +0 -1
- package/dist/type/transact.d.ts +0 -7
- package/dist/type/transact.js.map +0 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.coinSelectionPreview = coinSelectionPreview;
|
|
4
|
+
/**
|
|
5
|
+
* `ext.utxo.coinSelection`: a dry run of the configured coin selection. Signs nothing. The
|
|
6
|
+
* change output is sized for the sending address (the wallet's `changeAddress` is not known
|
|
7
|
+
* here), so the fee may differ from a build's by a change output's size difference.
|
|
8
|
+
*/
|
|
9
|
+
const error_1 = require("../../core/errors/error");
|
|
10
|
+
const coinselect_1 = require("./coinselect");
|
|
11
|
+
const spend_1 = require("./spend");
|
|
12
|
+
/**
|
|
13
|
+
* A caller's request reaches this method unchecked by the core (ext methods are the
|
|
14
|
+
* family's), so its shape is checked here: a malformed one is a fixed-text validation
|
|
15
|
+
* error, never a foreign `TypeError`. Addresses are checked where they are decoded.
|
|
16
|
+
*/
|
|
17
|
+
function assertRequest(request) {
|
|
18
|
+
const invalid = (reason) => new error_1.ValidationError('INVALID_INTENT', reason);
|
|
19
|
+
if (request === null || typeof request !== 'object') {
|
|
20
|
+
throw invalid('a coin selection request is { from, outputs, fee?, exclude? }');
|
|
21
|
+
}
|
|
22
|
+
if (!Array.isArray(request.outputs)) {
|
|
23
|
+
throw invalid('outputs must be an array of { to, amount }');
|
|
24
|
+
}
|
|
25
|
+
for (const output of request.outputs) {
|
|
26
|
+
if (output === null || typeof output !== 'object') {
|
|
27
|
+
throw invalid('outputs must be an array of { to, amount }');
|
|
28
|
+
}
|
|
29
|
+
const { amount } = output;
|
|
30
|
+
if (typeof amount !== 'bigint' || amount <= 0n) {
|
|
31
|
+
throw new error_1.ValidationError('INVALID_AMOUNT', 'an output amount must be a positive bigint (satoshis)');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const exclude = request.exclude;
|
|
35
|
+
if (exclude !== undefined &&
|
|
36
|
+
(!Array.isArray(exclude) || !exclude.every((o) => typeof o === 'string'))) {
|
|
37
|
+
throw invalid('exclude must be an array of outpoints (txid:vout)');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async function coinSelectionPreview(ctx, request) {
|
|
41
|
+
assertRequest(request);
|
|
42
|
+
const sender = (0, spend_1.senderOf)(ctx, request.from);
|
|
43
|
+
const outputs = (0, spend_1.plannedOutputs)(ctx, request.outputs);
|
|
44
|
+
const rate = await (0, spend_1.rateOf)(ctx, request.fee ?? 'normal');
|
|
45
|
+
const candidates = await (0, spend_1.spendable)(ctx, sender.from.canonical, request.exclude, ctx.config.minInputConfirmations);
|
|
46
|
+
const selection = (0, coinselect_1.selectCoins)({
|
|
47
|
+
candidates,
|
|
48
|
+
outputs,
|
|
49
|
+
changeScript: sender.from.script,
|
|
50
|
+
inputType: sender.type,
|
|
51
|
+
rate,
|
|
52
|
+
dustRelayFee: ctx.config.dustRelayFee,
|
|
53
|
+
strategy: ctx.config.coinSelection,
|
|
54
|
+
});
|
|
55
|
+
const inputs = selection.ok ? selection.inputs : candidates;
|
|
56
|
+
return {
|
|
57
|
+
inputs: inputs.map((i) => ({ outpoint: i.outpoint, value: i.value })),
|
|
58
|
+
fee: selection.fee,
|
|
59
|
+
satPerKvB: rate,
|
|
60
|
+
vsize: selection.vsize,
|
|
61
|
+
change: selection.ok ? selection.change : 0n,
|
|
62
|
+
sufficient: selection.ok,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview.js","sourceRoot":"","sources":["../../../src/adapters/utxo/preview.ts"],"names":[],"mappings":";;AA6CA,oDAgCC;AA7ED;;;;GAIG;AACH,mDAA0D;AAC1D,6CAA2C;AAE3C,mCAAsE;AAGtE;;;;GAIG;AACH,SAAS,aAAa,CAAC,OAA6B;IAClD,MAAM,OAAO,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,uBAAe,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;IAClF,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QACpD,MAAM,OAAO,CAAC,+DAA+D,CAAC,CAAC;IACjF,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACpC,MAAM,OAAO,CAAC,4CAA4C,CAAC,CAAC;IAC9D,CAAC;IACD,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,OAA6B,EAAE,CAAC;QAC3D,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAClD,MAAM,OAAO,CAAC,4CAA4C,CAAC,CAAC;QAC9D,CAAC;QACD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAuC,CAAC;QAC3D,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,IAAI,EAAE,EAAE,CAAC;YAC/C,MAAM,IAAI,uBAAe,CACvB,gBAAgB,EAChB,uDAAuD,CACxD,CAAC;QACJ,CAAC;IACH,CAAC;IACD,MAAM,OAAO,GAAY,OAAO,CAAC,OAAO,CAAC;IACzC,IACE,OAAO,KAAK,SAAS;QACrB,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,EACzE,CAAC;QACD,MAAM,OAAO,CAAC,mDAAmD,CAAC,CAAC;IACrE,CAAC;AACH,CAAC;AAEM,KAAK,UAAU,oBAAoB,CACxC,GAAgB,EAChB,OAA6B;IAE7B,aAAa,CAAC,OAAO,CAAC,CAAC;IACvB,MAAM,MAAM,GAAG,IAAA,gBAAQ,EAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,OAAO,GAAG,IAAA,sBAAc,EAAC,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACrD,MAAM,IAAI,GAAG,MAAM,IAAA,cAAM,EAAC,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,QAAQ,CAAC,CAAC;IACxD,MAAM,UAAU,GAAG,MAAM,IAAA,iBAAS,EAChC,GAAG,EACH,MAAM,CAAC,IAAI,CAAC,SAAS,EACrB,OAAO,CAAC,OAAO,EACf,GAAG,CAAC,MAAM,CAAC,qBAAqB,CACjC,CAAC;IACF,MAAM,SAAS,GAAG,IAAA,wBAAW,EAAC;QAC5B,UAAU;QACV,OAAO;QACP,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM;QAChC,SAAS,EAAE,MAAM,CAAC,IAAI;QACtB,IAAI;QACJ,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,YAAY;QACrC,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,aAAa;KACnC,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC;IAC5D,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;QACrE,GAAG,EAAE,SAAS,CAAC,GAAG;QAClB,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,SAAS,CAAC,KAAK;QACtB,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;QAC5C,UAAU,EAAE,SAAS,CAAC,EAAE;KACzB,CAAC;AACJ,CAAC","sourcesContent":["/**\n * `ext.utxo.coinSelection`: a dry run of the configured coin selection. Signs nothing. The\n * change output is sized for the sending address (the wallet's `changeAddress` is not known\n * here), so the fee may differ from a build's by a change output's size difference.\n */\nimport { ValidationError } from '../../core/errors/error';\nimport { selectCoins } from './coinselect';\nimport type { UtxoContext } from './context';\nimport { plannedOutputs, rateOf, senderOf, spendable } from './spend';\nimport type { UtxoSelectionPreview, UtxoSelectionRequest } from './types';\n\n/**\n * A caller's request reaches this method unchecked by the core (ext methods are the\n * family's), so its shape is checked here: a malformed one is a fixed-text validation\n * error, never a foreign `TypeError`. Addresses are checked where they are decoded.\n */\nfunction assertRequest(request: UtxoSelectionRequest): void {\n const invalid = (reason: string) => new ValidationError('INVALID_INTENT', reason);\n if (request === null || typeof request !== 'object') {\n throw invalid('a coin selection request is { from, outputs, fee?, exclude? }');\n }\n if (!Array.isArray(request.outputs)) {\n throw invalid('outputs must be an array of { to, amount }');\n }\n for (const output of request.outputs as readonly unknown[]) {\n if (output === null || typeof output !== 'object') {\n throw invalid('outputs must be an array of { to, amount }');\n }\n const { amount } = output as { readonly amount?: unknown };\n if (typeof amount !== 'bigint' || amount <= 0n) {\n throw new ValidationError(\n 'INVALID_AMOUNT',\n 'an output amount must be a positive bigint (satoshis)',\n );\n }\n }\n const exclude: unknown = request.exclude;\n if (\n exclude !== undefined &&\n (!Array.isArray(exclude) || !exclude.every((o) => typeof o === 'string'))\n ) {\n throw invalid('exclude must be an array of outpoints (txid:vout)');\n }\n}\n\nexport async function coinSelectionPreview(\n ctx: UtxoContext,\n request: UtxoSelectionRequest,\n): Promise<UtxoSelectionPreview> {\n assertRequest(request);\n const sender = senderOf(ctx, request.from);\n const outputs = plannedOutputs(ctx, request.outputs);\n const rate = await rateOf(ctx, request.fee ?? 'normal');\n const candidates = await spendable(\n ctx,\n sender.from.canonical,\n request.exclude,\n ctx.config.minInputConfirmations,\n );\n const selection = selectCoins({\n candidates,\n outputs,\n changeScript: sender.from.script,\n inputType: sender.type,\n rate,\n dustRelayFee: ctx.config.dustRelayFee,\n strategy: ctx.config.coinSelection,\n });\n const inputs = selection.ok ? selection.inputs : candidates;\n return {\n inputs: inputs.map((i) => ({ outpoint: i.outpoint, value: i.value })),\n fee: selection.fee,\n satPerKvB: rate,\n vsize: selection.vsize,\n change: selection.ok ? selection.change : 0n,\n sufficient: selection.ok,\n };\n}\n"]}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proofs (finalized-state checks behind `proven` verdicts) and the block source.
|
|
3
|
+
*
|
|
4
|
+
* Finality is N confirmations. Every fact is attested at its own height with a monotone
|
|
5
|
+
* predicate quorum key, and no endpoint proposes a height. "Block h is final" is "every
|
|
6
|
+
* proof endpoint holds a block at h + N − 1": the quorum reads the head with the key
|
|
7
|
+
* `head >= h + N − 1`, so endpoints further ahead agree, and one that trails decides
|
|
8
|
+
* nothing. Only `finalizedHead` (no anchor of its own) takes one endpoint's head, trails
|
|
9
|
+
* it by `PEER_SKEW`, then attests it. One endpoint's head never decides finality.
|
|
10
|
+
*
|
|
11
|
+
* `includedFinal` answers "not included" only when an input of our Attempt has a
|
|
12
|
+
* quorum-attested final spender that is neither our txid nor a malleated copy of it.
|
|
13
|
+
* Every other case decides nothing (a retryable `ProviderError`): our transaction in a
|
|
14
|
+
* mempool or in a block not yet final, an unknown spender, a lagging or load-balanced
|
|
15
|
+
* backend. A stale inclusion (its block is no longer the block at its height) is a
|
|
16
|
+
* retryable `PROVIDER_INCONSISTENT`, and so is a transaction view that puts ours in a
|
|
17
|
+
* block while another transaction's spend of its input is final: both cannot hold. So
|
|
18
|
+
* `includedFinal` never answers "not included" without its own attestation of a different
|
|
19
|
+
* final spend, and an endpoint-set change between the monitor's `slotConsumed` and
|
|
20
|
+
* `includedFinal` calls cannot produce a false proven `replaced`.
|
|
21
|
+
*
|
|
22
|
+
* The block source delivers only what authenticated bytes say. A block's transactions are
|
|
23
|
+
* decoded from its own bytes (`rawBlock`), which must hash to the block the scan asked for
|
|
24
|
+
* and commit to every transaction and witness, and the header read at its height must be
|
|
25
|
+
* those bytes' own (parent and time). The outputs a delivered transaction's inputs spend,
|
|
26
|
+
* which give its `from`, input values and fee, are read from the block itself or from each
|
|
27
|
+
* previous transaction's bytes, bound to the txid the input names. So no endpoint can add,
|
|
28
|
+
* drop or alter a transaction, an output or a sender of what is delivered. A filtered scan
|
|
29
|
+
* picks transactions by their outputs (the bytes) and by the inputs the index's pages say
|
|
30
|
+
* spend from a watched address; each page must be the bytes' own, confirmed in that block,
|
|
31
|
+
* and its claims must hold for every transaction delivered, so a lying index can at most
|
|
32
|
+
* hide a watched address's spend that pays no watched address. Which block is at a height
|
|
33
|
+
* stays the endpoint's word, as in every family (the proof quorum confirms rollbacks). A
|
|
34
|
+
* reorg while reading, or a block, page or previous transaction the endpoint does not have,
|
|
35
|
+
* decides nothing (retryable). Address filters match output and prevout scripts, so a
|
|
36
|
+
* watched address's spend is kept even when no output of it has an address.
|
|
37
|
+
*/
|
|
38
|
+
import type { BlockSource, ProofSource } from '../../core/driver/types';
|
|
39
|
+
import { type UtxoContext } from './context';
|
|
40
|
+
import type { EsploraTx } from './types';
|
|
41
|
+
/** Blocks `finalizedHead` trails one endpoint's head by, so peers can attest it. */
|
|
42
|
+
export declare const PEER_SKEW = 2n;
|
|
43
|
+
/**
|
|
44
|
+
* The reads a proof attests under the proof quorum, each fact at its own height. The
|
|
45
|
+
* proof source and the builder share them: the builder's proof-tagged reads are this
|
|
46
|
+
* module's, never a copy.
|
|
47
|
+
*/
|
|
48
|
+
export declare function attestedReads(ctx: UtxoContext, signal?: AbortSignal): {
|
|
49
|
+
holds: (height: bigint) => Promise<boolean>;
|
|
50
|
+
hashAt: (height: bigint) => Promise<string | null>;
|
|
51
|
+
assertCanonical: (height: bigint, hash: string) => Promise<void>;
|
|
52
|
+
txView: (txid: string) => Promise<EsploraTx | null>;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Each of `txids` (the previous transactions of the inputs a build adds) is in a
|
|
56
|
+
* block, attested under the proof quorum at its own height: the proof endpoints agree on the
|
|
57
|
+
* transaction and its block, all hold a block `confirmations − 1` above it, and have that
|
|
58
|
+
* block at that height. Its bytes authenticate themselves, but only this proves a
|
|
59
|
+
* chain holds it: an indexer's invented transaction, or one a reorg took out, would stall an
|
|
60
|
+
* Attempt for good, since nothing would ever spend its outpoint. Anything short of that is a
|
|
61
|
+
* retryable `PROVIDER_UNAVAILABLE` (a stale view `PROVIDER_INCONSISTENT`), and every read
|
|
62
|
+
* decides nothing on failure. A parent found final is not read again.
|
|
63
|
+
*/
|
|
64
|
+
export declare function assertConfirmed(ctx: UtxoContext, txids: readonly string[], confirmations: number, signal?: AbortSignal): Promise<void>;
|
|
65
|
+
export declare function proofSource(ctx: UtxoContext): ProofSource;
|
|
66
|
+
export declare function blockSource(ctx: UtxoContext): BlockSource;
|
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PEER_SKEW = void 0;
|
|
4
|
+
exports.attestedReads = attestedReads;
|
|
5
|
+
exports.assertConfirmed = assertConfirmed;
|
|
6
|
+
exports.proofSource = proofSource;
|
|
7
|
+
exports.blockSource = blockSource;
|
|
8
|
+
const error_1 = require("../../core/errors/error");
|
|
9
|
+
const bytes_1 = require("../../core/util/bytes");
|
|
10
|
+
const address_1 = require("./address");
|
|
11
|
+
const context_1 = require("./context");
|
|
12
|
+
const decode_1 = require("./decode");
|
|
13
|
+
const esplora_1 = require("./esplora");
|
|
14
|
+
const rawblock_1 = require("./rawblock");
|
|
15
|
+
const reader_1 = require("./reader");
|
|
16
|
+
/** Blocks `finalizedHead` trails one endpoint's head by, so peers can attest it. */
|
|
17
|
+
exports.PEER_SKEW = 2n;
|
|
18
|
+
/** Esplora's page of block transactions (electrs' `CHAIN_TXS_PER_PAGE`). */
|
|
19
|
+
const PAGE = 25;
|
|
20
|
+
/**
|
|
21
|
+
* How many previous transactions a block scan reads at once: a full block's delivered
|
|
22
|
+
* transactions spend outputs of thousands. The transport's rate limit still paces them.
|
|
23
|
+
*/
|
|
24
|
+
const PREVIOUS_READS = 8;
|
|
25
|
+
/** No height is below 0 or beyond what a server parses: such a height is never sent. */
|
|
26
|
+
const MAX_HEIGHT = BigInt(Number.MAX_SAFE_INTEGER);
|
|
27
|
+
const outOfRange = (height) => height < 0n || height > MAX_HEIGHT;
|
|
28
|
+
const undecided = (reason) => new error_1.ProviderError('PROVIDER_UNAVAILABLE', reason);
|
|
29
|
+
/** Two quorum reads that cannot both hold decide nothing (retryable). */
|
|
30
|
+
const contradiction = (reason) => new error_1.ProviderError('PROVIDER_INCONSISTENT', reason, { retryable: true });
|
|
31
|
+
const stale = () => contradiction('the including block is no longer the block at its height');
|
|
32
|
+
/** The block a scan reads is gone from the endpoint's chain, or was never on it. */
|
|
33
|
+
const changed = (block) => contradiction(`block ${block.height} changed while scanning`);
|
|
34
|
+
/**
|
|
35
|
+
* An output of a block's or a previous transaction's bytes as an Esplora page shows it.
|
|
36
|
+
* Its value is in range (consensus), so out of range the bytes are not chain data.
|
|
37
|
+
*/
|
|
38
|
+
function outputView(output) {
|
|
39
|
+
if (output.value < 0n || output.value > esplora_1.MAX_MONEY)
|
|
40
|
+
throw (0, esplora_1.malformed)('output value');
|
|
41
|
+
return {
|
|
42
|
+
script: (0, bytes_1.toHex)(output.script),
|
|
43
|
+
type: (0, decode_1.scriptType)(output.script),
|
|
44
|
+
value: output.value,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Whether a page's transaction is `own`, the one the block's bytes hold at its place: the
|
|
49
|
+
* same txid, and the same inputs (outpoints, sequences, coinbase) and outputs.
|
|
50
|
+
*/
|
|
51
|
+
function samePageTx(page, own) {
|
|
52
|
+
return (page.txid === own.txid &&
|
|
53
|
+
page.version === own.version &&
|
|
54
|
+
page.locktime === own.locktime &&
|
|
55
|
+
page.vin.length === own.inputs.length &&
|
|
56
|
+
page.vout.length === own.outputs.length &&
|
|
57
|
+
page.vin.every((input, n) => {
|
|
58
|
+
const mine = own.inputs[n];
|
|
59
|
+
return (mine !== undefined &&
|
|
60
|
+
input.txid === mine.txid &&
|
|
61
|
+
input.vout === mine.vout &&
|
|
62
|
+
input.sequence === mine.sequence &&
|
|
63
|
+
input.coinbase === (0, rawblock_1.isNullOutpoint)(mine));
|
|
64
|
+
}) &&
|
|
65
|
+
page.vout.every((output, n) => {
|
|
66
|
+
const mine = own.outputs[n];
|
|
67
|
+
return (mine !== undefined &&
|
|
68
|
+
output.value === mine.value &&
|
|
69
|
+
output.script === (0, bytes_1.toHex)(mine.script));
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* A block hash read under the proof quorum is compared as `parseHash` reads it, so two
|
|
74
|
+
* honest endpoints that differ only by whitespace agree, and the key is exactly the value
|
|
75
|
+
* the verdict uses. Compared as raw text, one endpoint's trailing newline would split the
|
|
76
|
+
* quorum forever.
|
|
77
|
+
*/
|
|
78
|
+
const HASH_PROOF = { ...context_1.PROOF, quorumKey: esplora_1.parseHash };
|
|
79
|
+
/** A transaction view as the proof quorum compares it: its txid, and its block and height. */
|
|
80
|
+
const txViewKey = (answer) => {
|
|
81
|
+
const t = (0, esplora_1.parseTx)(answer);
|
|
82
|
+
return t.status.confirmed
|
|
83
|
+
? `${t.txid}@${t.status.blockHash}:${t.status.blockHeight}`
|
|
84
|
+
: `${t.txid}:unconfirmed`;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* The reads a proof attests under the proof quorum, each fact at its own height. The
|
|
88
|
+
* proof source and the builder share them: the builder's proof-tagged reads are this
|
|
89
|
+
* module's, never a copy.
|
|
90
|
+
*/
|
|
91
|
+
function attestedReads(ctx, signal) {
|
|
92
|
+
const { esplora } = ctx;
|
|
93
|
+
/** "I hold a block at `height`" (monotone in the head, so endpoints further ahead agree). */
|
|
94
|
+
const holds = async (height) => {
|
|
95
|
+
const head = await esplora.tipHeight({
|
|
96
|
+
...(0, context_1.withSignal)(context_1.PROOF, signal),
|
|
97
|
+
quorumKey: (answer) => (0, esplora_1.parseHeight)(answer) >= height,
|
|
98
|
+
});
|
|
99
|
+
return head >= height;
|
|
100
|
+
};
|
|
101
|
+
/** The hash of the block at `height` on the proof endpoints' chain. */
|
|
102
|
+
const hashAt = (height) => esplora.blockHashAt(height, (0, context_1.withSignal)(HASH_PROOF, signal));
|
|
103
|
+
/** The quorum's hash at `height` must be `hash`; otherwise the answer was stale. */
|
|
104
|
+
const assertCanonical = async (height, hash) => {
|
|
105
|
+
if ((await hashAt(height)) !== hash)
|
|
106
|
+
throw stale();
|
|
107
|
+
};
|
|
108
|
+
/** A transaction and the block it is in, as the proof endpoints agree on it. */
|
|
109
|
+
const txView = (txid) => esplora.tx(txid, { ...(0, context_1.withSignal)(context_1.PROOF, signal), quorumKey: txViewKey });
|
|
110
|
+
return { holds, hashAt, assertCanonical, txView };
|
|
111
|
+
}
|
|
112
|
+
/** How many parents `assertConfirmed` reads at once, and keeps once final. */
|
|
113
|
+
const PARENT_READS = 4;
|
|
114
|
+
const FINAL_PARENTS = 10_000;
|
|
115
|
+
const finalParents = new WeakMap();
|
|
116
|
+
const notConfirmed = () => new error_1.ProviderError('PROVIDER_UNAVAILABLE', "an input's previous transaction is not in a block the proof endpoints hold yet");
|
|
117
|
+
/**
|
|
118
|
+
* Each of `txids` (the previous transactions of the inputs a build adds) is in a
|
|
119
|
+
* block, attested under the proof quorum at its own height: the proof endpoints agree on the
|
|
120
|
+
* transaction and its block, all hold a block `confirmations − 1` above it, and have that
|
|
121
|
+
* block at that height. Its bytes authenticate themselves, but only this proves a
|
|
122
|
+
* chain holds it: an indexer's invented transaction, or one a reorg took out, would stall an
|
|
123
|
+
* Attempt for good, since nothing would ever spend its outpoint. Anything short of that is a
|
|
124
|
+
* retryable `PROVIDER_UNAVAILABLE` (a stale view `PROVIDER_INCONSISTENT`), and every read
|
|
125
|
+
* decides nothing on failure. A parent found final is not read again.
|
|
126
|
+
*/
|
|
127
|
+
async function assertConfirmed(ctx, txids, confirmations, signal) {
|
|
128
|
+
let final = finalParents.get(ctx.esplora);
|
|
129
|
+
if (!final) {
|
|
130
|
+
final = new Map();
|
|
131
|
+
finalParents.set(ctx.esplora, final);
|
|
132
|
+
}
|
|
133
|
+
const known = final;
|
|
134
|
+
const pending = [...new Set(txids)].filter((txid) => !known.has(txid));
|
|
135
|
+
if (pending.length === 0)
|
|
136
|
+
return;
|
|
137
|
+
await (0, context_1.proofRead)(async () => {
|
|
138
|
+
const reads = attestedReads(ctx, signal);
|
|
139
|
+
const blocks = new Map();
|
|
140
|
+
let top = 0n;
|
|
141
|
+
await (0, context_1.forEachBounded)(pending, PARENT_READS, async (txid) => {
|
|
142
|
+
const tx = await reads.txView(txid);
|
|
143
|
+
if (!tx?.status.confirmed)
|
|
144
|
+
throw notConfirmed();
|
|
145
|
+
const height = tx.status.blockHeight;
|
|
146
|
+
blocks.set(tx.status.blockHash, height);
|
|
147
|
+
if (height > top)
|
|
148
|
+
top = height;
|
|
149
|
+
});
|
|
150
|
+
// Monotone: the proof endpoints hold `top + confirmations − 1` only if they hold every
|
|
151
|
+
// lower height, so one read attests every parent's depth.
|
|
152
|
+
if (!(await reads.holds(top + BigInt(Math.max(1, confirmations)) - 1n))) {
|
|
153
|
+
throw notConfirmed();
|
|
154
|
+
}
|
|
155
|
+
for (const [hash, height] of blocks)
|
|
156
|
+
await reads.assertCanonical(height, hash);
|
|
157
|
+
if (await reads.holds(top + BigInt(ctx.config.confirmations) - 1n)) {
|
|
158
|
+
for (const txid of pending) {
|
|
159
|
+
known.set(txid, true);
|
|
160
|
+
if (known.size > FINAL_PARENTS)
|
|
161
|
+
known.delete(known.keys().next().value);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function proofSource(ctx) {
|
|
167
|
+
const { esplora, config } = ctx;
|
|
168
|
+
const depth = BigInt(config.confirmations) - 1n;
|
|
169
|
+
const { holds, hashAt, assertCanonical, txView } = attestedReads(ctx);
|
|
170
|
+
/** The transaction that spent `input` in a final, canonical block (quorum-attested). */
|
|
171
|
+
const finalSpender = async (input) => {
|
|
172
|
+
const spend = await esplora.outspend(input.txid, input.vout, {
|
|
173
|
+
...context_1.PROOF,
|
|
174
|
+
quorumKey: (answer) => {
|
|
175
|
+
const s = (0, esplora_1.parseOutspend)(answer);
|
|
176
|
+
return s.spent && s.status?.confirmed
|
|
177
|
+
? `${s.txid}@${s.status.blockHash}:${s.status.blockHeight}`
|
|
178
|
+
: 'not-in-a-block';
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
const status = spend.status;
|
|
182
|
+
if (!spend.spent || spend.txid === undefined || !status?.confirmed)
|
|
183
|
+
return undefined;
|
|
184
|
+
const height = status.blockHeight;
|
|
185
|
+
const hash = status.blockHash;
|
|
186
|
+
if (!(await holds(height + depth)))
|
|
187
|
+
return undefined;
|
|
188
|
+
await assertCanonical(height, hash);
|
|
189
|
+
return { txid: spend.txid, height, hash };
|
|
190
|
+
};
|
|
191
|
+
const inputsOf = (ordering) => ordering.kind === 'inputs' ? ordering.inputs.map(context_1.parseOutpoint) : [];
|
|
192
|
+
const source = {
|
|
193
|
+
async finalizedHead() {
|
|
194
|
+
const anchor = (await esplora.tipHeight(context_1.MONITOR)) - exports.PEER_SKEW;
|
|
195
|
+
if (anchor < 0n || !(await holds(anchor))) {
|
|
196
|
+
throw undecided('the proof endpoints have not reached the head');
|
|
197
|
+
}
|
|
198
|
+
const final = anchor - depth;
|
|
199
|
+
const height = final < 0n ? 0n : final;
|
|
200
|
+
const hash = await hashAt(height);
|
|
201
|
+
if (hash === null)
|
|
202
|
+
throw undecided('the final block is not visible to the proof endpoints');
|
|
203
|
+
return { height, hash };
|
|
204
|
+
},
|
|
205
|
+
async includedFinal(ref, ordering, from) {
|
|
206
|
+
if (!(0, esplora_1.isHash)(ref.id))
|
|
207
|
+
throw undecided('malformed transaction id');
|
|
208
|
+
const tx = await txView(ref.id);
|
|
209
|
+
if (tx?.status.confirmed) {
|
|
210
|
+
const height = tx.status.blockHeight;
|
|
211
|
+
const hash = tx.status.blockHash;
|
|
212
|
+
if (await holds(height + depth)) {
|
|
213
|
+
await assertCanonical(height, hash);
|
|
214
|
+
// A transaction in a block has executed; its txid commits to its outputs.
|
|
215
|
+
return {
|
|
216
|
+
included: true,
|
|
217
|
+
success: true,
|
|
218
|
+
blockHeight: height,
|
|
219
|
+
blockHash: hash,
|
|
220
|
+
txHash: tx.txid,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
// Unknown, in a mempool, or not yet final: only a final spender of one of our inputs
|
|
225
|
+
// decides. Our own txid there means the views are inconsistent (decide nothing); a
|
|
226
|
+
// malleated copy of ours is our payment; any other transaction proves ours dead,
|
|
227
|
+
// unless the quorum also puts ours in a block (the views contradict each other).
|
|
228
|
+
for (const input of inputsOf(ordering)) {
|
|
229
|
+
const spender = await finalSpender(input);
|
|
230
|
+
if (spender === undefined)
|
|
231
|
+
continue;
|
|
232
|
+
if (spender.txid === ref.id) {
|
|
233
|
+
throw undecided('the spend and the transaction views disagree');
|
|
234
|
+
}
|
|
235
|
+
if (await (0, reader_1.isOwnCopy)(ctx, ref.id, from, spender.txid, context_1.PROOF)) {
|
|
236
|
+
return {
|
|
237
|
+
included: true,
|
|
238
|
+
success: true,
|
|
239
|
+
blockHeight: spender.height,
|
|
240
|
+
blockHash: spender.hash,
|
|
241
|
+
txHash: spender.txid,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
if (tx?.status.confirmed) {
|
|
245
|
+
throw contradiction('the transaction is in a block while another spend of its input is final');
|
|
246
|
+
}
|
|
247
|
+
return { included: false };
|
|
248
|
+
}
|
|
249
|
+
throw undecided(tx
|
|
250
|
+
? 'the transaction is not final yet'
|
|
251
|
+
: 'the indexer does not know this transaction yet');
|
|
252
|
+
},
|
|
253
|
+
async slotConsumed(ordering, _from, level) {
|
|
254
|
+
for (const input of inputsOf(ordering)) {
|
|
255
|
+
if (level === 'latest') {
|
|
256
|
+
if ((await esplora.outspend(input.txid, input.vout, context_1.MONITOR)).spent)
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
259
|
+
else if ((await finalSpender(input)) !== undefined) {
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return false;
|
|
264
|
+
},
|
|
265
|
+
expired: async () => false,
|
|
266
|
+
async blockHash(height, level) {
|
|
267
|
+
if (outOfRange(height))
|
|
268
|
+
return null;
|
|
269
|
+
if (level === 'finalized' && !(await holds(height + depth)))
|
|
270
|
+
return null;
|
|
271
|
+
return hashAt(height);
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
// Every read of every proof decides nothing on "not available here".
|
|
275
|
+
return {
|
|
276
|
+
finalizedHead: () => (0, context_1.proofRead)(() => source.finalizedHead()),
|
|
277
|
+
includedFinal: (ref, ordering, from) => (0, context_1.proofRead)(() => source.includedFinal(ref, ordering, from)),
|
|
278
|
+
slotConsumed: (ordering, from, level) => (0, context_1.proofRead)(() => source.slotConsumed(ordering, from, level)),
|
|
279
|
+
expired: (ordering) => source.expired(ordering),
|
|
280
|
+
blockHash: (height, level) => (0, context_1.proofRead)(() => source.blockHash(height, level)),
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
function blockSource(ctx) {
|
|
284
|
+
const { esplora, config } = ctx;
|
|
285
|
+
/** The output scripts of the watched addresses; `undefined` means no filter. */
|
|
286
|
+
const scriptsOf = (addresses) => {
|
|
287
|
+
if (addresses === undefined || addresses.length === 0)
|
|
288
|
+
return undefined;
|
|
289
|
+
const scripts = new Set();
|
|
290
|
+
for (const address of addresses) {
|
|
291
|
+
try {
|
|
292
|
+
scripts.add((0, bytes_1.toHex)((0, address_1.decodeAddress)(address, config.address).script));
|
|
293
|
+
}
|
|
294
|
+
catch {
|
|
295
|
+
// Not an address of this network: it matches nothing.
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return scripts;
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* The places of `raw`'s transactions that touch `wanted`, with each one's page: an output
|
|
302
|
+
* to it, read from the block's own bytes, or an input that, by the index's pages, spends
|
|
303
|
+
* from it. Every page is bound to the bytes: exactly the transactions they hold at its
|
|
304
|
+
* places, with the same inputs and outputs, confirmed in this block. So a page only claims
|
|
305
|
+
* which outputs the block's inputs spend, and `viewOf` checks the claims of every
|
|
306
|
+
* transaction delivered against the previous transactions' own bytes: all a lying index
|
|
307
|
+
* can do is hide a spend from a watched address that pays no watched address.
|
|
308
|
+
*/
|
|
309
|
+
const touching = async (block, raw, wanted) => {
|
|
310
|
+
const picked = new Map();
|
|
311
|
+
for (let start = 0; start < raw.txs.length; start += PAGE) {
|
|
312
|
+
let page;
|
|
313
|
+
try {
|
|
314
|
+
page = await esplora.blockTxs(block.hash, start, context_1.MONITOR);
|
|
315
|
+
}
|
|
316
|
+
catch (error) {
|
|
317
|
+
// A backend that does not have the block (lagging, load-balanced) decides nothing.
|
|
318
|
+
if ((0, esplora_1.isNotFound)(error))
|
|
319
|
+
throw changed(block);
|
|
320
|
+
throw error;
|
|
321
|
+
}
|
|
322
|
+
// Each page holds exactly what the block leaves for it.
|
|
323
|
+
if (page.length !== Math.min(PAGE, raw.txs.length - start)) {
|
|
324
|
+
throw (0, esplora_1.malformed)('block txs page');
|
|
325
|
+
}
|
|
326
|
+
page.forEach((tx, offset) => {
|
|
327
|
+
const own = raw.txs[start + offset];
|
|
328
|
+
if (!samePageTx(tx, own)) {
|
|
329
|
+
throw contradiction("a block page differs from the block's own bytes");
|
|
330
|
+
}
|
|
331
|
+
const { status } = tx;
|
|
332
|
+
if (!status.confirmed ||
|
|
333
|
+
status.blockHash !== block.hash ||
|
|
334
|
+
status.blockHeight !== block.height) {
|
|
335
|
+
throw changed(block);
|
|
336
|
+
}
|
|
337
|
+
if (own.outputs.some((output) => wanted.has((0, bytes_1.toHex)(output.script))) ||
|
|
338
|
+
tx.vin.some((input) => input.prevout && wanted.has(input.prevout.script))) {
|
|
339
|
+
picked.set(start + offset, tx);
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
return picked;
|
|
344
|
+
};
|
|
345
|
+
/**
|
|
346
|
+
* The outputs the inputs of `txs` spend, by previous txid: a transaction of the block
|
|
347
|
+
* itself, or the previous transaction's own bytes, bound to its txid (`outputsOf`). One
|
|
348
|
+
* endpoint answers, so one that does not have a previous transaction decides nothing.
|
|
349
|
+
*/
|
|
350
|
+
const spentOutputs = async (raw, txs) => {
|
|
351
|
+
const known = new Map(raw.txs.map((tx) => [tx.txid, tx.outputs]));
|
|
352
|
+
const missing = new Set();
|
|
353
|
+
for (const tx of txs) {
|
|
354
|
+
for (const input of tx.inputs) {
|
|
355
|
+
if (!(0, rawblock_1.isNullOutpoint)(input) && !known.has(input.txid))
|
|
356
|
+
missing.add(input.txid);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
await (0, context_1.forEachBounded)([...missing], PREVIOUS_READS, async (txid) => {
|
|
360
|
+
const outputs = await esplora.outputsOf(txid, context_1.MONITOR);
|
|
361
|
+
if (!outputs)
|
|
362
|
+
throw undecided("an input's previous transaction is not available");
|
|
363
|
+
known.set(txid, outputs);
|
|
364
|
+
});
|
|
365
|
+
return known;
|
|
366
|
+
};
|
|
367
|
+
/**
|
|
368
|
+
* A transaction of the block as Esplora shows it, from its own bytes and the outputs its
|
|
369
|
+
* inputs spend, so it decodes as a page of it would. A page's claims about those outputs
|
|
370
|
+
* (`page`) must be what the previous transactions hold.
|
|
371
|
+
*/
|
|
372
|
+
const viewOf = (tx, spent, status, page) => {
|
|
373
|
+
const vout = tx.outputs.map(outputView);
|
|
374
|
+
let coinbase = false;
|
|
375
|
+
let fee = -vout.reduce((sum, output) => sum + output.value, 0n);
|
|
376
|
+
const vin = tx.inputs.map((input, n) => {
|
|
377
|
+
const outpoint = { txid: input.txid, vout: input.vout, sequence: input.sequence };
|
|
378
|
+
if ((0, rawblock_1.isNullOutpoint)(input)) {
|
|
379
|
+
coinbase = true;
|
|
380
|
+
return { ...outpoint, coinbase: true };
|
|
381
|
+
}
|
|
382
|
+
const output = spent.get(input.txid)?.[input.vout];
|
|
383
|
+
if (!output)
|
|
384
|
+
throw contradiction('a block input spends an output that does not exist');
|
|
385
|
+
const prevout = outputView(output);
|
|
386
|
+
const claim = page?.vin[n]?.prevout;
|
|
387
|
+
if (claim && (claim.script !== prevout.script || claim.value !== prevout.value)) {
|
|
388
|
+
throw contradiction('the index names another output than the one an input spends');
|
|
389
|
+
}
|
|
390
|
+
fee += prevout.value;
|
|
391
|
+
return { ...outpoint, coinbase: false, prevout };
|
|
392
|
+
});
|
|
393
|
+
// Esplora's convention: a coinbase's fee is 0.
|
|
394
|
+
if (coinbase)
|
|
395
|
+
fee = 0n;
|
|
396
|
+
if (fee < 0n || fee > esplora_1.MAX_MONEY)
|
|
397
|
+
throw (0, esplora_1.malformed)('tx fee');
|
|
398
|
+
return {
|
|
399
|
+
txid: tx.txid,
|
|
400
|
+
version: tx.version,
|
|
401
|
+
locktime: tx.locktime,
|
|
402
|
+
weight: tx.strippedSize * 3 + tx.bytes.length,
|
|
403
|
+
fee,
|
|
404
|
+
vin,
|
|
405
|
+
vout,
|
|
406
|
+
status,
|
|
407
|
+
};
|
|
408
|
+
};
|
|
409
|
+
return {
|
|
410
|
+
async header(height) {
|
|
411
|
+
if (outOfRange(height))
|
|
412
|
+
return null;
|
|
413
|
+
const hash = await esplora.blockHashAt(height, context_1.MONITOR);
|
|
414
|
+
if (!hash)
|
|
415
|
+
return null;
|
|
416
|
+
const block = await esplora.block(hash, context_1.MONITOR);
|
|
417
|
+
if (!block)
|
|
418
|
+
return null;
|
|
419
|
+
// The block at `height` must say it is at `height`.
|
|
420
|
+
if (block.height !== height) {
|
|
421
|
+
throw contradiction(`block ${height} changed while reading`);
|
|
422
|
+
}
|
|
423
|
+
return {
|
|
424
|
+
height: block.height,
|
|
425
|
+
hash: block.hash,
|
|
426
|
+
parentHash: block.parentHash,
|
|
427
|
+
timestamp: block.timestamp,
|
|
428
|
+
};
|
|
429
|
+
},
|
|
430
|
+
async transactions(block, filter) {
|
|
431
|
+
// `filter.assets` is a hint: a list without the native asset wants tokens only, and a
|
|
432
|
+
// Bitcoin block has none, so nothing is read.
|
|
433
|
+
if (filter?.assets?.length && !filter.assets.includes('native'))
|
|
434
|
+
return [];
|
|
435
|
+
// The block's own bytes, bound to its hash (`rawBlock`): every transaction delivered
|
|
436
|
+
// is the block's, byte for byte, whatever the index's pages say.
|
|
437
|
+
const raw = await esplora.rawBlock(block.hash, context_1.MONITOR);
|
|
438
|
+
// A backend that does not have the block (lagging, load-balanced, or a full-mode
|
|
439
|
+
// electrs, which serves its best chain's only) decides nothing.
|
|
440
|
+
if (!raw)
|
|
441
|
+
throw changed(block);
|
|
442
|
+
// The header read at this height must be the bytes' own, so the block delivered (its
|
|
443
|
+
// parent link and time) is the one its hash names.
|
|
444
|
+
if (raw.parentHash !== block.parentHash || raw.time !== block.timestamp) {
|
|
445
|
+
throw contradiction(`the header of block ${block.height} is not its own`);
|
|
446
|
+
}
|
|
447
|
+
const wanted = scriptsOf(filter?.addresses);
|
|
448
|
+
const picked = wanted && (await touching(block, raw, wanted));
|
|
449
|
+
const txs = picked ? raw.txs.filter((_, i) => picked.has(i)) : raw.txs;
|
|
450
|
+
const spent = await spentOutputs(raw, txs);
|
|
451
|
+
// Checked after the reads, so a reorg while reading is caught.
|
|
452
|
+
if ((await esplora.blockHashAt(block.height, context_1.MONITOR)) !== block.hash) {
|
|
453
|
+
throw changed(block);
|
|
454
|
+
}
|
|
455
|
+
const status = {
|
|
456
|
+
confirmed: true,
|
|
457
|
+
blockHeight: block.height,
|
|
458
|
+
blockHash: block.hash,
|
|
459
|
+
blockTime: raw.time,
|
|
460
|
+
};
|
|
461
|
+
return raw.txs.flatMap((tx, i) => picked && !picked.has(i)
|
|
462
|
+
? []
|
|
463
|
+
: [
|
|
464
|
+
(0, decode_1.decodeTransaction)(viewOf(tx, spent, status, picked?.get(i)), config.address),
|
|
465
|
+
]);
|
|
466
|
+
},
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
//# sourceMappingURL=proofs.js.map
|