@getomnichain/omnichain 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +66 -0
- package/dist/abstract_gas_pricing.d.ts +31 -0
- package/dist/abstract_gas_pricing.d.ts.map +1 -0
- package/dist/abstract_gas_pricing.js +22 -0
- package/dist/abstract_gas_pricing.js.map +1 -0
- package/dist/address.d.ts +10 -0
- package/dist/address.d.ts.map +1 -0
- package/dist/address.factory.d.ts +26 -0
- package/dist/address.factory.d.ts.map +1 -0
- package/dist/address.factory.js +75 -0
- package/dist/address.factory.js.map +1 -0
- package/dist/address.js +13 -0
- package/dist/address.js.map +1 -0
- package/dist/address_field.decorator.d.ts +17 -0
- package/dist/address_field.decorator.d.ts.map +1 -0
- package/dist/address_field.decorator.js +34 -0
- package/dist/address_field.decorator.js.map +1 -0
- package/dist/chain.base.d.ts +79 -0
- package/dist/chain.base.d.ts.map +1 -0
- package/dist/chain.base.js +113 -0
- package/dist/chain.base.js.map +1 -0
- package/dist/chain_ids.d.ts +122 -0
- package/dist/chain_ids.d.ts.map +1 -0
- package/dist/chain_ids.js +193 -0
- package/dist/chain_ids.js.map +1 -0
- package/dist/errors.d.ts +42 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +62 -0
- package/dist/errors.js.map +1 -0
- package/dist/evm/evm_address.d.ts +11 -0
- package/dist/evm/evm_address.d.ts.map +1 -0
- package/dist/evm/evm_address.js +56 -0
- package/dist/evm/evm_address.js.map +1 -0
- package/dist/evm/evm_chain.d.ts +123 -0
- package/dist/evm/evm_chain.d.ts.map +1 -0
- package/dist/evm/evm_chain.js +685 -0
- package/dist/evm/evm_chain.js.map +1 -0
- package/dist/evm/evm_chains.d.ts +83 -0
- package/dist/evm/evm_chains.d.ts.map +1 -0
- package/dist/evm/evm_chains.js +493 -0
- package/dist/evm/evm_chains.js.map +1 -0
- package/dist/evm/evm_gas_estimate.d.ts +45 -0
- package/dist/evm/evm_gas_estimate.d.ts.map +1 -0
- package/dist/evm/evm_gas_estimate.js +70 -0
- package/dist/evm/evm_gas_estimate.js.map +1 -0
- package/dist/evm/evm_gas_pricing.d.ts +40 -0
- package/dist/evm/evm_gas_pricing.d.ts.map +1 -0
- package/dist/evm/evm_gas_pricing.js +56 -0
- package/dist/evm/evm_gas_pricing.js.map +1 -0
- package/dist/evm/evm_token.d.ts +7 -0
- package/dist/evm/evm_token.d.ts.map +1 -0
- package/dist/evm/evm_token.js +22 -0
- package/dist/evm/evm_token.js.map +1 -0
- package/dist/evm/evm_tokens.d.ts +81 -0
- package/dist/evm/evm_tokens.d.ts.map +1 -0
- package/dist/evm/evm_tokens.js +104 -0
- package/dist/evm/evm_tokens.js.map +1 -0
- package/dist/evm/evm_transaction_status.d.ts +108 -0
- package/dist/evm/evm_transaction_status.d.ts.map +1 -0
- package/dist/evm/evm_transaction_status.js +177 -0
- package/dist/evm/evm_transaction_status.js.map +1 -0
- package/dist/evm/index.d.ts +10 -0
- package/dist/evm/index.d.ts.map +1 -0
- package/dist/evm/index.js +10 -0
- package/dist/evm/index.js.map +1 -0
- package/dist/evm/unsigned_evm_transaction.d.ts +19 -0
- package/dist/evm/unsigned_evm_transaction.d.ts.map +1 -0
- package/dist/evm/unsigned_evm_transaction.js +18 -0
- package/dist/evm/unsigned_evm_transaction.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/is_address.decorator.d.ts +3 -0
- package/dist/is_address.decorator.d.ts.map +1 -0
- package/dist/is_address.decorator.js +51 -0
- package/dist/is_address.decorator.js.map +1 -0
- package/dist/network_type.d.ts +73 -0
- package/dist/network_type.d.ts.map +1 -0
- package/dist/network_type.js +144 -0
- package/dist/network_type.js.map +1 -0
- package/dist/priority.d.ts +23 -0
- package/dist/priority.d.ts.map +1 -0
- package/dist/priority.js +23 -0
- package/dist/priority.js.map +1 -0
- package/dist/solana/index.d.ts +9 -0
- package/dist/solana/index.d.ts.map +1 -0
- package/dist/solana/index.js +9 -0
- package/dist/solana/index.js.map +1 -0
- package/dist/solana/solana_address.d.ts +20 -0
- package/dist/solana/solana_address.d.ts.map +1 -0
- package/dist/solana/solana_address.js +45 -0
- package/dist/solana/solana_address.js.map +1 -0
- package/dist/solana/solana_chain.d.ts +213 -0
- package/dist/solana/solana_chain.d.ts.map +1 -0
- package/dist/solana/solana_chain.js +704 -0
- package/dist/solana/solana_chain.js.map +1 -0
- package/dist/solana/solana_chains.d.ts +24 -0
- package/dist/solana/solana_chains.d.ts.map +1 -0
- package/dist/solana/solana_chains.js +84 -0
- package/dist/solana/solana_chains.js.map +1 -0
- package/dist/solana/solana_gas_pricing.d.ts +30 -0
- package/dist/solana/solana_gas_pricing.d.ts.map +1 -0
- package/dist/solana/solana_gas_pricing.js +26 -0
- package/dist/solana/solana_gas_pricing.js.map +1 -0
- package/dist/solana/solana_token.d.ts +19 -0
- package/dist/solana/solana_token.d.ts.map +1 -0
- package/dist/solana/solana_token.js +34 -0
- package/dist/solana/solana_token.js.map +1 -0
- package/dist/solana/solana_tokens.d.ts +22 -0
- package/dist/solana/solana_tokens.d.ts.map +1 -0
- package/dist/solana/solana_tokens.js +26 -0
- package/dist/solana/solana_tokens.js.map +1 -0
- package/dist/solana/solana_transaction_status.d.ts +59 -0
- package/dist/solana/solana_transaction_status.d.ts.map +1 -0
- package/dist/solana/solana_transaction_status.js +144 -0
- package/dist/solana/solana_transaction_status.js.map +1 -0
- package/dist/solana/unsigned_solana_transaction.d.ts +31 -0
- package/dist/solana/unsigned_solana_transaction.d.ts.map +1 -0
- package/dist/solana/unsigned_solana_transaction.js +26 -0
- package/dist/solana/unsigned_solana_transaction.js.map +1 -0
- package/dist/token.d.ts +35 -0
- package/dist/token.d.ts.map +1 -0
- package/dist/token.js +62 -0
- package/dist/token.js.map +1 -0
- package/dist/ton/index.d.ts +2 -0
- package/dist/ton/index.d.ts.map +1 -0
- package/dist/ton/index.js +2 -0
- package/dist/ton/index.js.map +1 -0
- package/dist/ton/ton_address.d.ts +10 -0
- package/dist/ton/ton_address.d.ts.map +1 -0
- package/dist/ton/ton_address.js +53 -0
- package/dist/ton/ton_address.js.map +1 -0
- package/dist/transaction_status.d.ts +140 -0
- package/dist/transaction_status.d.ts.map +1 -0
- package/dist/transaction_status.js +271 -0
- package/dist/transaction_status.js.map +1 -0
- package/dist/unsigned_transaction.d.ts +7 -0
- package/dist/unsigned_transaction.d.ts.map +1 -0
- package/dist/unsigned_transaction.js +9 -0
- package/dist/unsigned_transaction.js.map +1 -0
- package/dist/utxo/btc/btc_address.d.ts +15 -0
- package/dist/utxo/btc/btc_address.d.ts.map +1 -0
- package/dist/utxo/btc/btc_address.js +39 -0
- package/dist/utxo/btc/btc_address.js.map +1 -0
- package/dist/utxo/btc/btc_chain.d.ts +34 -0
- package/dist/utxo/btc/btc_chain.d.ts.map +1 -0
- package/dist/utxo/btc/btc_chain.js +62 -0
- package/dist/utxo/btc/btc_chain.js.map +1 -0
- package/dist/utxo/btc/btc_chains.d.ts +25 -0
- package/dist/utxo/btc/btc_chains.d.ts.map +1 -0
- package/dist/utxo/btc/btc_chains.js +43 -0
- package/dist/utxo/btc/btc_chains.js.map +1 -0
- package/dist/utxo/btc/btc_token.d.ts +6 -0
- package/dist/utxo/btc/btc_token.d.ts.map +1 -0
- package/dist/utxo/btc/btc_token.js +11 -0
- package/dist/utxo/btc/btc_token.js.map +1 -0
- package/dist/utxo/btc/index.d.ts +14 -0
- package/dist/utxo/btc/index.d.ts.map +1 -0
- package/dist/utxo/btc/index.js +14 -0
- package/dist/utxo/btc/index.js.map +1 -0
- package/dist/utxo/btc/network_params.d.ts +50 -0
- package/dist/utxo/btc/network_params.d.ts.map +1 -0
- package/dist/utxo/btc/network_params.js +188 -0
- package/dist/utxo/btc/network_params.js.map +1 -0
- package/dist/utxo/btc/tools/asset_outpoint.d.ts +7 -0
- package/dist/utxo/btc/tools/asset_outpoint.d.ts.map +1 -0
- package/dist/utxo/btc/tools/asset_outpoint.js +12 -0
- package/dist/utxo/btc/tools/asset_outpoint.js.map +1 -0
- package/dist/utxo/btc/tools/bitcoin_core.tool.d.ts +41 -0
- package/dist/utxo/btc/tools/bitcoin_core.tool.d.ts.map +1 -0
- package/dist/utxo/btc/tools/bitcoin_core.tool.js +172 -0
- package/dist/utxo/btc/tools/bitcoin_core.tool.js.map +1 -0
- package/dist/utxo/btc/tools/esplora.tool.d.ts +27 -0
- package/dist/utxo/btc/tools/esplora.tool.d.ts.map +1 -0
- package/dist/utxo/btc/tools/esplora.tool.js +113 -0
- package/dist/utxo/btc/tools/esplora.tool.js.map +1 -0
- package/dist/utxo/btc/tools/inscription_index.d.ts +6 -0
- package/dist/utxo/btc/tools/inscription_index.d.ts.map +1 -0
- package/dist/utxo/btc/tools/inscription_index.js +2 -0
- package/dist/utxo/btc/tools/inscription_index.js.map +1 -0
- package/dist/utxo/btc/tools/ordiscan.tool.d.ts +19 -0
- package/dist/utxo/btc/tools/ordiscan.tool.d.ts.map +1 -0
- package/dist/utxo/btc/tools/ordiscan.tool.js +53 -0
- package/dist/utxo/btc/tools/ordiscan.tool.js.map +1 -0
- package/dist/utxo/btc/tools/rare_sat_index.d.ts +6 -0
- package/dist/utxo/btc/tools/rare_sat_index.d.ts.map +1 -0
- package/dist/utxo/btc/tools/rare_sat_index.js +2 -0
- package/dist/utxo/btc/tools/rare_sat_index.js.map +1 -0
- package/dist/utxo/btc/tools/rune_index.d.ts +6 -0
- package/dist/utxo/btc/tools/rune_index.d.ts.map +1 -0
- package/dist/utxo/btc/tools/rune_index.js +2 -0
- package/dist/utxo/btc/tools/rune_index.js.map +1 -0
- package/dist/utxo/btc/tools/unisat.tool.d.ts +18 -0
- package/dist/utxo/btc/tools/unisat.tool.d.ts.map +1 -0
- package/dist/utxo/btc/tools/unisat.tool.js +49 -0
- package/dist/utxo/btc/tools/unisat.tool.js.map +1 -0
- package/dist/utxo/coin_selection.d.ts +29 -0
- package/dist/utxo/coin_selection.d.ts.map +1 -0
- package/dist/utxo/coin_selection.js +156 -0
- package/dist/utxo/coin_selection.js.map +1 -0
- package/dist/utxo/doge/doge_chains.d.ts +17 -0
- package/dist/utxo/doge/doge_chains.d.ts.map +1 -0
- package/dist/utxo/doge/doge_chains.js +28 -0
- package/dist/utxo/doge/doge_chains.js.map +1 -0
- package/dist/utxo/doge/index.d.ts +3 -0
- package/dist/utxo/doge/index.d.ts.map +1 -0
- package/dist/utxo/doge/index.js +3 -0
- package/dist/utxo/doge/index.js.map +1 -0
- package/dist/utxo/doge/network_params.d.ts +4 -0
- package/dist/utxo/doge/network_params.d.ts.map +1 -0
- package/dist/utxo/doge/network_params.js +24 -0
- package/dist/utxo/doge/network_params.js.map +1 -0
- package/dist/utxo/ecc.d.ts +2 -0
- package/dist/utxo/ecc.d.ts.map +1 -0
- package/dist/utxo/ecc.js +11 -0
- package/dist/utxo/ecc.js.map +1 -0
- package/dist/utxo/fee.d.ts +12 -0
- package/dist/utxo/fee.d.ts.map +1 -0
- package/dist/utxo/fee.js +51 -0
- package/dist/utxo/fee.js.map +1 -0
- package/dist/utxo/index.d.ts +20 -0
- package/dist/utxo/index.d.ts.map +1 -0
- package/dist/utxo/index.js +20 -0
- package/dist/utxo/index.js.map +1 -0
- package/dist/utxo/ltc/index.d.ts +3 -0
- package/dist/utxo/ltc/index.d.ts.map +1 -0
- package/dist/utxo/ltc/index.js +3 -0
- package/dist/utxo/ltc/index.js.map +1 -0
- package/dist/utxo/ltc/ltc_chains.d.ts +17 -0
- package/dist/utxo/ltc/ltc_chains.d.ts.map +1 -0
- package/dist/utxo/ltc/ltc_chains.js +28 -0
- package/dist/utxo/ltc/ltc_chains.js.map +1 -0
- package/dist/utxo/ltc/network_params.d.ts +4 -0
- package/dist/utxo/ltc/network_params.d.ts.map +1 -0
- package/dist/utxo/ltc/network_params.js +27 -0
- package/dist/utxo/ltc/network_params.js.map +1 -0
- package/dist/utxo/script.d.ts +16 -0
- package/dist/utxo/script.d.ts.map +1 -0
- package/dist/utxo/script.js +52 -0
- package/dist/utxo/script.js.map +1 -0
- package/dist/utxo/tools/broadcaster.d.ts +6 -0
- package/dist/utxo/tools/broadcaster.d.ts.map +1 -0
- package/dist/utxo/tools/broadcaster.js +2 -0
- package/dist/utxo/tools/broadcaster.js.map +1 -0
- package/dist/utxo/tools/chain_tip_provider.d.ts +5 -0
- package/dist/utxo/tools/chain_tip_provider.d.ts.map +1 -0
- package/dist/utxo/tools/chain_tip_provider.js +2 -0
- package/dist/utxo/tools/chain_tip_provider.js.map +1 -0
- package/dist/utxo/tools/fee_estimator.d.ts +6 -0
- package/dist/utxo/tools/fee_estimator.d.ts.map +1 -0
- package/dist/utxo/tools/fee_estimator.js +2 -0
- package/dist/utxo/tools/fee_estimator.js.map +1 -0
- package/dist/utxo/tools/raw_transaction_provider.d.ts +8 -0
- package/dist/utxo/tools/raw_transaction_provider.d.ts.map +1 -0
- package/dist/utxo/tools/raw_transaction_provider.js +2 -0
- package/dist/utxo/tools/raw_transaction_provider.js.map +1 -0
- package/dist/utxo/tools/utxo_provider.d.ts +7 -0
- package/dist/utxo/tools/utxo_provider.d.ts.map +1 -0
- package/dist/utxo/tools/utxo_provider.js +2 -0
- package/dist/utxo/tools/utxo_provider.js.map +1 -0
- package/dist/utxo/unsigned_utxo_transaction.d.ts +32 -0
- package/dist/utxo/unsigned_utxo_transaction.d.ts.map +1 -0
- package/dist/utxo/unsigned_utxo_transaction.js +32 -0
- package/dist/utxo/unsigned_utxo_transaction.js.map +1 -0
- package/dist/utxo/utxo.d.ts +43 -0
- package/dist/utxo/utxo.d.ts.map +1 -0
- package/dist/utxo/utxo.js +2 -0
- package/dist/utxo/utxo.js.map +1 -0
- package/dist/utxo/utxo_chain.d.ts +102 -0
- package/dist/utxo/utxo_chain.d.ts.map +1 -0
- package/dist/utxo/utxo_chain.js +524 -0
- package/dist/utxo/utxo_chain.js.map +1 -0
- package/dist/utxo/utxo_chains.d.ts +29 -0
- package/dist/utxo/utxo_chains.d.ts.map +1 -0
- package/dist/utxo/utxo_chains.js +63 -0
- package/dist/utxo/utxo_chains.js.map +1 -0
- package/dist/utxo/utxo_gas_pricing.d.ts +22 -0
- package/dist/utxo/utxo_gas_pricing.d.ts.map +1 -0
- package/dist/utxo/utxo_gas_pricing.js +20 -0
- package/dist/utxo/utxo_gas_pricing.js.map +1 -0
- package/dist/utxo/utxo_network_params.d.ts +25 -0
- package/dist/utxo/utxo_network_params.d.ts.map +1 -0
- package/dist/utxo/utxo_network_params.js +15 -0
- package/dist/utxo/utxo_network_params.js.map +1 -0
- package/dist/utxo/utxo_transaction_status.d.ts +73 -0
- package/dist/utxo/utxo_transaction_status.d.ts.map +1 -0
- package/dist/utxo/utxo_transaction_status.js +89 -0
- package/dist/utxo/utxo_transaction_status.js.map +1 -0
- package/docs/PUBLISHING.md +119 -0
- package/docs/README.md +273 -0
- package/docs/evm.md +205 -0
- package/docs/solana.md +220 -0
- package/docs/utxo.md +364 -0
- package/package.json +94 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset_outpoint.d.ts","sourceRoot":"","sources":["../../../../utxo/btc/tools/asset_outpoint.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,aAAa,CAAC,SAAS,oBAAoB,EAAE,CAAC,GACrD,GAAG,CAAC,MAAM,CAAC,CAMb"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function outpointKey(txid, vout) {
|
|
2
|
+
return `${txid}:${vout}`;
|
|
3
|
+
}
|
|
4
|
+
export function unionOutpoints(groups) {
|
|
5
|
+
const set = new Set();
|
|
6
|
+
for (const group of groups) {
|
|
7
|
+
for (const o of group)
|
|
8
|
+
set.add(outpointKey(o.txid, o.vout));
|
|
9
|
+
}
|
|
10
|
+
return set;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=asset_outpoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset_outpoint.js","sourceRoot":"","sources":["../../../../utxo/btc/tools/asset_outpoint.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,IAAY;IACpD,OAAO,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,MAAsD;IAEtD,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,KAAK,MAAM,CAAC,IAAI,KAAK;YAAE,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { UtxoBroadcaster } from '../../tools/broadcaster.ts';
|
|
2
|
+
import { UtxoChainTipProvider } from '../../tools/chain_tip_provider.ts';
|
|
3
|
+
import { UtxoFeeEstimator } from '../../tools/fee_estimator.ts';
|
|
4
|
+
import { UtxoRawTransactionProvider } from '../../tools/raw_transaction_provider.ts';
|
|
5
|
+
import { UtxoProvider } from '../../tools/utxo_provider.ts';
|
|
6
|
+
import { UtxoNetworkParams } from '../../utxo_network_params.ts';
|
|
7
|
+
import { AddressBalance, BroadcastResult, FeeEstimate, RawTransactionView, UnspentTransactionOutput } from '../../utxo.ts';
|
|
8
|
+
export interface BitcoinCoreToolOptions {
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
user: string;
|
|
11
|
+
password: string;
|
|
12
|
+
params: UtxoNetworkParams;
|
|
13
|
+
wallet?: string;
|
|
14
|
+
timeoutMs?: number;
|
|
15
|
+
feeEstimateMode?: 'CONSERVATIVE' | 'ECONOMICAL';
|
|
16
|
+
importTimestamp?: 'now' | number;
|
|
17
|
+
watchOnlyLabel?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare class BitcoinCoreTool implements UtxoProvider, UtxoRawTransactionProvider, UtxoFeeEstimator, UtxoBroadcaster, UtxoChainTipProvider {
|
|
20
|
+
private readonly client;
|
|
21
|
+
private readonly params;
|
|
22
|
+
private readonly wallet?;
|
|
23
|
+
private readonly feeEstimateMode;
|
|
24
|
+
private readonly importTimestamp;
|
|
25
|
+
private readonly watchOnlyLabel;
|
|
26
|
+
private readonly watchedAddresses;
|
|
27
|
+
constructor(options: BitcoinCoreToolOptions);
|
|
28
|
+
get name(): string;
|
|
29
|
+
getUtxos(address: string): Promise<UnspentTransactionOutput[]>;
|
|
30
|
+
ensureAddressWatched(address: string): Promise<void>;
|
|
31
|
+
getAddressBalance(address: string): Promise<AddressBalance>;
|
|
32
|
+
getRawTransactionHex(txid: string): Promise<string>;
|
|
33
|
+
getRawTransactionHexBatch(txids: readonly string[]): Promise<string[]>;
|
|
34
|
+
getTransaction(txid: string): Promise<RawTransactionView>;
|
|
35
|
+
getFeeEstimate(targetBlocks: number): Promise<FeeEstimate>;
|
|
36
|
+
broadcast(rawHex: string): Promise<BroadcastResult>;
|
|
37
|
+
getChainTipHeight(): Promise<number>;
|
|
38
|
+
private rpc;
|
|
39
|
+
private batchRpc;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=bitcoin_core.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitcoin_core.tool.d.ts","sourceRoot":"","sources":["../../../../utxo/btc/tools/bitcoin_core.tool.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCA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qB9D,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA6BpD,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAW3D,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAInD,yBAAyB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAKtE,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA2BzD,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAe1D,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAKnD,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;YAI5B,GAAG;YAaH,QAAQ;CA0BvB"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { addressToScriptPubKey, detectScriptType } from "../../script.js";
|
|
3
|
+
const SATS_PER_BTC = 100_000_000;
|
|
4
|
+
export class BitcoinCoreTool {
|
|
5
|
+
client;
|
|
6
|
+
params;
|
|
7
|
+
wallet;
|
|
8
|
+
feeEstimateMode;
|
|
9
|
+
importTimestamp;
|
|
10
|
+
watchOnlyLabel;
|
|
11
|
+
watchedAddresses = new Set();
|
|
12
|
+
constructor(options) {
|
|
13
|
+
if (!options.baseUrl || options.baseUrl.trim().length === 0) {
|
|
14
|
+
throw new Error('BitcoinCoreTool: baseUrl is required');
|
|
15
|
+
}
|
|
16
|
+
this.params = options.params;
|
|
17
|
+
this.wallet = options.wallet;
|
|
18
|
+
this.feeEstimateMode = options.feeEstimateMode ?? 'CONSERVATIVE';
|
|
19
|
+
this.importTimestamp = options.importTimestamp ?? 'now';
|
|
20
|
+
this.watchOnlyLabel = options.watchOnlyLabel ?? 'utxo-watch';
|
|
21
|
+
const auth = Buffer.from(`${options.user}:${options.password}`).toString('base64');
|
|
22
|
+
this.client = axios.create({
|
|
23
|
+
baseURL: options.baseUrl.replace(/\/$/, ''),
|
|
24
|
+
timeout: options.timeoutMs ?? 10_000,
|
|
25
|
+
headers: { Authorization: `Basic ${auth}`, 'Content-Type': 'text/plain' },
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
get name() {
|
|
29
|
+
return `bitcoin-core(${this.params.name})`;
|
|
30
|
+
}
|
|
31
|
+
async getUtxos(address) {
|
|
32
|
+
await this.ensureAddressWatched(address);
|
|
33
|
+
const items = await this.rpc('listunspent', [
|
|
34
|
+
0,
|
|
35
|
+
9_999_999,
|
|
36
|
+
[address],
|
|
37
|
+
]);
|
|
38
|
+
const scriptPubKey = addressToScriptPubKey(address, this.params.networkInfo);
|
|
39
|
+
const scriptType = detectScriptType(scriptPubKey);
|
|
40
|
+
const scriptPubKeyHex = Buffer.from(scriptPubKey).toString('hex');
|
|
41
|
+
return items.map((u) => ({
|
|
42
|
+
txid: u.txid,
|
|
43
|
+
vout: u.vout,
|
|
44
|
+
valueSats: Math.round(u.amount * SATS_PER_BTC),
|
|
45
|
+
scriptPubKeyHex,
|
|
46
|
+
scriptType,
|
|
47
|
+
confirmations: u.confirmations,
|
|
48
|
+
ownerAddress: address,
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
async ensureAddressWatched(address) {
|
|
52
|
+
if (this.watchedAddresses.has(address))
|
|
53
|
+
return;
|
|
54
|
+
const info = await this.rpc('getaddressinfo', [address]);
|
|
55
|
+
if (info.ismine || info.iswatchonly) {
|
|
56
|
+
this.watchedAddresses.add(address);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const descriptor = `addr(${address})`;
|
|
60
|
+
const info2 = await this.rpc('getdescriptorinfo', [descriptor]);
|
|
61
|
+
const result = await this.rpc('importdescriptors', [
|
|
62
|
+
[
|
|
63
|
+
{
|
|
64
|
+
desc: info2.descriptor,
|
|
65
|
+
timestamp: this.importTimestamp,
|
|
66
|
+
active: false,
|
|
67
|
+
internal: false,
|
|
68
|
+
label: this.watchOnlyLabel,
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
]);
|
|
72
|
+
if (!result[0]?.success) {
|
|
73
|
+
const err = result[0]?.error;
|
|
74
|
+
throw new Error(`BitcoinCoreTool: failed to import descriptor for ${address}: ${err?.message ?? 'unknown error'}`);
|
|
75
|
+
}
|
|
76
|
+
this.watchedAddresses.add(address);
|
|
77
|
+
}
|
|
78
|
+
async getAddressBalance(address) {
|
|
79
|
+
const utxos = await this.getUtxos(address);
|
|
80
|
+
let confirmed = 0;
|
|
81
|
+
let unconfirmed = 0;
|
|
82
|
+
for (const u of utxos) {
|
|
83
|
+
if (u.confirmations > 0)
|
|
84
|
+
confirmed += u.valueSats;
|
|
85
|
+
else
|
|
86
|
+
unconfirmed += u.valueSats;
|
|
87
|
+
}
|
|
88
|
+
return { confirmedSats: confirmed, unconfirmedSats: unconfirmed };
|
|
89
|
+
}
|
|
90
|
+
async getRawTransactionHex(txid) {
|
|
91
|
+
return this.rpc('getrawtransaction', [txid, false]);
|
|
92
|
+
}
|
|
93
|
+
async getRawTransactionHexBatch(txids) {
|
|
94
|
+
if (txids.length === 0)
|
|
95
|
+
return [];
|
|
96
|
+
return this.batchRpc(txids.map((txid) => ({ method: 'getrawtransaction', params: [txid, false] })));
|
|
97
|
+
}
|
|
98
|
+
async getTransaction(txid) {
|
|
99
|
+
const verbose = await this.rpc('getrawtransaction', [txid, true]);
|
|
100
|
+
const vin = verbose.vin
|
|
101
|
+
.filter((v) => v.txid !== undefined && v.vout !== undefined)
|
|
102
|
+
.map((v) => ({ txid: v.txid, vout: v.vout }));
|
|
103
|
+
const vout = verbose.vout.map((o) => {
|
|
104
|
+
const hex = o.scriptPubKey.hex;
|
|
105
|
+
const buf = Buffer.from(hex, 'hex');
|
|
106
|
+
return {
|
|
107
|
+
valueSats: Math.round(o.value * SATS_PER_BTC),
|
|
108
|
+
scriptPubKeyHex: hex,
|
|
109
|
+
scriptType: detectScriptType(buf),
|
|
110
|
+
address: o.scriptPubKey.address ?? null,
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
return {
|
|
114
|
+
txid: verbose.txid,
|
|
115
|
+
hex: verbose.hex,
|
|
116
|
+
vin,
|
|
117
|
+
vout,
|
|
118
|
+
confirmations: verbose.confirmations ?? 0,
|
|
119
|
+
blockHeight: verbose.blockheight ?? null,
|
|
120
|
+
blockTime: typeof verbose.blocktime === 'number' ? new Date(verbose.blocktime * 1000) : null,
|
|
121
|
+
fees: verbose.fee !== undefined ? { absoluteSats: Math.round(verbose.fee * SATS_PER_BTC) } : null,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
async getFeeEstimate(targetBlocks) {
|
|
125
|
+
const result = await this.rpc('estimatesmartfee', [
|
|
126
|
+
targetBlocks,
|
|
127
|
+
this.feeEstimateMode,
|
|
128
|
+
]);
|
|
129
|
+
if (result.feerate === undefined) {
|
|
130
|
+
throw new Error(`BitcoinCoreTool: estimatesmartfee returned no feerate (${result.errors?.join(', ') ?? 'no detail'})`);
|
|
131
|
+
}
|
|
132
|
+
const satsPerKvByte = Math.ceil(result.feerate * SATS_PER_BTC);
|
|
133
|
+
const satsPerVByte = Math.max(1, Math.ceil(satsPerKvByte / 1000));
|
|
134
|
+
return { satsPerVByte };
|
|
135
|
+
}
|
|
136
|
+
async broadcast(rawHex) {
|
|
137
|
+
const txid = await this.rpc('sendrawtransaction', [rawHex]);
|
|
138
|
+
return { txid };
|
|
139
|
+
}
|
|
140
|
+
async getChainTipHeight() {
|
|
141
|
+
return this.rpc('getblockcount', []);
|
|
142
|
+
}
|
|
143
|
+
async rpc(method, params) {
|
|
144
|
+
const path = this.wallet ? `/wallet/${this.wallet}` : '/';
|
|
145
|
+
const body = JSON.stringify({ jsonrpc: '1.0', id: 'rpc', method, params });
|
|
146
|
+
const { data } = await this.client.post(path, body);
|
|
147
|
+
if (data.error) {
|
|
148
|
+
throw new Error(`bitcoin-core ${method}: ${data.error.code} ${data.error.message}`);
|
|
149
|
+
}
|
|
150
|
+
return data.result;
|
|
151
|
+
}
|
|
152
|
+
async batchRpc(calls) {
|
|
153
|
+
if (calls.length === 0)
|
|
154
|
+
return [];
|
|
155
|
+
const path = this.wallet ? `/wallet/${this.wallet}` : '/';
|
|
156
|
+
const body = JSON.stringify(calls.map((c, i) => ({ jsonrpc: '1.0', id: `rpc-${i}`, method: c.method, params: c.params })));
|
|
157
|
+
const { data } = await this.client.post(path, body);
|
|
158
|
+
const results = new Array(calls.length);
|
|
159
|
+
for (const entry of data) {
|
|
160
|
+
const idx = parseInt(entry.id.split('-')[1] ?? '', 10);
|
|
161
|
+
if (!Number.isInteger(idx) || idx < 0 || idx >= calls.length) {
|
|
162
|
+
throw new Error(`bitcoin-core batch: unexpected response id "${entry.id}"`);
|
|
163
|
+
}
|
|
164
|
+
if (entry.error) {
|
|
165
|
+
throw new Error(`bitcoin-core[${idx}] ${calls[idx].method}: ${entry.error.code} ${entry.error.message}`);
|
|
166
|
+
}
|
|
167
|
+
results[idx] = entry.result;
|
|
168
|
+
}
|
|
169
|
+
return results;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=bitcoin_core.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitcoin_core.tool.js","sourceRoot":"","sources":["../../../../utxo/btc/tools/bitcoin_core.tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AA0F1E,MAAM,YAAY,GAAG,WAAW,CAAC;AAEjC,MAAM,OAAO,eAAe;IAQT,MAAM,CAAgB;IACtB,MAAM,CAAoB;IAC1B,MAAM,CAAU;IAChB,eAAe,CAAgC;IAC/C,eAAe,CAAiB;IAChC,cAAc,CAAS;IACvB,gBA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C,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAC9F,CAAC;QACF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAErC,IAAI,EAAE,IAAI,CAAC,CAAC;QACd,MAAM,OAAO,GAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC7C,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE,CAAC;YACzB,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;YACvD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;gBAC7D,MAAM,IAAI,KAAK,CAAC,+CAA+C,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;YAC9E,CAAC;YACD,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;gBAChB,MAAM,IAAI,KAAK,CACb,gBAAgB,GAAG,KAAK,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CACxF,CAAC;YACJ,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC;QAC9B,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { UtxoBroadcaster } from '../../tools/broadcaster.ts';
|
|
2
|
+
import { UtxoChainTipProvider } from '../../tools/chain_tip_provider.ts';
|
|
3
|
+
import { UtxoFeeEstimator } from '../../tools/fee_estimator.ts';
|
|
4
|
+
import { UtxoRawTransactionProvider } from '../../tools/raw_transaction_provider.ts';
|
|
5
|
+
import { UtxoProvider } from '../../tools/utxo_provider.ts';
|
|
6
|
+
import { UtxoNetworkParams } from '../../utxo_network_params.ts';
|
|
7
|
+
import { AddressBalance, BroadcastResult, FeeEstimate, RawTransactionView, UnspentTransactionOutput } from '../../utxo.ts';
|
|
8
|
+
export interface EsploraToolOptions {
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
params: UtxoNetworkParams;
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class EsploraTool implements UtxoProvider, UtxoRawTransactionProvider, UtxoFeeEstimator, UtxoBroadcaster, UtxoChainTipProvider {
|
|
14
|
+
private readonly client;
|
|
15
|
+
private readonly params;
|
|
16
|
+
constructor(options: EsploraToolOptions);
|
|
17
|
+
get name(): string;
|
|
18
|
+
getRawTransactionHexBatch(txids: readonly string[]): Promise<string[]>;
|
|
19
|
+
getUtxos(address: string): Promise<UnspentTransactionOutput[]>;
|
|
20
|
+
getAddressBalance(address: string): Promise<AddressBalance>;
|
|
21
|
+
getRawTransactionHex(txid: string): Promise<string>;
|
|
22
|
+
getTransaction(txid: string): Promise<RawTransactionView>;
|
|
23
|
+
getFeeEstimate(targetBlocks: number): Promise<FeeEstimate>;
|
|
24
|
+
broadcast(rawHex: string): Promise<BroadcastResult>;
|
|
25
|
+
getChainTipHeight(): Promise<number>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=esplora.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esplora.tool.d.ts","sourceRoot":"","sources":["../../../../utxo/btc/tools/esplora.tool.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;A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../../script.js";
|
|
3
|
+
export class EsploraTool {
|
|
4
|
+
client;
|
|
5
|
+
params;
|
|
6
|
+
constructor(options) {
|
|
7
|
+
if (!options.baseUrl || options.baseUrl.trim().length === 0) {
|
|
8
|
+
throw new Error('EsploraTool: baseUrl is required');
|
|
9
|
+
}
|
|
10
|
+
this.params = options.params;
|
|
11
|
+
this.client = axios.create({
|
|
12
|
+
baseURL: options.baseUrl.replace(/\/$/, ''),
|
|
13
|
+
timeout: options.timeoutMs ?? 10_000,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
get name() {
|
|
17
|
+
return `esplora(${this.params.name})`;
|
|
18
|
+
}
|
|
19
|
+
async getRawTransactionHexBatch(txids) {
|
|
20
|
+
return Promise.all(txids.map((txid) => this.getRawTransactionHex(txid)));
|
|
21
|
+
}
|
|
22
|
+
async getUtxos(address) {
|
|
23
|
+
const tipHeight = await this.getChainTipHeight();
|
|
24
|
+
const { data } = await this.client.get(`/address/${address}/utxo`);
|
|
25
|
+
const scriptPubKey = addressToScriptPubKey(address, this.params.networkInfo);
|
|
26
|
+
const scriptType = detectScriptType(scriptPubKey);
|
|
27
|
+
const scriptPubKeyHex = Buffer.from(scriptPubKey).toString('hex');
|
|
28
|
+
return data.map((u) => ({
|
|
29
|
+
txid: u.txid,
|
|
30
|
+
vout: u.vout,
|
|
31
|
+
valueSats: u.value,
|
|
32
|
+
scriptPubKeyHex,
|
|
33
|
+
scriptType,
|
|
34
|
+
confirmations: u.status.confirmed && u.status.block_height
|
|
35
|
+
? Math.max(0, tipHeight - u.status.block_height + 1)
|
|
36
|
+
: 0,
|
|
37
|
+
ownerAddress: address,
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
async getAddressBalance(address) {
|
|
41
|
+
const { data } = await this.client.get(`/address/${address}`);
|
|
42
|
+
const confirmed = data.chain_stats.funded_txo_sum - data.chain_stats.spent_txo_sum;
|
|
43
|
+
const mempool = data.mempool_stats.funded_txo_sum - data.mempool_stats.spent_txo_sum;
|
|
44
|
+
return { confirmedSats: confirmed, unconfirmedSats: mempool };
|
|
45
|
+
}
|
|
46
|
+
async getRawTransactionHex(txid) {
|
|
47
|
+
const { data } = await this.client.get(`/tx/${txid}/hex`, { responseType: 'text' });
|
|
48
|
+
return data;
|
|
49
|
+
}
|
|
50
|
+
async getTransaction(txid) {
|
|
51
|
+
const tipHeight = await this.getChainTipHeight();
|
|
52
|
+
const [{ data: meta }, hex] = await Promise.all([
|
|
53
|
+
this.client.get(`/tx/${txid}`),
|
|
54
|
+
this.getRawTransactionHex(txid),
|
|
55
|
+
]);
|
|
56
|
+
const vin = meta.vin.map((v) => ({ txid: v.txid, vout: v.vout }));
|
|
57
|
+
const vout = meta.vout.map((o) => {
|
|
58
|
+
const script = Buffer.from(o.scriptpubkey, 'hex');
|
|
59
|
+
return {
|
|
60
|
+
valueSats: o.value,
|
|
61
|
+
scriptPubKeyHex: o.scriptpubkey,
|
|
62
|
+
scriptType: detectScriptType(script),
|
|
63
|
+
address: o.scriptpubkey_address ?? null,
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
const blockHeight = meta.status.confirmed && meta.status.block_height ? meta.status.block_height : null;
|
|
67
|
+
const blockTime = meta.status.confirmed && typeof meta.status.block_time === 'number'
|
|
68
|
+
? new Date(meta.status.block_time * 1000)
|
|
69
|
+
: null;
|
|
70
|
+
return {
|
|
71
|
+
txid: meta.txid,
|
|
72
|
+
hex,
|
|
73
|
+
vin,
|
|
74
|
+
vout,
|
|
75
|
+
confirmations: blockHeight ? Math.max(0, tipHeight - blockHeight + 1) : 0,
|
|
76
|
+
blockHeight,
|
|
77
|
+
blockTime,
|
|
78
|
+
fees: meta.fee !== undefined ? { absoluteSats: meta.fee } : null,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
async getFeeEstimate(targetBlocks) {
|
|
82
|
+
const { data } = await this.client.get(`/fee-estimates`);
|
|
83
|
+
const keys = Object.keys(data)
|
|
84
|
+
.map((k) => parseInt(k, 10))
|
|
85
|
+
.filter((k) => !Number.isNaN(k))
|
|
86
|
+
.sort((a, b) => a - b);
|
|
87
|
+
let chosenKey;
|
|
88
|
+
for (const k of keys) {
|
|
89
|
+
if (k >= targetBlocks) {
|
|
90
|
+
chosenKey = k;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (chosenKey === undefined)
|
|
95
|
+
chosenKey = keys[keys.length - 1];
|
|
96
|
+
if (chosenKey === undefined)
|
|
97
|
+
throw new Error('EsploraTool: no fee estimates returned');
|
|
98
|
+
const rate = Math.max(1, Math.ceil(data[String(chosenKey)]));
|
|
99
|
+
return { satsPerVByte: rate };
|
|
100
|
+
}
|
|
101
|
+
async broadcast(rawHex) {
|
|
102
|
+
const { data } = await this.client.post(`/tx`, rawHex, {
|
|
103
|
+
headers: { 'Content-Type': 'text/plain' },
|
|
104
|
+
responseType: 'text',
|
|
105
|
+
});
|
|
106
|
+
return { txid: data.trim() };
|
|
107
|
+
}
|
|
108
|
+
async getChainTipHeight() {
|
|
109
|
+
const { data } = await this.client.get(`/blocks/tip/height`, { responseType: 'text' });
|
|
110
|
+
return parseInt(String(data).trim(), 10);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=esplora.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esplora.tool.js","sourceRoot":"","sources":["../../../../utxo/btc/tools/esplora.tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAsD1E,MAAM,OAAO,WAAW;IAQL,MAAM,CAAgB;IACtB,MAAM,CAAoB;IAE3C,YAAY,OAA2B;QACrC,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5D,M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IAChC,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,MAAc;QAC5B,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAS,KAAK,EAAE,MAAM,EAAE;YAC7D,OAAO,EAAE,EAAE,cAAc,EAAE,YAAY,EAAE;YACzC,YAAY,EAAE,MAAM;SACrB,CAAC,CAAC;QACH,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,iBAAiB;QACrB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAS,oBAAoB,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC;QAC/F,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IAC3C,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inscription_index.d.ts","sourceRoot":"","sources":["../../../../utxo/btc/tools/inscription_index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,oBAAoB,EAAE,CAAC,CAAC;CACtF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inscription_index.js","sourceRoot":"","sources":["../../../../utxo/btc/tools/inscription_index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AssetBearingOutpoint } from './asset_outpoint.ts';
|
|
2
|
+
import { BtcInscriptionIndex } from './inscription_index.ts';
|
|
3
|
+
import { BtcRareSatIndex } from './rare_sat_index.ts';
|
|
4
|
+
import { BtcRuneIndex } from './rune_index.ts';
|
|
5
|
+
export interface OrdiscanIndexOptions {
|
|
6
|
+
apiKey: string;
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
timeoutMs?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare class OrdiscanIndex implements BtcInscriptionIndex, BtcRuneIndex, BtcRareSatIndex {
|
|
11
|
+
private readonly client;
|
|
12
|
+
constructor(options: OrdiscanIndexOptions);
|
|
13
|
+
get name(): string;
|
|
14
|
+
outpointsWithInscriptions(address: string): Promise<readonly AssetBearingOutpoint[]>;
|
|
15
|
+
outpointsWithRunes(address: string): Promise<readonly AssetBearingOutpoint[]>;
|
|
16
|
+
outpointsWithRareSats(address: string): Promise<readonly AssetBearingOutpoint[]>;
|
|
17
|
+
private fetch;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=ordiscan.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ordiscan.tool.d.ts","sourceRoot":"","sources":["../../../../utxo/btc/tools/ordiscan.tool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAqBD,qBAAa,aACX,YAAW,mBAAmB,EAAE,YAAY,EAAE,eAAe;IAE7D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;gBAE3B,OAAO,EAAE,oBAAoB;IAWzC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAEK,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,oBAAoB,EAAE,CAAC;IAKpF,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,oBAAoB,EAAE,CAAC;IAK7E,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,oBAAoB,EAAE,CAAC;YAKxE,KAAK;CAIpB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
const DEFAULT_BASE_URL = 'https://api.ordiscan.com';
|
|
3
|
+
export class OrdiscanIndex {
|
|
4
|
+
client;
|
|
5
|
+
constructor(options) {
|
|
6
|
+
if (!options.apiKey || options.apiKey.trim().length === 0) {
|
|
7
|
+
throw new Error('OrdiscanIndex: apiKey is required');
|
|
8
|
+
}
|
|
9
|
+
this.client = axios.create({
|
|
10
|
+
baseURL: (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, ''),
|
|
11
|
+
timeout: options.timeoutMs ?? 10_000,
|
|
12
|
+
headers: { Authorization: `Bearer ${options.apiKey}` },
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
get name() {
|
|
16
|
+
return 'ordiscan';
|
|
17
|
+
}
|
|
18
|
+
async outpointsWithInscriptions(address) {
|
|
19
|
+
const list = await this.fetch(`/v1/address/${address}/inscriptions`);
|
|
20
|
+
return mapOutpoints(list.map((i) => i.output));
|
|
21
|
+
}
|
|
22
|
+
async outpointsWithRunes(address) {
|
|
23
|
+
const list = await this.fetch(`/v1/address/${address}/runes`);
|
|
24
|
+
return mapOutpoints(list.map((r) => r.output));
|
|
25
|
+
}
|
|
26
|
+
async outpointsWithRareSats(address) {
|
|
27
|
+
const list = await this.fetch(`/v1/address/${address}/rare-sats`);
|
|
28
|
+
return mapOutpoints(list.map((r) => r.utxo));
|
|
29
|
+
}
|
|
30
|
+
async fetch(path) {
|
|
31
|
+
const { data } = await this.client.get(path);
|
|
32
|
+
return data.data ?? [];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function mapOutpoints(rawOutpoints) {
|
|
36
|
+
const out = [];
|
|
37
|
+
for (const raw of rawOutpoints) {
|
|
38
|
+
const op = parseOutput(raw);
|
|
39
|
+
if (op)
|
|
40
|
+
out.push(op);
|
|
41
|
+
}
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
function parseOutput(raw) {
|
|
45
|
+
const m = /^([0-9a-fA-F]{64}):(\d+)(?::\d+)?$/.exec(raw);
|
|
46
|
+
if (!m)
|
|
47
|
+
return null;
|
|
48
|
+
const vout = parseInt(m[2], 10);
|
|
49
|
+
if (!Number.isFinite(vout) || vout < 0)
|
|
50
|
+
return null;
|
|
51
|
+
return { txid: m[1].toLowerCase(), vout };
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=ordiscan.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ordiscan.tool.js","sourceRoot":"","sources":["../../../../utxo/btc/tools/ordiscan.tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AA8B7C,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAEpD,MAAM,OAAO,aAAa;IAGP,MAAM,CAAgB;IAEvC,YAAY,OAA6B;QACvC,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1D,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACvD,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;YACzB,OAAO,EAAE,CAAC,OAAO,CAAC,OAAO,IAAI,gBAAgB,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;YACjE,OAAO,EAAE,OAAO,CAAC,SAAS,IAAI,MAAM;YACpC,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,OAAO,CAAC,MAAM,EAAE,EAAE;SACv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AAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,WAAW,CAAC,GAAW;IAC9B,MAAM,CAAC,GAAG,oCAAoC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzD,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACpB,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAChC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACpD,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rare_sat_index.d.ts","sourceRoot":"","sources":["../../../../utxo/btc/tools/rare_sat_index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,oBAAoB,EAAE,CAAC,CAAC;CAClF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rare_sat_index.js","sourceRoot":"","sources":["../../../../utxo/btc/tools/rare_sat_index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rune_index.d.ts","sourceRoot":"","sources":["../../../../utxo/btc/tools/rune_index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,oBAAoB,EAAE,CAAC,CAAC;CAC/E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rune_index.js","sourceRoot":"","sources":["../../../../utxo/btc/tools/rune_index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AssetBearingOutpoint } from './asset_outpoint.ts';
|
|
2
|
+
import { BtcInscriptionIndex } from './inscription_index.ts';
|
|
3
|
+
export interface UnisatIndexOptions {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
timeoutMs?: number;
|
|
7
|
+
pageSize?: number;
|
|
8
|
+
maxPages?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare class UnisatIndex implements BtcInscriptionIndex {
|
|
11
|
+
private readonly client;
|
|
12
|
+
private readonly pageSize;
|
|
13
|
+
private readonly maxPages;
|
|
14
|
+
constructor(options: UnisatIndexOptions);
|
|
15
|
+
get name(): string;
|
|
16
|
+
outpointsWithInscriptions(address: string): Promise<readonly AssetBearingOutpoint[]>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=unisat.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unisat.tool.d.ts","sourceRoot":"","sources":["../../../../utxo/btc/tools/unisat.tool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AA0BD,qBAAa,WAAY,YAAW,mBAAmB;IACrD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IACvC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;gBAEtB,OAAO,EAAE,kBAAkB;IAavC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAEK,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,oBAAoB,EAAE,CAAC;CAyB3F"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
const DEFAULT_BASE_URL = 'https://open-api.unisat.io';
|
|
3
|
+
const DEFAULT_PAGE_SIZE = 100;
|
|
4
|
+
const DEFAULT_MAX_PAGES = 200;
|
|
5
|
+
export class UnisatIndex {
|
|
6
|
+
client;
|
|
7
|
+
pageSize;
|
|
8
|
+
maxPages;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
if (!options.apiKey || options.apiKey.trim().length === 0) {
|
|
11
|
+
throw new Error('UnisatIndex: apiKey is required');
|
|
12
|
+
}
|
|
13
|
+
this.client = axios.create({
|
|
14
|
+
baseURL: (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, ''),
|
|
15
|
+
timeout: options.timeoutMs ?? 10_000,
|
|
16
|
+
headers: { Authorization: `Bearer ${options.apiKey}` },
|
|
17
|
+
});
|
|
18
|
+
this.pageSize = options.pageSize ?? DEFAULT_PAGE_SIZE;
|
|
19
|
+
this.maxPages = options.maxPages ?? DEFAULT_MAX_PAGES;
|
|
20
|
+
}
|
|
21
|
+
get name() {
|
|
22
|
+
return 'unisat';
|
|
23
|
+
}
|
|
24
|
+
async outpointsWithInscriptions(address) {
|
|
25
|
+
const seen = new Set();
|
|
26
|
+
const out = [];
|
|
27
|
+
let cursor = 0;
|
|
28
|
+
for (let page = 0; page < this.maxPages; page++) {
|
|
29
|
+
const { data } = await this.client.get(`/v1/indexer/address/${address}/inscription-data`, { params: { cursor, size: this.pageSize } });
|
|
30
|
+
if (data.code !== 0 && data.code !== undefined && data.code !== 200) {
|
|
31
|
+
throw new Error(`UnisatIndex: ${data.code} ${data.msg}`);
|
|
32
|
+
}
|
|
33
|
+
const utxos = data.data.inscription ?? data.data.utxo ?? [];
|
|
34
|
+
for (const u of utxos) {
|
|
35
|
+
const key = `${u.txid}:${u.vout}`;
|
|
36
|
+
if (seen.has(key))
|
|
37
|
+
continue;
|
|
38
|
+
seen.add(key);
|
|
39
|
+
out.push({ txid: u.txid, vout: u.vout });
|
|
40
|
+
}
|
|
41
|
+
cursor += utxos.length;
|
|
42
|
+
const total = data.data.total ?? 0;
|
|
43
|
+
if (utxos.length === 0 || cursor >= total)
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=unisat.tool.js.map
|