1 | import { networks, Network } from 'bitcoinjs-lib';
|
2 | import BN from 'bn.js';
|
3 | /**
|
4 | * @ignore
|
5 | */
|
6 | export declare type UTXO = {
|
7 | value?: number;
|
8 | confirmations?: number;
|
9 | tx_hash: string;
|
10 | tx_output_n: number;
|
11 | };
|
12 | /**
|
13 | * @private
|
14 | * @ignore
|
15 | */
|
16 | export declare class BitcoinNetwork {
|
17 | broadcastTransaction(transaction: string): Promise<any>;
|
18 | getBlockHeight(): Promise<number>;
|
19 | getTransactionInfo(txid: string): Promise<{
|
20 | block_height: number;
|
21 | }>;
|
22 | getNetworkedUTXOs(address: string): Promise<Array<UTXO>>;
|
23 | }
|
24 | /**
|
25 | * @private
|
26 | * @ignore
|
27 | */
|
28 | export declare class BlockstackNetwork {
|
29 | blockstackAPIUrl: string;
|
30 | broadcastServiceUrl: string;
|
31 | layer1: Network;
|
32 | DUST_MINIMUM: number;
|
33 | includeUtxoMap: {
|
34 | [address: string]: UTXO[];
|
35 | };
|
36 | excludeUtxoSet: Array<UTXO>;
|
37 | btc: BitcoinNetwork;
|
38 | MAGIC_BYTES: string;
|
39 | constructor(apiUrl: string, broadcastServiceUrl: string, bitcoinAPI: BitcoinNetwork, network?: networks.Network);
|
40 | coerceAddress(address: string): string;
|
41 | /**
|
42 | * @ignore
|
43 | */
|
44 | getDefaultBurnAddress(): string;
|
45 | /**
|
46 | * Get the price of a name via the legacy /v1/prices API endpoint.
|
47 | * @param {String} fullyQualifiedName the name to query
|
48 | * Promise} a promise to an Object with { units: String, amount: BigInteger }
{ |
49 | *
|
50 | */
|
51 | getNamePriceV1(fullyQualifiedName: string): Promise<{
|
52 | units: string;
|
53 | amount: BN;
|
54 | }>;
|
55 | /**
|
56 | * Get the price of a namespace via the legacy /v1/prices API endpoint.
|
57 | * @param {String} namespaceID the namespace to query
|
58 | * @return {Promise} a promise to an Object with { units: String, amount: BigInteger }
|
59 | * @private
|
60 | */
|
61 | getNamespacePriceV1(namespaceID: string): Promise<{
|
62 | units: string;
|
63 | amount: BN;
|
64 | }>;
|
65 | /**
|
66 | * Get the price of a name via the /v2/prices API endpoint.
|
67 | * @param {String} fullyQualifiedName the name to query
|
68 | * @return {Promise} a promise to an Object with { units: String, amount: BigInteger }
|
69 | * @private
|
70 | */
|
71 | getNamePriceV2(fullyQualifiedName: string): Promise<{
|
72 | units: string;
|
73 | amount: BN;
|
74 | }>;
|
75 | /**
|
76 | * Get the price of a namespace via the /v2/prices API endpoint.
|
77 | * @param {String} namespaceID the namespace to query
|
78 | * @return {Promise} a promise to an Object with { units: String, amount: BigInteger }
|
79 | * @private
|
80 | */
|
81 | getNamespacePriceV2(namespaceID: string): Promise<{
|
82 | units: string;
|
83 | amount: BN;
|
84 | }>;
|
85 | /**
|
86 | * Get the price of a name.
|
87 | * @param {String} fullyQualifiedName the name to query
|
88 | * @return {Promise} a promise to an Object with { units: String, amount: BigInteger }, where
|
89 | * .units encodes the cryptocurrency units to pay (e.g. BTC, STACKS), and
|
90 | * .amount encodes the number of units, in the smallest denominiated amount
|
91 | * (e.g. if .units is BTC, .amount will be satoshis; if .units is STACKS,
|
92 | * .amount will be microStacks)
|
93 | */
|
94 | getNamePrice(fullyQualifiedName: string): Promise<{
|
95 | units: string;
|
96 | amount: BN;
|
97 | }>;
|
98 | /**
|
99 | * Get the price of a namespace
|
100 | * @param {String} namespaceID the namespace to query
|
101 | * @return {Promise} a promise to an Object with { units: String, amount: BigInteger }, where
|
102 | * .units encodes the cryptocurrency units to pay (e.g. BTC, STACKS), and
|
103 | * .amount encodes the number of units, in the smallest denominiated amount
|
104 | * (e.g. if .units is BTC, .amount will be satoshis; if .units is STACKS,
|
105 | * .amount will be microStacks)
|
106 | */
|
107 | getNamespacePrice(namespaceID: string): Promise<{
|
108 | units: string;
|
109 | amount: BN;
|
110 | }>;
|
111 | /**
|
112 | * How many blocks can pass between a name expiring and the name being able to be
|
113 | * re-registered by a different owner?
|
114 | * @param {string} fullyQualifiedName unused
|
115 | * @return {Promise} a promise to the number of blocks
|
116 | */
|
117 | getGracePeriod(fullyQualifiedName?: string): Promise<number>;
|
118 | /**
|
119 | * Get the names -- both on-chain and off-chain -- owned by an address.
|
120 | * @param {String} address the blockchain address (the hash of the owner public key)
|
121 | * @return {Promise} a promise that resolves to a list of names (Strings)
|
122 | */
|
123 | getNamesOwned(address: string): Promise<string[]>;
|
124 | /**
|
125 | * Get the blockchain address to which a name's registration fee must be sent
|
126 | * (the address will depend on the namespace in which it is registered.)
|
127 | * @param {String} namespace the namespace ID
|
128 | * @return {Promise} a promise that resolves to an address (String)
|
129 | */
|
130 | getNamespaceBurnAddress(namespace: string): Promise<string>;
|
131 | /**
|
132 | * Get WHOIS-like information for a name, including the address that owns it,
|
133 | * the block at which it expires, and the zone file anchored to it (if available).
|
134 | * @param {String} fullyQualifiedName the name to query. Can be on-chain of off-chain.
|
135 | * @return {Promise} a promise that resolves to the WHOIS-like information
|
136 | */
|
137 | getNameInfo(fullyQualifiedName: string): Promise<any>;
|
138 | /**
|
139 | * Get the pricing parameters and creation history of a namespace.
|
140 | * @param {String} namespaceID the namespace to query
|
141 | * @return {Promise} a promise that resolves to the namespace information.
|
142 | */
|
143 | getNamespaceInfo(namespaceID: string): Promise<any>;
|
144 | /**
|
145 | * Get a zone file, given its hash. Throws an exception if the zone file
|
146 | * obtained does not match the hash.
|
147 | * @param {String} zonefileHash the ripemd160(sha256) hash of the zone file
|
148 | * @return {Promise} a promise that resolves to the zone file's text
|
149 | */
|
150 | getZonefile(zonefileHash: string): Promise<string>;
|
151 | /**
|
152 | * Get the status of an account for a particular token holding. This includes its total number of
|
153 | * expenditures and credits, lockup times, last txid, and so on.
|
154 | * @param {String} address the account
|
155 | * @param {String} tokenType the token type to query
|
156 | * @return {Promise} a promise that resolves to an object representing the state of the account
|
157 | * for this token
|
158 | */
|
159 | getAccountStatus(address: string, tokenType: string): Promise<any>;
|
160 | /**
|
161 | * Get a page of an account's transaction history.
|
162 | * @param {String} address the account's address
|
163 | * @param {number} page the page number. Page 0 is the most recent transactions
|
164 | * @return {Promise} a promise that resolves to an Array of Objects, where each Object encodes
|
165 | * states of the account at various block heights (e.g. prior balances, txids, etc)
|
166 | */
|
167 | getAccountHistoryPage(address: string, page: number): Promise<any[]>;
|
168 | /**
|
169 | * Get the state(s) of an account at a particular block height. This includes the state of the
|
170 | * account beginning with this block's transactions, as well as all of the states the account
|
171 | * passed through when this block was processed (if any).
|
172 | * @param {String} address the account's address
|
173 | * @param {Integer} blockHeight the block to query
|
174 | * @return {Promise} a promise that resolves to an Array of Objects, where each Object encodes
|
175 | * states of the account at this block.
|
176 | */
|
177 | getAccountAt(address: string, blockHeight: number): Promise<any[]>;
|
178 | /**
|
179 | * Get the set of token types that this account owns
|
180 | * @param {String} address the account's address
|
181 | * @return {Promise} a promise that resolves to an Array of Strings, where each item encodes the
|
182 | * type of token this account holds (excluding the underlying blockchain's tokens)
|
183 | */
|
184 | getAccountTokens(address: string): Promise<{
|
185 | tokens: string[];
|
186 | }>;
|
187 | /**
|
188 | * Get the number of tokens owned by an account. If the account does not exist or has no
|
189 | * tokens of this type, then 0 will be returned.
|
190 | * @param {String} address the account's address
|
191 | * @param {String} tokenType the type of token to query.
|
192 | * @return {Promise} a promise that resolves to a BigInteger that encodes the number of tokens
|
193 | * held by this account.
|
194 | */
|
195 | getAccountBalance(address: string, tokenType: string): Promise<BN>;
|
196 | /**
|
197 | * Performs a POST request to the given URL
|
198 | * @param {String} endpoint the name of
|
199 | * @param {String} body [description]
|
200 | * @return {Promise<Object|Error>} Returns a `Promise` that resolves to the object requested.
|
201 | * In the event of an error, it rejects with:
|
202 | * * a `RemoteServiceError` if there is a problem
|
203 | * with the transaction broadcast service
|
204 | * * `MissingParameterError` if you call the function without a required
|
205 | * parameter
|
206 | *
|
207 | * @private
|
208 | */
|
209 | broadcastServiceFetchHelper(endpoint: string, body: any): Promise<any | Error>;
|
210 | /**
|
211 | * Broadcasts a signed bitcoin transaction to the network optionally waiting to broadcast the
|
212 | * transaction until a second transaction has a certain number of confirmations.
|
213 | *
|
214 | * @param {string} transaction the hex-encoded transaction to broadcast
|
215 | * @param {string} transactionToWatch the hex transaction id of the transaction to watch for
|
216 | * the specified number of confirmations before broadcasting the `transaction`
|
217 | * @param {number} confirmations the number of confirmations `transactionToWatch` must have
|
218 | * before broadcasting `transaction`.
|
219 | * @return {Promise<Object|Error>} Returns a Promise that resolves to an object with a
|
220 | * `transaction_hash` key containing the transaction hash of the broadcasted transaction.
|
221 | *
|
222 | * In the event of an error, it rejects with:
|
223 | * * a `RemoteServiceError` if there is a problem
|
224 | * with the transaction broadcast service
|
225 | * * `MissingParameterError` if you call the function without a required
|
226 | * parameter
|
227 | * @private
|
228 | */
|
229 | broadcastTransaction(transaction: string, transactionToWatch?: string, confirmations?: number): Promise<any>;
|
230 | /**
|
231 | * Broadcasts a zone file to the Atlas network via the transaction broadcast service.
|
232 | *
|
233 | * @param {String} zoneFile the zone file to be broadcast to the Atlas network
|
234 | * @param {String} transactionToWatch the hex transaction id of the transaction
|
235 | * to watch for confirmation before broadcasting the zone file to the Atlas network
|
236 | * @return {Promise<Object|Error>} Returns a Promise that resolves to an object with a
|
237 | * `transaction_hash` key containing the transaction hash of the broadcasted transaction.
|
238 | *
|
239 | * In the event of an error, it rejects with:
|
240 | * * a `RemoteServiceError` if there is a problem
|
241 | * with the transaction broadcast service
|
242 | * * `MissingParameterError` if you call the function without a required
|
243 | * parameter
|
244 | * @private
|
245 | */
|
246 | broadcastZoneFile(zoneFile?: string, transactionToWatch?: string): Promise<any>;
|
247 | /**
|
248 | * Sends the preorder and registration transactions and zone file
|
249 | * for a Blockstack name registration
|
250 | * along with the to the transaction broadcast service.
|
251 | *
|
252 | * The transaction broadcast:
|
253 | *
|
254 | * * immediately broadcasts the preorder transaction
|
255 | * * broadcasts the register transactions after the preorder transaction
|
256 | * has an appropriate number of confirmations
|
257 | * * broadcasts the zone file to the Atlas network after the register transaction
|
258 | * has an appropriate number of confirmations
|
259 | *
|
260 | * @param {String} preorderTransaction the hex-encoded, signed preorder transaction generated
|
261 | * using the `makePreorder` function
|
262 | * @param {String} registerTransaction the hex-encoded, signed register transaction generated
|
263 | * using the `makeRegister` function
|
264 | * @param {String} zoneFile the zone file to be broadcast to the Atlas network
|
265 | * @return {Promise<Object|Error>} Returns a Promise that resolves to an object with a
|
266 | * `transaction_hash` key containing the transaction hash of the broadcasted transaction.
|
267 | *
|
268 | * In the event of an error, it rejects with:
|
269 | * * a `RemoteServiceError` if there is a problem
|
270 | * with the transaction broadcast service
|
271 | * * `MissingParameterError` if you call the function without a required
|
272 | * parameter
|
273 | * @private
|
274 | */
|
275 | broadcastNameRegistration(preorderTransaction: string, registerTransaction: string, zoneFile: string): Promise<any>;
|
276 | /**
|
277 | * @ignore
|
278 | */
|
279 | getFeeRate(): Promise<number>;
|
280 | /**
|
281 | * @ignore
|
282 | */
|
283 | countDustOutputs(): void;
|
284 | /**
|
285 | * @ignore
|
286 | */
|
287 | getUTXOs(address: string): Promise<Array<UTXO>>;
|
288 | /**
|
289 | * This will modify the network's utxo set to include UTXOs
|
290 | * from the given transaction and exclude UTXOs *spent* in
|
291 | * that transaction
|
292 | * @param {String} txHex - the hex-encoded transaction to use
|
293 | * @return {void} no return value, this modifies the UTXO config state
|
294 | * @private
|
295 | * @ignore
|
296 | */
|
297 | modifyUTXOSetFrom(txHex: string): void;
|
298 | resetUTXOs(address: string): void;
|
299 | /**
|
300 | * @ignore
|
301 | */
|
302 | getConsensusHash(): Promise<any>;
|
303 | getTransactionInfo(txHash: string): Promise<{
|
304 | block_height: number;
|
305 | }>;
|
306 | /**
|
307 | * @ignore
|
308 | */
|
309 | getBlockHeight(): Promise<number>;
|
310 | getNetworkedUTXOs(address: string): Promise<Array<UTXO>>;
|
311 | }
|
312 | /**
|
313 | * @ignore
|
314 | */
|
315 | export declare class LocalRegtest extends BlockstackNetwork {
|
316 | constructor(apiUrl: string, broadcastServiceUrl: string, bitcoinAPI: BitcoinNetwork);
|
317 | getFeeRate(): Promise<number>;
|
318 | }
|
319 | /**
|
320 | * @ignore
|
321 | */
|
322 | export declare class BitcoindAPI extends BitcoinNetwork {
|
323 | bitcoindUrl: string;
|
324 | bitcoindCredentials: {
|
325 | username: string;
|
326 | password: string;
|
327 | };
|
328 | importedBefore: any;
|
329 | constructor(bitcoindUrl: string, bitcoindCredentials: {
|
330 | username: string;
|
331 | password: string;
|
332 | });
|
333 | broadcastTransaction(transaction: string): Promise<any>;
|
334 | getBlockHeight(): Promise<any>;
|
335 | getTransactionInfo(txHash: string): Promise<{
|
336 | block_height: number;
|
337 | }>;
|
338 | getNetworkedUTXOs(address: string): Promise<Array<UTXO>>;
|
339 | }
|
340 | /**
|
341 | * @ignore
|
342 | */
|
343 | export declare class InsightClient extends BitcoinNetwork {
|
344 | apiUrl: string;
|
345 | constructor(insightUrl?: string);
|
346 | broadcastTransaction(transaction: string): Promise<any>;
|
347 | getBlockHeight(): Promise<any>;
|
348 | getTransactionInfo(txHash: string): Promise<{
|
349 | block_height: number;
|
350 | }>;
|
351 | getNetworkedUTXOs(address: string): Promise<Array<UTXO>>;
|
352 | }
|
353 | /**
|
354 | * @ignore
|
355 | */
|
356 | export declare class BlockchainInfoApi extends BitcoinNetwork {
|
357 | utxoProviderUrl: string;
|
358 | constructor(blockchainInfoUrl?: string);
|
359 | getBlockHeight(): Promise<any>;
|
360 | getNetworkedUTXOs(address: string): Promise<Array<UTXO>>;
|
361 | getTransactionInfo(txHash: string): Promise<{
|
362 | block_height: number;
|
363 | }>;
|
364 | broadcastTransaction(transaction: string): Promise<string>;
|
365 | }
|
366 | /**
|
367 | * Get WHOIS-like information for a name, including the address that owns it,
|
368 | * the block at which it expires, and the zone file anchored to it (if available).
|
369 | * @param {String} fullyQualifiedName the name to query. Can be on-chain of off-chain.
|
370 | * @return {Promise} a promise that resolves to the WHOIS-like information
|
371 | */
|
372 | export declare function getNameInfo(fullyQualifiedName: string): Promise<any>;
|
373 | /**
|
374 | * @ignore
|
375 | */
|
376 | export declare const network: {
|
377 | BlockstackNetwork: typeof BlockstackNetwork;
|
378 | LocalRegtest: typeof LocalRegtest;
|
379 | BlockchainInfoApi: typeof BlockchainInfoApi;
|
380 | BitcoindAPI: typeof BitcoindAPI;
|
381 | InsightClient: typeof InsightClient;
|
382 | defaults: {
|
383 | LOCAL_REGTEST: LocalRegtest;
|
384 | MAINNET_DEFAULT: BlockstackNetwork;
|
385 | };
|
386 | };
|