@getomnichain/omnichain 0.2.0 → 0.3.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/dist/cjs/abstract_gas_pricing.js +27 -0
- package/dist/cjs/abstract_gas_pricing.js.map +1 -0
- package/dist/cjs/address.factory.js +81 -0
- package/dist/cjs/address.factory.js.map +1 -0
- package/dist/cjs/address.js +17 -0
- package/dist/cjs/address.js.map +1 -0
- package/dist/cjs/address_field.decorator.js +37 -0
- package/dist/cjs/address_field.decorator.js.map +1 -0
- package/dist/cjs/chain.base.js +118 -0
- package/dist/cjs/chain.base.js.map +1 -0
- package/dist/cjs/chain_ids.js +205 -0
- package/dist/cjs/chain_ids.js.map +1 -0
- package/dist/cjs/errors.js +118 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/evm/evm_address.js +63 -0
- package/dist/cjs/evm/evm_address.js.map +1 -0
- package/dist/cjs/evm/evm_chain.js +1109 -0
- package/dist/cjs/evm/evm_chain.js.map +1 -0
- package/dist/cjs/evm/evm_chains.js +530 -0
- package/dist/cjs/evm/evm_chains.js.map +1 -0
- package/dist/cjs/evm/evm_gas_estimate.js +76 -0
- package/dist/cjs/evm/evm_gas_estimate.js.map +1 -0
- package/dist/cjs/evm/evm_gas_pricing.js +62 -0
- package/dist/cjs/evm/evm_gas_pricing.js.map +1 -0
- package/dist/cjs/evm/evm_token.js +26 -0
- package/dist/cjs/evm/evm_token.js.map +1 -0
- package/dist/cjs/evm/evm_tokens.js +109 -0
- package/dist/cjs/evm/evm_tokens.js.map +1 -0
- package/dist/cjs/evm/evm_transaction_status.js +187 -0
- package/dist/cjs/evm/evm_transaction_status.js.map +1 -0
- package/dist/cjs/evm/index.js +26 -0
- package/dist/cjs/evm/index.js.map +1 -0
- package/dist/cjs/evm/unsigned_evm_transaction.js +34 -0
- package/dist/cjs/evm/unsigned_evm_transaction.js.map +1 -0
- package/dist/cjs/index.js +34 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/is_address.decorator.js +54 -0
- package/dist/cjs/is_address.decorator.js.map +1 -0
- package/dist/cjs/network_type.js +152 -0
- package/dist/cjs/network_type.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/priority.js +26 -0
- package/dist/cjs/priority.js.map +1 -0
- package/dist/cjs/solana/index.js +25 -0
- package/dist/cjs/solana/index.js.map +1 -0
- package/dist/cjs/solana/solana_address.js +49 -0
- package/dist/cjs/solana/solana_address.js.map +1 -0
- package/dist/cjs/solana/solana_chain.js +1305 -0
- package/dist/cjs/solana/solana_chain.js.map +1 -0
- package/dist/cjs/solana/solana_chains.js +88 -0
- package/dist/cjs/solana/solana_chains.js.map +1 -0
- package/dist/cjs/solana/solana_gas_pricing.js +30 -0
- package/dist/cjs/solana/solana_gas_pricing.js.map +1 -0
- package/dist/cjs/solana/solana_token.js +38 -0
- package/dist/cjs/solana/solana_token.js.map +1 -0
- package/dist/cjs/solana/solana_tokens.js +29 -0
- package/dist/cjs/solana/solana_tokens.js.map +1 -0
- package/dist/cjs/solana/solana_transaction_status.js +149 -0
- package/dist/cjs/solana/solana_transaction_status.js.map +1 -0
- package/dist/cjs/solana/unsigned_solana_transaction.js +63 -0
- package/dist/cjs/solana/unsigned_solana_transaction.js.map +1 -0
- package/dist/cjs/token.js +66 -0
- package/dist/cjs/token.js.map +1 -0
- package/dist/cjs/ton/index.js +18 -0
- package/dist/cjs/ton/index.js.map +1 -0
- package/dist/cjs/ton/ton_address.js +57 -0
- package/dist/cjs/ton/ton_address.js.map +1 -0
- package/dist/cjs/transaction_status.js +283 -0
- package/dist/cjs/transaction_status.js.map +1 -0
- package/dist/cjs/unsigned_transaction.js +13 -0
- package/dist/cjs/unsigned_transaction.js.map +1 -0
- package/dist/cjs/utxo/btc/btc_address.js +43 -0
- package/dist/cjs/utxo/btc/btc_address.js.map +1 -0
- package/dist/cjs/utxo/btc/btc_chain.js +66 -0
- package/dist/cjs/utxo/btc/btc_chain.js.map +1 -0
- package/dist/cjs/utxo/btc/btc_chains.js +49 -0
- package/dist/cjs/utxo/btc/btc_chains.js.map +1 -0
- package/dist/cjs/utxo/btc/btc_token.js +15 -0
- package/dist/cjs/utxo/btc/btc_token.js.map +1 -0
- package/dist/cjs/utxo/btc/index.js +30 -0
- package/dist/cjs/utxo/btc/index.js.map +1 -0
- package/dist/cjs/utxo/btc/network_params.js +196 -0
- package/dist/cjs/utxo/btc/network_params.js.map +1 -0
- package/dist/cjs/utxo/btc/tools/asset_outpoint.js +16 -0
- package/dist/cjs/utxo/btc/tools/asset_outpoint.js.map +1 -0
- package/dist/cjs/utxo/btc/tools/bitcoin_core.tool.js +179 -0
- package/dist/cjs/utxo/btc/tools/bitcoin_core.tool.js.map +1 -0
- package/dist/cjs/utxo/btc/tools/esplora.tool.js +120 -0
- package/dist/cjs/utxo/btc/tools/esplora.tool.js.map +1 -0
- package/dist/cjs/utxo/btc/tools/inscription_index.js +3 -0
- package/dist/cjs/utxo/btc/tools/inscription_index.js.map +1 -0
- package/dist/cjs/utxo/btc/tools/ordiscan.tool.js +60 -0
- package/dist/cjs/utxo/btc/tools/ordiscan.tool.js.map +1 -0
- package/dist/cjs/utxo/btc/tools/rare_sat_index.js +3 -0
- package/dist/cjs/utxo/btc/tools/rare_sat_index.js.map +1 -0
- package/dist/cjs/utxo/btc/tools/rune_index.js +3 -0
- package/dist/cjs/utxo/btc/tools/rune_index.js.map +1 -0
- package/dist/cjs/utxo/btc/tools/unisat.tool.js +56 -0
- package/dist/cjs/utxo/btc/tools/unisat.tool.js.map +1 -0
- package/dist/cjs/utxo/coin_selection.js +160 -0
- package/dist/cjs/utxo/coin_selection.js.map +1 -0
- package/dist/cjs/utxo/doge/doge_chains.js +32 -0
- package/dist/cjs/utxo/doge/doge_chains.js.map +1 -0
- package/dist/cjs/utxo/doge/index.js +19 -0
- package/dist/cjs/utxo/doge/index.js.map +1 -0
- package/dist/cjs/utxo/doge/network_params.js +30 -0
- package/dist/cjs/utxo/doge/network_params.js.map +1 -0
- package/dist/cjs/utxo/ecc.js +47 -0
- package/dist/cjs/utxo/ecc.js.map +1 -0
- package/dist/cjs/utxo/fee.js +61 -0
- package/dist/cjs/utxo/fee.js.map +1 -0
- package/dist/cjs/utxo/index.js +36 -0
- package/dist/cjs/utxo/index.js.map +1 -0
- package/dist/cjs/utxo/ltc/index.js +19 -0
- package/dist/cjs/utxo/ltc/index.js.map +1 -0
- package/dist/cjs/utxo/ltc/ltc_chains.js +32 -0
- package/dist/cjs/utxo/ltc/ltc_chains.js.map +1 -0
- package/dist/cjs/utxo/ltc/network_params.js +33 -0
- package/dist/cjs/utxo/ltc/network_params.js.map +1 -0
- package/dist/cjs/utxo/script.js +59 -0
- package/dist/cjs/utxo/script.js.map +1 -0
- package/dist/cjs/utxo/tools/broadcaster.js +3 -0
- package/dist/cjs/utxo/tools/broadcaster.js.map +1 -0
- package/dist/cjs/utxo/tools/chain_tip_provider.js +3 -0
- package/dist/cjs/utxo/tools/chain_tip_provider.js.map +1 -0
- package/dist/cjs/utxo/tools/fee_estimator.js +3 -0
- package/dist/cjs/utxo/tools/fee_estimator.js.map +1 -0
- package/dist/cjs/utxo/tools/raw_transaction_provider.js +3 -0
- package/dist/cjs/utxo/tools/raw_transaction_provider.js.map +1 -0
- package/dist/cjs/utxo/tools/utxo_provider.js +3 -0
- package/dist/cjs/utxo/tools/utxo_provider.js.map +1 -0
- package/dist/cjs/utxo/unsigned_utxo_transaction.js +36 -0
- package/dist/cjs/utxo/unsigned_utxo_transaction.js.map +1 -0
- package/dist/cjs/utxo/utxo.js +3 -0
- package/dist/{utxo → cjs/utxo}/utxo.js.map +1 -1
- package/dist/cjs/utxo/utxo_chain.js +612 -0
- package/dist/cjs/utxo/utxo_chain.js.map +1 -0
- package/dist/cjs/utxo/utxo_chains.js +68 -0
- package/dist/cjs/utxo/utxo_chains.js.map +1 -0
- package/dist/cjs/utxo/utxo_gas_pricing.js +24 -0
- package/dist/cjs/utxo/utxo_gas_pricing.js.map +1 -0
- package/dist/cjs/utxo/utxo_network_params.js +18 -0
- package/dist/cjs/utxo/utxo_network_params.js.map +1 -0
- package/dist/cjs/utxo/utxo_transaction_status.js +95 -0
- package/dist/cjs/utxo/utxo_transaction_status.js.map +1 -0
- package/dist/esm/abstract_gas_pricing.d.ts.map +1 -0
- package/dist/esm/abstract_gas_pricing.js.map +1 -0
- package/dist/esm/address.d.ts.map +1 -0
- package/dist/esm/address.factory.d.ts.map +1 -0
- package/dist/esm/address.factory.js.map +1 -0
- package/dist/esm/address.js.map +1 -0
- package/dist/esm/address_field.decorator.d.ts.map +1 -0
- package/dist/esm/address_field.decorator.js.map +1 -0
- package/dist/{chain.base.d.ts → esm/chain.base.d.ts} +38 -1
- package/dist/esm/chain.base.d.ts.map +1 -0
- package/dist/esm/chain.base.js.map +1 -0
- package/dist/esm/chain_ids.d.ts.map +1 -0
- package/dist/esm/chain_ids.js.map +1 -0
- package/dist/{errors.d.ts → esm/errors.d.ts} +13 -0
- package/dist/esm/errors.d.ts.map +1 -0
- package/dist/esm/errors.js +107 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/evm/evm_address.d.ts.map +1 -0
- package/dist/esm/evm/evm_address.js.map +1 -0
- package/dist/{evm → esm/evm}/evm_chain.d.ts +48 -2
- package/dist/esm/evm/evm_chain.d.ts.map +1 -0
- package/dist/{evm → esm/evm}/evm_chain.js +423 -4
- package/dist/esm/evm/evm_chain.js.map +1 -0
- package/dist/esm/evm/evm_chains.d.ts.map +1 -0
- package/dist/esm/evm/evm_chains.js.map +1 -0
- package/dist/esm/evm/evm_gas_estimate.d.ts.map +1 -0
- package/dist/esm/evm/evm_gas_estimate.js.map +1 -0
- package/dist/esm/evm/evm_gas_pricing.d.ts.map +1 -0
- package/dist/esm/evm/evm_gas_pricing.js.map +1 -0
- package/dist/esm/evm/evm_token.d.ts.map +1 -0
- package/dist/esm/evm/evm_token.js.map +1 -0
- package/dist/esm/evm/evm_tokens.d.ts.map +1 -0
- package/dist/esm/evm/evm_tokens.js.map +1 -0
- package/dist/{evm → esm/evm}/evm_transaction_status.d.ts +4 -0
- package/dist/esm/evm/evm_transaction_status.d.ts.map +1 -0
- package/dist/{evm → esm/evm}/evm_transaction_status.js +4 -0
- package/dist/esm/evm/evm_transaction_status.js.map +1 -0
- package/dist/esm/evm/index.d.ts.map +1 -0
- package/dist/esm/evm/index.js.map +1 -0
- package/dist/{evm → esm/evm}/unsigned_evm_transaction.d.ts +13 -0
- package/dist/esm/evm/unsigned_evm_transaction.d.ts.map +1 -0
- package/dist/{evm → esm/evm}/unsigned_evm_transaction.js +12 -0
- package/dist/esm/evm/unsigned_evm_transaction.js.map +1 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/is_address.decorator.d.ts.map +1 -0
- package/dist/esm/is_address.decorator.js.map +1 -0
- package/dist/esm/network_type.d.ts.map +1 -0
- package/dist/esm/network_type.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/priority.d.ts.map +1 -0
- package/dist/esm/priority.js.map +1 -0
- package/dist/esm/solana/index.d.ts.map +1 -0
- package/dist/esm/solana/index.js.map +1 -0
- package/dist/esm/solana/solana_address.d.ts.map +1 -0
- package/dist/esm/solana/solana_address.js.map +1 -0
- package/dist/{solana → esm/solana}/solana_chain.d.ts +87 -3
- package/dist/esm/solana/solana_chain.d.ts.map +1 -0
- package/dist/{solana → esm/solana}/solana_chain.js +618 -23
- package/dist/esm/solana/solana_chain.js.map +1 -0
- package/dist/esm/solana/solana_chains.d.ts.map +1 -0
- package/dist/esm/solana/solana_chains.js.map +1 -0
- package/dist/esm/solana/solana_gas_pricing.d.ts.map +1 -0
- package/dist/esm/solana/solana_gas_pricing.js.map +1 -0
- package/dist/esm/solana/solana_token.d.ts.map +1 -0
- package/dist/esm/solana/solana_token.js.map +1 -0
- package/dist/esm/solana/solana_tokens.d.ts.map +1 -0
- package/dist/esm/solana/solana_tokens.js.map +1 -0
- package/dist/esm/solana/solana_transaction_status.d.ts.map +1 -0
- package/dist/esm/solana/solana_transaction_status.js.map +1 -0
- package/dist/{solana → esm/solana}/unsigned_solana_transaction.d.ts +20 -1
- package/dist/esm/solana/unsigned_solana_transaction.d.ts.map +1 -0
- package/dist/esm/solana/unsigned_solana_transaction.js +59 -0
- package/dist/esm/solana/unsigned_solana_transaction.js.map +1 -0
- package/dist/esm/token.d.ts.map +1 -0
- package/dist/esm/token.js.map +1 -0
- package/dist/esm/ton/index.d.ts.map +1 -0
- package/dist/esm/ton/index.js.map +1 -0
- package/dist/esm/ton/ton_address.d.ts.map +1 -0
- package/dist/esm/ton/ton_address.js.map +1 -0
- package/dist/esm/transaction_status.d.ts.map +1 -0
- package/dist/esm/transaction_status.js.map +1 -0
- package/dist/esm/unsigned_transaction.d.ts.map +1 -0
- package/dist/esm/unsigned_transaction.js.map +1 -0
- package/dist/esm/utxo/btc/btc_address.d.ts.map +1 -0
- package/dist/esm/utxo/btc/btc_address.js.map +1 -0
- package/dist/esm/utxo/btc/btc_chain.d.ts.map +1 -0
- package/dist/esm/utxo/btc/btc_chain.js.map +1 -0
- package/dist/esm/utxo/btc/btc_chains.d.ts.map +1 -0
- package/dist/esm/utxo/btc/btc_chains.js.map +1 -0
- package/dist/esm/utxo/btc/btc_token.d.ts.map +1 -0
- package/dist/esm/utxo/btc/btc_token.js.map +1 -0
- package/dist/esm/utxo/btc/index.d.ts.map +1 -0
- package/dist/esm/utxo/btc/index.js.map +1 -0
- package/dist/esm/utxo/btc/network_params.d.ts.map +1 -0
- package/dist/esm/utxo/btc/network_params.js.map +1 -0
- package/dist/esm/utxo/btc/tools/asset_outpoint.d.ts.map +1 -0
- package/dist/esm/utxo/btc/tools/asset_outpoint.js.map +1 -0
- package/dist/esm/utxo/btc/tools/bitcoin_core.tool.d.ts.map +1 -0
- package/dist/esm/utxo/btc/tools/bitcoin_core.tool.js.map +1 -0
- package/dist/esm/utxo/btc/tools/esplora.tool.d.ts.map +1 -0
- package/dist/esm/utxo/btc/tools/esplora.tool.js.map +1 -0
- package/dist/esm/utxo/btc/tools/inscription_index.d.ts.map +1 -0
- package/dist/esm/utxo/btc/tools/inscription_index.js.map +1 -0
- package/dist/esm/utxo/btc/tools/ordiscan.tool.d.ts.map +1 -0
- package/dist/esm/utxo/btc/tools/ordiscan.tool.js.map +1 -0
- package/dist/esm/utxo/btc/tools/rare_sat_index.d.ts.map +1 -0
- package/dist/esm/utxo/btc/tools/rare_sat_index.js.map +1 -0
- package/dist/esm/utxo/btc/tools/rune_index.d.ts.map +1 -0
- package/dist/esm/utxo/btc/tools/rune_index.js.map +1 -0
- package/dist/esm/utxo/btc/tools/unisat.tool.d.ts.map +1 -0
- package/dist/esm/utxo/btc/tools/unisat.tool.js.map +1 -0
- package/dist/esm/utxo/coin_selection.d.ts.map +1 -0
- package/dist/esm/utxo/coin_selection.js.map +1 -0
- package/dist/esm/utxo/doge/doge_chains.d.ts.map +1 -0
- package/dist/esm/utxo/doge/doge_chains.js.map +1 -0
- package/dist/esm/utxo/doge/index.d.ts.map +1 -0
- package/dist/esm/utxo/doge/index.js.map +1 -0
- package/dist/esm/utxo/doge/network_params.d.ts.map +1 -0
- package/dist/esm/utxo/doge/network_params.js.map +1 -0
- package/dist/esm/utxo/ecc.d.ts.map +1 -0
- package/dist/esm/utxo/ecc.js.map +1 -0
- package/dist/esm/utxo/fee.d.ts.map +1 -0
- package/dist/esm/utxo/fee.js.map +1 -0
- package/dist/esm/utxo/index.d.ts.map +1 -0
- package/dist/esm/utxo/index.js.map +1 -0
- package/dist/esm/utxo/ltc/index.d.ts.map +1 -0
- package/dist/esm/utxo/ltc/index.js.map +1 -0
- package/dist/{utxo/doge/doge_chains.d.ts.map → esm/utxo/ltc/ltc_chains.d.ts.map} +1 -1
- package/dist/{utxo/doge/doge_chains.js.map → esm/utxo/ltc/ltc_chains.js.map} +1 -1
- package/dist/esm/utxo/ltc/network_params.d.ts.map +1 -0
- package/dist/esm/utxo/ltc/network_params.js.map +1 -0
- package/dist/esm/utxo/script.d.ts.map +1 -0
- package/dist/esm/utxo/script.js.map +1 -0
- package/dist/esm/utxo/tools/broadcaster.d.ts.map +1 -0
- package/dist/esm/utxo/tools/broadcaster.js.map +1 -0
- package/dist/esm/utxo/tools/chain_tip_provider.d.ts.map +1 -0
- package/dist/esm/utxo/tools/chain_tip_provider.js.map +1 -0
- package/dist/esm/utxo/tools/fee_estimator.d.ts.map +1 -0
- package/dist/esm/utxo/tools/fee_estimator.js.map +1 -0
- package/dist/esm/utxo/tools/raw_transaction_provider.d.ts.map +1 -0
- package/dist/esm/utxo/tools/raw_transaction_provider.js.map +1 -0
- package/dist/esm/utxo/tools/utxo_provider.d.ts.map +1 -0
- package/dist/esm/utxo/tools/utxo_provider.js.map +1 -0
- package/dist/esm/utxo/unsigned_utxo_transaction.d.ts.map +1 -0
- package/dist/esm/utxo/unsigned_utxo_transaction.js.map +1 -0
- package/dist/esm/utxo/utxo.d.ts.map +1 -0
- package/dist/esm/utxo/utxo.js.map +1 -0
- package/dist/{utxo → esm/utxo}/utxo_chain.d.ts +15 -2
- package/dist/esm/utxo/utxo_chain.d.ts.map +1 -0
- package/dist/{utxo → esm/utxo}/utxo_chain.js +96 -13
- package/dist/esm/utxo/utxo_chain.js.map +1 -0
- package/dist/esm/utxo/utxo_chains.d.ts.map +1 -0
- package/dist/esm/utxo/utxo_chains.js.map +1 -0
- package/dist/esm/utxo/utxo_gas_pricing.d.ts.map +1 -0
- package/dist/esm/utxo/utxo_gas_pricing.js.map +1 -0
- package/dist/esm/utxo/utxo_network_params.d.ts.map +1 -0
- package/dist/esm/utxo/utxo_network_params.js.map +1 -0
- package/dist/esm/utxo/utxo_transaction_status.d.ts.map +1 -0
- package/dist/esm/utxo/utxo_transaction_status.js.map +1 -0
- package/docs/CONNECTIONS.md +33 -0
- package/docs/EIP7702.md +77 -0
- package/docs/JITO.md +41 -0
- package/docs/MULTI_RPC.md +28 -0
- package/package.json +32 -16
- package/dist/abstract_gas_pricing.d.ts.map +0 -1
- package/dist/abstract_gas_pricing.js.map +0 -1
- package/dist/address.d.ts.map +0 -1
- package/dist/address.factory.d.ts.map +0 -1
- package/dist/address.factory.js.map +0 -1
- package/dist/address.js.map +0 -1
- package/dist/address_field.decorator.d.ts.map +0 -1
- package/dist/address_field.decorator.js.map +0 -1
- package/dist/chain.base.d.ts.map +0 -1
- package/dist/chain.base.js.map +0 -1
- package/dist/chain_ids.d.ts.map +0 -1
- package/dist/chain_ids.js.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -62
- package/dist/errors.js.map +0 -1
- package/dist/evm/evm_address.d.ts.map +0 -1
- package/dist/evm/evm_address.js.map +0 -1
- package/dist/evm/evm_chain.d.ts.map +0 -1
- package/dist/evm/evm_chain.js.map +0 -1
- package/dist/evm/evm_chains.d.ts.map +0 -1
- package/dist/evm/evm_chains.js.map +0 -1
- package/dist/evm/evm_gas_estimate.d.ts.map +0 -1
- package/dist/evm/evm_gas_estimate.js.map +0 -1
- package/dist/evm/evm_gas_pricing.d.ts.map +0 -1
- package/dist/evm/evm_gas_pricing.js.map +0 -1
- package/dist/evm/evm_token.d.ts.map +0 -1
- package/dist/evm/evm_token.js.map +0 -1
- package/dist/evm/evm_tokens.d.ts.map +0 -1
- package/dist/evm/evm_tokens.js.map +0 -1
- package/dist/evm/evm_transaction_status.d.ts.map +0 -1
- package/dist/evm/evm_transaction_status.js.map +0 -1
- package/dist/evm/index.d.ts.map +0 -1
- package/dist/evm/index.js.map +0 -1
- package/dist/evm/unsigned_evm_transaction.d.ts.map +0 -1
- package/dist/evm/unsigned_evm_transaction.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/is_address.decorator.d.ts.map +0 -1
- package/dist/is_address.decorator.js.map +0 -1
- package/dist/network_type.d.ts.map +0 -1
- package/dist/network_type.js.map +0 -1
- package/dist/priority.d.ts.map +0 -1
- package/dist/priority.js.map +0 -1
- package/dist/solana/index.d.ts.map +0 -1
- package/dist/solana/index.js.map +0 -1
- package/dist/solana/solana_address.d.ts.map +0 -1
- package/dist/solana/solana_address.js.map +0 -1
- package/dist/solana/solana_chain.d.ts.map +0 -1
- package/dist/solana/solana_chain.js.map +0 -1
- package/dist/solana/solana_chains.d.ts.map +0 -1
- package/dist/solana/solana_chains.js.map +0 -1
- package/dist/solana/solana_gas_pricing.d.ts.map +0 -1
- package/dist/solana/solana_gas_pricing.js.map +0 -1
- package/dist/solana/solana_token.d.ts.map +0 -1
- package/dist/solana/solana_token.js.map +0 -1
- package/dist/solana/solana_tokens.d.ts.map +0 -1
- package/dist/solana/solana_tokens.js.map +0 -1
- package/dist/solana/solana_transaction_status.d.ts.map +0 -1
- package/dist/solana/solana_transaction_status.js.map +0 -1
- package/dist/solana/unsigned_solana_transaction.d.ts.map +0 -1
- package/dist/solana/unsigned_solana_transaction.js +0 -26
- package/dist/solana/unsigned_solana_transaction.js.map +0 -1
- package/dist/token.d.ts.map +0 -1
- package/dist/token.js.map +0 -1
- package/dist/ton/index.d.ts.map +0 -1
- package/dist/ton/index.js.map +0 -1
- package/dist/ton/ton_address.d.ts.map +0 -1
- package/dist/ton/ton_address.js.map +0 -1
- package/dist/transaction_status.d.ts.map +0 -1
- package/dist/transaction_status.js.map +0 -1
- package/dist/unsigned_transaction.d.ts.map +0 -1
- package/dist/unsigned_transaction.js.map +0 -1
- package/dist/utxo/btc/btc_address.d.ts.map +0 -1
- package/dist/utxo/btc/btc_address.js.map +0 -1
- package/dist/utxo/btc/btc_chain.d.ts.map +0 -1
- package/dist/utxo/btc/btc_chain.js.map +0 -1
- package/dist/utxo/btc/btc_chains.d.ts.map +0 -1
- package/dist/utxo/btc/btc_chains.js.map +0 -1
- package/dist/utxo/btc/btc_token.d.ts.map +0 -1
- package/dist/utxo/btc/btc_token.js.map +0 -1
- package/dist/utxo/btc/index.d.ts.map +0 -1
- package/dist/utxo/btc/index.js.map +0 -1
- package/dist/utxo/btc/network_params.d.ts.map +0 -1
- package/dist/utxo/btc/network_params.js.map +0 -1
- package/dist/utxo/btc/tools/asset_outpoint.d.ts.map +0 -1
- package/dist/utxo/btc/tools/asset_outpoint.js.map +0 -1
- package/dist/utxo/btc/tools/bitcoin_core.tool.d.ts.map +0 -1
- package/dist/utxo/btc/tools/bitcoin_core.tool.js.map +0 -1
- package/dist/utxo/btc/tools/esplora.tool.d.ts.map +0 -1
- package/dist/utxo/btc/tools/esplora.tool.js.map +0 -1
- package/dist/utxo/btc/tools/inscription_index.d.ts.map +0 -1
- package/dist/utxo/btc/tools/inscription_index.js.map +0 -1
- package/dist/utxo/btc/tools/ordiscan.tool.d.ts.map +0 -1
- package/dist/utxo/btc/tools/ordiscan.tool.js.map +0 -1
- package/dist/utxo/btc/tools/rare_sat_index.d.ts.map +0 -1
- package/dist/utxo/btc/tools/rare_sat_index.js.map +0 -1
- package/dist/utxo/btc/tools/rune_index.d.ts.map +0 -1
- package/dist/utxo/btc/tools/rune_index.js.map +0 -1
- package/dist/utxo/btc/tools/unisat.tool.d.ts.map +0 -1
- package/dist/utxo/btc/tools/unisat.tool.js.map +0 -1
- package/dist/utxo/coin_selection.d.ts.map +0 -1
- package/dist/utxo/coin_selection.js.map +0 -1
- package/dist/utxo/doge/index.d.ts.map +0 -1
- package/dist/utxo/doge/index.js.map +0 -1
- package/dist/utxo/doge/network_params.d.ts.map +0 -1
- package/dist/utxo/doge/network_params.js.map +0 -1
- package/dist/utxo/ecc.d.ts.map +0 -1
- package/dist/utxo/ecc.js.map +0 -1
- package/dist/utxo/fee.d.ts.map +0 -1
- package/dist/utxo/fee.js.map +0 -1
- package/dist/utxo/index.d.ts.map +0 -1
- package/dist/utxo/index.js.map +0 -1
- package/dist/utxo/ltc/index.d.ts.map +0 -1
- package/dist/utxo/ltc/index.js.map +0 -1
- package/dist/utxo/ltc/ltc_chains.d.ts.map +0 -1
- package/dist/utxo/ltc/ltc_chains.js.map +0 -1
- package/dist/utxo/ltc/network_params.d.ts.map +0 -1
- package/dist/utxo/ltc/network_params.js.map +0 -1
- package/dist/utxo/script.d.ts.map +0 -1
- package/dist/utxo/script.js.map +0 -1
- package/dist/utxo/tools/broadcaster.d.ts.map +0 -1
- package/dist/utxo/tools/broadcaster.js.map +0 -1
- package/dist/utxo/tools/chain_tip_provider.d.ts.map +0 -1
- package/dist/utxo/tools/chain_tip_provider.js.map +0 -1
- package/dist/utxo/tools/fee_estimator.d.ts.map +0 -1
- package/dist/utxo/tools/fee_estimator.js.map +0 -1
- package/dist/utxo/tools/raw_transaction_provider.d.ts.map +0 -1
- package/dist/utxo/tools/raw_transaction_provider.js.map +0 -1
- package/dist/utxo/tools/utxo_provider.d.ts.map +0 -1
- package/dist/utxo/tools/utxo_provider.js.map +0 -1
- package/dist/utxo/unsigned_utxo_transaction.d.ts.map +0 -1
- package/dist/utxo/unsigned_utxo_transaction.js.map +0 -1
- package/dist/utxo/utxo.d.ts.map +0 -1
- package/dist/utxo/utxo_chain.d.ts.map +0 -1
- package/dist/utxo/utxo_chain.js.map +0 -1
- package/dist/utxo/utxo_chains.d.ts.map +0 -1
- package/dist/utxo/utxo_chains.js.map +0 -1
- package/dist/utxo/utxo_gas_pricing.d.ts.map +0 -1
- package/dist/utxo/utxo_gas_pricing.js.map +0 -1
- package/dist/utxo/utxo_network_params.d.ts.map +0 -1
- package/dist/utxo/utxo_network_params.js.map +0 -1
- package/dist/utxo/utxo_transaction_status.d.ts.map +0 -1
- package/dist/utxo/utxo_transaction_status.js.map +0 -1
- /package/dist/{abstract_gas_pricing.d.ts → esm/abstract_gas_pricing.d.ts} +0 -0
- /package/dist/{abstract_gas_pricing.js → esm/abstract_gas_pricing.js} +0 -0
- /package/dist/{address.d.ts → esm/address.d.ts} +0 -0
- /package/dist/{address.factory.d.ts → esm/address.factory.d.ts} +0 -0
- /package/dist/{address.factory.js → esm/address.factory.js} +0 -0
- /package/dist/{address.js → esm/address.js} +0 -0
- /package/dist/{address_field.decorator.d.ts → esm/address_field.decorator.d.ts} +0 -0
- /package/dist/{address_field.decorator.js → esm/address_field.decorator.js} +0 -0
- /package/dist/{chain.base.js → esm/chain.base.js} +0 -0
- /package/dist/{chain_ids.d.ts → esm/chain_ids.d.ts} +0 -0
- /package/dist/{chain_ids.js → esm/chain_ids.js} +0 -0
- /package/dist/{evm → esm/evm}/evm_address.d.ts +0 -0
- /package/dist/{evm → esm/evm}/evm_address.js +0 -0
- /package/dist/{evm → esm/evm}/evm_chains.d.ts +0 -0
- /package/dist/{evm → esm/evm}/evm_chains.js +0 -0
- /package/dist/{evm → esm/evm}/evm_gas_estimate.d.ts +0 -0
- /package/dist/{evm → esm/evm}/evm_gas_estimate.js +0 -0
- /package/dist/{evm → esm/evm}/evm_gas_pricing.d.ts +0 -0
- /package/dist/{evm → esm/evm}/evm_gas_pricing.js +0 -0
- /package/dist/{evm → esm/evm}/evm_token.d.ts +0 -0
- /package/dist/{evm → esm/evm}/evm_token.js +0 -0
- /package/dist/{evm → esm/evm}/evm_tokens.d.ts +0 -0
- /package/dist/{evm → esm/evm}/evm_tokens.js +0 -0
- /package/dist/{evm → esm/evm}/index.d.ts +0 -0
- /package/dist/{evm → esm/evm}/index.js +0 -0
- /package/dist/{index.d.ts → esm/index.d.ts} +0 -0
- /package/dist/{index.js → esm/index.js} +0 -0
- /package/dist/{is_address.decorator.d.ts → esm/is_address.decorator.d.ts} +0 -0
- /package/dist/{is_address.decorator.js → esm/is_address.decorator.js} +0 -0
- /package/dist/{network_type.d.ts → esm/network_type.d.ts} +0 -0
- /package/dist/{network_type.js → esm/network_type.js} +0 -0
- /package/dist/{priority.d.ts → esm/priority.d.ts} +0 -0
- /package/dist/{priority.js → esm/priority.js} +0 -0
- /package/dist/{solana → esm/solana}/index.d.ts +0 -0
- /package/dist/{solana → esm/solana}/index.js +0 -0
- /package/dist/{solana → esm/solana}/solana_address.d.ts +0 -0
- /package/dist/{solana → esm/solana}/solana_address.js +0 -0
- /package/dist/{solana → esm/solana}/solana_chains.d.ts +0 -0
- /package/dist/{solana → esm/solana}/solana_chains.js +0 -0
- /package/dist/{solana → esm/solana}/solana_gas_pricing.d.ts +0 -0
- /package/dist/{solana → esm/solana}/solana_gas_pricing.js +0 -0
- /package/dist/{solana → esm/solana}/solana_token.d.ts +0 -0
- /package/dist/{solana → esm/solana}/solana_token.js +0 -0
- /package/dist/{solana → esm/solana}/solana_tokens.d.ts +0 -0
- /package/dist/{solana → esm/solana}/solana_tokens.js +0 -0
- /package/dist/{solana → esm/solana}/solana_transaction_status.d.ts +0 -0
- /package/dist/{solana → esm/solana}/solana_transaction_status.js +0 -0
- /package/dist/{token.d.ts → esm/token.d.ts} +0 -0
- /package/dist/{token.js → esm/token.js} +0 -0
- /package/dist/{ton → esm/ton}/index.d.ts +0 -0
- /package/dist/{ton → esm/ton}/index.js +0 -0
- /package/dist/{ton → esm/ton}/ton_address.d.ts +0 -0
- /package/dist/{ton → esm/ton}/ton_address.js +0 -0
- /package/dist/{transaction_status.d.ts → esm/transaction_status.d.ts} +0 -0
- /package/dist/{transaction_status.js → esm/transaction_status.js} +0 -0
- /package/dist/{unsigned_transaction.d.ts → esm/unsigned_transaction.d.ts} +0 -0
- /package/dist/{unsigned_transaction.js → esm/unsigned_transaction.js} +0 -0
- /package/dist/{utxo → esm/utxo}/btc/btc_address.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/btc_address.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/btc_chain.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/btc_chain.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/btc_chains.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/btc_chains.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/btc_token.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/btc_token.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/index.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/index.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/network_params.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/network_params.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/asset_outpoint.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/asset_outpoint.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/bitcoin_core.tool.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/bitcoin_core.tool.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/esplora.tool.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/esplora.tool.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/inscription_index.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/inscription_index.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/ordiscan.tool.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/ordiscan.tool.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/rare_sat_index.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/rare_sat_index.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/rune_index.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/rune_index.js +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/unisat.tool.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/btc/tools/unisat.tool.js +0 -0
- /package/dist/{utxo → esm/utxo}/coin_selection.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/coin_selection.js +0 -0
- /package/dist/{utxo → esm/utxo}/doge/doge_chains.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/doge/doge_chains.js +0 -0
- /package/dist/{utxo → esm/utxo}/doge/index.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/doge/index.js +0 -0
- /package/dist/{utxo → esm/utxo}/doge/network_params.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/doge/network_params.js +0 -0
- /package/dist/{utxo → esm/utxo}/ecc.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/ecc.js +0 -0
- /package/dist/{utxo → esm/utxo}/fee.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/fee.js +0 -0
- /package/dist/{utxo → esm/utxo}/index.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/index.js +0 -0
- /package/dist/{utxo → esm/utxo}/ltc/index.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/ltc/index.js +0 -0
- /package/dist/{utxo → esm/utxo}/ltc/ltc_chains.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/ltc/ltc_chains.js +0 -0
- /package/dist/{utxo → esm/utxo}/ltc/network_params.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/ltc/network_params.js +0 -0
- /package/dist/{utxo → esm/utxo}/script.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/script.js +0 -0
- /package/dist/{utxo → esm/utxo}/tools/broadcaster.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/tools/broadcaster.js +0 -0
- /package/dist/{utxo → esm/utxo}/tools/chain_tip_provider.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/tools/chain_tip_provider.js +0 -0
- /package/dist/{utxo → esm/utxo}/tools/fee_estimator.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/tools/fee_estimator.js +0 -0
- /package/dist/{utxo → esm/utxo}/tools/raw_transaction_provider.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/tools/raw_transaction_provider.js +0 -0
- /package/dist/{utxo → esm/utxo}/tools/utxo_provider.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/tools/utxo_provider.js +0 -0
- /package/dist/{utxo → esm/utxo}/unsigned_utxo_transaction.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/unsigned_utxo_transaction.js +0 -0
- /package/dist/{utxo → esm/utxo}/utxo.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/utxo.js +0 -0
- /package/dist/{utxo → esm/utxo}/utxo_chains.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/utxo_chains.js +0 -0
- /package/dist/{utxo → esm/utxo}/utxo_gas_pricing.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/utxo_gas_pricing.js +0 -0
- /package/dist/{utxo → esm/utxo}/utxo_network_params.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/utxo_network_params.js +0 -0
- /package/dist/{utxo → esm/utxo}/utxo_transaction_status.d.ts +0 -0
- /package/dist/{utxo → esm/utxo}/utxo_transaction_status.js +0 -0
|
@@ -0,0 +1,612 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UtxoChain = void 0;
|
|
4
|
+
exports.sanitizeUtxoErrMessage = sanitizeUtxoErrMessage;
|
|
5
|
+
const bitcoinjs_lib_1 = require("bitcoinjs-lib");
|
|
6
|
+
const chain_ids_ts_1 = require("../chain_ids.js");
|
|
7
|
+
const network_params_ts_1 = require("./btc/network_params.js");
|
|
8
|
+
const chain_base_ts_1 = require("../chain.base.js");
|
|
9
|
+
const errors_ts_1 = require("../errors.js");
|
|
10
|
+
const network_type_ts_1 = require("../network_type.js");
|
|
11
|
+
const priority_ts_1 = require("../priority.js");
|
|
12
|
+
const token_ts_1 = require("../token.js");
|
|
13
|
+
const transaction_status_ts_1 = require("../transaction_status.js");
|
|
14
|
+
const utxo_transaction_status_ts_1 = require("./utxo_transaction_status.js");
|
|
15
|
+
require("./ecc.js");
|
|
16
|
+
const coin_selection_ts_1 = require("./coin_selection.js");
|
|
17
|
+
const fee_ts_1 = require("./fee.js");
|
|
18
|
+
const script_ts_1 = require("./script.js");
|
|
19
|
+
const utxo_network_params_ts_1 = require("./utxo_network_params.js");
|
|
20
|
+
const unsigned_utxo_transaction_ts_1 = require("./unsigned_utxo_transaction.js");
|
|
21
|
+
const RESERVED_BTC_CHAIN_IDS = [
|
|
22
|
+
chain_ids_ts_1.CHAIN_ID_BITCOIN_MAINNET,
|
|
23
|
+
chain_ids_ts_1.CHAIN_ID_BITCOIN_TESTNET,
|
|
24
|
+
chain_ids_ts_1.CHAIN_ID_BITCOIN_SIGNET,
|
|
25
|
+
];
|
|
26
|
+
const DEFAULT_BLOCK_TIME_SECONDS = 600;
|
|
27
|
+
const DEFAULT_FEE_TARGET_BLOCKS = 3;
|
|
28
|
+
const DEFAULT_LONG_TERM_FEE_RATE = 5;
|
|
29
|
+
const DEFAULT_NATIVE_DECIMALS = 8;
|
|
30
|
+
class UtxoNativeToken extends token_ts_1.Token {
|
|
31
|
+
constructor(chainId, symbol, decimals) {
|
|
32
|
+
super(chainId, symbol, undefined, decimals);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
class UtxoChain extends chain_base_ts_1.Chain {
|
|
36
|
+
params;
|
|
37
|
+
utxoProvider;
|
|
38
|
+
rawTxProvider;
|
|
39
|
+
feeEstimator;
|
|
40
|
+
broadcaster;
|
|
41
|
+
chainTipProvider;
|
|
42
|
+
walletExplorerTemplate;
|
|
43
|
+
tokenExplorerTemplate;
|
|
44
|
+
transactionExplorerTemplate;
|
|
45
|
+
_nativeToken;
|
|
46
|
+
defaultFeeTargetBlocks;
|
|
47
|
+
longTermFeeRateSatsPerVByte;
|
|
48
|
+
rbfEnabled;
|
|
49
|
+
constructor(init) {
|
|
50
|
+
// Reject a non-BTC UTXO chain (LTC/DOGE/DASH/ZEC/BCH — mainnet AND
|
|
51
|
+
// testnet) constructed with a reserved BTC chainId. The prior slip44
|
|
52
|
+
// heuristic let `litecoinTestnetChain({chainId: -2})` through because
|
|
53
|
+
// LTC testnet's slip44 is `Slip44.Testnet` (same as BTC testnet). Gate
|
|
54
|
+
// on the seeded BTC params directly: at reserved ids the constructor
|
|
55
|
+
// must present params shape-identical to what's already seeded, else
|
|
56
|
+
// it's a chain claiming a BTC id with foreign address rules.
|
|
57
|
+
if (RESERVED_BTC_CHAIN_IDS.includes(init.chainId)) {
|
|
58
|
+
const seeded = (0, network_params_ts_1.btcParamsForChainId)(BigInt(init.chainId));
|
|
59
|
+
const paramsAsBtc = init.params;
|
|
60
|
+
// Use the strict comparator exported from btc/network_params.ts so
|
|
61
|
+
// both this guard and registerBtcChainParams share ONE invariant.
|
|
62
|
+
// A non-BtcNetworkParams (missing `name`, `hrp`, etc.) fails the
|
|
63
|
+
// comparator on the first field mismatch.
|
|
64
|
+
if (init.params !== seeded && !(0, network_params_ts_1.btcParamsShapeMatches)(seeded, paramsAsBtc)) {
|
|
65
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, `chainId ${init.chainId} is reserved for BTC; UtxoChain construction with foreign params (slip44=${init.params.slip44CoinId}) is not permitted. Choose a distinct chainId for this network.`, { chainId: init.chainId });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
super(init.chainId, init.name, network_type_ts_1.NetworkType.BTC, init.blockTimeSeconds ?? DEFAULT_BLOCK_TIME_SECONDS, init.nativeSymbol, init.walletExplorerUrlTemplate);
|
|
69
|
+
this.params = init.params;
|
|
70
|
+
this.utxoProvider = init.utxoProvider;
|
|
71
|
+
this.rawTxProvider = init.rawTxProvider;
|
|
72
|
+
this.feeEstimator = init.feeEstimator;
|
|
73
|
+
this.broadcaster = init.broadcaster;
|
|
74
|
+
this.chainTipProvider = init.chainTipProvider;
|
|
75
|
+
this.walletExplorerTemplate = init.walletExplorerUrlTemplate;
|
|
76
|
+
this.tokenExplorerTemplate = init.tokenExplorerUrlTemplate ?? init.walletExplorerUrlTemplate;
|
|
77
|
+
this.transactionExplorerTemplate = init.transactionExplorerUrlTemplate;
|
|
78
|
+
this._nativeToken = new UtxoNativeToken(init.chainId, init.nativeSymbol, init.nativeDecimals ?? DEFAULT_NATIVE_DECIMALS);
|
|
79
|
+
this.defaultFeeTargetBlocks = init.defaultFeeTargetBlocks ?? DEFAULT_FEE_TARGET_BLOCKS;
|
|
80
|
+
this.longTermFeeRateSatsPerVByte = init.longTermFeeRateSatsPerVByte ?? DEFAULT_LONG_TERM_FEE_RATE;
|
|
81
|
+
this.rbfEnabled = init.rbfEnabled ?? true;
|
|
82
|
+
(0, network_type_ts_1.registerNonEvmChain)(init.chainId, network_type_ts_1.NetworkType.BTC);
|
|
83
|
+
}
|
|
84
|
+
get nativeToken() {
|
|
85
|
+
return this._nativeToken;
|
|
86
|
+
}
|
|
87
|
+
get slip44CoinId() {
|
|
88
|
+
return this.params.slip44CoinId;
|
|
89
|
+
}
|
|
90
|
+
get supportedDerivationPurposes() {
|
|
91
|
+
return this.params.supportedDerivationPurposes;
|
|
92
|
+
}
|
|
93
|
+
get dustValueSats() {
|
|
94
|
+
return this.params.dustValueSats;
|
|
95
|
+
}
|
|
96
|
+
getWalletExplorerUrl(address) {
|
|
97
|
+
return this.walletExplorerTemplate.replace('{wallet_address}', address);
|
|
98
|
+
}
|
|
99
|
+
getTokenExplorerUrl(_tokenIdentifier) {
|
|
100
|
+
return this.tokenExplorerTemplate.replace('{wallet_address}', '');
|
|
101
|
+
}
|
|
102
|
+
getTransactionExplorerUrl(txHash) {
|
|
103
|
+
return this.transactionExplorerTemplate.replace('{tx_hash}', txHash);
|
|
104
|
+
}
|
|
105
|
+
validateAddress(raw) {
|
|
106
|
+
if (typeof raw !== 'string' || raw.length === 0)
|
|
107
|
+
return false;
|
|
108
|
+
return this.params.walletAddressRegex.test(raw);
|
|
109
|
+
}
|
|
110
|
+
validateTokenIdentifier(raw) {
|
|
111
|
+
return raw === undefined;
|
|
112
|
+
}
|
|
113
|
+
async getUtxos(addresses, _options) {
|
|
114
|
+
if (addresses.length === 0)
|
|
115
|
+
return [];
|
|
116
|
+
const lists = await Promise.all(addresses.map((address) => this.utxoProvider.getUtxos(address)));
|
|
117
|
+
return lists.flat();
|
|
118
|
+
}
|
|
119
|
+
async getBalance(owner, tokenIdentifier) {
|
|
120
|
+
if (!this.validateTokenIdentifier(tokenIdentifier)) {
|
|
121
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidTokenIdentifier, `${this.name}: only the native token is supported (got ${tokenIdentifier})`, { chainId: this.chainId, identifier: tokenIdentifier });
|
|
122
|
+
}
|
|
123
|
+
if (!this.validateAddress(owner)) {
|
|
124
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidAddress, `${this.name}: invalid wallet address ${owner}`, { chainId: this.chainId, address: owner });
|
|
125
|
+
}
|
|
126
|
+
const balance = await this.utxoProvider.getAddressBalance(owner);
|
|
127
|
+
return BigInt(balance.confirmedSats);
|
|
128
|
+
}
|
|
129
|
+
async getChainTipHeight() {
|
|
130
|
+
return this.chainTipProvider.getChainTipHeight();
|
|
131
|
+
}
|
|
132
|
+
async getTransactionStatus(txHash, opts) {
|
|
133
|
+
if (opts?.wait || (opts?.confirmations !== undefined && opts.confirmations > 1)) {
|
|
134
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.FeatureNotSupported, `UtxoChain.getTransactionStatus does not honor wait/confirmations opts in 0.3.0 (would silently return immediately). Poll the block-tip provider consumer-side or omit the opts.`, { chainId: this.chainId });
|
|
135
|
+
}
|
|
136
|
+
if (Array.isArray(txHash)) {
|
|
137
|
+
const results = new Array(txHash.length);
|
|
138
|
+
let cursor = 0;
|
|
139
|
+
let aborted = false;
|
|
140
|
+
const spawn = async () => {
|
|
141
|
+
while (!aborted) {
|
|
142
|
+
const idx = cursor++;
|
|
143
|
+
if (idx >= txHash.length)
|
|
144
|
+
return;
|
|
145
|
+
try {
|
|
146
|
+
results[idx] = await this.getUtxoStatusOnce(txHash[idx]);
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
aborted = true;
|
|
150
|
+
throw err;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const workerCount = Math.min(8, txHash.length);
|
|
155
|
+
await Promise.all(Array.from({ length: workerCount }, spawn));
|
|
156
|
+
return results;
|
|
157
|
+
}
|
|
158
|
+
return this.getUtxoStatusOnce(txHash);
|
|
159
|
+
}
|
|
160
|
+
async getUtxoStatusOnce(txHash) {
|
|
161
|
+
// Narrow the try to the provider call only. Constructor asserts and
|
|
162
|
+
// upsert failures must NOT be silently coerced into NotFound.
|
|
163
|
+
// Classify: (a) provider signalled "no such tx" (Esplora HTTP 404,
|
|
164
|
+
// Bitcoin Core RPC code -5) → NotFound; (b) any other throw →
|
|
165
|
+
// RpcError so consumers can retry rather than treating a 429/timeout
|
|
166
|
+
// as a definitive miss.
|
|
167
|
+
let tx;
|
|
168
|
+
try {
|
|
169
|
+
tx = await this.rawTxProvider.getTransaction(txHash);
|
|
170
|
+
}
|
|
171
|
+
catch (err) {
|
|
172
|
+
if (err instanceof errors_ts_1.ChainError)
|
|
173
|
+
throw err;
|
|
174
|
+
if (isProviderNotFoundError(err)) {
|
|
175
|
+
return new utxo_transaction_status_ts_1.UtxoTransactionStatus({
|
|
176
|
+
chainId: this.chainId,
|
|
177
|
+
status: transaction_status_ts_1.TransactionStatusTypes.NotFound,
|
|
178
|
+
confirmationAt: null,
|
|
179
|
+
balanceChanges: null,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
const rawMsg = err instanceof Error ? err.message : String(err);
|
|
183
|
+
const sanitizedMsg = sanitizeUtxoErrMessage(rawMsg);
|
|
184
|
+
// Build a scrubbed cause: sanitizeCause strips axios `.config`/
|
|
185
|
+
// `.request`/`.response` object trees (which carry Authorization
|
|
186
|
+
// headers + query-string keys) by rebuilding a plain Error with
|
|
187
|
+
// only sanitized message+stack. Consumers walking `.cause` in a
|
|
188
|
+
// structured logger no longer leak API keys.
|
|
189
|
+
const safeCause = err instanceof Error
|
|
190
|
+
? sanitizedCauseForUtxo(err, sanitizedMsg)
|
|
191
|
+
: undefined;
|
|
192
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.RpcError, `Failed to read UTXO tx ${txHash}: ${sanitizedMsg}`, { chainId: this.chainId, txHash }, safeCause);
|
|
193
|
+
}
|
|
194
|
+
// Bitcoin Core reports `confirmations: -1` for a conflicted/RBF-
|
|
195
|
+
// replaced tx (a reorged-out deposit). Do not run the shape asserts
|
|
196
|
+
// that would throw InvalidArgument on the way out — surface as
|
|
197
|
+
// NotFound so the status poll doesn't crash.
|
|
198
|
+
if (tx.confirmations < 0) {
|
|
199
|
+
return new utxo_transaction_status_ts_1.UtxoTransactionStatus({
|
|
200
|
+
chainId: this.chainId,
|
|
201
|
+
status: transaction_status_ts_1.TransactionStatusTypes.NotFound,
|
|
202
|
+
confirmationAt: null,
|
|
203
|
+
balanceChanges: null,
|
|
204
|
+
error: {
|
|
205
|
+
code: 'CONFLICTED',
|
|
206
|
+
reason: `Provider reports confirmations=${tx.confirmations} (RBF-replaced / reorged)`,
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
// Wrap the decode block so a non-integer valueSats/absoluteSats from a
|
|
211
|
+
// consumer's provider tool (BTC-float→sats overflow) or a
|
|
212
|
+
// Transaction.fromHex failure surfaces as a typed
|
|
213
|
+
// ChainError(TransactionDecodeFailed) rather than a raw RangeError.
|
|
214
|
+
// Mirrors evm_chain.ts:decodeBalanceChanges catch.
|
|
215
|
+
try {
|
|
216
|
+
// Populate outputs on both pending AND confirmed paths — a 0-conf
|
|
217
|
+
// mempool tx still has visible outputs, and BTC/LTC/DOGE deposit
|
|
218
|
+
// detectors need them. balanceChanges stays null on Pending per the
|
|
219
|
+
// TransactionStatus base invariant.
|
|
220
|
+
const outputs = tx.vout.map((o) => new utxo_transaction_status_ts_1.UtxoTransactionOutput({
|
|
221
|
+
scriptPubkeyHex: o.scriptPubKeyHex,
|
|
222
|
+
address: o.address,
|
|
223
|
+
valueSats: BigInt(o.valueSats),
|
|
224
|
+
}));
|
|
225
|
+
// Derive vsize from the raw hex — bitcoinjs-lib is already a dep
|
|
226
|
+
// and both Esplora + Bitcoin Core populate tx.hex. Falls back to
|
|
227
|
+
// null on malformed hex so the status still returns.
|
|
228
|
+
let vsize = null;
|
|
229
|
+
try {
|
|
230
|
+
if (tx.hex && tx.hex.length > 0) {
|
|
231
|
+
vsize = bitcoinjs_lib_1.Transaction.fromHex(tx.hex).virtualSize();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
catch {
|
|
235
|
+
vsize = null;
|
|
236
|
+
}
|
|
237
|
+
const fees = tx.fees !== null
|
|
238
|
+
? new utxo_transaction_status_ts_1.UtxoTransactionFees({ absoluteSats: BigInt(tx.fees.absoluteSats), vsize })
|
|
239
|
+
: null;
|
|
240
|
+
const isPending = tx.confirmations === 0;
|
|
241
|
+
if (isPending) {
|
|
242
|
+
return new utxo_transaction_status_ts_1.UtxoTransactionStatus({
|
|
243
|
+
chainId: this.chainId,
|
|
244
|
+
status: transaction_status_ts_1.TransactionStatusTypes.Pending,
|
|
245
|
+
confirmationAt: null,
|
|
246
|
+
balanceChanges: null,
|
|
247
|
+
confirmations: 0,
|
|
248
|
+
outputs,
|
|
249
|
+
vsize,
|
|
250
|
+
fees,
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
// Outputs-only per-address native deltas. Full input-side accounting
|
|
254
|
+
// to compute net native change (Python's `_native_balance_changes`
|
|
255
|
+
// parity) is deferred — the raw-tx provider currently returns only
|
|
256
|
+
// vin.txid+vout, no address/value/scriptPubKeyHex. Noted in
|
|
257
|
+
// SINAN_OPEN_QUESTIONS.md.
|
|
258
|
+
const balanceChanges = new Map();
|
|
259
|
+
const perAddressSats = new Map();
|
|
260
|
+
for (const out of tx.vout) {
|
|
261
|
+
if (!out.address)
|
|
262
|
+
continue;
|
|
263
|
+
perAddressSats.set(out.address, (perAddressSats.get(out.address) ?? 0n) + BigInt(out.valueSats));
|
|
264
|
+
}
|
|
265
|
+
for (const [address, sats] of perAddressSats) {
|
|
266
|
+
transaction_status_ts_1.AssetBalanceChange.upsert(balanceChanges, address, this._nativeToken, transaction_status_ts_1.AssetBalanceChange.fromMr(sats, this._nativeToken.decimals));
|
|
267
|
+
}
|
|
268
|
+
return new utxo_transaction_status_ts_1.UtxoTransactionStatus({
|
|
269
|
+
chainId: this.chainId,
|
|
270
|
+
status: transaction_status_ts_1.TransactionStatusTypes.Success,
|
|
271
|
+
confirmationAt: tx.blockTime,
|
|
272
|
+
balanceChanges,
|
|
273
|
+
confirmations: tx.confirmations,
|
|
274
|
+
outputs,
|
|
275
|
+
vsize,
|
|
276
|
+
fees,
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
catch (err) {
|
|
280
|
+
if (err instanceof errors_ts_1.ChainError)
|
|
281
|
+
throw err;
|
|
282
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.TransactionDecodeFailed, `Failed to decode UTXO tx ${txHash}: ${err instanceof Error ? err.message : String(err)}`, { chainId: this.chainId, txHash }, err instanceof Error ? err : undefined);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
async createTransferUnsignedTransaction(req) {
|
|
286
|
+
return this.buildTransfer(req, undefined);
|
|
287
|
+
}
|
|
288
|
+
async broadcast(signed, opts) {
|
|
289
|
+
if (opts && opts.signal !== undefined) {
|
|
290
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.FeatureNotSupported, `UTXO broadcast: signal is not honored in 0.3.0 (silently ignoring would let a caller conclude 'not sent' while the tx still lands). Cancellation returns in 0.3.1.`, { chainId: this.chainId });
|
|
291
|
+
}
|
|
292
|
+
let hex;
|
|
293
|
+
let txBytes;
|
|
294
|
+
if (typeof signed === 'string') {
|
|
295
|
+
const stripped = signed.startsWith('0x') ? signed.slice(2) : signed;
|
|
296
|
+
if (!/^[0-9a-fA-F]+$/.test(stripped) || stripped.length % 2 !== 0 || stripped.length === 0) {
|
|
297
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, `UTXO broadcast: signed transaction must be Uint8Array or hex string (got malformed string of length ${signed.length})`, { chainId: this.chainId });
|
|
298
|
+
}
|
|
299
|
+
hex = stripped;
|
|
300
|
+
txBytes = Buffer.from(stripped, 'hex');
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
if (signed.length === 0) {
|
|
304
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, `UTXO broadcast: signed transaction bytes are empty`, { chainId: this.chainId });
|
|
305
|
+
}
|
|
306
|
+
hex = Buffer.from(signed).toString('hex');
|
|
307
|
+
txBytes = Buffer.from(signed);
|
|
308
|
+
}
|
|
309
|
+
try {
|
|
310
|
+
const { txid } = await this.broadcaster.broadcast(hex);
|
|
311
|
+
return txid;
|
|
312
|
+
}
|
|
313
|
+
catch (err) {
|
|
314
|
+
const resp = err.response;
|
|
315
|
+
const body = resp?.data;
|
|
316
|
+
const httpStatus = resp?.status;
|
|
317
|
+
const bodyStr = body === undefined ? '' : ` — node response: ${typeof body === 'string' ? body : JSON.stringify(body)}`;
|
|
318
|
+
const rawMsg = (err instanceof Error ? err.message : String(err)) + bodyStr;
|
|
319
|
+
const sanitizedMsg = sanitizeUtxoErrMessage(rawMsg);
|
|
320
|
+
const lowerMsg = rawMsg.toLowerCase();
|
|
321
|
+
const safeCause = err instanceof Error ? sanitizedCauseForUtxo(err, sanitizedMsg) : undefined;
|
|
322
|
+
if (/already in block chain|txn-already-known|txn-already-in-mempool|already[- ]?known|already[- ]?in mempool/.test(lowerMsg)) {
|
|
323
|
+
return this.computeUtxoTxidLE(txBytes);
|
|
324
|
+
}
|
|
325
|
+
if (/econnreset|econnrefused|econnaborted|etimedout|enotfound|socket hang up|network request failed|fetch failed|too\s+many\s+requests|rate.?limit/.test(lowerMsg)
|
|
326
|
+
|| (typeof httpStatus === 'number' && (httpStatus === 429 || httpStatus === 502 || httpStatus === 503 || httpStatus === 504))) {
|
|
327
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.RpcError, `UTXO broadcast RPC transport failure on ${this.name}: ${sanitizedMsg}`, { chainId: this.chainId }, safeCause);
|
|
328
|
+
}
|
|
329
|
+
if (/insufficient|-6\b|not enough funds/.test(lowerMsg)) {
|
|
330
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InsufficientFunds, `UTXO broadcast rejected on ${this.name}: ${sanitizedMsg}`, { chainId: this.chainId }, safeCause);
|
|
331
|
+
}
|
|
332
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.BroadcastRejected, `UTXO broadcast rejected on ${this.name}: ${sanitizedMsg}`, { chainId: this.chainId }, safeCause);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
computeUtxoTxidLE(txBytes) {
|
|
336
|
+
try {
|
|
337
|
+
const first = bitcoinjs_lib_1.Transaction.fromBuffer(txBytes).getHash();
|
|
338
|
+
return Buffer.from(first).reverse().toString('hex');
|
|
339
|
+
}
|
|
340
|
+
catch (err) {
|
|
341
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.BroadcastRejected, `UTXO already-known path: node reported the tx as already accepted, but the local bytes could not be parsed by bitcoinjs to derive a txid. Do NOT re-sign — poll by the txid the consumer computed pre-broadcast.`, { chainId: this.chainId }, err instanceof Error ? err : undefined);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
async buildTransfer(req, getUtxosOptions) {
|
|
345
|
+
// UTXO builder does not yet consume the CreateTransferRequest fields
|
|
346
|
+
// introduced in Wave 2B (Python-parity amountHr / isFullBalance /
|
|
347
|
+
// gasPricing). Rejecting them at entry — silently letting an
|
|
348
|
+
// amountHr-only request through would produce `amount === undefined`
|
|
349
|
+
// downstream and end in a NaN cointoss after several RPC round-trips.
|
|
350
|
+
if (req.amountHr !== undefined) {
|
|
351
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, `${this.name}: CreateTransferRequest.amountHr is not yet supported — pass \`amount\` (bigint sats) or \`outputs\` (multi-recipient) instead.`, { chainId: this.chainId });
|
|
352
|
+
}
|
|
353
|
+
if (req.isFullBalance === true) {
|
|
354
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, `${this.name}: CreateTransferRequest.isFullBalance is not yet supported — pass \`amount\` explicitly and reserve fees yourself.`, { chainId: this.chainId });
|
|
355
|
+
}
|
|
356
|
+
if (req.gasPricing !== undefined) {
|
|
357
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, `${this.name}: CreateTransferRequest.gasPricing is not yet consumed by UtxoChain (Phase 2 follow-up). Use \`feeRateSatsPerVByte\` / \`feeTargetBlocks\` on CreateUtxoTransferOptions for now.`, { chainId: this.chainId });
|
|
358
|
+
}
|
|
359
|
+
if (!this.validateTokenIdentifier(req.tokenIdentifier)) {
|
|
360
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidTokenIdentifier, `${this.name}: only the native token is supported`, { chainId: this.chainId, identifier: req.tokenIdentifier });
|
|
361
|
+
}
|
|
362
|
+
if (req.from === undefined || !this.validateAddress(req.from)) {
|
|
363
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidAddress, `${this.name}: invalid sender address ${req.from ?? '<missing>'}`, { chainId: this.chainId, address: req.from });
|
|
364
|
+
}
|
|
365
|
+
const fromAddress = req.from;
|
|
366
|
+
const opts = req;
|
|
367
|
+
// Normalize: single-output form (to/amount) OR multi-output form (outputs[]).
|
|
368
|
+
// Exactly one must be provided; the multi-output form is preferred going forward.
|
|
369
|
+
const hasSingle = req.to !== undefined || req.amount !== undefined;
|
|
370
|
+
const hasMulti = Array.isArray(opts.outputs) && opts.outputs.length > 0;
|
|
371
|
+
if (hasSingle && hasMulti) {
|
|
372
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, `${this.name}: cannot specify both single-output (to/amount) and multi-output (outputs[]) forms`, { chainId: this.chainId });
|
|
373
|
+
}
|
|
374
|
+
if (!hasSingle && !hasMulti) {
|
|
375
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, `${this.name}: must specify either (to, amount) or a non-empty outputs[] array`, { chainId: this.chainId });
|
|
376
|
+
}
|
|
377
|
+
// Wave 2B made `amount` optional on the base CreateTransferRequest so
|
|
378
|
+
// `amountHr` could coexist. UTXO's single-output form still needs
|
|
379
|
+
// `amount: bigint` — reject `{to, memo}`-without-amount up front
|
|
380
|
+
// rather than let it propagate through as NaN downstream.
|
|
381
|
+
if (hasSingle && !hasMulti && req.amount === undefined) {
|
|
382
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, `${this.name}: single-output form requires \`amount: bigint\` (bitcoin satoshis) — omitting amount would produce NaN downstream`, { chainId: this.chainId });
|
|
383
|
+
}
|
|
384
|
+
const normalizedOutputs = hasMulti
|
|
385
|
+
? opts.outputs.slice()
|
|
386
|
+
: [{ to: req.to, amount: req.amount }];
|
|
387
|
+
for (let i = 0; i < normalizedOutputs.length; i++) {
|
|
388
|
+
const o = normalizedOutputs[i];
|
|
389
|
+
if (!this.validateAddress(o.to)) {
|
|
390
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidAddress, `${this.name}: invalid recipient address at outputs[${i}]: ${o.to}`, { chainId: this.chainId, address: o.to });
|
|
391
|
+
}
|
|
392
|
+
if (typeof o.amount !== 'bigint') {
|
|
393
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, `${this.name}: outputs[${i}].amount must be a bigint (got ${typeof o.amount})`, { chainId: this.chainId });
|
|
394
|
+
}
|
|
395
|
+
if (o.amount <= 0n) {
|
|
396
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, `${this.name}: outputs[${i}] amount must be > 0`, { chainId: this.chainId });
|
|
397
|
+
}
|
|
398
|
+
const sats = bigintToNumber(o.amount);
|
|
399
|
+
if (sats < this.params.dustValueSats) {
|
|
400
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, `${this.name}: outputs[${i}] amount ${sats} below dust ${this.params.dustValueSats}`, { chainId: this.chainId });
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
const totalTargetSats = normalizedOutputs.reduce((acc, o) => acc + bigintToNumber(o.amount), 0);
|
|
404
|
+
const recipientTypes = normalizedOutputs.map((o) => (0, script_ts_1.scriptTypeForAddress)(o.to, this.params.networkInfo));
|
|
405
|
+
const memoBytes = encodeMemo(req.memo);
|
|
406
|
+
const feeRateSatsPerVByte = await this.resolveFeeRate(opts.feeRateSatsPerVByte, opts.feeTargetBlocks);
|
|
407
|
+
const utxos = await this.getUtxos([fromAddress], getUtxosOptions);
|
|
408
|
+
if (utxos.length === 0) {
|
|
409
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, `${this.name}: no spendable UTXOs available for ${fromAddress}`, { chainId: this.chainId, address: fromAddress });
|
|
410
|
+
}
|
|
411
|
+
const changeAddress = opts.changeAddress ?? fromAddress;
|
|
412
|
+
const changeType = (0, script_ts_1.scriptTypeForAddress)(changeAddress, this.params.networkInfo);
|
|
413
|
+
const outputsFixedVBytes = recipientTypes.reduce((acc, t) => acc + (0, fee_ts_1.outputVBytes)(t), 0) +
|
|
414
|
+
(memoBytes ? memoBytes.length + 11 : 0);
|
|
415
|
+
const selection = this.runCoinSelection({
|
|
416
|
+
utxos,
|
|
417
|
+
targetSats: totalTargetSats,
|
|
418
|
+
feeRateSatsPerVByte,
|
|
419
|
+
changeOutputType: changeType,
|
|
420
|
+
outputsFixedVBytes,
|
|
421
|
+
costOfChangeSats: (0, fee_ts_1.costOfChangeSats)(changeType, feeRateSatsPerVByte, this.longTermFeeRateSatsPerVByte),
|
|
422
|
+
});
|
|
423
|
+
if (selection.outcome !== coin_selection_ts_1.CoinSelectionOutcomes.Success) {
|
|
424
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, `${this.name}: coin selection failed (${selection.outcome}) for target ${totalTargetSats} sats`, { chainId: this.chainId });
|
|
425
|
+
}
|
|
426
|
+
const rbfEnabled = opts.rbfEnabled ?? this.rbfEnabled;
|
|
427
|
+
const sequence = rbfEnabled ? utxo_network_params_ts_1.RBF_SEQUENCE : utxo_network_params_ts_1.FINAL_SEQUENCE;
|
|
428
|
+
const psbt = new bitcoinjs_lib_1.Psbt({ network: this.params.networkInfo });
|
|
429
|
+
const rawTxByTxid = await this.fetchParentTransactions(selection.selected);
|
|
430
|
+
const inputsToSign = {};
|
|
431
|
+
selection.selected.forEach((utxo, index) => {
|
|
432
|
+
this.addInputToPsbt({
|
|
433
|
+
psbt,
|
|
434
|
+
utxo,
|
|
435
|
+
sequence,
|
|
436
|
+
parentTxHex: rawTxByTxid.get(utxo.txid),
|
|
437
|
+
});
|
|
438
|
+
const list = inputsToSign[utxo.ownerAddress] ?? [];
|
|
439
|
+
list.push(index);
|
|
440
|
+
inputsToSign[utxo.ownerAddress] = list;
|
|
441
|
+
});
|
|
442
|
+
for (const o of normalizedOutputs) {
|
|
443
|
+
psbt.addOutput({ address: o.to, value: BigInt(bigintToNumber(o.amount)) });
|
|
444
|
+
}
|
|
445
|
+
if (selection.hasChange) {
|
|
446
|
+
psbt.addOutput({ address: changeAddress, value: BigInt(selection.changeSats) });
|
|
447
|
+
}
|
|
448
|
+
if (memoBytes) {
|
|
449
|
+
psbt.addOutput({ script: (0, script_ts_1.buildOpReturnScript)(memoBytes), value: 0n });
|
|
450
|
+
}
|
|
451
|
+
const estimatedVBytes = (0, fee_ts_1.estimateTxVBytes)(selection.selected.map((u) => u.scriptType), selection.hasChange ? [...recipientTypes, changeType] : recipientTypes, memoBytes ? [memoBytes.length] : []);
|
|
452
|
+
return new unsigned_utxo_transaction_ts_1.UnsignedUtxoTransaction({
|
|
453
|
+
chainId: this.chainId,
|
|
454
|
+
params: this.params,
|
|
455
|
+
psbtBase64: psbt.toBase64(),
|
|
456
|
+
selectedInputs: selection.selected,
|
|
457
|
+
feeSats: selection.feeSats,
|
|
458
|
+
feeRateSatsPerVByte,
|
|
459
|
+
estimatedVBytes,
|
|
460
|
+
totalInputSats: selection.totalValueSats,
|
|
461
|
+
totalOutputSats: totalTargetSats + (selection.hasChange ? selection.changeSats : 0),
|
|
462
|
+
changeAddress: selection.hasChange ? changeAddress : null,
|
|
463
|
+
inputsToSign,
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
addInputToPsbt(args) {
|
|
467
|
+
const { psbt, utxo, sequence, parentTxHex } = args;
|
|
468
|
+
const scriptPubKey = Buffer.from(utxo.scriptPubKeyHex, 'hex');
|
|
469
|
+
const scriptType = (0, script_ts_1.detectScriptType)(scriptPubKey);
|
|
470
|
+
const parentTxBytes = Buffer.from(parentTxHex, 'hex');
|
|
471
|
+
const input = {
|
|
472
|
+
hash: utxo.txid,
|
|
473
|
+
index: utxo.vout,
|
|
474
|
+
sequence,
|
|
475
|
+
nonWitnessUtxo: parentTxBytes,
|
|
476
|
+
};
|
|
477
|
+
if (scriptType === script_ts_1.UtxoScriptTypes.P2WPKH ||
|
|
478
|
+
scriptType === script_ts_1.UtxoScriptTypes.P2WSH ||
|
|
479
|
+
scriptType === script_ts_1.UtxoScriptTypes.P2TR ||
|
|
480
|
+
scriptType === script_ts_1.UtxoScriptTypes.P2SH) {
|
|
481
|
+
input.witnessUtxo = { script: scriptPubKey, value: BigInt(utxo.valueSats) };
|
|
482
|
+
}
|
|
483
|
+
psbt.addInput(input);
|
|
484
|
+
}
|
|
485
|
+
async resolveFeeRate(overrideRate, targetBlocks) {
|
|
486
|
+
if (overrideRate !== undefined) {
|
|
487
|
+
if (overrideRate < 1) {
|
|
488
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, `${this.name}: feeRateSatsPerVByte must be >= 1 (got ${overrideRate})`, { chainId: this.chainId });
|
|
489
|
+
}
|
|
490
|
+
return Math.ceil(overrideRate);
|
|
491
|
+
}
|
|
492
|
+
const estimate = await this.feeEstimator.getFeeEstimate(targetBlocks ?? this.defaultFeeTargetBlocks);
|
|
493
|
+
return estimate.satsPerVByte;
|
|
494
|
+
}
|
|
495
|
+
static targetBlocksForPriority(priority) {
|
|
496
|
+
switch (priority) {
|
|
497
|
+
case priority_ts_1.Priority.FAST: return 1;
|
|
498
|
+
case priority_ts_1.Priority.NORMAL: return 3;
|
|
499
|
+
case priority_ts_1.Priority.SLOW: return 6;
|
|
500
|
+
default: {
|
|
501
|
+
const unreachable = priority;
|
|
502
|
+
throw new Error(`Unhandled Priority value: ${unreachable}`);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
async suggestFeeRate(priority) {
|
|
507
|
+
return this.resolveFeeRate(undefined, UtxoChain.targetBlocksForPriority(priority));
|
|
508
|
+
}
|
|
509
|
+
async fetchParentTransactions(utxos) {
|
|
510
|
+
const uniqueTxids = Array.from(new Set(utxos.map((u) => u.txid)));
|
|
511
|
+
const hexes = await this.rawTxProvider.getRawTransactionHexBatch(uniqueTxids);
|
|
512
|
+
if (hexes.length !== uniqueTxids.length) {
|
|
513
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.RpcError, `${this.name}: provider returned ${hexes.length} parent txs for ${uniqueTxids.length} requested`, { chainId: this.chainId });
|
|
514
|
+
}
|
|
515
|
+
return new Map(uniqueTxids.map((txid, i) => [txid, hexes[i]]));
|
|
516
|
+
}
|
|
517
|
+
runCoinSelection(params) {
|
|
518
|
+
return (0, coin_selection_ts_1.selectCoins)(params);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
exports.UtxoChain = UtxoChain;
|
|
522
|
+
function bigintToNumber(value) {
|
|
523
|
+
if (value > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
524
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, `UTXO amount ${value} exceeds Number.MAX_SAFE_INTEGER`);
|
|
525
|
+
}
|
|
526
|
+
return Number(value);
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Detect whether the underlying provider signalled "no such tx" (as opposed
|
|
530
|
+
* to a transport failure). Two canonical shapes are recognised:
|
|
531
|
+
*
|
|
532
|
+
* - Esplora / any axios-based HTTP provider → `response.status === 404`
|
|
533
|
+
* - Bitcoin Core `getrawtransaction` on an unknown txid → RPC error code
|
|
534
|
+
* `-5` (surfaces via `bitcoin-core.tool.ts` as
|
|
535
|
+
* `Error("bitcoin-core getrawtransaction: -5 <msg>")`).
|
|
536
|
+
*
|
|
537
|
+
* Everything else is treated as a transport failure and wrapped in
|
|
538
|
+
* `ChainError(RpcError)` so consumers can retry.
|
|
539
|
+
*/
|
|
540
|
+
function isProviderNotFoundError(err) {
|
|
541
|
+
if (!err || typeof err !== 'object')
|
|
542
|
+
return false;
|
|
543
|
+
const anyErr = err;
|
|
544
|
+
const status = anyErr.response?.status;
|
|
545
|
+
if (typeof status === 'number' && status === 404)
|
|
546
|
+
return true;
|
|
547
|
+
const message = typeof anyErr.message === 'string' ? anyErr.message : '';
|
|
548
|
+
if (/getrawtransaction:\s*-5\b/.test(message)) {
|
|
549
|
+
// Bitcoin Core RPC code -5 has TWO meanings:
|
|
550
|
+
// - "No such mempool or blockchain transaction" → genuinely unknown
|
|
551
|
+
// (node has -txindex enabled, or the tx is unknown even in mempool)
|
|
552
|
+
// - "No such mempool transaction. Use -txindex or provide a block hash…"
|
|
553
|
+
// → the tx MIGHT exist on-chain but the node can't look it up
|
|
554
|
+
// without a block hash. Reporting NotFound here would silently
|
|
555
|
+
// misreport every confirmed deposit as missing on a non-txindex
|
|
556
|
+
// node — a real-money fail-open. Route it as RpcError so the
|
|
557
|
+
// consumer sees a node-misconfiguration signal.
|
|
558
|
+
if (/mempool or blockchain/i.test(message))
|
|
559
|
+
return true;
|
|
560
|
+
return false;
|
|
561
|
+
}
|
|
562
|
+
return false;
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Best-effort scrub for provider error messages so API keys and auth
|
|
566
|
+
* tokens don't leak into `TransactionErrorInfo.reason`. The UTXO
|
|
567
|
+
* providers (Esplora, Unisat, Ordiscan) carry keys in URL query strings,
|
|
568
|
+
* Authorization headers, AND URL paths (`/v1/<key>/tx/…`); a raw axios
|
|
569
|
+
* error stringifies the full request URL. Matches EVM's
|
|
570
|
+
* `sanitizeMessage` intent (errors.ts).
|
|
571
|
+
*/
|
|
572
|
+
function sanitizeUtxoErrMessage(msg) {
|
|
573
|
+
const utxoSpecific = msg
|
|
574
|
+
// Basic-auth credentials in a URL: http://user:pass@host — the
|
|
575
|
+
// canonical Bitcoin Core RPC form, which the -5 branch above
|
|
576
|
+
// specifically expects and could otherwise expose.
|
|
577
|
+
.replace(/(:\/\/)[^:@\s/]+:[^@\s/]+@/g, '$1***:***@')
|
|
578
|
+
// Provider-prefixed key markers (Blockstream/Unisat/Ordiscan style).
|
|
579
|
+
.replace(/\b(?:pk|sk|ghp|gho)_[A-Za-z0-9]{20,}\b/g, '***')
|
|
580
|
+
.replace(/\/[A-Fa-f0-9]{32,}\b/g, '/***');
|
|
581
|
+
// Route through the shared sanitizer so signed-tx redaction, apiKey/token
|
|
582
|
+
// params, Bearer headers, and path-embedded key rules apply uniformly
|
|
583
|
+
// across families (was: parallel UTXO-only sweep that had no signed-tx
|
|
584
|
+
// rule at all — a provider echoing the submitted hex would leak it).
|
|
585
|
+
return (0, errors_ts_1.sanitizeMessage)(utxoSpecific, null);
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* Rebuild a fresh Error from `cause` with the sanitized message + a
|
|
589
|
+
* sanitized stack. Drops axios `.config` / `.response` / `.request`
|
|
590
|
+
* object trees that carry Authorization headers and full request URLs.
|
|
591
|
+
* Symmetric with `sanitizeCause` (errors.ts) but with the UTXO-specific
|
|
592
|
+
* regex sweeps applied instead of a per-chain rpcUrl scrub.
|
|
593
|
+
*/
|
|
594
|
+
function sanitizedCauseForUtxo(cause, sanitizedMsg) {
|
|
595
|
+
const safe = new Error(sanitizedMsg);
|
|
596
|
+
safe.name = cause.name;
|
|
597
|
+
if (cause.stack)
|
|
598
|
+
safe.stack = sanitizeUtxoErrMessage(cause.stack);
|
|
599
|
+
return safe;
|
|
600
|
+
}
|
|
601
|
+
function encodeMemo(memo) {
|
|
602
|
+
if (memo === undefined || memo === null)
|
|
603
|
+
return null;
|
|
604
|
+
const buf = Buffer.from(memo, 'utf8');
|
|
605
|
+
if (buf.length === 0)
|
|
606
|
+
return null;
|
|
607
|
+
if (buf.length > utxo_network_params_ts_1.OP_RETURN_MAX_BYTES) {
|
|
608
|
+
throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, `memo length ${buf.length} bytes exceeds OP_RETURN max ${utxo_network_params_ts_1.OP_RETURN_MAX_BYTES}`);
|
|
609
|
+
}
|
|
610
|
+
return buf;
|
|
611
|
+
}
|
|
612
|
+
//# sourceMappingURL=utxo_chain.js.map
|