crypto-aio 0.0.3 → 0.1.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 +17 -0
- package/README.md +144 -14
- 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 +326 -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 +170 -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 +135 -0
- package/dist/adapters/evm/ethers-client.js.map +1 -0
- package/dist/adapters/evm/fees.d.ts +79 -0
- package/dist/adapters/evm/fees.js +234 -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 +11 -0
- package/dist/adapters/evm/index.js.map +1 -0
- package/dist/adapters/evm/network.d.ts +60 -0
- package/dist/adapters/evm/network.js +131 -0
- package/dist/adapters/evm/network.js.map +1 -0
- package/dist/adapters/evm/plugin.d.ts +36 -0
- package/dist/adapters/evm/plugin.js +102 -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 +358 -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 +65 -0
- package/dist/adapters/evm/reader.js +292 -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 +7 -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 +255 -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 +23 -0
- package/dist/adapters/evm/web3-client.js +159 -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 +545 -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 +68 -0
- package/dist/adapters/solana/fees.js +205 -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/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 +41 -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 +121 -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 +83 -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 +813 -0
- package/dist/adapters/ton/proofs.js.map +1 -0
- package/dist/adapters/ton/reader.d.ts +194 -0
- package/dist/adapters/ton/reader.js +781 -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 +48 -0
- package/dist/adapters/ton/trace.js +277 -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 +39 -0
- package/dist/adapters/tron/abi.js +110 -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 +553 -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 +50 -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 +370 -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 +47 -0
- package/dist/adapters/tron/reader.js +203 -0
- package/dist/adapters/tron/reader.js.map +1 -0
- package/dist/adapters/tron/tokens.d.ts +7 -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 +99 -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 +57 -0
- package/dist/adapters/utxo/context.js +118 -0
- package/dist/adapters/utxo/context.js.map +1 -0
- package/dist/adapters/utxo/decode.d.ts +14 -0
- package/dist/adapters/utxo/decode.js +85 -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 +74 -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 +79 -0
- package/dist/adapters/utxo/esplora.js +451 -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 +57 -0
- package/dist/adapters/utxo/proofs.js +331 -0
- package/dist/adapters/utxo/proofs.js.map +1 -0
- package/dist/adapters/utxo/rawtx.d.ts +59 -0
- package/dist/adapters/utxo/rawtx.js +234 -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 +200 -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 +165 -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 +69 -0
- package/dist/core/container/container.js +466 -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 +346 -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 +153 -0
- package/dist/core/errors/codes.js +49 -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 +107 -0
- package/dist/core/lifecycle/engine-rules.js +257 -0
- package/dist/core/lifecycle/engine-rules.js.map +1 -0
- package/dist/core/lifecycle/engine.d.ts +500 -0
- package/dist/core/lifecycle/engine.js +1732 -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 +72 -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 +606 -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 +82 -0
- package/dist/core/lifecycle/workers.js +329 -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 +37 -0
- package/dist/core/model/ids.js +13 -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 +20 -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 +116 -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 +355 -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 +153 -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/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 +246 -0
- package/dist/core/store/types.js +117 -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 +1695 -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 +144 -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 +29 -0
- package/dist/core/util/json.js +165 -0
- package/dist/core/util/json.js.map +1 -0
- package/dist/core/util/names.d.ts +21 -0
- package/dist/core/util/names.js +46 -0
- package/dist/core/util/names.js.map +1 -0
- package/dist/index.d.ts +64 -14
- package/dist/index.js +105 -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 +718 -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 +63 -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 +36 -0
- package/dist/testing/faulty-store.js +66 -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 +188 -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,451 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EsploraClient = exports.isHash = exports.MAX_MONEY = exports.PREVIOUS_TX_CACHE = void 0;
|
|
4
|
+
exports.malformed = malformed;
|
|
5
|
+
exports.isNotFound = isNotFound;
|
|
6
|
+
exports.parseHeight = parseHeight;
|
|
7
|
+
exports.parseHash = parseHash;
|
|
8
|
+
exports.parseStatus = parseStatus;
|
|
9
|
+
exports.parseTx = parseTx;
|
|
10
|
+
exports.parseOutspend = parseOutspend;
|
|
11
|
+
exports.parseFeeEstimates = parseFeeEstimates;
|
|
12
|
+
/**
|
|
13
|
+
* The Esplora REST API, sent directly over the core transport. Every call carries the
|
|
14
|
+
* calling driver method's tags and a `route` template with no identifiers in it, which
|
|
15
|
+
* events and logs show instead of the path. Answers are validated strictly: a malformed
|
|
16
|
+
* one is a retryable `ProviderError('PROVIDER_UNAVAILABLE')`, a missing or ill-typed
|
|
17
|
+
* field is malformed and never a default, an answer for another id than the one asked for is
|
|
18
|
+
* refused, and a 404 is `null`. Chain data is read as the chain allows it, never bounded by
|
|
19
|
+
* what this library builds (lenient readers). Chain reads use the `rpc` transport; address
|
|
20
|
+
* reads use the `indexer`. Only raw transaction hex is decoded, by the strict linear
|
|
21
|
+
* reader (`rawtx.ts`), to bind it to its txid.
|
|
22
|
+
*/
|
|
23
|
+
const error_1 = require("../../core/errors/error");
|
|
24
|
+
const codec_1 = require("./codec");
|
|
25
|
+
const HEX64 = /^[0-9a-f]{64}$/;
|
|
26
|
+
/**
|
|
27
|
+
* The previous transactions one client keeps, by count and by bytes without the
|
|
28
|
+
* witness (a larger one is not kept). A typical one is a few hundred bytes.
|
|
29
|
+
*/
|
|
30
|
+
exports.PREVIOUS_TX_CACHE = Object.freeze({ entries: 1_000, bytes: 8_000_000 });
|
|
31
|
+
/** Bitcoin Core's `MAX_MONEY`: no output, and no balance, is larger. */
|
|
32
|
+
exports.MAX_MONEY = 2100000000000000n;
|
|
33
|
+
/**
|
|
34
|
+
* Lowercase hex of whole bytes. A flat character class, not `([0-9a-f]{2})+`: that pattern
|
|
35
|
+
* overflows V8's regexp stack on the hex of a transaction of about 3.5 MB, which is valid.
|
|
36
|
+
*/
|
|
37
|
+
const isHex = (value) => value.length % 2 === 0 && /^[0-9a-f]*$/.test(value);
|
|
38
|
+
function malformed(what) {
|
|
39
|
+
return new error_1.ProviderError('PROVIDER_UNAVAILABLE', `malformed Esplora answer: ${what}`);
|
|
40
|
+
}
|
|
41
|
+
/** A definitive 404 (not an ambiguous or retried failure): the resource is not there. */
|
|
42
|
+
function isNotFound(error) {
|
|
43
|
+
return ((0, error_1.isCryptoAioError)(error, 'RPC_ERROR') &&
|
|
44
|
+
!error.ambiguous &&
|
|
45
|
+
error.details?.status === 404);
|
|
46
|
+
}
|
|
47
|
+
const record = (value, what) => {
|
|
48
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
49
|
+
throw malformed(what);
|
|
50
|
+
return value;
|
|
51
|
+
};
|
|
52
|
+
const hash = (value, what) => {
|
|
53
|
+
if (typeof value !== 'string' || !HEX64.test(value))
|
|
54
|
+
throw malformed(what);
|
|
55
|
+
return value;
|
|
56
|
+
};
|
|
57
|
+
const integer = (value, what, max = Number.MAX_SAFE_INTEGER) => {
|
|
58
|
+
if (!Number.isSafeInteger(value) || value < 0 || value > max) {
|
|
59
|
+
throw malformed(what);
|
|
60
|
+
}
|
|
61
|
+
return value;
|
|
62
|
+
};
|
|
63
|
+
const sats = (value, what) => BigInt(integer(value, what, Number(exports.MAX_MONEY)));
|
|
64
|
+
const u32 = (value, what) => integer(value, what, 0xffffffff);
|
|
65
|
+
/**
|
|
66
|
+
* A transaction's 32-bit version, which Esplora servers print signed or unsigned, as one
|
|
67
|
+
* signed value (`v | 0`), so both printings agree. Chain data: any version a block holds is
|
|
68
|
+
* read, whatever this library builds (version 2).
|
|
69
|
+
*/
|
|
70
|
+
const txVersion = (value) => {
|
|
71
|
+
if (!Number.isSafeInteger(value) ||
|
|
72
|
+
value < -0x80000000 ||
|
|
73
|
+
value > 0xffffffff) {
|
|
74
|
+
throw malformed('tx.version');
|
|
75
|
+
}
|
|
76
|
+
return value | 0;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* A cumulative total of an address (every output it ever received or spent), read exactly
|
|
80
|
+
* (`exactIntegers`): a busy address's totals exceed 21 million bitcoin, and may exceed 2^53.
|
|
81
|
+
*/
|
|
82
|
+
const total = (value, what) => {
|
|
83
|
+
if (typeof value === 'bigint') {
|
|
84
|
+
if (value < 0n)
|
|
85
|
+
throw malformed(what);
|
|
86
|
+
return value;
|
|
87
|
+
}
|
|
88
|
+
return BigInt(integer(value, what));
|
|
89
|
+
};
|
|
90
|
+
function parseHeight(text) {
|
|
91
|
+
if (typeof text !== 'string' || !/^(0|[1-9][0-9]{0,9})$/.test(text.trim())) {
|
|
92
|
+
throw malformed('block height');
|
|
93
|
+
}
|
|
94
|
+
return BigInt(text.trim());
|
|
95
|
+
}
|
|
96
|
+
function parseHash(text) {
|
|
97
|
+
return hash(typeof text === 'string' ? text.trim() : text, 'block hash');
|
|
98
|
+
}
|
|
99
|
+
function parseStatus(value) {
|
|
100
|
+
const status = record(value, 'status');
|
|
101
|
+
if (typeof status.confirmed !== 'boolean')
|
|
102
|
+
throw malformed('status.confirmed');
|
|
103
|
+
if (!status.confirmed)
|
|
104
|
+
return { confirmed: false };
|
|
105
|
+
return {
|
|
106
|
+
confirmed: true,
|
|
107
|
+
blockHeight: BigInt(integer(status.block_height, 'status.block_height')),
|
|
108
|
+
blockHash: hash(status.block_hash, 'status.block_hash'),
|
|
109
|
+
...(status.block_time !== undefined && status.block_time !== null
|
|
110
|
+
? { blockTime: integer(status.block_time, 'status.block_time') }
|
|
111
|
+
: {}),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function parseOutput(value) {
|
|
115
|
+
const output = record(value, 'vout');
|
|
116
|
+
if (typeof output.scriptpubkey !== 'string' || !isHex(output.scriptpubkey)) {
|
|
117
|
+
throw malformed('vout.scriptpubkey');
|
|
118
|
+
}
|
|
119
|
+
if (typeof output.scriptpubkey_type !== 'string')
|
|
120
|
+
throw malformed('vout.scriptpubkey_type');
|
|
121
|
+
const address = output.scriptpubkey_address;
|
|
122
|
+
if (address !== undefined && address !== null && typeof address !== 'string') {
|
|
123
|
+
throw malformed('vout.scriptpubkey_address');
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
script: output.scriptpubkey,
|
|
127
|
+
type: output.scriptpubkey_type,
|
|
128
|
+
...(typeof address === 'string' ? { address } : {}),
|
|
129
|
+
value: sats(output.value, 'vout.value'),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function parseInput(value) {
|
|
133
|
+
const input = record(value, 'vin');
|
|
134
|
+
// It decides whether the input has a previous output and the transaction a fee.
|
|
135
|
+
if (typeof input.is_coinbase !== 'boolean')
|
|
136
|
+
throw malformed('vin.is_coinbase');
|
|
137
|
+
const coinbase = input.is_coinbase;
|
|
138
|
+
return {
|
|
139
|
+
txid: hash(input.txid, 'vin.txid'),
|
|
140
|
+
vout: u32(input.vout, 'vin.vout'),
|
|
141
|
+
coinbase,
|
|
142
|
+
sequence: u32(input.sequence, 'vin.sequence'),
|
|
143
|
+
...(coinbase ? {} : { prevout: parseOutput(input.prevout) }),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function parseTx(value) {
|
|
147
|
+
const tx = record(value, 'tx');
|
|
148
|
+
if (!Array.isArray(tx.vin) || !Array.isArray(tx.vout))
|
|
149
|
+
throw malformed('tx.vin/vout');
|
|
150
|
+
return {
|
|
151
|
+
txid: hash(tx.txid, 'tx.txid'),
|
|
152
|
+
version: txVersion(tx.version),
|
|
153
|
+
locktime: u32(tx.locktime, 'tx.locktime'),
|
|
154
|
+
weight: integer(tx.weight, 'tx.weight'),
|
|
155
|
+
// Esplora answers `fee` for every transaction (0 for a coinbase): missing is malformed.
|
|
156
|
+
fee: sats(tx.fee, 'tx.fee'),
|
|
157
|
+
vin: tx.vin.map(parseInput),
|
|
158
|
+
vout: tx.vout.map(parseOutput),
|
|
159
|
+
status: parseStatus(tx.status),
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function parseBlock(value) {
|
|
163
|
+
const block = record(value, 'block');
|
|
164
|
+
const height = BigInt(integer(block.height, 'block.height'));
|
|
165
|
+
return {
|
|
166
|
+
hash: hash(block.id, 'block.id'),
|
|
167
|
+
height,
|
|
168
|
+
parentHash: height === 0n && block.previousblockhash === null
|
|
169
|
+
? '0'.repeat(64)
|
|
170
|
+
: hash(block.previousblockhash, 'block.previousblockhash'),
|
|
171
|
+
timestamp: integer(block.timestamp, 'block.timestamp'),
|
|
172
|
+
txCount: integer(block.tx_count, 'block.tx_count'),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function parseOutspend(value) {
|
|
176
|
+
const spend = record(value, 'outspend');
|
|
177
|
+
if (typeof spend.spent !== 'boolean')
|
|
178
|
+
throw malformed('outspend.spent');
|
|
179
|
+
if (!spend.spent)
|
|
180
|
+
return { spent: false };
|
|
181
|
+
return {
|
|
182
|
+
spent: true,
|
|
183
|
+
txid: hash(spend.txid, 'outspend.txid'),
|
|
184
|
+
vin: u32(spend.vin, 'outspend.vin'),
|
|
185
|
+
status: parseStatus(spend.status),
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function parseUtxo(value) {
|
|
189
|
+
const utxo = record(value, 'utxo');
|
|
190
|
+
return {
|
|
191
|
+
txid: hash(utxo.txid, 'utxo.txid'),
|
|
192
|
+
vout: u32(utxo.vout, 'utxo.vout'),
|
|
193
|
+
value: sats(utxo.value, 'utxo.value'),
|
|
194
|
+
status: parseStatus(utxo.status),
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function list(value, what, parse) {
|
|
198
|
+
if (!Array.isArray(value))
|
|
199
|
+
throw malformed(what);
|
|
200
|
+
return value.map(parse);
|
|
201
|
+
}
|
|
202
|
+
/** Esplora's `/fee-estimates`: confirmation target (blocks) → sat/vB (a float). */
|
|
203
|
+
function parseFeeEstimates(value) {
|
|
204
|
+
const estimates = record(value, 'fee-estimates');
|
|
205
|
+
const out = new Map();
|
|
206
|
+
for (const [target, rate] of Object.entries(estimates)) {
|
|
207
|
+
if (!/^[1-9][0-9]{0,3}$/.test(target))
|
|
208
|
+
throw malformed('fee-estimates target');
|
|
209
|
+
if (typeof rate !== 'number' || !Number.isFinite(rate) || rate < 0 || rate > 1e7) {
|
|
210
|
+
throw malformed('fee-estimates rate');
|
|
211
|
+
}
|
|
212
|
+
out.set(Number(target), rate);
|
|
213
|
+
}
|
|
214
|
+
return out;
|
|
215
|
+
}
|
|
216
|
+
/** Whether a caller's id is a txid or block hash (64 lowercase hex characters). */
|
|
217
|
+
const isHash = (value) => typeof value === 'string' && HEX64.test(value);
|
|
218
|
+
exports.isHash = isHash;
|
|
219
|
+
/**
|
|
220
|
+
* A URL path segment from a caller must be exactly an id or an address, so no `..`, `/`
|
|
221
|
+
* or query can reach another route. The reader maps a malformed id to "not found" first.
|
|
222
|
+
*/
|
|
223
|
+
function segment(value, kind) {
|
|
224
|
+
if (kind === 'id' && !(0, exports.isHash)(value)) {
|
|
225
|
+
throw new error_1.ValidationError('INVALID_INTENT', 'a transaction or block id must be 64 lowercase hex digits');
|
|
226
|
+
}
|
|
227
|
+
if (kind === 'address' && !/^[0-9A-Za-z]{1,90}$/.test(value)) {
|
|
228
|
+
throw new error_1.ValidationError('INVALID_ADDRESS', 'invalid Bitcoin address');
|
|
229
|
+
}
|
|
230
|
+
return value;
|
|
231
|
+
}
|
|
232
|
+
/** The txid of strictly decoded transaction hex, or `undefined`. */
|
|
233
|
+
function txidOf(hex) {
|
|
234
|
+
try {
|
|
235
|
+
return { txid: (0, codec_1.txidOfHex)(hex) };
|
|
236
|
+
}
|
|
237
|
+
catch {
|
|
238
|
+
return undefined;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/** Transactions kept per txid, oldest out first, by count and by bytes without witness. */
|
|
242
|
+
class TxCache {
|
|
243
|
+
bounds;
|
|
244
|
+
#txs = new Map();
|
|
245
|
+
#bytes = 0;
|
|
246
|
+
constructor(bounds) {
|
|
247
|
+
this.bounds = bounds;
|
|
248
|
+
}
|
|
249
|
+
has(txid) {
|
|
250
|
+
return this.#txs.has(txid);
|
|
251
|
+
}
|
|
252
|
+
/** The transaction, now the most recently used, or `undefined`. */
|
|
253
|
+
get(txid) {
|
|
254
|
+
const tx = this.#txs.get(txid);
|
|
255
|
+
if (tx) {
|
|
256
|
+
this.#txs.delete(txid);
|
|
257
|
+
this.#txs.set(txid, tx);
|
|
258
|
+
}
|
|
259
|
+
return tx;
|
|
260
|
+
}
|
|
261
|
+
set(tx) {
|
|
262
|
+
if (tx.bytes.length > this.bounds.bytes)
|
|
263
|
+
return;
|
|
264
|
+
const old = this.#txs.get(tx.txid);
|
|
265
|
+
if (old) {
|
|
266
|
+
this.#txs.delete(tx.txid);
|
|
267
|
+
this.#bytes -= old.bytes.length;
|
|
268
|
+
}
|
|
269
|
+
this.#txs.set(tx.txid, tx);
|
|
270
|
+
this.#bytes += tx.bytes.length;
|
|
271
|
+
// The oldest go first (a Map iterates in insertion order).
|
|
272
|
+
for (const [id, entry] of this.#txs) {
|
|
273
|
+
if (this.#txs.size <= this.bounds.entries && this.#bytes <= this.bounds.bytes)
|
|
274
|
+
break;
|
|
275
|
+
this.#txs.delete(id);
|
|
276
|
+
this.#bytes -= entry.bytes.length;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
/** One Esplora endpoint family (the `rpc` transport) and its address index (`indexer`). */
|
|
281
|
+
class EsploraClient {
|
|
282
|
+
chain;
|
|
283
|
+
indexer;
|
|
284
|
+
cache;
|
|
285
|
+
#previous;
|
|
286
|
+
#own;
|
|
287
|
+
constructor(chain, indexer, cache = exports.PREVIOUS_TX_CACHE) {
|
|
288
|
+
this.chain = chain;
|
|
289
|
+
this.indexer = indexer;
|
|
290
|
+
this.cache = cache;
|
|
291
|
+
this.#previous = new TxCache(cache);
|
|
292
|
+
this.#own = new TxCache(cache);
|
|
293
|
+
}
|
|
294
|
+
#get(transport, path, route, tags, responseType = 'json', exactIntegers = false) {
|
|
295
|
+
const request = { method: 'GET', path, route, responseType };
|
|
296
|
+
return transport.http(request, exactIntegers ? { ...tags, exactIntegers } : tags);
|
|
297
|
+
}
|
|
298
|
+
async #orNull(work) {
|
|
299
|
+
try {
|
|
300
|
+
return await work();
|
|
301
|
+
}
|
|
302
|
+
catch (error) {
|
|
303
|
+
if (isNotFound(error))
|
|
304
|
+
return null;
|
|
305
|
+
throw error;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
async tipHeight(tags) {
|
|
309
|
+
return parseHeight(await this.#get(this.chain, '/blocks/tip/height', '/blocks/tip/height', tags, 'text'));
|
|
310
|
+
}
|
|
311
|
+
/** The hash of the block at `height` on this endpoint's best chain, or `null` above its tip. */
|
|
312
|
+
blockHashAt(height, tags) {
|
|
313
|
+
return this.#orNull(async () => parseHash(await this.#get(this.chain, `/block-height/${height}`, '/block-height/:height', tags, 'text')));
|
|
314
|
+
}
|
|
315
|
+
block(blockHash, tags) {
|
|
316
|
+
return this.#orNull(async () => {
|
|
317
|
+
const block = parseBlock(await this.#get(this.chain, `/block/${segment(blockHash, 'id')}`, '/block/:hash', tags));
|
|
318
|
+
// The answer must be the block asked for.
|
|
319
|
+
if (block.hash !== blockHash)
|
|
320
|
+
throw malformed('block.id');
|
|
321
|
+
return block;
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
async blockTxids(blockHash, tags) {
|
|
325
|
+
const ids = await this.#get(this.chain, `/block/${segment(blockHash, 'id')}/txids`, '/block/:hash/txids', tags);
|
|
326
|
+
return list(ids, 'txids', (id) => hash(id, 'txid'));
|
|
327
|
+
}
|
|
328
|
+
/** Up to 25 transactions of a block from `start` (a multiple of 25). */
|
|
329
|
+
async blockTxs(blockHash, start, tags) {
|
|
330
|
+
const txs = await this.#get(this.chain, `/block/${segment(blockHash, 'id')}/txs/${start}`, '/block/:hash/txs/:start', tags);
|
|
331
|
+
return list(txs, 'block txs', parseTx);
|
|
332
|
+
}
|
|
333
|
+
tx(txid, tags) {
|
|
334
|
+
return this.#orNull(async () => {
|
|
335
|
+
const tx = parseTx(await this.#get(this.chain, `/tx/${segment(txid, 'id')}`, '/tx/:txid', tags));
|
|
336
|
+
// The answer must be the transaction asked for.
|
|
337
|
+
if (tx.txid !== txid)
|
|
338
|
+
throw malformed('tx.txid');
|
|
339
|
+
return tx;
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* `/tx/:txid/hex`, decoded strictly once and bound to `txid`: bytes that do not decode are
|
|
344
|
+
* malformed, and the bytes of another transaction are a retryable `PROVIDER_INCONSISTENT`,
|
|
345
|
+
* so a garbled answer is never taken for the caller's error. The decoder's cap is the
|
|
346
|
+
* largest transaction a block can hold, never what this library builds. Under
|
|
347
|
+
* a quorum, each endpoint's answer is keyed on the txid its bytes hash to, and the answer
|
|
348
|
+
* the quorum returns is not decoded again.
|
|
349
|
+
*/
|
|
350
|
+
async #rawTx(txid, tags, decode) {
|
|
351
|
+
const decoded = new Map();
|
|
352
|
+
const read = (answer) => {
|
|
353
|
+
const hex = typeof answer === 'string' ? answer.trim() : '';
|
|
354
|
+
if (!decoded.has(hex)) {
|
|
355
|
+
decoded.set(hex, hex.length > 0 && isHex(hex) ? decode(hex) : undefined);
|
|
356
|
+
}
|
|
357
|
+
return { hex, tx: decoded.get(hex) };
|
|
358
|
+
};
|
|
359
|
+
const keyed = tags.quorum === undefined
|
|
360
|
+
? tags
|
|
361
|
+
: {
|
|
362
|
+
...tags,
|
|
363
|
+
// A throwing key counts as a disagreement.
|
|
364
|
+
quorumKey: (answer) => {
|
|
365
|
+
const { tx } = read(answer);
|
|
366
|
+
if (!tx)
|
|
367
|
+
throw malformed('tx hex');
|
|
368
|
+
return tx.txid;
|
|
369
|
+
},
|
|
370
|
+
};
|
|
371
|
+
const answer = await this.#get(this.chain, `/tx/${segment(txid, 'id')}/hex`, '/tx/:txid/hex', keyed, 'text');
|
|
372
|
+
const { hex, tx } = read(answer);
|
|
373
|
+
if (!tx)
|
|
374
|
+
throw malformed('tx hex');
|
|
375
|
+
if (tx.txid !== txid) {
|
|
376
|
+
throw new error_1.ProviderError('PROVIDER_INCONSISTENT', 'the transaction bytes do not hash to the id asked for', { retryable: true });
|
|
377
|
+
}
|
|
378
|
+
return { hex, tx };
|
|
379
|
+
}
|
|
380
|
+
/** The raw transaction, as hex, bound to `txid` (see `#rawTx`). */
|
|
381
|
+
txHex(txid, tags) {
|
|
382
|
+
return this.#orNull(async () => (await this.#rawTx(txid, tags, txidOf)).hex);
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* An input's previous transaction, decoded once and bound to `txid` (see
|
|
386
|
+
* `#rawTx`). Its bytes authenticate themselves, so it is kept per txid, whatever endpoint
|
|
387
|
+
* served it, in a bounded cache: a replacement's inputs are read once per client.
|
|
388
|
+
*/
|
|
389
|
+
async previousTx(txid, tags) {
|
|
390
|
+
const known = this.#own.get(txid) ?? this.#previous.get(txid);
|
|
391
|
+
if (known)
|
|
392
|
+
return known;
|
|
393
|
+
const found = await this.#orNull(async () => (await this.#rawTx(txid, tags, codec_1.previousTxOf)).tx);
|
|
394
|
+
if (found)
|
|
395
|
+
this.#previous.set(found);
|
|
396
|
+
return found;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* A transaction this client sent for an Attempt and a node took. Its bytes are
|
|
400
|
+
* known here, so its outputs are not an indexer's word even before a block holds it, and
|
|
401
|
+
* under `minInputConfirmations: 0` they may be spent unconfirmed. Kept like the cache.
|
|
402
|
+
*/
|
|
403
|
+
rememberOwn(tx) {
|
|
404
|
+
this.#own.set(tx);
|
|
405
|
+
}
|
|
406
|
+
isOwn(txid) {
|
|
407
|
+
return this.#own.has(txid);
|
|
408
|
+
}
|
|
409
|
+
async outspend(txid, vout, tags) {
|
|
410
|
+
return parseOutspend(await this.#get(this.chain, `/tx/${segment(txid, 'id')}/outspend/${vout}`, '/tx/:txid/outspend/:vout', tags));
|
|
411
|
+
}
|
|
412
|
+
async feeEstimates(tags) {
|
|
413
|
+
return parseFeeEstimates(await this.#get(this.chain, '/fee-estimates', '/fee-estimates', tags));
|
|
414
|
+
}
|
|
415
|
+
/** `POST /tx`: the node's txid on success; a node refusal is the transport's `RPC_ERROR`. */
|
|
416
|
+
async broadcast(hex, tags) {
|
|
417
|
+
const answer = await this.chain.http({ method: 'POST', path: '/tx', route: '/tx', body: hex, responseType: 'text' }, tags);
|
|
418
|
+
if (typeof answer !== 'string' || !HEX64.test(answer.trim())) {
|
|
419
|
+
// The node answered 2xx, so the bytes may have been accepted.
|
|
420
|
+
throw new error_1.ProviderError('PROVIDER_UNAVAILABLE', 'malformed Esplora answer: broadcast txid', {
|
|
421
|
+
ambiguous: true,
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
return answer.trim();
|
|
425
|
+
}
|
|
426
|
+
async addressUtxos(address, tags) {
|
|
427
|
+
const utxos = await this.#get(this.indexer, `/address/${segment(address, 'address')}/utxo`, '/address/:address/utxo', tags);
|
|
428
|
+
return list(utxos, 'utxo list', parseUtxo);
|
|
429
|
+
}
|
|
430
|
+
async addressStats(address, tags) {
|
|
431
|
+
const info = record(await this.#get(this.indexer, `/address/${segment(address, 'address')}`, '/address/:address', tags, 'json', true), 'address');
|
|
432
|
+
const chain = record(info.chain_stats, 'chain_stats');
|
|
433
|
+
const funded = total(chain.funded_txo_sum, 'funded_txo_sum');
|
|
434
|
+
const spent = total(chain.spent_txo_sum, 'spent_txo_sum');
|
|
435
|
+
// The totals are unbounded; the balance is the chain's: 0 to 21 million bitcoin.
|
|
436
|
+
if (spent > funded || funded - spent > exports.MAX_MONEY)
|
|
437
|
+
throw malformed('address balance');
|
|
438
|
+
return { funded, spent };
|
|
439
|
+
}
|
|
440
|
+
/** Confirmed history, newest first, 25 per page, after `lastSeen` when given. */
|
|
441
|
+
async addressTxs(address, lastSeen, tags) {
|
|
442
|
+
const base = `/address/${segment(address, 'address')}/txs/chain`;
|
|
443
|
+
const path = lastSeen ? `${base}/${segment(lastSeen, 'id')}` : base;
|
|
444
|
+
const route = lastSeen
|
|
445
|
+
? '/address/:address/txs/chain/:last_seen_txid'
|
|
446
|
+
: '/address/:address/txs/chain';
|
|
447
|
+
return list(await this.#get(this.indexer, path, route, tags), 'address txs', parseTx);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
exports.EsploraClient = EsploraClient;
|
|
451
|
+
//# sourceMappingURL=esplora.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esplora.js","sourceRoot":"","sources":["../../../src/adapters/utxo/esplora.ts"],"names":[],"mappings":";;;AAgDA,8BAEC;AAGD,gCAMC;AA+CD,kCAKC;AAED,8BAEC;AAED,kCAYC;AAmCD,0BAcC;AAiBD,sCAUC;AAkBD,8CAWC;AA1OD;;;;;;;;;;GAUG;AACH,mDAIiC;AAEjC,mCAAmE;AAenE,MAAM,KAAK,GAAG,gBAAgB,CAAC;AAC/B;;;GAGG;AACU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;YAC/C,CAAC,CAAC,6BAA6B,CAAC;QAClC,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;IACxF,CAAC;CACF;AA5RD,sCA4RC","sourcesContent":["/**\n * The Esplora REST API, sent directly over the core transport. Every call carries the\n * calling driver method's tags and a `route` template with no identifiers in it, which\n * events and logs show instead of the path. Answers are validated strictly: a malformed\n * one is a retryable `ProviderError('PROVIDER_UNAVAILABLE')`, a missing or ill-typed\n * field is malformed and never a default, an answer for another id than the one asked for is\n * refused, and a 404 is `null`. Chain data is read as the chain allows it, never bounded by\n * what this library builds (lenient readers). Chain reads use the `rpc` transport; address\n * reads use the `indexer`. Only raw transaction hex is decoded, by the strict linear\n * reader (`rawtx.ts`), to bind it to its txid.\n */\nimport {\n ProviderError,\n ValidationError,\n isCryptoAioError,\n} from '../../core/errors/error';\nimport type { HttpRequest, Transport } from '../../core/transport/types';\nimport { previousTxOf, txidOfHex, type PreviousTx } from './codec';\nimport type {\n EsploraAddressStats,\n EsploraBlock,\n EsploraInput,\n EsploraOutput,\n EsploraOutspend,\n EsploraStatus,\n EsploraTx,\n EsploraUtxo,\n UtxoCallTags,\n} from './types';\n\ntype Json = Readonly<Record<string, unknown>>;\n\nconst HEX64 = /^[0-9a-f]{64}$/;\n/**\n * The previous transactions one client keeps, by count and by bytes without the\n * witness (a larger one is not kept). A typical one is a few hundred bytes.\n */\nexport const PREVIOUS_TX_CACHE = Object.freeze({ entries: 1_000, bytes: 8_000_000 });\n/** Bitcoin Core's `MAX_MONEY`: no output, and no balance, is larger. */\nexport const MAX_MONEY = 2_100_000_000_000_000n;\n\n/**\n * Lowercase hex of whole bytes. A flat character class, not `([0-9a-f]{2})+`: that pattern\n * overflows V8's regexp stack on the hex of a transaction of about 3.5 MB, which is valid.\n */\nconst isHex = (value: string): boolean =>\n value.length % 2 === 0 && /^[0-9a-f]*$/.test(value);\n\nexport function malformed(what: string): ProviderError {\n return new ProviderError('PROVIDER_UNAVAILABLE', `malformed Esplora answer: ${what}`);\n}\n\n/** A definitive 404 (not an ambiguous or retried failure): the resource is not there. */\nexport function isNotFound(error: unknown): boolean {\n return (\n isCryptoAioError(error, 'RPC_ERROR') &&\n !error.ambiguous &&\n error.details?.status === 404\n );\n}\n\nconst record = (value: unknown, what: string): Json => {\n if (value === null || typeof value !== 'object' || Array.isArray(value))\n throw malformed(what);\n return value as Json;\n};\nconst hash = (value: unknown, what: string): string => {\n if (typeof value !== 'string' || !HEX64.test(value)) throw malformed(what);\n return value;\n};\nconst integer = (value: unknown, what: string, max = Number.MAX_SAFE_INTEGER): number => {\n if (!Number.isSafeInteger(value) || (value as number) < 0 || (value as number) > max) {\n throw malformed(what);\n }\n return value as number;\n};\nconst sats = (value: unknown, what: string): bigint =>\n BigInt(integer(value, what, Number(MAX_MONEY)));\nconst u32 = (value: unknown, what: string): number => integer(value, what, 0xffffffff);\n/**\n * A transaction's 32-bit version, which Esplora servers print signed or unsigned, as one\n * signed value (`v | 0`), so both printings agree. Chain data: any version a block holds is\n * read, whatever this library builds (version 2).\n */\nconst txVersion = (value: unknown): number => {\n if (\n !Number.isSafeInteger(value) ||\n (value as number) < -0x80000000 ||\n (value as number) > 0xffffffff\n ) {\n throw malformed('tx.version');\n }\n return (value as number) | 0;\n};\n/**\n * A cumulative total of an address (every output it ever received or spent), read exactly\n * (`exactIntegers`): a busy address's totals exceed 21 million bitcoin, and may exceed 2^53.\n */\nconst total = (value: unknown, what: string): bigint => {\n if (typeof value === 'bigint') {\n if (value < 0n) throw malformed(what);\n return value;\n }\n return BigInt(integer(value, what));\n};\n\nexport function parseHeight(text: unknown): bigint {\n if (typeof text !== 'string' || !/^(0|[1-9][0-9]{0,9})$/.test(text.trim())) {\n throw malformed('block height');\n }\n return BigInt(text.trim());\n}\n\nexport function parseHash(text: unknown): string {\n return hash(typeof text === 'string' ? text.trim() : text, 'block hash');\n}\n\nexport function parseStatus(value: unknown): EsploraStatus {\n const status = record(value, 'status');\n if (typeof status.confirmed !== 'boolean') throw malformed('status.confirmed');\n if (!status.confirmed) return { confirmed: false };\n return {\n confirmed: true,\n blockHeight: BigInt(integer(status.block_height, 'status.block_height')),\n blockHash: hash(status.block_hash, 'status.block_hash'),\n ...(status.block_time !== undefined && status.block_time !== null\n ? { blockTime: integer(status.block_time, 'status.block_time') }\n : {}),\n };\n}\n\nfunction parseOutput(value: unknown): EsploraOutput {\n const output = record(value, 'vout');\n if (typeof output.scriptpubkey !== 'string' || !isHex(output.scriptpubkey)) {\n throw malformed('vout.scriptpubkey');\n }\n if (typeof output.scriptpubkey_type !== 'string')\n throw malformed('vout.scriptpubkey_type');\n const address = output.scriptpubkey_address;\n if (address !== undefined && address !== null && typeof address !== 'string') {\n throw malformed('vout.scriptpubkey_address');\n }\n return {\n script: output.scriptpubkey,\n type: output.scriptpubkey_type,\n ...(typeof address === 'string' ? { address } : {}),\n value: sats(output.value, 'vout.value'),\n };\n}\n\nfunction parseInput(value: unknown): EsploraInput {\n const input = record(value, 'vin');\n // It decides whether the input has a previous output and the transaction a fee.\n if (typeof input.is_coinbase !== 'boolean') throw malformed('vin.is_coinbase');\n const coinbase = input.is_coinbase;\n return {\n txid: hash(input.txid, 'vin.txid'),\n vout: u32(input.vout, 'vin.vout'),\n coinbase,\n sequence: u32(input.sequence, 'vin.sequence'),\n ...(coinbase ? {} : { prevout: parseOutput(input.prevout) }),\n };\n}\n\nexport function parseTx(value: unknown): EsploraTx {\n const tx = record(value, 'tx');\n if (!Array.isArray(tx.vin) || !Array.isArray(tx.vout)) throw malformed('tx.vin/vout');\n return {\n txid: hash(tx.txid, 'tx.txid'),\n version: txVersion(tx.version),\n locktime: u32(tx.locktime, 'tx.locktime'),\n weight: integer(tx.weight, 'tx.weight'),\n // Esplora answers `fee` for every transaction (0 for a coinbase): missing is malformed.\n fee: sats(tx.fee, 'tx.fee'),\n vin: tx.vin.map(parseInput),\n vout: tx.vout.map(parseOutput),\n status: parseStatus(tx.status),\n };\n}\n\nfunction parseBlock(value: unknown): EsploraBlock {\n const block = record(value, 'block');\n const height = BigInt(integer(block.height, 'block.height'));\n return {\n hash: hash(block.id, 'block.id'),\n height,\n parentHash:\n height === 0n && block.previousblockhash === null\n ? '0'.repeat(64)\n : hash(block.previousblockhash, 'block.previousblockhash'),\n timestamp: integer(block.timestamp, 'block.timestamp'),\n txCount: integer(block.tx_count, 'block.tx_count'),\n };\n}\n\nexport function parseOutspend(value: unknown): EsploraOutspend {\n const spend = record(value, 'outspend');\n if (typeof spend.spent !== 'boolean') throw malformed('outspend.spent');\n if (!spend.spent) return { spent: false };\n return {\n spent: true,\n txid: hash(spend.txid, 'outspend.txid'),\n vin: u32(spend.vin, 'outspend.vin'),\n status: parseStatus(spend.status),\n };\n}\n\nfunction parseUtxo(value: unknown): EsploraUtxo {\n const utxo = record(value, 'utxo');\n return {\n txid: hash(utxo.txid, 'utxo.txid'),\n vout: u32(utxo.vout, 'utxo.vout'),\n value: sats(utxo.value, 'utxo.value'),\n status: parseStatus(utxo.status),\n };\n}\n\nfunction list<T>(value: unknown, what: string, parse: (item: unknown) => T): T[] {\n if (!Array.isArray(value)) throw malformed(what);\n return value.map(parse);\n}\n\n/** Esplora's `/fee-estimates`: confirmation target (blocks) → sat/vB (a float). */\nexport function parseFeeEstimates(value: unknown): ReadonlyMap<number, number> {\n const estimates = record(value, 'fee-estimates');\n const out = new Map<number, number>();\n for (const [target, rate] of Object.entries(estimates)) {\n if (!/^[1-9][0-9]{0,3}$/.test(target)) throw malformed('fee-estimates target');\n if (typeof rate !== 'number' || !Number.isFinite(rate) || rate < 0 || rate > 1e7) {\n throw malformed('fee-estimates rate');\n }\n out.set(Number(target), rate);\n }\n return out;\n}\n\n/** Whether a caller's id is a txid or block hash (64 lowercase hex characters). */\nexport const isHash = (value: unknown): value is string =>\n typeof value === 'string' && HEX64.test(value);\n\n/**\n * A URL path segment from a caller must be exactly an id or an address, so no `..`, `/`\n * or query can reach another route. The reader maps a malformed id to \"not found\" first.\n */\nfunction segment(value: string, kind: 'id' | 'address'): string {\n if (kind === 'id' && !isHash(value)) {\n throw new ValidationError(\n 'INVALID_INTENT',\n 'a transaction or block id must be 64 lowercase hex digits',\n );\n }\n if (kind === 'address' && !/^[0-9A-Za-z]{1,90}$/.test(value)) {\n throw new ValidationError('INVALID_ADDRESS', 'invalid Bitcoin address');\n }\n return value;\n}\n\n/** The txid of strictly decoded transaction hex, or `undefined`. */\nfunction txidOf(hex: string): { readonly txid: string } | undefined {\n try {\n return { txid: txidOfHex(hex) };\n } catch {\n return undefined;\n }\n}\n\n/** Transactions kept per txid, oldest out first, by count and by bytes without witness. */\nclass TxCache {\n readonly #txs = new Map<string, PreviousTx>();\n #bytes = 0;\n\n constructor(\n private readonly bounds: { readonly entries: number; readonly bytes: number },\n ) {}\n\n has(txid: string): boolean {\n return this.#txs.has(txid);\n }\n\n /** The transaction, now the most recently used, or `undefined`. */\n get(txid: string): PreviousTx | undefined {\n const tx = this.#txs.get(txid);\n if (tx) {\n this.#txs.delete(txid);\n this.#txs.set(txid, tx);\n }\n return tx;\n }\n\n set(tx: PreviousTx): void {\n if (tx.bytes.length > this.bounds.bytes) return;\n const old = this.#txs.get(tx.txid);\n if (old) {\n this.#txs.delete(tx.txid);\n this.#bytes -= old.bytes.length;\n }\n this.#txs.set(tx.txid, tx);\n this.#bytes += tx.bytes.length;\n // The oldest go first (a Map iterates in insertion order).\n for (const [id, entry] of this.#txs) {\n if (this.#txs.size <= this.bounds.entries && this.#bytes <= this.bounds.bytes)\n break;\n this.#txs.delete(id);\n this.#bytes -= entry.bytes.length;\n }\n }\n}\n\n/** One Esplora endpoint family (the `rpc` transport) and its address index (`indexer`). */\nexport class EsploraClient {\n readonly #previous: TxCache;\n readonly #own: TxCache;\n\n constructor(\n private readonly chain: Transport,\n private readonly indexer: Transport,\n private readonly cache: {\n readonly entries: number;\n readonly bytes: number;\n } = PREVIOUS_TX_CACHE,\n ) {\n this.#previous = new TxCache(cache);\n this.#own = new TxCache(cache);\n }\n\n #get<T>(\n transport: Transport,\n path: string,\n route: string,\n tags: UtxoCallTags,\n responseType: 'json' | 'text' = 'json',\n exactIntegers = false,\n ): Promise<T> {\n const request: HttpRequest = { method: 'GET', path, route, responseType };\n return transport.http<T>(request, exactIntegers ? { ...tags, exactIntegers } : tags);\n }\n\n async #orNull<T>(work: () => Promise<T>): Promise<T | null> {\n try {\n return await work();\n } catch (error) {\n if (isNotFound(error)) return null;\n throw error;\n }\n }\n\n async tipHeight(tags: UtxoCallTags): Promise<bigint> {\n return parseHeight(\n await this.#get(\n this.chain,\n '/blocks/tip/height',\n '/blocks/tip/height',\n tags,\n 'text',\n ),\n );\n }\n\n /** The hash of the block at `height` on this endpoint's best chain, or `null` above its tip. */\n blockHashAt(height: bigint, tags: UtxoCallTags): Promise<string | null> {\n return this.#orNull(async () =>\n parseHash(\n await this.#get(\n this.chain,\n `/block-height/${height}`,\n '/block-height/:height',\n tags,\n 'text',\n ),\n ),\n );\n }\n\n block(blockHash: string, tags: UtxoCallTags): Promise<EsploraBlock | null> {\n return this.#orNull(async () => {\n const block = parseBlock(\n await this.#get(\n this.chain,\n `/block/${segment(blockHash, 'id')}`,\n '/block/:hash',\n tags,\n ),\n );\n // The answer must be the block asked for.\n if (block.hash !== blockHash) throw malformed('block.id');\n return block;\n });\n }\n\n async blockTxids(blockHash: string, tags: UtxoCallTags): Promise<string[]> {\n const ids = await this.#get(\n this.chain,\n `/block/${segment(blockHash, 'id')}/txids`,\n '/block/:hash/txids',\n tags,\n );\n return list(ids, 'txids', (id) => hash(id, 'txid'));\n }\n\n /** Up to 25 transactions of a block from `start` (a multiple of 25). */\n async blockTxs(\n blockHash: string,\n start: number,\n tags: UtxoCallTags,\n ): Promise<EsploraTx[]> {\n const txs = await this.#get(\n this.chain,\n `/block/${segment(blockHash, 'id')}/txs/${start}`,\n '/block/:hash/txs/:start',\n tags,\n );\n return list(txs, 'block txs', parseTx);\n }\n\n tx(txid: string, tags: UtxoCallTags): Promise<EsploraTx | null> {\n return this.#orNull(async () => {\n const tx = parseTx(\n await this.#get(this.chain, `/tx/${segment(txid, 'id')}`, '/tx/:txid', tags),\n );\n // The answer must be the transaction asked for.\n if (tx.txid !== txid) throw malformed('tx.txid');\n return tx;\n });\n }\n\n /**\n * `/tx/:txid/hex`, decoded strictly once and bound to `txid`: bytes that do not decode are\n * malformed, and the bytes of another transaction are a retryable `PROVIDER_INCONSISTENT`,\n * so a garbled answer is never taken for the caller's error. The decoder's cap is the\n * largest transaction a block can hold, never what this library builds. Under\n * a quorum, each endpoint's answer is keyed on the txid its bytes hash to, and the answer\n * the quorum returns is not decoded again.\n */\n async #rawTx<T extends { readonly txid: string }>(\n txid: string,\n tags: UtxoCallTags,\n decode: (hex: string) => T | undefined,\n ): Promise<{ readonly hex: string; readonly tx: T }> {\n const decoded = new Map<string, T | undefined>();\n const read = (answer: unknown): { hex: string; tx: T | undefined } => {\n const hex = typeof answer === 'string' ? answer.trim() : '';\n if (!decoded.has(hex)) {\n decoded.set(hex, hex.length > 0 && isHex(hex) ? decode(hex) : undefined);\n }\n return { hex, tx: decoded.get(hex) };\n };\n const keyed: UtxoCallTags =\n tags.quorum === undefined\n ? tags\n : {\n ...tags,\n // A throwing key counts as a disagreement.\n quorumKey: (answer) => {\n const { tx } = read(answer);\n if (!tx) throw malformed('tx hex');\n return tx.txid;\n },\n };\n const answer = await this.#get(\n this.chain,\n `/tx/${segment(txid, 'id')}/hex`,\n '/tx/:txid/hex',\n keyed,\n 'text',\n );\n const { hex, tx } = read(answer);\n if (!tx) throw malformed('tx hex');\n if (tx.txid !== txid) {\n throw new ProviderError(\n 'PROVIDER_INCONSISTENT',\n 'the transaction bytes do not hash to the id asked for',\n { retryable: true },\n );\n }\n return { hex, tx };\n }\n\n /** The raw transaction, as hex, bound to `txid` (see `#rawTx`). */\n txHex(txid: string, tags: UtxoCallTags): Promise<string | null> {\n return this.#orNull(async () => (await this.#rawTx(txid, tags, txidOf)).hex);\n }\n\n /**\n * An input's previous transaction, decoded once and bound to `txid` (see\n * `#rawTx`). Its bytes authenticate themselves, so it is kept per txid, whatever endpoint\n * served it, in a bounded cache: a replacement's inputs are read once per client.\n */\n async previousTx(txid: string, tags: UtxoCallTags): Promise<PreviousTx | null> {\n const known = this.#own.get(txid) ?? this.#previous.get(txid);\n if (known) return known;\n const found = await this.#orNull(\n async () => (await this.#rawTx(txid, tags, previousTxOf)).tx,\n );\n if (found) this.#previous.set(found);\n return found;\n }\n\n /**\n * A transaction this client sent for an Attempt and a node took. Its bytes are\n * known here, so its outputs are not an indexer's word even before a block holds it, and\n * under `minInputConfirmations: 0` they may be spent unconfirmed. Kept like the cache.\n */\n rememberOwn(tx: PreviousTx): void {\n this.#own.set(tx);\n }\n\n isOwn(txid: string): boolean {\n return this.#own.has(txid);\n }\n\n async outspend(\n txid: string,\n vout: number,\n tags: UtxoCallTags,\n ): Promise<EsploraOutspend> {\n return parseOutspend(\n await this.#get(\n this.chain,\n `/tx/${segment(txid, 'id')}/outspend/${vout}`,\n '/tx/:txid/outspend/:vout',\n tags,\n ),\n );\n }\n\n async feeEstimates(tags: UtxoCallTags): Promise<ReadonlyMap<number, number>> {\n return parseFeeEstimates(\n await this.#get(this.chain, '/fee-estimates', '/fee-estimates', tags),\n );\n }\n\n /** `POST /tx`: the node's txid on success; a node refusal is the transport's `RPC_ERROR`. */\n async broadcast(hex: string, tags: UtxoCallTags): Promise<string> {\n const answer = await this.chain.http<string>(\n { method: 'POST', path: '/tx', route: '/tx', body: hex, responseType: 'text' },\n tags,\n );\n if (typeof answer !== 'string' || !HEX64.test(answer.trim())) {\n // The node answered 2xx, so the bytes may have been accepted.\n throw new ProviderError(\n 'PROVIDER_UNAVAILABLE',\n 'malformed Esplora answer: broadcast txid',\n {\n ambiguous: true,\n },\n );\n }\n return answer.trim();\n }\n\n async addressUtxos(address: string, tags: UtxoCallTags): Promise<EsploraUtxo[]> {\n const utxos = await this.#get(\n this.indexer,\n `/address/${segment(address, 'address')}/utxo`,\n '/address/:address/utxo',\n tags,\n );\n return list(utxos, 'utxo list', parseUtxo);\n }\n\n async addressStats(address: string, tags: UtxoCallTags): Promise<EsploraAddressStats> {\n const info = record(\n await this.#get(\n this.indexer,\n `/address/${segment(address, 'address')}`,\n '/address/:address',\n tags,\n 'json',\n true,\n ),\n 'address',\n );\n const chain = record(info.chain_stats, 'chain_stats');\n const funded = total(chain.funded_txo_sum, 'funded_txo_sum');\n const spent = total(chain.spent_txo_sum, 'spent_txo_sum');\n // The totals are unbounded; the balance is the chain's: 0 to 21 million bitcoin.\n if (spent > funded || funded - spent > MAX_MONEY) throw malformed('address balance');\n return { funded, spent };\n }\n\n /** Confirmed history, newest first, 25 per page, after `lastSeen` when given. */\n async addressTxs(\n address: string,\n lastSeen: string | undefined,\n tags: UtxoCallTags,\n ): Promise<EsploraTx[]> {\n const base = `/address/${segment(address, 'address')}/txs/chain`;\n const path = lastSeen ? `${base}/${segment(lastSeen, 'id')}` : base;\n const route = lastSeen\n ? '/address/:address/txs/chain/:last_seen_txid'\n : '/address/:address/txs/chain';\n return list(await this.#get(this.indexer, path, route, tags), 'address txs', parseTx);\n }\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { FeeOverride, FeeSpeed } from '../../core/model/fee';
|
|
2
|
+
import type { UtxoNetworkConfig } from './network';
|
|
3
|
+
/** Confirmation targets (blocks) per speed: library policy, not a network fact. */
|
|
4
|
+
export declare const SPEED_TARGETS: Readonly<Record<FeeSpeed, number>>;
|
|
5
|
+
type FeePolicy = Pick<UtxoNetworkConfig, 'minRelayFee' | 'feeFallback' | 'maxFeeRate' | 'maxFee' | 'maxEstimatedFeeRate'>;
|
|
6
|
+
/** Esplora's sat/vB float as sat/kvB, rounded up after removing float noise. */
|
|
7
|
+
export declare function satPerKvB(satPerVByte: number): bigint;
|
|
8
|
+
/**
|
|
9
|
+
* The rate for a speed: the estimate at its target, else at the nearest faster target the
|
|
10
|
+
* endpoint has; never below the minimum relay fee. With no usable estimate, a test
|
|
11
|
+
* network's `feeFallback`, else a retryable `PROVIDER_UNAVAILABLE` (nothing is guessed).
|
|
12
|
+
* The relay floor clamps the fallback too: it is registry data, never checked against
|
|
13
|
+
* `minRelayFee`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function rateForSpeed(estimates: ReadonlyMap<number, number>, speed: FeeSpeed, policy: FeePolicy): bigint;
|
|
16
|
+
/** `{ satPerVByte }` as sat/kvB. `INVALID_INTENT` when malformed, `FEE_TOO_LOW` below relay. */
|
|
17
|
+
export declare function rateFromOverride(override: FeeOverride, policy: FeePolicy): bigint;
|
|
18
|
+
/** Bitcoin Core's `CFeeRate::GetFee`: `rate × vsize / 1000`, rounded up. */
|
|
19
|
+
export declare function feeAt(rate: bigint, vsize: number): bigint;
|
|
20
|
+
/**
|
|
21
|
+
* The absurd-fee guard (a burn of funds by a fee bug or a fat-fingered override): refuses
|
|
22
|
+
* a fee above `maxFee` or a rate above `maxFeeRate` before anything is signed.
|
|
23
|
+
*/
|
|
24
|
+
export declare function assertSaneFee(fee: bigint, vsize: number, policy: FeePolicy): void;
|
|
25
|
+
export interface PaidFee {
|
|
26
|
+
readonly fee: bigint;
|
|
27
|
+
/** Estimated with worst-case signatures (an upper bound of the real size). */
|
|
28
|
+
readonly vsize: number;
|
|
29
|
+
/**
|
|
30
|
+
* A lower bound of the real size: a signature can be shorter than the worst case the
|
|
31
|
+
* estimate assumes. Default `vsize`.
|
|
32
|
+
*/
|
|
33
|
+
readonly minVsize?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The least fee a replacement of `vsize` may pay over `previous` (rules 3, 4 and 6). It does
|
|
37
|
+
* not count descendants of the replaced transaction (a recipient's CPFP): a node then refuses
|
|
38
|
+
* with `FEE_TOO_LOW`, and a higher explicit fee resolves it.
|
|
39
|
+
*/
|
|
40
|
+
export declare function replacementFloor(previous: PaidFee, vsize: number, incrementalRelayFee: bigint): bigint;
|
|
41
|
+
export {};
|