@pioneer-platform/blockbook 8.3.13 → 8.3.16
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/lib/index.d.ts +177 -17
- package/lib/index.js +654 -294
- package/package.json +2 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,26 +1,186 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Blockbook Client Integration Module
|
|
3
|
+
*
|
|
4
|
+
* Provides a unified interface for interacting with Blockbook blockchain explorers
|
|
5
|
+
* across multiple cryptocurrency networks. Handles pagination, retries, and fallbacks.
|
|
6
|
+
*
|
|
7
|
+
* @module blockbook-client
|
|
8
|
+
*/
|
|
2
9
|
declare const Blockbook: any;
|
|
3
10
|
declare const log: any;
|
|
4
11
|
declare const fakeUa: any;
|
|
5
12
|
declare const Axios: any;
|
|
6
13
|
declare const https: any;
|
|
7
14
|
declare const nodes: any;
|
|
8
|
-
declare const axios: any;
|
|
9
15
|
declare const axiosRetry: any;
|
|
10
|
-
declare
|
|
11
|
-
declare
|
|
12
|
-
declare
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
declare const TAG = " | blockbook-client | ";
|
|
17
|
+
declare const NOW_NODES_API: string | undefined;
|
|
18
|
+
declare const axios: any;
|
|
19
|
+
interface BlockbookToken {
|
|
20
|
+
name: string;
|
|
21
|
+
path?: string;
|
|
22
|
+
balance?: string;
|
|
23
|
+
transfers?: number;
|
|
24
|
+
totalReceived?: string;
|
|
25
|
+
totalSent?: string;
|
|
26
|
+
}
|
|
27
|
+
interface XpubResponse {
|
|
28
|
+
page?: number;
|
|
29
|
+
totalPages?: number;
|
|
30
|
+
itemsOnPage?: number;
|
|
31
|
+
address?: string;
|
|
32
|
+
balance: string;
|
|
33
|
+
totalReceived: string;
|
|
34
|
+
totalSent: string;
|
|
35
|
+
unconfirmedBalance: string;
|
|
36
|
+
unconfirmedTxs: number;
|
|
37
|
+
txs: number;
|
|
38
|
+
addrTxCount?: number;
|
|
39
|
+
txids?: string[];
|
|
40
|
+
usedTokens?: number;
|
|
41
|
+
tokens?: BlockbookToken[];
|
|
42
|
+
transactions?: any[];
|
|
43
|
+
}
|
|
44
|
+
interface NextIndexes {
|
|
45
|
+
nextReceiveAddressIndex: number;
|
|
46
|
+
nextChangeAddressIndex: number;
|
|
47
|
+
}
|
|
48
|
+
interface BlockbookConfig {
|
|
49
|
+
symbol: string;
|
|
50
|
+
service: string;
|
|
51
|
+
websocket?: string;
|
|
52
|
+
}
|
|
53
|
+
interface FeeEstimate {
|
|
54
|
+
fast?: number;
|
|
55
|
+
average?: number;
|
|
56
|
+
slow?: number;
|
|
57
|
+
blockTime?: number;
|
|
58
|
+
blockHeight?: number;
|
|
59
|
+
}
|
|
60
|
+
declare let BLOCKBOOK_URLS: Record<string, string>;
|
|
61
|
+
declare let BLOCKBOOK_SOCKETS: Record<string, any>;
|
|
62
|
+
declare const cache: Map<string, {
|
|
63
|
+
data: any;
|
|
64
|
+
timestamp: number;
|
|
65
|
+
}>;
|
|
66
|
+
declare const CACHE_TTL = 60000;
|
|
67
|
+
/**
|
|
68
|
+
* Get cached data if available and not expired
|
|
69
|
+
*/
|
|
70
|
+
declare function getCached(key: string): any | null;
|
|
71
|
+
/**
|
|
72
|
+
* Store data in cache
|
|
73
|
+
*/
|
|
74
|
+
declare function setCache(key: string, data: any): void;
|
|
75
|
+
/**
|
|
76
|
+
* Initialize the Blockbook network with seed nodes and custom servers
|
|
77
|
+
* @param servers Optional array of custom Blockbook server configurations
|
|
78
|
+
* @returns Promise<boolean> indicating successful initialization
|
|
79
|
+
*/
|
|
80
|
+
declare function init_network(servers?: BlockbookConfig[]): Promise<boolean>;
|
|
81
|
+
/**
|
|
82
|
+
* Get fee estimates for a specific coin
|
|
83
|
+
* @param coin Coin symbol (e.g., 'BTC', 'ETH')
|
|
84
|
+
* @returns Promise<FeeEstimate> containing fee recommendations
|
|
85
|
+
*/
|
|
86
|
+
declare function get_fees(coin: string): Promise<FeeEstimate>;
|
|
87
|
+
/**
|
|
88
|
+
* Fetch xpub info from Blockbook with tokens, handling pagination and fallbacks.
|
|
89
|
+
* @param coin Uppercase/anycase coin key resolvable in BLOCKBOOK_URLS (e.g., 'BTC')
|
|
90
|
+
* @param pubkey xpub/ypub/zpub/tpub/vpub
|
|
91
|
+
* @param page Starting page number (default 1)
|
|
92
|
+
* @param pageSize Items per page (default 1000)
|
|
93
|
+
* @returns Promise<XpubResponse> with complete token information including changeIndex and receiveIndex
|
|
94
|
+
*/
|
|
95
|
+
declare function get_info_by_pubkey(coin: string, pubkey: string, page?: number, pageSize?: number): Promise<XpubResponse & {
|
|
96
|
+
changeIndex: number;
|
|
97
|
+
receiveIndex: number;
|
|
98
|
+
}>;
|
|
99
|
+
/**
|
|
100
|
+
* Compute next indexes from Blockbook tokens array.
|
|
101
|
+
* Returns the next external (receive) and internal (change) indexes.
|
|
102
|
+
*
|
|
103
|
+
* Logic:
|
|
104
|
+
* - Consider an address "used" if transfers > 0 OR balance !== '0'
|
|
105
|
+
* - Next index = (max used index on that branch) + 1
|
|
106
|
+
*
|
|
107
|
+
* @param tokens Array of BlockbookToken objects with path information
|
|
108
|
+
* @returns Object with nextReceiveAddressIndex and nextChangeAddressIndex
|
|
109
|
+
*/
|
|
110
|
+
declare function computeNextIndexes(tokens: BlockbookToken[]): NextIndexes;
|
|
111
|
+
/**
|
|
112
|
+
* Convenience function: fetch tokens and return the next indexes directly.
|
|
113
|
+
* @param coin Coin symbol
|
|
114
|
+
* @param pubkey Extended public key
|
|
115
|
+
* @param page Starting page
|
|
116
|
+
* @param pageSize Items per page
|
|
117
|
+
* @returns Promise<NextIndexes> with next receive and change indexes
|
|
118
|
+
*/
|
|
119
|
+
declare function get_next_indexes_by_pubkey(coin: string, pubkey: string, page?: number, pageSize?: number): Promise<NextIndexes>;
|
|
120
|
+
/**
|
|
121
|
+
* Get transaction IDs for a specific address with pagination support
|
|
122
|
+
* @param coin Coin symbol
|
|
123
|
+
* @param address Blockchain address
|
|
124
|
+
* @param page Page number (default 1)
|
|
125
|
+
* @returns Promise with address info including transaction IDs
|
|
126
|
+
*/
|
|
127
|
+
declare function get_txids_by_address(coin: string, address: string, page?: number): Promise<any>;
|
|
128
|
+
/**
|
|
129
|
+
* Get detailed information for a specific address
|
|
130
|
+
* @param coin Coin symbol
|
|
131
|
+
* @param address Blockchain address
|
|
132
|
+
* @param filter Detail level filter (default 'all')
|
|
133
|
+
* @returns Promise with complete address information
|
|
134
|
+
*/
|
|
135
|
+
declare function get_info_by_address(coin: string, address: string, filter?: string): Promise<any>;
|
|
136
|
+
/**
|
|
137
|
+
* Get all transactions for an extended public key
|
|
138
|
+
* @param coin Coin symbol
|
|
139
|
+
* @param xpub Extended public key
|
|
140
|
+
* @returns Promise with xpub info including all transactions
|
|
141
|
+
*/
|
|
142
|
+
declare function get_txs_by_xpub(coin: string, xpub: string): Promise<XpubResponse>;
|
|
143
|
+
/**
|
|
144
|
+
* Broadcast a raw transaction to the network
|
|
145
|
+
* @param coin Coin symbol
|
|
146
|
+
* @param hex Raw transaction hex
|
|
147
|
+
* @returns Promise with broadcast result including success status and txid or error
|
|
148
|
+
*/
|
|
149
|
+
declare function broadcast_transaction(coin: string, hex: string): Promise<{
|
|
21
150
|
success: boolean;
|
|
151
|
+
txid?: string;
|
|
152
|
+
error?: string;
|
|
153
|
+
statusCode?: number;
|
|
154
|
+
resp?: any;
|
|
155
|
+
}>;
|
|
156
|
+
/**
|
|
157
|
+
* Get detailed information about a specific transaction
|
|
158
|
+
* @param coin Coin symbol
|
|
159
|
+
* @param txid Transaction ID
|
|
160
|
+
* @returns Promise with transaction details
|
|
161
|
+
*/
|
|
162
|
+
declare function get_transaction(coin: string, txid: string): Promise<any>;
|
|
163
|
+
/**
|
|
164
|
+
* Get UTXOs (Unspent Transaction Outputs) for an extended public key
|
|
165
|
+
* @param coin Coin symbol
|
|
166
|
+
* @param xpub Extended public key
|
|
167
|
+
* @param confirmedOnly Whether to include only confirmed UTXOs (default false)
|
|
168
|
+
* @returns Promise with array of UTXOs
|
|
169
|
+
*/
|
|
170
|
+
declare function get_utxos_by_xpub(coin: string, xpub: string, confirmedOnly?: boolean): Promise<any[]>;
|
|
171
|
+
/**
|
|
172
|
+
* Get total balance for an extended public key in BTC (not satoshis)
|
|
173
|
+
* @param coin Coin symbol
|
|
174
|
+
* @param xpub Extended public key
|
|
175
|
+
* @returns Promise with balance in BTC (not satoshis)
|
|
176
|
+
*/
|
|
177
|
+
declare function get_balance_by_xpub(coin: string, xpub: string): Promise<number>;
|
|
178
|
+
/**
|
|
179
|
+
* Get information about the Blockbook nodes
|
|
180
|
+
* @returns Promise with node status information
|
|
181
|
+
*/
|
|
182
|
+
declare function get_node_info(): Promise<{
|
|
183
|
+
initialized: boolean;
|
|
184
|
+
availableNodes: string[];
|
|
185
|
+
activeWebsockets: string[];
|
|
22
186
|
}>;
|
|
23
|
-
declare let get_transaction: (coin: string, txid: string) => Promise<any>;
|
|
24
|
-
declare let get_utxos_by_xpub: (coin: string, xpub: string) => Promise<any>;
|
|
25
|
-
declare let get_balance_by_xpub: (coin: string, xpub: any) => Promise<number>;
|
|
26
|
-
declare let get_node_info: () => Promise<boolean>;
|