@did-btcr2/bitcoin 0.3.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/bitcoin.js +83 -84
- package/dist/cjs/bitcoin.js.map +1 -1
- package/dist/cjs/client/http.js +9 -0
- package/dist/cjs/client/http.js.map +1 -0
- package/dist/cjs/client/rest/address.js +20 -28
- package/dist/cjs/client/rest/address.js.map +1 -1
- package/dist/cjs/client/rest/block.js +23 -22
- package/dist/cjs/client/rest/block.js.map +1 -1
- package/dist/cjs/client/rest/index.js +31 -84
- package/dist/cjs/client/rest/index.js.map +1 -1
- package/dist/cjs/client/rest/protocol.js +129 -0
- package/dist/cjs/client/rest/protocol.js.map +1 -0
- package/dist/cjs/client/rest/transaction.js +19 -21
- package/dist/cjs/client/rest/transaction.js.map +1 -1
- package/dist/cjs/client/rpc/index.js +75 -337
- package/dist/cjs/client/rpc/index.js.map +1 -1
- package/dist/cjs/client/rpc/interface.js +1 -6
- package/dist/cjs/client/rpc/interface.js.map +1 -1
- package/dist/cjs/client/rpc/json-rpc.js +40 -63
- package/dist/cjs/client/rpc/json-rpc.js.map +1 -1
- package/dist/cjs/client/rpc/protocol.js +134 -0
- package/dist/cjs/client/rpc/protocol.js.map +1 -0
- package/dist/cjs/constants.js +16 -5
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/errors.js.map +1 -1
- package/dist/cjs/index.js +21 -13
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types.js +5 -55
- package/dist/cjs/types.js.map +1 -1
- package/dist/esm/bitcoin.js +83 -84
- package/dist/esm/bitcoin.js.map +1 -1
- package/dist/esm/client/http.js +9 -0
- package/dist/esm/client/http.js.map +1 -0
- package/dist/esm/client/rest/address.js +20 -28
- package/dist/esm/client/rest/address.js.map +1 -1
- package/dist/esm/client/rest/block.js +23 -22
- package/dist/esm/client/rest/block.js.map +1 -1
- package/dist/esm/client/rest/index.js +31 -84
- package/dist/esm/client/rest/index.js.map +1 -1
- package/dist/esm/client/rest/protocol.js +129 -0
- package/dist/esm/client/rest/protocol.js.map +1 -0
- package/dist/esm/client/rest/transaction.js +19 -21
- package/dist/esm/client/rest/transaction.js.map +1 -1
- package/dist/esm/client/rpc/index.js +75 -337
- package/dist/esm/client/rpc/index.js.map +1 -1
- package/dist/esm/client/rpc/interface.js +1 -6
- package/dist/esm/client/rpc/interface.js.map +1 -1
- package/dist/esm/client/rpc/json-rpc.js +40 -63
- package/dist/esm/client/rpc/json-rpc.js.map +1 -1
- package/dist/esm/client/rpc/protocol.js +134 -0
- package/dist/esm/client/rpc/protocol.js.map +1 -0
- package/dist/esm/constants.js +16 -5
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/index.js +21 -13
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types.js +5 -55
- package/dist/esm/types.js.map +1 -1
- package/dist/types/bitcoin.d.ts +66 -45
- package/dist/types/bitcoin.d.ts.map +1 -1
- package/dist/types/client/http.d.ts +21 -0
- package/dist/types/client/http.d.ts.map +1 -0
- package/dist/types/client/rest/address.d.ts +16 -19
- package/dist/types/client/rest/address.d.ts.map +1 -1
- package/dist/types/client/rest/block.d.ts +24 -16
- package/dist/types/client/rest/block.d.ts.map +1 -1
- package/dist/types/client/rest/index.d.ts +20 -51
- package/dist/types/client/rest/index.d.ts.map +1 -1
- package/dist/types/client/rest/protocol.d.ts +58 -0
- package/dist/types/client/rest/protocol.d.ts.map +1 -0
- package/dist/types/client/rest/transaction.d.ts +16 -17
- package/dist/types/client/rest/transaction.d.ts.map +1 -1
- package/dist/types/client/rpc/index.d.ts +105 -253
- package/dist/types/client/rpc/index.d.ts.map +1 -1
- package/dist/types/client/rpc/interface.d.ts +1 -4
- package/dist/types/client/rpc/interface.d.ts.map +1 -1
- package/dist/types/client/rpc/json-rpc.d.ts +20 -18
- package/dist/types/client/rpc/json-rpc.d.ts.map +1 -1
- package/dist/types/client/rpc/protocol.d.ts +82 -0
- package/dist/types/client/rpc/protocol.d.ts.map +1 -0
- package/dist/types/constants.d.ts +16 -5
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/errors.d.ts +4 -3
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/index.d.ts +20 -13
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +98 -696
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/bitcoin.ts +105 -118
- package/src/client/http.ts +28 -0
- package/src/client/rest/address.ts +24 -30
- package/src/client/rest/block.ts +29 -26
- package/src/client/rest/index.ts +38 -94
- package/src/client/rest/protocol.ts +153 -0
- package/src/client/rest/transaction.ts +23 -23
- package/src/client/rpc/index.ts +140 -379
- package/src/client/rpc/interface.ts +42 -51
- package/src/client/rpc/json-rpc.ts +53 -60
- package/src/client/rpc/protocol.ts +160 -0
- package/src/constants.ts +17 -5
- package/src/errors.ts +10 -3
- package/src/index.ts +81 -13
- package/src/types.ts +332 -972
|
@@ -1,56 +1,53 @@
|
|
|
1
|
-
import { AddressInfo, AddressUtxo, RawTransactionRest
|
|
1
|
+
import { AddressInfo, AddressUtxo, RawTransactionRest } from '../../types.js';
|
|
2
|
+
import { HttpRequest } from '../http.js';
|
|
3
|
+
import { EsploraProtocol } from './protocol.js';
|
|
2
4
|
/**
|
|
3
|
-
*
|
|
4
|
-
* @class BitcoinAddress
|
|
5
|
-
* @type {BitcoinAddress}
|
|
5
|
+
* Address-related Esplora REST API operations.
|
|
6
6
|
*/
|
|
7
7
|
export declare class BitcoinAddress {
|
|
8
|
-
private
|
|
9
|
-
|
|
8
|
+
private readonly protocol;
|
|
9
|
+
private readonly exec;
|
|
10
|
+
constructor(protocol: EsploraProtocol, exec: (req: HttpRequest) => Promise<any>);
|
|
10
11
|
/**
|
|
11
12
|
* Get transaction history for the specified address/scripthash, sorted with newest first.
|
|
12
13
|
* Returns up to 50 mempool transactions plus the first 25 confirmed transactions.
|
|
13
14
|
* See {@link https://github.com/blockstream/esplora/blob/master/API.md#get-addressaddresstxs | Esplora GET /address/:address/txs } for details.
|
|
14
15
|
* @param {string} addressOrScripthash The address or scripthash to check.
|
|
15
|
-
* @returns {Promise<Array<RawTransactionRest>>}
|
|
16
|
+
* @returns {Promise<Array<RawTransactionRest>>} Transaction history.
|
|
16
17
|
*/
|
|
17
18
|
getTxs(addressOrScripthash: string): Promise<Array<RawTransactionRest>>;
|
|
18
19
|
/**
|
|
19
|
-
*
|
|
20
|
-
* Toggle if those funds are confirmed.
|
|
20
|
+
* Checks if an address has any confirmed funded transactions.
|
|
21
21
|
* @param {string} addressOrScripthash The address or scripthash to check.
|
|
22
|
-
* @returns {Promise<boolean>} True if the address has
|
|
22
|
+
* @returns {Promise<boolean>} True if the address has confirmed funds.
|
|
23
23
|
*/
|
|
24
24
|
isFundedAddress(addressOrScripthash: string): Promise<boolean>;
|
|
25
25
|
/**
|
|
26
26
|
* Get unconfirmed transaction history for the specified address/scripthash.
|
|
27
27
|
* Returns up to 50 transactions (no paging).
|
|
28
28
|
* @param {string} addressOrScripthash The address or scripthash to check.
|
|
29
|
-
* @returns {Promise<Array<RawTransactionRest>>}
|
|
29
|
+
* @returns {Promise<Array<RawTransactionRest>>} Unconfirmed transactions.
|
|
30
30
|
*/
|
|
31
31
|
getTxsMempool(addressOrScripthash: string): Promise<Array<RawTransactionRest>>;
|
|
32
32
|
/**
|
|
33
33
|
* Get information about an address/scripthash.
|
|
34
|
-
* Available fields: address/scripthash, chain_stats and mempool_stats.
|
|
35
|
-
* {chain,mempool}_stats each contain an object with tx_count, funded_txo_count, funded_txo_sum, spent_txo_count and spent_txo_sum.
|
|
36
|
-
* Elements-based chains don't have the {funded,spent}_txo_sum fields.
|
|
37
34
|
* @param {string} addressOrScripthash The address or scripthash to check.
|
|
38
|
-
* @returns {Promise<AddressInfo>}
|
|
35
|
+
* @returns {Promise<AddressInfo>} Address information.
|
|
39
36
|
*/
|
|
40
37
|
getInfo(addressOrScripthash: string): Promise<AddressInfo>;
|
|
41
38
|
/**
|
|
42
39
|
* Get confirmed transaction history for the specified address/scripthash, sorted with newest first.
|
|
43
|
-
* Returns 25 transactions per page.
|
|
40
|
+
* Returns 25 transactions per page.
|
|
44
41
|
* @param {string} addressOrScripthash The address or scripthash to check.
|
|
45
|
-
* @param lastSeenTxId The last transaction id seen by the previous query
|
|
46
|
-
* @returns {Promise<Array<RawTransactionRest>>}
|
|
42
|
+
* @param {string} [lastSeenTxId] The last transaction id seen by the previous query for pagination.
|
|
43
|
+
* @returns {Promise<Array<RawTransactionRest>>} Confirmed transactions.
|
|
47
44
|
*/
|
|
48
45
|
getConfirmedTxs(addressOrScripthash: string, lastSeenTxId?: string): Promise<Array<RawTransactionRest>>;
|
|
49
46
|
/**
|
|
50
47
|
* Get the list of unspent transaction outputs associated with the address/scripthash.
|
|
51
48
|
* See {@link https://github.com/Blockstream/esplora/blob/master/API.md#get-addressaddressutxo | Esplora GET /address/:address/utxo } for details.
|
|
52
49
|
* @param {string} addressOrScripthash The address or scripthash to check.
|
|
53
|
-
* @returns {Promise<Array<
|
|
50
|
+
* @returns {Promise<Array<AddressUtxo>>} Unspent transaction outputs.
|
|
54
51
|
*/
|
|
55
52
|
getUtxos(addressOrScripthash: string): Promise<Array<AddressUtxo>>;
|
|
56
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../../../src/client/rest/address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../../../src/client/rest/address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;IAC3C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAqC;gBAE9C,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,GAAG,CAAC;IAK/E;;;;;;OAMG;IACU,MAAM,CAAC,mBAAmB,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAIpF;;;;OAIG;IACU,eAAe,CAAC,mBAAmB,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAM3E;;;;;OAKG;IACU,aAAa,CAAC,mBAAmB,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAI3F;;;;OAIG;IACU,OAAO,CAAC,mBAAmB,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAIvE;;;;;;OAMG;IACU,eAAe,CAAC,mBAAmB,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAIpH;;;;;OAKG;IACU,QAAQ,CAAC,mBAAmB,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;CAGhF"}
|
|
@@ -1,31 +1,39 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EsploraBlock } from '../../types.js';
|
|
2
|
+
import { HttpRequest } from '../http.js';
|
|
3
|
+
import { EsploraProtocol } from './protocol.js';
|
|
2
4
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
5
|
+
* Block-related Esplora REST API operations.
|
|
6
|
+
*
|
|
7
|
+
* Note: The Esplora API always returns the same block format regardless
|
|
8
|
+
* of any "verbosity" setting (unlike Bitcoin Core RPC). Use the RPC
|
|
9
|
+
* client if you need verbosity-controlled block responses.
|
|
6
10
|
*/
|
|
7
11
|
export declare class BitcoinBlock {
|
|
8
|
-
private
|
|
9
|
-
|
|
12
|
+
private readonly protocol;
|
|
13
|
+
private readonly exec;
|
|
14
|
+
constructor(protocol: EsploraProtocol, exec: (req: HttpRequest) => Promise<any>);
|
|
10
15
|
/**
|
|
11
|
-
* Returns the blockheight of the most-work fully-validated chain.
|
|
12
|
-
* @returns {
|
|
16
|
+
* Returns the blockheight of the most-work fully-validated chain.
|
|
17
|
+
* @returns {Promise<number>} The current block height.
|
|
13
18
|
*/
|
|
14
19
|
count(): Promise<number>;
|
|
15
20
|
/**
|
|
16
|
-
* Returns the block data
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {
|
|
19
|
-
* @param {
|
|
20
|
-
* @returns {
|
|
21
|
-
* @throws {
|
|
21
|
+
* Returns the Esplora block data for a given blockhash or height.
|
|
22
|
+
* @param {object} params The block hash or height.
|
|
23
|
+
* @param {string} [params.blockhash] The blockhash of the block to query.
|
|
24
|
+
* @param {number} [params.height] The block height of the block to query.
|
|
25
|
+
* @returns {Promise<EsploraBlock | undefined>} The block data.
|
|
26
|
+
* @throws {BitcoinRestError} If neither blockhash nor height is provided.
|
|
22
27
|
*/
|
|
23
|
-
get({ blockhash, height }:
|
|
28
|
+
get({ blockhash, height }: {
|
|
29
|
+
blockhash?: string;
|
|
30
|
+
height?: number;
|
|
31
|
+
}): Promise<EsploraBlock | undefined>;
|
|
24
32
|
/**
|
|
25
33
|
* Get the block hash for a given block height.
|
|
26
34
|
* See {@link https://github.com/blockstream/esplora/blob/master/API.md#get-block-heightheight | Esplora GET /block-height/:height } for details.
|
|
27
35
|
* @param {number} height The block height (required).
|
|
28
|
-
* @returns {Promise<string>} The hash of the block
|
|
36
|
+
* @returns {Promise<string>} The hash of the block at the given height.
|
|
29
37
|
*/
|
|
30
38
|
getHash(height: number): Promise<string>;
|
|
31
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../../src/client/rest/block.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../../src/client/rest/block.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD;;;;;;GAMG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;IAC3C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAqC;gBAE9C,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,GAAG,CAAC;IAK/E;;;OAGG;IACU,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;IAIrC;;;;;;;OAOG;IACU,GAAG,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IAanH;;;;;OAKG;IACU,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAGtD"}
|
|
@@ -1,66 +1,35 @@
|
|
|
1
1
|
import { BitcoinAddress } from './address.js';
|
|
2
2
|
import { BitcoinBlock } from './block.js';
|
|
3
3
|
import { BitcoinTransaction } from './transaction.js';
|
|
4
|
-
import {
|
|
4
|
+
import { EsploraProtocol } from './protocol.js';
|
|
5
|
+
import { RestConfig } from '../../types.js';
|
|
6
|
+
import { HttpExecutor } from '../http.js';
|
|
5
7
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @
|
|
8
|
+
* Esplora REST API client for Bitcoin.
|
|
9
|
+
*
|
|
10
|
+
* Wraps the sans-I/O {@link EsploraProtocol} with an {@link HttpExecutor}
|
|
11
|
+
* for convenience. Users who want full control over I/O can access the
|
|
12
|
+
* protocol layer directly via the {@link protocol} property.
|
|
9
13
|
*/
|
|
10
14
|
export declare class BitcoinRestClient {
|
|
11
|
-
/**
|
|
12
|
-
* The encapsulated {@link RestClientConfig} object.
|
|
13
|
-
* @private
|
|
14
|
-
* @type {RestClientConfig}
|
|
15
|
-
*/
|
|
16
15
|
private _config;
|
|
17
16
|
/**
|
|
18
|
-
* The
|
|
19
|
-
*
|
|
17
|
+
* The sans-I/O protocol layer. Use this to build {@link HttpRequest}
|
|
18
|
+
* descriptors without performing any I/O.
|
|
20
19
|
*/
|
|
20
|
+
readonly protocol: EsploraProtocol;
|
|
21
|
+
private readonly executor;
|
|
22
|
+
/** Transaction-related API calls. */
|
|
21
23
|
transaction: BitcoinTransaction;
|
|
22
|
-
/**
|
|
23
|
-
* The api calls related to bitcoin blocks.
|
|
24
|
-
* @type {BitcoinBlock}
|
|
25
|
-
*/
|
|
24
|
+
/** Block-related API calls. */
|
|
26
25
|
block: BitcoinBlock;
|
|
27
|
-
/**
|
|
28
|
-
* The api calls related to bitcoin addresses.
|
|
29
|
-
* @type {BitcoinAddress}
|
|
30
|
-
*/
|
|
26
|
+
/** Address-related API calls. */
|
|
31
27
|
address: BitcoinAddress;
|
|
28
|
+
constructor(config: RestConfig, executor?: HttpExecutor);
|
|
29
|
+
get config(): RestConfig;
|
|
32
30
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*/
|
|
36
|
-
api: (params: RestApiCallParams) => Promise<any>;
|
|
37
|
-
constructor(config: RestClientConfig);
|
|
38
|
-
/**
|
|
39
|
-
* Get the configuration object.
|
|
40
|
-
* @private
|
|
41
|
-
*/
|
|
42
|
-
get config(): RestClientConfig;
|
|
43
|
-
/**
|
|
44
|
-
* Static method connects to a bitcoin node running a esplora REST API.
|
|
45
|
-
*
|
|
46
|
-
* @param {RestClientConfig} config The configuration object for the client (optional).
|
|
47
|
-
* @returns {BitcoinRestClient} A new {@link BitcoinRestClient} instance.
|
|
48
|
-
* @example
|
|
49
|
-
* ```
|
|
50
|
-
* const rest = BitcoinRestClient.connect();
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
static connect(config?: RestClientConfig): BitcoinRestClient;
|
|
54
|
-
/**
|
|
55
|
-
* Make a REST API call to the configured Bitcoin node.
|
|
56
|
-
* @private
|
|
57
|
-
* @param {RestApiCallParams} params The parameters for the API call. See {@link RestApiCallParams} for details.
|
|
58
|
-
* @param {string} [params.path] The path to the API endpoint (required).
|
|
59
|
-
* @param {string} [params.url] The full URL to the API endpoint (optional).
|
|
60
|
-
* @param {string} [params.method] The HTTP method to use (default is 'GET').
|
|
61
|
-
* @param {any} [params.body] The body of the request (optional).
|
|
62
|
-
* @param {any} [params.headers] Additional headers to include in the request (optional).
|
|
63
|
-
* @returns {Promise<any>} A promise resolving to the response data.
|
|
31
|
+
* Execute an {@link HttpRequest} built by the protocol layer,
|
|
32
|
+
* parse the response, and throw on HTTP errors.
|
|
64
33
|
*/
|
|
65
|
-
private
|
|
34
|
+
private executeRequest;
|
|
66
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/rest/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/rest/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAoC,MAAM,YAAY,CAAC;AAE5E;;;;;;GAMG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,OAAO,CAAa;IAE5B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;IAEnC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IAExC,qCAAqC;IAC9B,WAAW,EAAE,kBAAkB,CAAC;IAEvC,+BAA+B;IACxB,KAAK,EAAE,YAAY,CAAC;IAE3B,iCAAiC;IAC1B,OAAO,EAAE,cAAc,CAAC;gBAEnB,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,YAAY;IAWvD,IAAI,MAAM,IAAI,UAAU,CAEvB;IAED;;;OAGG;YACW,cAAc;CAkB7B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { RestConfig } from '../../types.js';
|
|
2
|
+
import { HttpRequest } from '../http.js';
|
|
3
|
+
/**
|
|
4
|
+
* Sans-I/O Esplora REST API protocol.
|
|
5
|
+
*
|
|
6
|
+
* Every method returns an {@link HttpRequest} descriptor — a plain object
|
|
7
|
+
* describing *what* to request — without performing any I/O. The caller
|
|
8
|
+
* is responsible for executing the request with an HTTP client of their
|
|
9
|
+
* choice and deserializing the response.
|
|
10
|
+
*
|
|
11
|
+
* This mirrors the pattern used by the Rust `esploda` crate where
|
|
12
|
+
* `Esplora` methods return `http::Request<()>` objects.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const protocol = new EsploraProtocol({ host: 'https://mempool.space/api' });
|
|
17
|
+
*
|
|
18
|
+
* // Build a request descriptor (no I/O)
|
|
19
|
+
* const req = protocol.getTx('abc123...');
|
|
20
|
+
*
|
|
21
|
+
* // Execute with any HTTP client
|
|
22
|
+
* const res = await fetch(req.url, req);
|
|
23
|
+
* const tx: RawTransactionRest = await res.json();
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class EsploraProtocol {
|
|
27
|
+
private readonly baseUrl;
|
|
28
|
+
private readonly defaultHeaders;
|
|
29
|
+
constructor(config: RestConfig);
|
|
30
|
+
private static assertHex64;
|
|
31
|
+
private static assertAddress;
|
|
32
|
+
private get;
|
|
33
|
+
private post;
|
|
34
|
+
/** GET /tx/:txid */
|
|
35
|
+
getTx(txid: string): HttpRequest;
|
|
36
|
+
/** GET /tx/:txid/hex */
|
|
37
|
+
getTxHex(txid: string): HttpRequest;
|
|
38
|
+
/** GET /tx/:txid/raw */
|
|
39
|
+
getTxRaw(txid: string): HttpRequest;
|
|
40
|
+
/** POST /tx */
|
|
41
|
+
postTx(hex: string): HttpRequest;
|
|
42
|
+
/** GET /blocks/tip/height */
|
|
43
|
+
getBlockTipHeight(): HttpRequest;
|
|
44
|
+
/** GET /block/:blockhash */
|
|
45
|
+
getBlock(blockhash: string): HttpRequest;
|
|
46
|
+
/** GET /block-height/:height */
|
|
47
|
+
getBlockHeight(height: number): HttpRequest;
|
|
48
|
+
/** GET /address/:address/txs */
|
|
49
|
+
getAddressTxs(address: string): HttpRequest;
|
|
50
|
+
/** GET /address/:address/txs/mempool */
|
|
51
|
+
getAddressTxsMempool(address: string): HttpRequest;
|
|
52
|
+
/** GET /address/:address/txs/chain[/:last_seen_txid] */
|
|
53
|
+
getAddressTxsChain(address: string, lastSeenTxId?: string): HttpRequest;
|
|
54
|
+
/** GET /address/:address */
|
|
55
|
+
getAddressInfo(address: string): HttpRequest;
|
|
56
|
+
/** GET /address/:address/utxo */
|
|
57
|
+
getAddressUtxos(address: string): HttpRequest;
|
|
58
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../../../src/client/rest/protocol.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAIzC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAyB;gBAE5C,MAAM,EAAE,UAAU;IAU9B,OAAO,CAAC,MAAM,CAAC,WAAW;IAM1B,OAAO,CAAC,MAAM,CAAC,aAAa;IAQ5B,OAAO,CAAC,GAAG;IAQX,OAAO,CAAC,IAAI;IAWZ,oBAAoB;IACpB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW;IAKhC,wBAAwB;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW;IAKnC,wBAAwB;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW;IAKnC,eAAe;IACf,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW;IAMhC,6BAA6B;IAC7B,iBAAiB,IAAI,WAAW;IAIhC,4BAA4B;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW;IAKxC,gCAAgC;IAChC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW;IAM3C,gCAAgC;IAChC,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW;IAK3C,wCAAwC;IACxC,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW;IAKlD,wDAAwD;IACxD,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,WAAW;IASvE,4BAA4B;IAC5B,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW;IAK5C,iCAAiC;IACjC,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW;CAI9C"}
|
|
@@ -1,41 +1,40 @@
|
|
|
1
1
|
import { Bytes } from '@did-btcr2/common';
|
|
2
|
-
import { RawTransactionRest
|
|
2
|
+
import { RawTransactionRest } from '../../types.js';
|
|
3
|
+
import { HttpRequest } from '../http.js';
|
|
4
|
+
import { EsploraProtocol } from './protocol.js';
|
|
3
5
|
export declare class BitcoinTransaction {
|
|
4
|
-
private
|
|
5
|
-
|
|
6
|
+
private readonly protocol;
|
|
7
|
+
private readonly exec;
|
|
8
|
+
constructor(protocol: EsploraProtocol, exec: (req: HttpRequest) => Promise<any>);
|
|
6
9
|
/**
|
|
7
10
|
* Returns the transaction in JSON format.
|
|
8
11
|
* See {@link https://github.com/blockstream/esplora/blob/master/API.md#get-txtxid | Esplora GET /tx/:txid } for details.
|
|
9
12
|
* @param {string} txid The transaction id (required).
|
|
10
|
-
* @returns {
|
|
13
|
+
* @returns {Promise<RawTransactionRest>} A promise resolving to data about a transaction.
|
|
11
14
|
*/
|
|
12
15
|
get(txid: string): Promise<RawTransactionRest>;
|
|
13
16
|
/**
|
|
14
|
-
*
|
|
15
|
-
* See {@link https://github.com/blockstream/esplora/blob/master/API.md#get-txtxid | Esplora GET /tx/:txid } for details.
|
|
17
|
+
* Checks if a transaction is confirmed.
|
|
16
18
|
* @param {string} txid The transaction id (required).
|
|
17
|
-
* @returns {
|
|
19
|
+
* @returns {Promise<boolean>} True if the transaction is confirmed.
|
|
18
20
|
*/
|
|
19
21
|
isConfirmed(txid: string): Promise<boolean>;
|
|
20
22
|
/**
|
|
21
|
-
* Returns the raw transaction
|
|
22
|
-
* See {@link https://github.com/blockstream/esplora/blob/master/API.md#get-txtxidhex | Esplora GET /tx/:txid/hex }
|
|
23
|
-
* {@link https://github.com/blockstream/esplora/blob/master/API.md#get-txtxidraw | Esplora GET /tx/:txid/raw } for details.
|
|
23
|
+
* Returns the raw transaction as a hex string.
|
|
24
|
+
* See {@link https://github.com/blockstream/esplora/blob/master/API.md#get-txtxidhex | Esplora GET /tx/:txid/hex } for details.
|
|
24
25
|
* @param {string} txid The transaction id (required).
|
|
25
|
-
* @returns {Promise<
|
|
26
|
+
* @returns {Promise<string>} A promise resolving to the raw transaction hex.
|
|
26
27
|
*/
|
|
27
28
|
getHex(txid: string): Promise<string>;
|
|
28
29
|
/**
|
|
29
|
-
* Returns the raw transaction
|
|
30
|
-
* See {@link https://github.com/blockstream/esplora/blob/master/API.md#get-
|
|
31
|
-
* {@link https://github.com/blockstream/esplora/blob/master/API.md#get-txtxidraw | Esplora GET /tx/:txid/raw } for details.
|
|
30
|
+
* Returns the raw transaction as binary data.
|
|
31
|
+
* See {@link https://github.com/blockstream/esplora/blob/master/API.md#get-txtxidraw | Esplora GET /tx/:txid/raw } for details.
|
|
32
32
|
* @param {string} txid The transaction id (required).
|
|
33
|
-
* @returns {Promise<
|
|
33
|
+
* @returns {Promise<Bytes>} A promise resolving to the raw transaction bytes.
|
|
34
34
|
*/
|
|
35
35
|
getRaw(txid: string): Promise<Bytes>;
|
|
36
36
|
/**
|
|
37
|
-
* Broadcast a raw transaction to the network.
|
|
38
|
-
* will be returned on success.
|
|
37
|
+
* Broadcast a raw transaction to the network.
|
|
39
38
|
* See {@link https://github.com/blockstream/esplora/blob/master/API.md#post-tx | Esplora POST /tx } for details.
|
|
40
39
|
* @param {string} tx The raw transaction in hex format (required).
|
|
41
40
|
* @returns {Promise<string>} The transaction id of the broadcasted transaction.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../../src/client/rest/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../../src/client/rest/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;IAC3C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAqC;gBAE9C,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,GAAG,CAAC;IAK/E;;;;;OAKG;IACU,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAI3D;;;;OAIG;IACU,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKxD;;;;;OAKG;IACU,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIlD;;;;;OAKG;IACU,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAIjD;;;;;OAKG;IACU,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAG/C"}
|