otx-btc-wallet-connectors 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +554 -0
- package/dist/base-IAFq7sd8.d.mts +53 -0
- package/dist/base-IAFq7sd8.d.ts +53 -0
- package/dist/binance/index.d.mts +81 -0
- package/dist/binance/index.d.ts +81 -0
- package/dist/binance/index.js +13 -0
- package/dist/binance/index.js.map +1 -0
- package/dist/binance/index.mjs +4 -0
- package/dist/binance/index.mjs.map +1 -0
- package/dist/bitget/index.d.mts +84 -0
- package/dist/bitget/index.d.ts +84 -0
- package/dist/bitget/index.js +13 -0
- package/dist/bitget/index.js.map +1 -0
- package/dist/bitget/index.mjs +4 -0
- package/dist/bitget/index.mjs.map +1 -0
- package/dist/chunk-5Z5Q2Y75.mjs +91 -0
- package/dist/chunk-5Z5Q2Y75.mjs.map +1 -0
- package/dist/chunk-7KK2LZLZ.mjs +208 -0
- package/dist/chunk-7KK2LZLZ.mjs.map +1 -0
- package/dist/chunk-AW2JZIHR.mjs +753 -0
- package/dist/chunk-AW2JZIHR.mjs.map +1 -0
- package/dist/chunk-EIJOSZXZ.js +331 -0
- package/dist/chunk-EIJOSZXZ.js.map +1 -0
- package/dist/chunk-EQHR7P7G.js +541 -0
- package/dist/chunk-EQHR7P7G.js.map +1 -0
- package/dist/chunk-EWRXLZO4.mjs +539 -0
- package/dist/chunk-EWRXLZO4.mjs.map +1 -0
- package/dist/chunk-FISNQZZ7.js +802 -0
- package/dist/chunk-FISNQZZ7.js.map +1 -0
- package/dist/chunk-HL4WDMGS.js +200 -0
- package/dist/chunk-HL4WDMGS.js.map +1 -0
- package/dist/chunk-IPYWR76I.js +314 -0
- package/dist/chunk-IPYWR76I.js.map +1 -0
- package/dist/chunk-JYYNWR5G.js +142 -0
- package/dist/chunk-JYYNWR5G.js.map +1 -0
- package/dist/chunk-LNKTYZJM.js +701 -0
- package/dist/chunk-LNKTYZJM.js.map +1 -0
- package/dist/chunk-LVZMONQL.mjs +699 -0
- package/dist/chunk-LVZMONQL.mjs.map +1 -0
- package/dist/chunk-MFXLQWOE.js +93 -0
- package/dist/chunk-MFXLQWOE.js.map +1 -0
- package/dist/chunk-NBIA4TTE.mjs +204 -0
- package/dist/chunk-NBIA4TTE.mjs.map +1 -0
- package/dist/chunk-O4DD2XJ2.js +206 -0
- package/dist/chunk-O4DD2XJ2.js.map +1 -0
- package/dist/chunk-P7HVBU2B.mjs +140 -0
- package/dist/chunk-P7HVBU2B.mjs.map +1 -0
- package/dist/chunk-Q7QVQYEB.js +210 -0
- package/dist/chunk-Q7QVQYEB.js.map +1 -0
- package/dist/chunk-RLZEG6KL.mjs +329 -0
- package/dist/chunk-RLZEG6KL.mjs.map +1 -0
- package/dist/chunk-SYLDBJ75.mjs +246 -0
- package/dist/chunk-SYLDBJ75.mjs.map +1 -0
- package/dist/chunk-TTEUU3CI.mjs +198 -0
- package/dist/chunk-TTEUU3CI.mjs.map +1 -0
- package/dist/chunk-V66BXDTR.mjs +292 -0
- package/dist/chunk-V66BXDTR.mjs.map +1 -0
- package/dist/chunk-X77ZT4OI.js +268 -0
- package/dist/chunk-X77ZT4OI.js.map +1 -0
- package/dist/imtoken/index.d.mts +116 -0
- package/dist/imtoken/index.d.ts +116 -0
- package/dist/imtoken/index.js +14 -0
- package/dist/imtoken/index.js.map +1 -0
- package/dist/imtoken/index.mjs +5 -0
- package/dist/imtoken/index.mjs.map +1 -0
- package/dist/index.d.mts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +170 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +13 -0
- package/dist/index.mjs.map +1 -0
- package/dist/ledger/index.d.mts +290 -0
- package/dist/ledger/index.d.ts +290 -0
- package/dist/ledger/index.js +14 -0
- package/dist/ledger/index.js.map +1 -0
- package/dist/ledger/index.mjs +5 -0
- package/dist/ledger/index.mjs.map +1 -0
- package/dist/okx/index.d.mts +88 -0
- package/dist/okx/index.d.ts +88 -0
- package/dist/okx/index.js +13 -0
- package/dist/okx/index.js.map +1 -0
- package/dist/okx/index.mjs +4 -0
- package/dist/okx/index.mjs.map +1 -0
- package/dist/phantom/index.d.mts +96 -0
- package/dist/phantom/index.d.ts +96 -0
- package/dist/phantom/index.js +14 -0
- package/dist/phantom/index.js.map +1 -0
- package/dist/phantom/index.mjs +5 -0
- package/dist/phantom/index.mjs.map +1 -0
- package/dist/psbt-builder-CFOs69Z5.d.mts +131 -0
- package/dist/psbt-builder-CFOs69Z5.d.ts +131 -0
- package/dist/trezor/index.d.mts +155 -0
- package/dist/trezor/index.d.ts +155 -0
- package/dist/trezor/index.js +14 -0
- package/dist/trezor/index.js.map +1 -0
- package/dist/trezor/index.mjs +5 -0
- package/dist/trezor/index.mjs.map +1 -0
- package/dist/unisat/index.d.mts +75 -0
- package/dist/unisat/index.d.ts +75 -0
- package/dist/unisat/index.js +13 -0
- package/dist/unisat/index.js.map +1 -0
- package/dist/unisat/index.mjs +4 -0
- package/dist/unisat/index.mjs.map +1 -0
- package/dist/utils/index.d.mts +398 -0
- package/dist/utils/index.d.ts +398 -0
- package/dist/utils/index.js +120 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +3 -0
- package/dist/utils/index.mjs.map +1 -0
- package/dist/xverse/index.d.mts +79 -0
- package/dist/xverse/index.d.ts +79 -0
- package/dist/xverse/index.js +13 -0
- package/dist/xverse/index.js.map +1 -0
- package/dist/xverse/index.mjs +4 -0
- package/dist/xverse/index.mjs.map +1 -0
- package/package.json +108 -0
- package/src/base.ts +132 -0
- package/src/binance/BinanceConnector.ts +307 -0
- package/src/binance/index.ts +1 -0
- package/src/bitget/BitgetConnector.ts +301 -0
- package/src/bitget/index.ts +1 -0
- package/src/imtoken/ImTokenConnector.ts +420 -0
- package/src/imtoken/index.ts +2 -0
- package/src/index.ts +78 -0
- package/src/ledger/LedgerConnector.ts +1019 -0
- package/src/ledger/index.ts +8 -0
- package/src/okx/OKXConnector.ts +230 -0
- package/src/okx/index.ts +1 -0
- package/src/phantom/PhantomConnector.ts +381 -0
- package/src/phantom/index.ts +2 -0
- package/src/trezor/TrezorConnector.ts +824 -0
- package/src/trezor/index.ts +6 -0
- package/src/unisat/UnisatConnector.ts +312 -0
- package/src/unisat/index.ts +1 -0
- package/src/utils/blockstream.ts +230 -0
- package/src/utils/btc-service.ts +364 -0
- package/src/utils/index.ts +56 -0
- package/src/utils/mempool.ts +232 -0
- package/src/utils/psbt-builder.ts +492 -0
- package/src/utils/types.ts +183 -0
- package/src/xverse/XverseConnector.ts +479 -0
- package/src/xverse/index.ts +1 -0
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import { BitcoinNetwork } from 'otx-btc-wallet-core';
|
|
2
|
+
export { G as GeneratePsbtOptions, l as GeneratePsbtResult, b as bytesToHex, k as deriveAddressFromPublicKey, f as finalizeAllInputs, a as finalizeAndBroadcast, g as generatePsbtForSend, c as getAddressType, d as getBitcoinJsNetwork, j as getDustThreshold, e as getInputVBytes, i as getOutputVBytes, h as hexToBytes, s as selectUtxos, t as toXOnly } from '../psbt-builder-CFOs69Z5.mjs';
|
|
3
|
+
import 'bitcoinjs-lib';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* UTXO (Unspent Transaction Output) interface
|
|
7
|
+
*/
|
|
8
|
+
interface Utxo {
|
|
9
|
+
txid: string;
|
|
10
|
+
vout: number;
|
|
11
|
+
value: number;
|
|
12
|
+
status: {
|
|
13
|
+
confirmed: boolean;
|
|
14
|
+
block_height?: number;
|
|
15
|
+
block_hash?: string;
|
|
16
|
+
block_time?: number;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* UTXO with raw transaction hex (needed for Ledger signing)
|
|
21
|
+
*/
|
|
22
|
+
interface UtxoWithTx extends Utxo {
|
|
23
|
+
txHex: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Fee rates response
|
|
27
|
+
*/
|
|
28
|
+
interface FeeRates {
|
|
29
|
+
fastest: number;
|
|
30
|
+
halfHour: number;
|
|
31
|
+
hour: number;
|
|
32
|
+
economy: number;
|
|
33
|
+
minimum: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Transaction details
|
|
37
|
+
*/
|
|
38
|
+
interface Transaction {
|
|
39
|
+
txid: string;
|
|
40
|
+
version: number;
|
|
41
|
+
locktime: number;
|
|
42
|
+
size: number;
|
|
43
|
+
weight: number;
|
|
44
|
+
fee: number;
|
|
45
|
+
status: {
|
|
46
|
+
confirmed: boolean;
|
|
47
|
+
block_height?: number;
|
|
48
|
+
block_hash?: string;
|
|
49
|
+
block_time?: number;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Full transaction with inputs and outputs (for Trezor refTxs)
|
|
54
|
+
*/
|
|
55
|
+
interface FullTransaction extends Transaction {
|
|
56
|
+
vin: Array<{
|
|
57
|
+
txid: string;
|
|
58
|
+
vout: number;
|
|
59
|
+
sequence: number;
|
|
60
|
+
scriptsig: string;
|
|
61
|
+
scriptsig_asm?: string;
|
|
62
|
+
witness?: string[];
|
|
63
|
+
prevout?: {
|
|
64
|
+
scriptpubkey: string;
|
|
65
|
+
scriptpubkey_asm?: string;
|
|
66
|
+
scriptpubkey_type?: string;
|
|
67
|
+
scriptpubkey_address?: string;
|
|
68
|
+
value: number;
|
|
69
|
+
};
|
|
70
|
+
}>;
|
|
71
|
+
vout: Array<{
|
|
72
|
+
scriptpubkey: string;
|
|
73
|
+
scriptpubkey_asm?: string;
|
|
74
|
+
scriptpubkey_type?: string;
|
|
75
|
+
scriptpubkey_address?: string;
|
|
76
|
+
value: number;
|
|
77
|
+
}>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Address balance
|
|
81
|
+
*/
|
|
82
|
+
interface AddressBalance {
|
|
83
|
+
address: string;
|
|
84
|
+
chain_stats: {
|
|
85
|
+
funded_txo_count: number;
|
|
86
|
+
funded_txo_sum: number;
|
|
87
|
+
spent_txo_count: number;
|
|
88
|
+
spent_txo_sum: number;
|
|
89
|
+
tx_count: number;
|
|
90
|
+
};
|
|
91
|
+
mempool_stats: {
|
|
92
|
+
funded_txo_count: number;
|
|
93
|
+
funded_txo_sum: number;
|
|
94
|
+
spent_txo_count: number;
|
|
95
|
+
spent_txo_sum: number;
|
|
96
|
+
tx_count: number;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Bitcoin service interface that both Mempool and Blockstream services implement
|
|
101
|
+
*/
|
|
102
|
+
interface IBtcService {
|
|
103
|
+
readonly name: string;
|
|
104
|
+
readonly network: BitcoinNetwork;
|
|
105
|
+
setNetwork(network: BitcoinNetwork): void;
|
|
106
|
+
getUtxos(address: string): Promise<Utxo[]>;
|
|
107
|
+
getUtxosWithTxHex(address: string): Promise<UtxoWithTx[]>;
|
|
108
|
+
getTxHex(txid: string): Promise<string>;
|
|
109
|
+
getTransaction(txid: string): Promise<Transaction>;
|
|
110
|
+
getFullTransaction(txid: string): Promise<FullTransaction>;
|
|
111
|
+
broadcastTransaction(txHex: string): Promise<string>;
|
|
112
|
+
getBalance(address: string): Promise<number>;
|
|
113
|
+
getConfirmedBalance(address: string): Promise<number>;
|
|
114
|
+
getAddressInfo(address: string): Promise<AddressBalance>;
|
|
115
|
+
getFeeRates(): Promise<FeeRates>;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Network-specific endpoint URLs
|
|
119
|
+
*/
|
|
120
|
+
interface NetworkEndpoints {
|
|
121
|
+
mainnet?: string;
|
|
122
|
+
testnet?: string;
|
|
123
|
+
testnet4?: string;
|
|
124
|
+
signet?: string;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Configuration for BtcService endpoints
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* // Use custom mempool instance
|
|
132
|
+
* const config: BtcServiceConfig = {
|
|
133
|
+
* mempool: {
|
|
134
|
+
* mainnet: 'https://my-mempool.com/api',
|
|
135
|
+
* testnet: 'https://my-mempool.com/testnet/api',
|
|
136
|
+
* }
|
|
137
|
+
* };
|
|
138
|
+
*
|
|
139
|
+
* // Or use only one provider
|
|
140
|
+
* const config: BtcServiceConfig = {
|
|
141
|
+
* preferredProvider: 'mempool',
|
|
142
|
+
* mempool: {
|
|
143
|
+
* mainnet: 'https://custom-mempool.example.com/api',
|
|
144
|
+
* }
|
|
145
|
+
* };
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
interface BtcServiceConfig {
|
|
149
|
+
/**
|
|
150
|
+
* Custom Mempool.space API endpoints
|
|
151
|
+
* Default: https://mempool.space/api (mainnet)
|
|
152
|
+
*/
|
|
153
|
+
mempool?: NetworkEndpoints;
|
|
154
|
+
/**
|
|
155
|
+
* Custom Blockstream.info API endpoints
|
|
156
|
+
* Default: https://blockstream.info/api (mainnet)
|
|
157
|
+
*/
|
|
158
|
+
blockstream?: NetworkEndpoints;
|
|
159
|
+
/**
|
|
160
|
+
* Preferred provider to use ('mempool' | 'blockstream' | 'race')
|
|
161
|
+
* - 'mempool': Only use Mempool API
|
|
162
|
+
* - 'blockstream': Only use Blockstream API
|
|
163
|
+
* - 'race': Use both and return fastest response (default)
|
|
164
|
+
*/
|
|
165
|
+
preferredProvider?: 'mempool' | 'blockstream' | 'race';
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Mempool.space Bitcoin Service
|
|
170
|
+
*
|
|
171
|
+
* @see https://mempool.space/docs/api
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```typescript
|
|
175
|
+
* // Default usage
|
|
176
|
+
* const service = new MempoolService('mainnet');
|
|
177
|
+
*
|
|
178
|
+
* // With custom endpoints
|
|
179
|
+
* const service = new MempoolService('mainnet', {
|
|
180
|
+
* mainnet: 'https://my-mempool-proxy.com/api',
|
|
181
|
+
* testnet: 'https://my-mempool-proxy.com/testnet/api',
|
|
182
|
+
* });
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
declare class MempoolService implements IBtcService {
|
|
186
|
+
readonly name = "mempool";
|
|
187
|
+
private _network;
|
|
188
|
+
private _customEndpoints;
|
|
189
|
+
constructor(network?: BitcoinNetwork, customEndpoints?: NetworkEndpoints);
|
|
190
|
+
get network(): BitcoinNetwork;
|
|
191
|
+
private get baseUrl();
|
|
192
|
+
setNetwork(network: BitcoinNetwork): void;
|
|
193
|
+
/**
|
|
194
|
+
* Set custom endpoints for this service
|
|
195
|
+
*/
|
|
196
|
+
setCustomEndpoints(endpoints: NetworkEndpoints): void;
|
|
197
|
+
/**
|
|
198
|
+
* Get current endpoints configuration
|
|
199
|
+
*/
|
|
200
|
+
getEndpoints(): Record<BitcoinNetwork, string>;
|
|
201
|
+
getUtxos(address: string): Promise<Utxo[]>;
|
|
202
|
+
getUtxosWithTxHex(address: string): Promise<UtxoWithTx[]>;
|
|
203
|
+
getTxHex(txid: string): Promise<string>;
|
|
204
|
+
getTransaction(txid: string): Promise<Transaction>;
|
|
205
|
+
getFullTransaction(txid: string): Promise<FullTransaction>;
|
|
206
|
+
broadcastTransaction(txHex: string): Promise<string>;
|
|
207
|
+
getAddressInfo(address: string): Promise<AddressBalance>;
|
|
208
|
+
getBalance(address: string): Promise<number>;
|
|
209
|
+
getConfirmedBalance(address: string): Promise<number>;
|
|
210
|
+
getFeeRates(): Promise<FeeRates>;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Blockstream.info Bitcoin Service
|
|
215
|
+
*
|
|
216
|
+
* @see https://github.com/Blockstream/esplora/blob/master/API.md
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```typescript
|
|
220
|
+
* // Default usage
|
|
221
|
+
* const service = new BlockstreamService('mainnet');
|
|
222
|
+
*
|
|
223
|
+
* // With custom endpoints
|
|
224
|
+
* const service = new BlockstreamService('mainnet', {
|
|
225
|
+
* mainnet: 'https://my-esplora-proxy.com/api',
|
|
226
|
+
* testnet: 'https://my-esplora-proxy.com/testnet/api',
|
|
227
|
+
* });
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
declare class BlockstreamService implements IBtcService {
|
|
231
|
+
readonly name = "blockstream";
|
|
232
|
+
private _network;
|
|
233
|
+
private _customEndpoints;
|
|
234
|
+
constructor(network?: BitcoinNetwork, customEndpoints?: NetworkEndpoints);
|
|
235
|
+
get network(): BitcoinNetwork;
|
|
236
|
+
private get baseUrl();
|
|
237
|
+
setNetwork(network: BitcoinNetwork): void;
|
|
238
|
+
/**
|
|
239
|
+
* Set custom endpoints for this service
|
|
240
|
+
*/
|
|
241
|
+
setCustomEndpoints(endpoints: NetworkEndpoints): void;
|
|
242
|
+
/**
|
|
243
|
+
* Get current endpoints configuration
|
|
244
|
+
*/
|
|
245
|
+
getEndpoints(): Record<BitcoinNetwork, string>;
|
|
246
|
+
getUtxos(address: string): Promise<Utxo[]>;
|
|
247
|
+
getUtxosWithTxHex(address: string): Promise<UtxoWithTx[]>;
|
|
248
|
+
getTxHex(txid: string): Promise<string>;
|
|
249
|
+
getTransaction(txid: string): Promise<Transaction>;
|
|
250
|
+
getFullTransaction(txid: string): Promise<FullTransaction>;
|
|
251
|
+
broadcastTransaction(txHex: string): Promise<string>;
|
|
252
|
+
getAddressInfo(address: string): Promise<AddressBalance>;
|
|
253
|
+
getBalance(address: string): Promise<number>;
|
|
254
|
+
getConfirmedBalance(address: string): Promise<number>;
|
|
255
|
+
getFeeRates(): Promise<FeeRates>;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Configure global BtcService settings
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```typescript
|
|
263
|
+
* import { configureBtcService } from 'otx-btc-wallet-connectors';
|
|
264
|
+
*
|
|
265
|
+
* // Use custom mempool instance
|
|
266
|
+
* configureBtcService({
|
|
267
|
+
* mempool: {
|
|
268
|
+
* mainnet: 'https://my-mempool.com/api',
|
|
269
|
+
* testnet: 'https://my-mempool.com/testnet/api',
|
|
270
|
+
* }
|
|
271
|
+
* });
|
|
272
|
+
*
|
|
273
|
+
* // Use only mempool provider (no race)
|
|
274
|
+
* configureBtcService({
|
|
275
|
+
* preferredProvider: 'mempool',
|
|
276
|
+
* mempool: {
|
|
277
|
+
* mainnet: 'https://custom-api.example.com/api',
|
|
278
|
+
* }
|
|
279
|
+
* });
|
|
280
|
+
*
|
|
281
|
+
* // Reset to defaults
|
|
282
|
+
* configureBtcService({});
|
|
283
|
+
* ```
|
|
284
|
+
*/
|
|
285
|
+
declare function configureBtcService(config: BtcServiceConfig): void;
|
|
286
|
+
/**
|
|
287
|
+
* Get current global BtcService configuration
|
|
288
|
+
*/
|
|
289
|
+
declare function getBtcServiceConfig(): BtcServiceConfig;
|
|
290
|
+
/**
|
|
291
|
+
* Bitcoin Service that combines Mempool and Blockstream APIs
|
|
292
|
+
* Uses Promise.race for reliability and speed
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```typescript
|
|
296
|
+
* // Default usage
|
|
297
|
+
* const btcService = new BtcService('mainnet');
|
|
298
|
+
*
|
|
299
|
+
* // With custom configuration
|
|
300
|
+
* const btcService = new BtcService('mainnet', {
|
|
301
|
+
* mempool: {
|
|
302
|
+
* mainnet: 'https://my-mempool-proxy.com/api',
|
|
303
|
+
* },
|
|
304
|
+
* preferredProvider: 'mempool', // Only use mempool
|
|
305
|
+
* });
|
|
306
|
+
*
|
|
307
|
+
* // Get balance (uses fastest responding API if preferredProvider is 'race')
|
|
308
|
+
* const balance = await btcService.getBalance('bc1q...');
|
|
309
|
+
*
|
|
310
|
+
* // Get UTXOs with tx hex (for Ledger signing)
|
|
311
|
+
* const utxos = await btcService.getUtxosWithTxHex('bc1q...');
|
|
312
|
+
*
|
|
313
|
+
* // Broadcast transaction
|
|
314
|
+
* const txid = await btcService.broadcastTransaction(signedTxHex);
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
declare class BtcService implements IBtcService {
|
|
318
|
+
readonly name = "btc-service";
|
|
319
|
+
private _network;
|
|
320
|
+
private _mempool;
|
|
321
|
+
private _blockstream;
|
|
322
|
+
private _config;
|
|
323
|
+
constructor(network?: BitcoinNetwork, config?: BtcServiceConfig);
|
|
324
|
+
get network(): BitcoinNetwork;
|
|
325
|
+
/**
|
|
326
|
+
* Get the underlying Mempool service for direct access
|
|
327
|
+
*/
|
|
328
|
+
get mempool(): MempoolService;
|
|
329
|
+
/**
|
|
330
|
+
* Get the underlying Blockstream service for direct access
|
|
331
|
+
*/
|
|
332
|
+
get blockstream(): BlockstreamService;
|
|
333
|
+
/**
|
|
334
|
+
* Get current configuration
|
|
335
|
+
*/
|
|
336
|
+
get config(): BtcServiceConfig;
|
|
337
|
+
setNetwork(network: BitcoinNetwork): void;
|
|
338
|
+
/**
|
|
339
|
+
* Update configuration
|
|
340
|
+
*/
|
|
341
|
+
setConfig(config: BtcServiceConfig): void;
|
|
342
|
+
/**
|
|
343
|
+
* Execute method based on preferred provider setting
|
|
344
|
+
*/
|
|
345
|
+
private executeWithProvider;
|
|
346
|
+
getUtxos(address: string): Promise<Utxo[]>;
|
|
347
|
+
getUtxosWithTxHex(address: string): Promise<UtxoWithTx[]>;
|
|
348
|
+
getTxHex(txid: string): Promise<string>;
|
|
349
|
+
getTransaction(txid: string): Promise<Transaction>;
|
|
350
|
+
getFullTransaction(txid: string): Promise<FullTransaction>;
|
|
351
|
+
broadcastTransaction(txHex: string): Promise<string>;
|
|
352
|
+
getAddressInfo(address: string): Promise<AddressBalance>;
|
|
353
|
+
getBalance(address: string): Promise<number>;
|
|
354
|
+
getConfirmedBalance(address: string): Promise<number>;
|
|
355
|
+
getFeeRates(): Promise<FeeRates>;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Get UTXOs for an address
|
|
359
|
+
*/
|
|
360
|
+
declare function getUtxos(address: string, network?: BitcoinNetwork): Promise<Utxo[]>;
|
|
361
|
+
/**
|
|
362
|
+
* Get UTXOs with raw transaction hex
|
|
363
|
+
*/
|
|
364
|
+
declare function getUtxosWithTxHex(address: string, network?: BitcoinNetwork): Promise<UtxoWithTx[]>;
|
|
365
|
+
/**
|
|
366
|
+
* Get raw transaction hex
|
|
367
|
+
*/
|
|
368
|
+
declare function getTxHex(txid: string, network?: BitcoinNetwork): Promise<string>;
|
|
369
|
+
/**
|
|
370
|
+
* Get transaction details
|
|
371
|
+
*/
|
|
372
|
+
declare function getTransaction(txid: string, network?: BitcoinNetwork): Promise<Transaction>;
|
|
373
|
+
/**
|
|
374
|
+
* Get full transaction with inputs and outputs (for Trezor refTxs)
|
|
375
|
+
*/
|
|
376
|
+
declare function getFullTransaction(txid: string, network?: BitcoinNetwork): Promise<FullTransaction>;
|
|
377
|
+
/**
|
|
378
|
+
* Broadcast a signed transaction
|
|
379
|
+
*/
|
|
380
|
+
declare function broadcastTransaction(txHex: string, network?: BitcoinNetwork): Promise<string>;
|
|
381
|
+
/**
|
|
382
|
+
* Get address info
|
|
383
|
+
*/
|
|
384
|
+
declare function getAddressInfo(address: string, network?: BitcoinNetwork): Promise<AddressBalance>;
|
|
385
|
+
/**
|
|
386
|
+
* Get balance for an address
|
|
387
|
+
*/
|
|
388
|
+
declare function getBalance(address: string, network?: BitcoinNetwork): Promise<number>;
|
|
389
|
+
/**
|
|
390
|
+
* Get confirmed balance for an address
|
|
391
|
+
*/
|
|
392
|
+
declare function getConfirmedBalance(address: string, network?: BitcoinNetwork): Promise<number>;
|
|
393
|
+
/**
|
|
394
|
+
* Get current fee rates
|
|
395
|
+
*/
|
|
396
|
+
declare function getFeeRates(network?: BitcoinNetwork): Promise<FeeRates>;
|
|
397
|
+
|
|
398
|
+
export { type AddressBalance, BlockstreamService, BtcService, type BtcServiceConfig, type FeeRates, type FullTransaction, type IBtcService, MempoolService, type NetworkEndpoints, type Transaction, type Utxo, type UtxoWithTx, broadcastTransaction, configureBtcService, getAddressInfo, getBalance, getBtcServiceConfig, getConfirmedBalance, getFeeRates, getFullTransaction, getTransaction, getTxHex, getUtxos, getUtxosWithTxHex };
|