@did-btcr2/bitcoin 0.1.1 → 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/dist/cjs/{bitcoin.browser.js → bitcoin.js} +39 -16
- package/dist/cjs/bitcoin.js.map +1 -0
- package/dist/cjs/client/rest/address.js +76 -0
- package/dist/cjs/client/rest/address.js.map +1 -0
- package/dist/cjs/client/rest/block.js +50 -0
- package/dist/cjs/client/rest/block.js.map +1 -0
- package/dist/cjs/client/rest/index.js +118 -0
- package/dist/cjs/client/rest/index.js.map +1 -0
- package/dist/cjs/client/rest/transaction.js +56 -0
- package/dist/cjs/client/rest/transaction.js.map +1 -0
- package/dist/cjs/client/rpc/index.js +394 -0
- package/dist/cjs/client/rpc/index.js.map +1 -0
- package/dist/cjs/client/rpc/interface.js.map +1 -0
- package/dist/cjs/client/rpc/json-rpc.js +78 -0
- package/dist/cjs/client/rpc/json-rpc.js.map +1 -0
- package/dist/cjs/client/utils.js +28 -0
- package/dist/cjs/client/utils.js.map +1 -0
- package/dist/cjs/constants.js +34 -13
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/errors.js +8 -0
- package/dist/cjs/errors.js.map +1 -1
- package/dist/cjs/index.js +15 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/types.js +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/esm/{bitcoin.browser.js → bitcoin.js} +39 -16
- package/dist/esm/bitcoin.js.map +1 -0
- package/dist/esm/client/rest/address.js +76 -0
- package/dist/esm/client/rest/address.js.map +1 -0
- package/dist/esm/client/rest/block.js +50 -0
- package/dist/esm/client/rest/block.js.map +1 -0
- package/dist/esm/client/rest/index.js +118 -0
- package/dist/esm/client/rest/index.js.map +1 -0
- package/dist/esm/client/rest/transaction.js +56 -0
- package/dist/esm/client/rest/transaction.js.map +1 -0
- package/dist/esm/client/rpc/index.js +394 -0
- package/dist/esm/client/rpc/index.js.map +1 -0
- package/dist/esm/client/rpc/interface.js.map +1 -0
- package/dist/esm/client/rpc/json-rpc.js +78 -0
- package/dist/esm/client/rpc/json-rpc.js.map +1 -0
- package/dist/esm/client/utils.js +28 -0
- package/dist/esm/client/utils.js.map +1 -0
- package/dist/esm/constants.js +34 -13
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/errors.js +8 -0
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/index.js +15 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types.js +2 -2
- package/dist/esm/types.js.map +1 -1
- package/dist/types/{bitcoin.browser.d.ts → bitcoin.d.ts} +23 -8
- package/dist/types/bitcoin.d.ts.map +1 -0
- package/dist/types/client/rest/address.d.ts +56 -0
- package/dist/types/client/rest/address.d.ts.map +1 -0
- package/dist/types/client/rest/block.d.ts +32 -0
- package/dist/types/client/rest/block.d.ts.map +1 -0
- package/dist/types/client/rest/index.d.ts +149 -0
- package/dist/types/client/rest/index.d.ts.map +1 -0
- package/dist/types/client/rest/transaction.d.ts +44 -0
- package/dist/types/client/rest/transaction.d.ts.map +1 -0
- package/dist/types/client/rpc/index.d.ts +276 -0
- package/dist/types/client/rpc/index.d.ts.map +1 -0
- package/dist/types/client/rpc/interface.d.ts +27 -0
- package/dist/types/client/rpc/interface.d.ts.map +1 -0
- package/dist/types/client/rpc/json-rpc.d.ts +24 -0
- package/dist/types/client/rpc/json-rpc.d.ts.map +1 -0
- package/dist/types/client/utils.d.ts +12 -0
- package/dist/types/client/utils.d.ts.map +1 -0
- package/dist/types/constants.d.ts +46 -13
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/errors.d.ts +4 -0
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types.d.ts +8 -8
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +9 -15
- package/src/{bitcoin.browser.ts → bitcoin.ts} +48 -16
- package/src/client/rest/address.ts +84 -0
- package/src/client/rest/block.ts +58 -0
- package/src/client/rest/index.ts +217 -0
- package/src/client/rest/transaction.ts +64 -0
- package/src/client/rpc/index.ts +479 -0
- package/src/client/rpc/interface.ts +58 -0
- package/src/client/rpc/json-rpc.ts +82 -0
- package/src/client/utils.ts +21 -0
- package/src/constants.ts +35 -14
- package/src/errors.ts +9 -0
- package/src/index.ts +14 -0
- package/src/types.ts +9 -9
- package/dist/cjs/bitcoin.browser.js.map +0 -1
- package/dist/cjs/bitcoin.node.js +0 -85
- package/dist/cjs/bitcoin.node.js.map +0 -1
- package/dist/cjs/index.browser.js +0 -10
- package/dist/cjs/index.browser.js.map +0 -1
- package/dist/cjs/index.node.js +0 -10
- package/dist/cjs/index.node.js.map +0 -1
- package/dist/cjs/interface.js.map +0 -1
- package/dist/cjs/rest-client.js +0 -294
- package/dist/cjs/rest-client.js.map +0 -1
- package/dist/cjs/rpc-client.js +0 -722
- package/dist/cjs/rpc-client.js.map +0 -1
- package/dist/esm/bitcoin.browser.js.map +0 -1
- package/dist/esm/bitcoin.node.js +0 -85
- package/dist/esm/bitcoin.node.js.map +0 -1
- package/dist/esm/index.browser.js +0 -10
- package/dist/esm/index.browser.js.map +0 -1
- package/dist/esm/index.node.js +0 -10
- package/dist/esm/index.node.js.map +0 -1
- package/dist/esm/interface.js.map +0 -1
- package/dist/esm/rest-client.js +0 -294
- package/dist/esm/rest-client.js.map +0 -1
- package/dist/esm/rpc-client.js +0 -722
- package/dist/esm/rpc-client.js.map +0 -1
- package/dist/types/bitcoin.browser.d.ts.map +0 -1
- package/dist/types/bitcoin.node.d.ts +0 -47
- package/dist/types/bitcoin.node.d.ts.map +0 -1
- package/dist/types/index.browser.d.ts +0 -9
- package/dist/types/index.browser.d.ts.map +0 -1
- package/dist/types/index.node.d.ts +0 -9
- package/dist/types/index.node.d.ts.map +0 -1
- package/dist/types/interface.d.ts +0 -86
- package/dist/types/interface.d.ts.map +0 -1
- package/dist/types/rest-client.d.ts +0 -273
- package/dist/types/rest-client.d.ts.map +0 -1
- package/dist/types/rpc-client.d.ts +0 -506
- package/dist/types/rpc-client.d.ts.map +0 -1
- package/src/bitcoin.node.ts +0 -121
- package/src/index.browser.ts +0 -9
- package/src/index.node.ts +0 -9
- package/src/interface.ts +0 -160
- package/src/rest-client.ts +0 -420
- package/src/rpc-client.ts +0 -888
- /package/dist/cjs/{interface.js → client/rpc/interface.js} +0 -0
- /package/dist/esm/{interface.js → client/rpc/interface.js} +0 -0
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import { DEFAULT_BITCOIN_NETWORK_CONFIG } from '../../constants.js';
|
|
2
|
+
import { BitcoinRpcError } from '../../errors.js';
|
|
3
|
+
import { BitcoinRpcClientConfig } from '../../types.js';
|
|
4
|
+
import { JsonRpcTransport } from './json-rpc.js';
|
|
5
|
+
/**
|
|
6
|
+
* Class representing a Bitcoin Core RPC client.
|
|
7
|
+
* @class BitcoinCoreRpcClient
|
|
8
|
+
* @type {BitcoinCoreRpcClient}
|
|
9
|
+
* @implements {BitcoinRpcClient}
|
|
10
|
+
*/
|
|
11
|
+
export class BitcoinCoreRpcClient {
|
|
12
|
+
_transport;
|
|
13
|
+
_config;
|
|
14
|
+
/**
|
|
15
|
+
* Constructs a new {@link BitcoinCoreRpcClient} instance from a new {@link RpcClient | RpcClient}.
|
|
16
|
+
* @param {RpcClientConfig} config The bitcoin-core client instance.
|
|
17
|
+
* @example
|
|
18
|
+
* ```
|
|
19
|
+
* import BitcoinRpcClient from '@did-btcr2/method';
|
|
20
|
+
* const bob = BitcoinRpcClient.connect(); // To use default polar config, pass no args. Polar must run locally.
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
constructor(config) {
|
|
24
|
+
this._config = new BitcoinRpcClientConfig(config);
|
|
25
|
+
this._transport = new JsonRpcTransport(this._config);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get the config for the current BitcoinRpcClient object.
|
|
29
|
+
* @returns {BitcoinRpcClient} The encapsulated {@link BitcoinRpcClient} object.
|
|
30
|
+
* @example
|
|
31
|
+
* ```
|
|
32
|
+
* import BitcoinRpcClient from '@did-btcr2/method';
|
|
33
|
+
* const alice = BitcoinRpcClient.connect();
|
|
34
|
+
* const config = alice.config;
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
get config() {
|
|
38
|
+
const config = this._config;
|
|
39
|
+
return config;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get the client for the current BitcoinRpcClient object.
|
|
43
|
+
* @returns {RpcClient} The encapsulated {@link RpcClient} object.
|
|
44
|
+
* @example
|
|
45
|
+
* ```
|
|
46
|
+
* const alice = BitcoinRpcClient.connect();
|
|
47
|
+
* const config = alice.client;
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
get client() {
|
|
51
|
+
const client = this._transport;
|
|
52
|
+
return client;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Static method initializes a new BitcoinCoreRpcClient client with the given configuration.
|
|
56
|
+
* The RpcClient returned by this method does not have any named methods.
|
|
57
|
+
* Use this method to create and pass a new RpcClient instance to a BitcoinCoreRpcClient constructor.
|
|
58
|
+
*
|
|
59
|
+
* @param {RpcClientConfig} config The configuration object for the client (optional).
|
|
60
|
+
* @returns {BitcoinCoreRpcClient} A new RpcClient instance.
|
|
61
|
+
* @example
|
|
62
|
+
* ```
|
|
63
|
+
* const options: RpcClientConfig = {
|
|
64
|
+
* host: 'http://localhost:18443',
|
|
65
|
+
* username: 'alice',
|
|
66
|
+
* password: 'alicepass',
|
|
67
|
+
* version: '28.1.0',
|
|
68
|
+
* }
|
|
69
|
+
* const alice = BitcoinCoreRpcClient.initialize(options); // Client config required
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
static initialize(config) {
|
|
73
|
+
return BitcoinRpcClientConfig.initialize(config);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Static method connects to a bitcoin node running the bitcoin core daemon (bitcoind).
|
|
77
|
+
* To use default polar config, do not pass a config. See {@link DEFAULT_BITCOIN_NETWORK_CONFIG} for default config.
|
|
78
|
+
* @required A locally running {@link https://github.com/jamaljsr/polar | Polar Lightning} regtest node.
|
|
79
|
+
*
|
|
80
|
+
* @param {?RpcClientConfig} config The configuration object for the client (optional).
|
|
81
|
+
* @returns A new {@link BitcoinRpcClient} instance.
|
|
82
|
+
* @example
|
|
83
|
+
* ```
|
|
84
|
+
* const alice = BitcoinRpcClient.connect();
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
static connect(config) {
|
|
88
|
+
return new BitcoinCoreRpcClient(config ?? DEFAULT_BITCOIN_NETWORK_CONFIG.regtest.rpc);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Check if the given error is a JSON-RPC error.
|
|
92
|
+
* @param {unknown} e The error to check.
|
|
93
|
+
* @returns {boolean} True if the error is a JSON-RPC error, false otherwise.
|
|
94
|
+
*/
|
|
95
|
+
isJsonRpcError(e) {
|
|
96
|
+
return (e instanceof Error &&
|
|
97
|
+
e.name === 'RpcError' &&
|
|
98
|
+
typeof e.code === 'number');
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Executes a JSON-RPC command on the bitcoind node.
|
|
102
|
+
* @param {MethodNameInLowerCase} method The name of the method to call.
|
|
103
|
+
* @param {Array<any>} parameters The parameters to pass to the method.
|
|
104
|
+
* @returns {Promise<T>} A promise resolving to the result of the command.
|
|
105
|
+
*/
|
|
106
|
+
async executeRpc(method, parameters = []) {
|
|
107
|
+
try {
|
|
108
|
+
// raw call
|
|
109
|
+
const raw = await this.client.command([{ method, parameters }]);
|
|
110
|
+
// normalization/unwrapping, if needed
|
|
111
|
+
const normalized = JSON.unprototyped(raw) ? JSON.normalize(raw) : raw;
|
|
112
|
+
const result = Array.isArray(normalized)
|
|
113
|
+
? normalized[normalized.length - 1]
|
|
114
|
+
: normalized;
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
this.handleError(err, method, parameters);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Handle errors that occur while executing commands.
|
|
123
|
+
* @param methods An array of {@link BatchOption} objects.
|
|
124
|
+
* @param error The error that was thrown.
|
|
125
|
+
* @throws Throws a {@link BitcoinRpcError} with the error message.
|
|
126
|
+
*/
|
|
127
|
+
handleError(err, method, params) {
|
|
128
|
+
if (this.isJsonRpcError(err)) {
|
|
129
|
+
// a bitcoind JSON‑RPC error
|
|
130
|
+
throw new BitcoinRpcError(err.code, `RPC ${method} failed: ${err.message}`, { method, params });
|
|
131
|
+
}
|
|
132
|
+
if (err instanceof Error) {
|
|
133
|
+
// network, HTTP, or unexpected client error
|
|
134
|
+
throw new BitcoinRpcError('NETWORK_ERROR', `Network error in ${method}: ${err.message}`, { method, params, original: err });
|
|
135
|
+
}
|
|
136
|
+
// absolutely unknown
|
|
137
|
+
throw new BitcoinRpcError('UNKNOWN_ERROR', `Unknown failure in ${method}`, { method, params, err });
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Returns the block data associated with a `blockhash` of a valid block.
|
|
141
|
+
* @param {GetBlockParams} params See {@link GetBlockParams} for details.
|
|
142
|
+
* @param {?string} params.blockhash The blockhash of the block to query.
|
|
143
|
+
* @param {?number} params.height The block height of the block to query.
|
|
144
|
+
* @param {?VerbosityLevel} params.verbosity The verbosity level. See {@link VerbosityLevel}.
|
|
145
|
+
* @returns {BlockResponse} A promise resolving to a {@link BlockResponse} formatted depending on `verbosity` level.
|
|
146
|
+
* @throws {BitcoinRpcError} If neither `blockhash` nor `height` is provided.
|
|
147
|
+
*/
|
|
148
|
+
async getBlock({ blockhash, height, verbosity }) {
|
|
149
|
+
// Check if blockhash or height is provided, if neither throw an error
|
|
150
|
+
if (!blockhash && height === undefined) {
|
|
151
|
+
throw new BitcoinRpcError('blockhash or height required', 'INVALID_PARAMS_GET_BLOCK', { blockhash, height });
|
|
152
|
+
}
|
|
153
|
+
// If height is provided, get the blockhash
|
|
154
|
+
blockhash ??= await this.getBlockHash(height);
|
|
155
|
+
if (!blockhash || typeof blockhash !== 'string') {
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
// Get the block data
|
|
159
|
+
const block = await this.executeRpc('getblock', [blockhash, verbosity ?? 3]);
|
|
160
|
+
// Return the block data depending on verbosity level
|
|
161
|
+
switch (verbosity) {
|
|
162
|
+
case 0:
|
|
163
|
+
return block;
|
|
164
|
+
case 1:
|
|
165
|
+
return block;
|
|
166
|
+
case 2:
|
|
167
|
+
return block;
|
|
168
|
+
case 3:
|
|
169
|
+
return block;
|
|
170
|
+
default:
|
|
171
|
+
return block;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Returns the blockheight of the most-work fully-validated chain. The genesis block has height 0.
|
|
176
|
+
* @returns {Blockheight} The number of the blockheight with the most-work of the fully-validated chain.
|
|
177
|
+
*/
|
|
178
|
+
async getBlockCount() {
|
|
179
|
+
return await this.executeRpc('getblockcount');
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Returns the blockhash of the block at the given height in the active chain.
|
|
183
|
+
*/
|
|
184
|
+
async getBlockHash(height) {
|
|
185
|
+
return await this.executeRpc('getblockhash', [height]);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Returns an object containing various blockchain state info.
|
|
189
|
+
*/
|
|
190
|
+
async getBlockchainInfo() {
|
|
191
|
+
return this.executeRpc('getblockchaininfo');
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Sign inputs for raw transaction (serialized, hex-encoded).
|
|
195
|
+
* The second optional argument (may be null) is an array of previous transaction outputs that
|
|
196
|
+
* this transaction depends on but may not yet be in the block chain.
|
|
197
|
+
* Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.
|
|
198
|
+
* @param {string} hexstring The hex-encoded transaction to send.
|
|
199
|
+
*/
|
|
200
|
+
async signRawTransaction(hexstring) {
|
|
201
|
+
return await this.executeRpc('signrawtransactionwithwallet', [hexstring]);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Submit a raw transaction (serialized, hex-encoded) to local node and network.
|
|
205
|
+
*
|
|
206
|
+
* The transaction will be sent unconditionally to all peers, so using sendrawtransaction
|
|
207
|
+
* for manual rebroadcast may degrade privacy by leaking the transaction's origin, as
|
|
208
|
+
* nodes will normally not rebroadcast non-wallet transactions already in their mempool.
|
|
209
|
+
*
|
|
210
|
+
* @param {string} hexstring The hex-encoded transaction to send.
|
|
211
|
+
* @param {numbner} [maxfeerate] If not passed, default is 0.10.
|
|
212
|
+
* @returns {Promise<string>} A promise resolving to the transaction hash in hex.
|
|
213
|
+
*/
|
|
214
|
+
async sendRawTransaction(hexstring, maxfeerate, maxBurnAmount) {
|
|
215
|
+
console.log('sendRawTransaction', { hexstring, maxfeerate, maxBurnAmount });
|
|
216
|
+
return await this.executeRpc('sendrawtransaction', [hexstring, maxfeerate ?? 0.10, maxBurnAmount ?? 0.00]);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Combines calls to `signRawTransaction` and `sendRawTransaction`.
|
|
220
|
+
* @param {string} params.hexstring The hex-encoded transaction to send.
|
|
221
|
+
* @returns {Promise<string>} A promise resolving to the transaction hash in hex.
|
|
222
|
+
*/
|
|
223
|
+
async signAndSendRawTransaction(hexstring) {
|
|
224
|
+
const signedRawTx = await this.signRawTransaction(hexstring);
|
|
225
|
+
return await this.sendRawTransaction(signedRawTx.hex);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Combines calls to `createRawTransaction`, `signRawTransaction` and `sendRawTransaction`.
|
|
229
|
+
* @param {CreateRawTxInputs[]} inputs The inputs to the transaction (required).
|
|
230
|
+
* @param {CreateRawTxOutputs[]} outputs The outputs of the transaction (required).
|
|
231
|
+
* @returns {Promise<string>} A promise resolving to the transaction hash in hex.
|
|
232
|
+
*/
|
|
233
|
+
async createSignSendRawTransaction(inputs, outputs) {
|
|
234
|
+
const rawTx = await this.createRawTransaction(inputs, outputs);
|
|
235
|
+
const signedRawTx = await this.signRawTransaction(rawTx);
|
|
236
|
+
const sentRawTx = await this.sendRawTransaction(signedRawTx.hex);
|
|
237
|
+
return sentRawTx;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* TODO: Comments
|
|
241
|
+
*/
|
|
242
|
+
async listTransactions(params) {
|
|
243
|
+
return await this.executeRpc('listtransactions', [params]);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Create a transaction spending the given inputs and creating new outputs.
|
|
247
|
+
* Outputs can be addresses or data.
|
|
248
|
+
* Returns hex-encoded raw transaction.
|
|
249
|
+
* Note that the transaction's inputs are not signed, and
|
|
250
|
+
* it is not stored in the wallet or transmitted to the network.
|
|
251
|
+
* @param {TxInForCreateRaw[]} inputs The inputs to the transaction (required).
|
|
252
|
+
* @param {CreateRawTxOutputs[]} outputs The outputs of the transaction (required).
|
|
253
|
+
* @param {number} [locktime] The locktime of the transaction (optional).
|
|
254
|
+
* @param {boolean} [replacable] Whether the transaction is replaceable (optional).
|
|
255
|
+
* @returns {string} The hex-encoded raw transaction.
|
|
256
|
+
*/
|
|
257
|
+
async createRawTransaction(inputs, outputs, locktime, replacable) {
|
|
258
|
+
return await this.executeRpc('createrawtransaction', [inputs, outputs, locktime, replacable]);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Derives one or more addresses corresponding to an output descriptor.
|
|
262
|
+
* Examples of output descriptors are:
|
|
263
|
+
* pkh(<pubkey>) P2PKH outputs for the given pubkey
|
|
264
|
+
* wpkh(<pubkey>) Native segwit P2PKH outputs for the given pubkey
|
|
265
|
+
* sh(multi(<n>,<pubkey>,<pubkey>,...)) P2SH-multisig outputs for the given threshold and pubkeys
|
|
266
|
+
* raw(<hex script>) Outputs whose output script equals the specified hex-encoded bytes
|
|
267
|
+
* tr(<pubkey>,multi_a(<n>,<pubkey>,<pubkey>,...)) P2TR-multisig outputs for the given threshold and pubkeys
|
|
268
|
+
*
|
|
269
|
+
* In the above, <pubkey> either refers to a fixed public key in hexadecimal notation, or to an xpub/xprv optionally followed by one
|
|
270
|
+
* or more path elements separated by "/", where "h" represents a hardened child key.
|
|
271
|
+
*
|
|
272
|
+
* See {@link https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md | github.com/bitcoin/bitcoin/descriptors.md}
|
|
273
|
+
* for more information.
|
|
274
|
+
* @param {string} descriptor The descriptor.
|
|
275
|
+
* @param {Array<number>} range If descriptor is ranged, must specify end or [begin,end] to derive.
|
|
276
|
+
* @returns {Array<DerivedAddresses>} a list of derived addresses
|
|
277
|
+
* @example First three native segwit receive addresses
|
|
278
|
+
* ```
|
|
279
|
+
* const bitcoind = BitcoinRpcClient.connect()
|
|
280
|
+
* const addresses = bitcoind.deriveAddresses("wpkh([d34db33f/84h/0h/0h]xpub6DJ2dN.../0/*)#cjjspncu", [0,2])
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
async deriveAddresses(descriptor, range) {
|
|
284
|
+
return await this.executeRpc('deriveaddresses', [descriptor, range]);
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Returns the total available balance. The available balance is what the wallet
|
|
288
|
+
* considers currently spendable, and is thus affected by options which limit
|
|
289
|
+
* spendability such as -spendzeroconfchange.
|
|
290
|
+
* @returns {Promise<number>} A promise resolving to the total available balance in BTC.
|
|
291
|
+
*/
|
|
292
|
+
async getBalance() {
|
|
293
|
+
return await this.executeRpc('getbalance');
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Returns a new Bitcoin address for receiving payments. If 'label' is specified,
|
|
297
|
+
* it is added to the address book so payments received with the address will be associated with 'label'.
|
|
298
|
+
* The 'address_type' can be one of "legacy", "p2sh-segwit", "bech32", or "bech32m".
|
|
299
|
+
* @param {string} addressType The address type to use (required, options=["legacy", "p2sh-segwit", "bech32", "bech32m"], default="bech32").
|
|
300
|
+
* @param {string} [label] The label to associate with the new address (optional).
|
|
301
|
+
* @returns {Promise<string>} A promise resolving to the new address.
|
|
302
|
+
*/
|
|
303
|
+
async getNewAddress(addressType, label) {
|
|
304
|
+
return await this.executeRpc('getnewaddress', [label ?? '', addressType]);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Returns array of unspent transaction outputs with between minconf and maxconf (inclusive) confirmations.
|
|
308
|
+
* Optionally filter to only include txouts paid to specified addresses.
|
|
309
|
+
* @param {Object} params The parameters for the listUnspent command.
|
|
310
|
+
* @param {number} [params.minconf=0] The minimum number of confirmations an output must have to be included.
|
|
311
|
+
* @param {number} [params.maxconf=9999999] The maximum number of confirmations an output can have to be included.
|
|
312
|
+
* @param {string[]} [params.address] Only include outputs paid to these addresses.
|
|
313
|
+
* @param {boolean} [params.include_unsafe=true] Whether to include outputs that are not safe to spend.
|
|
314
|
+
* @returns {Promise<UnspentTxInfo[]>} A promise resolving to an array of {@link UnspentTxInfo} objects.
|
|
315
|
+
*/
|
|
316
|
+
async listUnspent(params) {
|
|
317
|
+
const args = { minconf: 0, maxconf: 9999999, include_unsafe: true, ...params };
|
|
318
|
+
return await this.executeRpc('listunspent', [args]);
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Send an amount to a given address.
|
|
322
|
+
* @param {string} address The address to send to.
|
|
323
|
+
* @param {number} amount The amount to send in BTC.
|
|
324
|
+
* @returns {Promise<SendToAddressResult>} A promise resolving to the transaction id.
|
|
325
|
+
*/
|
|
326
|
+
async sendToAddress(address, amount) {
|
|
327
|
+
const txid = await this.executeRpc('sendtoaddress', [address, amount]);
|
|
328
|
+
return await this.getRawTransaction(txid);
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Sign a message with the private key of an address.
|
|
332
|
+
* @param {string} address The address to sign the message with.
|
|
333
|
+
* @param {string} message The message to sign.
|
|
334
|
+
* @returns {Promise<string>} A promise resolving to the signature in base64.
|
|
335
|
+
*/
|
|
336
|
+
async signMessage(address, message) {
|
|
337
|
+
return await this.executeRpc('signmessage', [address, message]);
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Verify a signed message.
|
|
341
|
+
* @param {string} address The address to verify the message with.
|
|
342
|
+
* @param {string} signature The signature to verify in base64.
|
|
343
|
+
* @param {string} message The message to verify.
|
|
344
|
+
* @returns {Promise<boolean>} A promise resolving to true if the signature is valid, false otherwise.
|
|
345
|
+
*/
|
|
346
|
+
async verifyMessage(address, signature, message) {
|
|
347
|
+
return await this.executeRpc('verifymessage', [address, signature, message]);
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Get detailed information about in-wallet transaction <txid>.
|
|
351
|
+
* @param txid: The transaction id. (string, required)
|
|
352
|
+
* @param {boolean} include_watchonly Whether to include watch-only addresses in balance calculation and details.
|
|
353
|
+
* @returns {WalletTransaction} A promise resolving to a {@link WalletTransaction} object.
|
|
354
|
+
*/
|
|
355
|
+
async getTransaction(txid, include_watchonly) {
|
|
356
|
+
return await this.executeRpc('gettransaction', [txid, include_watchonly]);
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Get detailed information about a transaction.
|
|
360
|
+
* By default, this call only returns a transaction if it is in the mempool. If -txindex is enabled
|
|
361
|
+
* and no blockhash argument is passed, it will return the transaction if it is in the mempool or any block.
|
|
362
|
+
* If a blockhash argument is passed, it will return the transaction if the specified block is available and
|
|
363
|
+
* the transaction is in that block.
|
|
364
|
+
* @param {string} txid The transaction id (required).
|
|
365
|
+
* @param {?VerbosityLevel} verbosity Response format: 0 (hex), 1 (json) or 2 (jsonext).
|
|
366
|
+
* @param {?string} blockhash The block in which to look for the transaction (optional).
|
|
367
|
+
* @returns {GetRawTransaction} A promise resolving to data about a transaction in the form specified by verbosity.
|
|
368
|
+
*/
|
|
369
|
+
async getRawTransaction(txid, verbosity, blockhash) {
|
|
370
|
+
// Get the raw transaction
|
|
371
|
+
const rawTransaction = await this.executeRpc('getrawtransaction', [txid, verbosity ?? 2, blockhash]);
|
|
372
|
+
// Return the raw transaction based on verbosity
|
|
373
|
+
switch (verbosity) {
|
|
374
|
+
case 0:
|
|
375
|
+
return rawTransaction;
|
|
376
|
+
case 1:
|
|
377
|
+
return rawTransaction;
|
|
378
|
+
case 2:
|
|
379
|
+
return rawTransaction;
|
|
380
|
+
default:
|
|
381
|
+
return rawTransaction;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Get detailed information about multiple transactions. An extension of {@link getRawTransaction}.
|
|
386
|
+
* @param {Array<string>} txids An array of transaction ids.
|
|
387
|
+
* @param {?VerbosityLevel} verbosity Response format: 0 (hex), 1 (json) or 2 (jsonext).
|
|
388
|
+
* @returns {Promise<Array<RawTransactionResponse>>}
|
|
389
|
+
*/
|
|
390
|
+
async getRawTransactions(txids, verbosity) {
|
|
391
|
+
return await Promise.all(txids.map(async (txid) => await this.getRawTransaction(txid, verbosity ?? 2)));
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/client/rpc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAEL,sBAAsB,EAuBvB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,OAAO,oBAAoB;IACvB,UAAU,CAAmB;IAC7B,OAAO,CAAkB;IAEjC;;;;;;;;OAQG;IACH,YAAY,MAAuB;QACjC,IAAI,CAAC,OAAO,GAAG,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAC;QAClD,IAAI,CAAC,UAAU,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,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AO,CAAC,CAAC,CAAC;IAC/E,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,cAAc,CAAC,IAAY,EAAE,iBAA2B;QACnE,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,gBAAgB,EAAE,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED;;;;;;;;;;OAUG;IACI,KAAK,CAAC,iBAAiB,CAAC,IAAY,EAAE,SAA0B,EAAE,SAAkB;QACzF,0BAA0B;QAC1B,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,mBAAmB,EAAE,CAAC,IAAI,EAAE,SAAS,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;QACrG,gDAAgD;QAChD,QAAO,SAAS,EAAE,CAAC;YACjB,KAAK,CAAC;gBACJ,OAAO,cAAkC,CAAC;YAC5C,KAAK,CAAC;gBACJ,OAAO,cAAkC,CAAC;YAC5C,KAAK,CAAC;gBACJ,OAAO,cAAkC,CAAC;YAC5C;gBACE,OAAO,cAAkC,CAAC;QAC9C,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,kBAAkB,CAAC,KAAe,EAAE,SAA0B;QACzE,OAAO,MAAM,OAAO,CAAC,GAAG,CACtB,KAAK,CAAC,GAAG,CACP,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,SAAS,IAAI,CAAC,CAAC,CACnE,CACF,CAAC;IACJ,CAAC;CAEF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../../src/client/rpc/interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { safeText, toBase64 } from '../utils.js';
|
|
2
|
+
export class JsonRpcTransport {
|
|
3
|
+
url;
|
|
4
|
+
authHeader;
|
|
5
|
+
id = 0;
|
|
6
|
+
constructor(cfg) {
|
|
7
|
+
this.url = (cfg.host || 'http://127.0.0.1:8332').replace(/\/+$/, '');
|
|
8
|
+
if (cfg.username && cfg.password) {
|
|
9
|
+
this.authHeader = `Basic ${toBase64(`${cfg.username}:${cfg.password}`)}`;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
try {
|
|
13
|
+
const u = new URL(this.url);
|
|
14
|
+
if (u.username || u.password) {
|
|
15
|
+
this.authHeader = `Basic ${toBase64(`${decodeURIComponent(u.username)}:${decodeURIComponent(u.password)}`)}`;
|
|
16
|
+
// strip creds from URL if they were embedded
|
|
17
|
+
u.username = '';
|
|
18
|
+
u.password = '';
|
|
19
|
+
this.url = u.toString().replace(/\/+$/, '');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
console.error('Invalid URL in Bitcoin RPC config');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Make a JSON-RPC call or batch of calls to the Bitcoin node.
|
|
29
|
+
* @param {BatchOption[] | { method: string; parameters?: any[] }} batch A single RPC call or an array of calls to be made.
|
|
30
|
+
* @returns {Promise<any[] | any>} The result of the RPC call(s).
|
|
31
|
+
* @example
|
|
32
|
+
*/
|
|
33
|
+
async command(batch) {
|
|
34
|
+
if (Array.isArray(batch)) {
|
|
35
|
+
const out = [];
|
|
36
|
+
for (const item of batch) {
|
|
37
|
+
out.push(await this.call(item.method, item.parameters ?? []));
|
|
38
|
+
}
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
return this.call(batch.method, batch.parameters ?? []);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Internal method to perform the actual JSON-RPC call.
|
|
47
|
+
* @param {string} method The RPC method to call.
|
|
48
|
+
* @param {any[]} params The parameters for the RPC method.
|
|
49
|
+
* @returns {Promise<any>} The result of the RPC call.
|
|
50
|
+
*/
|
|
51
|
+
async call(method, params) {
|
|
52
|
+
const body = { jsonrpc: '2.0', id: ++this.id, method, params };
|
|
53
|
+
const res = await fetch(this.url, {
|
|
54
|
+
method: 'POST',
|
|
55
|
+
headers: {
|
|
56
|
+
'Content-Type': 'application/json',
|
|
57
|
+
...(this.authHeader ? { Authorization: this.authHeader } : {})
|
|
58
|
+
},
|
|
59
|
+
body: JSON.stringify(body)
|
|
60
|
+
});
|
|
61
|
+
if (!res.ok) {
|
|
62
|
+
const text = await safeText(res);
|
|
63
|
+
const err = new Error(text || `${res.status} ${res.statusText}`);
|
|
64
|
+
err.code = res.status;
|
|
65
|
+
err.rpc = true;
|
|
66
|
+
throw err;
|
|
67
|
+
}
|
|
68
|
+
const payload = await res.json();
|
|
69
|
+
if (payload.error) {
|
|
70
|
+
const err = new Error(payload.error.message);
|
|
71
|
+
err.code = payload.error.code;
|
|
72
|
+
err.rpc = true;
|
|
73
|
+
throw err;
|
|
74
|
+
}
|
|
75
|
+
return payload.result;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=json-rpc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-rpc.js","sourceRoot":"","sources":["../../../../src/client/rpc/json-rpc.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,OAAO,gBAAgB;IACnB,GAAG,CAAS;IACZ,UAAU,CAAU;IACpB,EAAE,GAAG,CAAC,CAAC;IAEf,YAAY,GAAoB;QAC9B,IAAI,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,uBAAuB,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAErE,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;YACjC,IAAI,CAAC,UAAU,GAAG,SAAS,QAAQ,CAAC,GAAG,GAAG,CAAC,QAAQ,IAA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;QACZ,CAAC;QACD,OAAO,OAAO,CAAC,MAAM,CAAC;IACxB,CAAC;CACF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encode a string to base64
|
|
3
|
+
* @param {string} s The string to encode
|
|
4
|
+
* @returns {string} The base64 encoded string
|
|
5
|
+
*/
|
|
6
|
+
export function toBase64(s) {
|
|
7
|
+
// Node >= 18 and browser-safe
|
|
8
|
+
if (typeof Buffer !== 'undefined')
|
|
9
|
+
return Buffer.from(s, 'utf8').toString('base64');
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
if (typeof btoa !== 'undefined')
|
|
12
|
+
return btoa(s);
|
|
13
|
+
throw new Error('No base64 encoder available');
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Safely get text from a Response object
|
|
17
|
+
* @param {Response} res The Response object
|
|
18
|
+
* @returns {Promise<string>} The text content or empty string on failure
|
|
19
|
+
*/
|
|
20
|
+
export async function safeText(res) {
|
|
21
|
+
try {
|
|
22
|
+
return await res.text();
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return '';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/client/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,CAAS;IAChC,8BAA8B;IAC9B,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACpF,aAAa;IACb,IAAI,OAAO,IAAI,KAAK,WAAW;QAAE,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;IAChD,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;AACjD,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,GAAa;IAC1C,IAAI,CAAC;QAAC,OAAO,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC;QAAC,OAAO,EAAE,CAAC;IAAC,CAAC;AACvD,CAAC"}
|
package/dist/esm/constants.js
CHANGED
|
@@ -1,20 +1,41 @@
|
|
|
1
1
|
export const INITIAL_BLOCK_REWARD = 50;
|
|
2
2
|
export const HALVING_INTERVAL = 150;
|
|
3
3
|
export const COINBASE_MATURITY_DELAY = 100;
|
|
4
|
-
export const DEFAULT_RPC_CLIENT_CONFIG = {
|
|
5
|
-
network: 'regtest',
|
|
6
|
-
host: 'http://localhost:18443',
|
|
7
|
-
port: 18443,
|
|
8
|
-
username: 'polaruser',
|
|
9
|
-
password: 'polarpass',
|
|
10
|
-
allowDefaultWallet: true,
|
|
11
|
-
version: '28.1.0',
|
|
12
|
-
};
|
|
13
|
-
export const DEFAULT_REST_CLIENT_CONFIG = {
|
|
14
|
-
network: 'regtest',
|
|
15
|
-
host: 'http://localhost:3000'
|
|
16
|
-
};
|
|
17
4
|
export const DEFAULT_BLOCK_CONFIRMATIONS = 7;
|
|
18
5
|
export const TXIN_WITNESS_COINBASE = '0000000000000000000000000000000000000000000000000000000000000000';
|
|
19
6
|
export const GENESIS_TX_ID = '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b';
|
|
7
|
+
export const DEFAULT_BITCOIN_NETWORK_CONFIG = {
|
|
8
|
+
mainnet: {
|
|
9
|
+
rpc: undefined,
|
|
10
|
+
rest: { host: 'https://mempool.space/api' }
|
|
11
|
+
},
|
|
12
|
+
testnet3: {
|
|
13
|
+
rpc: undefined,
|
|
14
|
+
rest: { host: 'https://mempool.space/testnet/api' }
|
|
15
|
+
},
|
|
16
|
+
testnet4: {
|
|
17
|
+
rpc: undefined,
|
|
18
|
+
rest: { host: 'https://mempool.space/testnet4/api' }
|
|
19
|
+
},
|
|
20
|
+
signet: {
|
|
21
|
+
rpc: undefined,
|
|
22
|
+
rest: { host: 'https://mempool.space/signet/api' }
|
|
23
|
+
},
|
|
24
|
+
mutinynet: {
|
|
25
|
+
rpc: undefined,
|
|
26
|
+
rest: { host: 'https://mutinynet.com/api' }
|
|
27
|
+
},
|
|
28
|
+
regtest: {
|
|
29
|
+
rpc: {
|
|
30
|
+
network: 'regtest',
|
|
31
|
+
host: 'http://localhost:18443',
|
|
32
|
+
port: 18443,
|
|
33
|
+
username: 'polaruser',
|
|
34
|
+
password: 'polarpass',
|
|
35
|
+
allowDefaultWallet: true,
|
|
36
|
+
version: '28.1.0',
|
|
37
|
+
},
|
|
38
|
+
rest: { host: 'http://localhost:3000' }
|
|
39
|
+
},
|
|
40
|
+
};
|
|
20
41
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AACvC,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AACpC,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AACvC,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AACpC,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAC7C,MAAM,CAAC,MAAM,qBAAqB,GAAG,kEAAkE,CAAC;AACxG,MAAM,CAAC,MAAM,aAAa,GAAG,kEAAkE,CAAC;AAChG,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,OAAO,EAAG;QACR,GAAG,EAAI,SAAS;QAChB,IAAI,EAAG,EAAE,IAAI,EAAE,2BAA2B,EAAE;KAC7C;IACD,QAAQ,EAAG;QACT,GAAG,EAAI,SAAS;QAChB,IAAI,EAAG,EAAE,IAAI,EAAE,mCAAmC,EAAE;KACrD;IACD,QAAQ,EAAG;QACT,GAAG,EAAI,SAAS;QAChB,IAAI,EAAG,EAAE,IAAI,EAAE,oCAAoC,EAAE;KACtD;IACD,MAAM,EAAI;QACR,GAAG,EAAI,SAAS;QAChB,IAAI,EAAG,EAAE,IAAI,EAAE,kCAAkC,EAAE;KACpD;IACD,SAAS,EAAG;QACV,GAAG,EAAI,SAAS;QAChB,IAAI,EAAG,EAAE,IAAI,EAAE,2BAA2B,EAAE;KAC7C;IACD,OAAO,EAAG;QACR,GAAG,EAAI;YACL,OAAO,EAAc,SAAS;YAC9B,IAAI,EAAiB,wBAAwB;YAC7C,IAAI,EAAiB,KAAK;YAC1B,QAAQ,EAAa,WAAW;YAChC,QAAQ,EAAa,WAAW;YAChC,kBAAkB,EAAG,IAAI;YACzB,OAAO,EAAc,QAAQ;SAC9B;QACD,IAAI,EAAG,EAAE,IAAI,EAAE,uBAAuB,EAAE;KACzC;CACO,CAAC"}
|
package/dist/esm/errors.js
CHANGED
|
@@ -11,4 +11,12 @@ export class BitcoinRpcError extends Error {
|
|
|
11
11
|
this.name = 'BitcoinRpcError';
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
+
export class BitcoinRestError extends Error {
|
|
15
|
+
data;
|
|
16
|
+
constructor(message, data) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.data = data;
|
|
19
|
+
this.name = 'BitcoinRestError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
14
22
|
//# sourceMappingURL=errors.js.map
|
package/dist/esm/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxB,IAAI,CAAkB;IACtB,IAAI,CAAO;IAC3B,YAAY,IAAqB,EAAE,OAAe,EAAE,IAAU;QAC5D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF"}
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxB,IAAI,CAAkB;IACtB,IAAI,CAAO;IAC3B,YAAY,IAAqB,EAAE,OAAe,EAAE,IAAU;QAC5D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzB,IAAI,CAAO;IAC3B,YAAY,OAAe,EAAE,IAAU;QACrC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './bitcoin.js';
|
|
2
|
+
export * from './client/rest/address.js';
|
|
3
|
+
export * from './client/rest/block.js';
|
|
4
|
+
export * from './client/rest/index.js';
|
|
5
|
+
export * from './client/rest/transaction.js';
|
|
6
|
+
export * from './client/rpc/index.js';
|
|
7
|
+
export * from './client/rpc/interface.js';
|
|
8
|
+
export * from './client/rpc/json-rpc.js';
|
|
9
|
+
export * from './client/utils.js';
|
|
10
|
+
export * from './constants.js';
|
|
11
|
+
export * from './errors.js';
|
|
12
|
+
export * from './network.js';
|
|
13
|
+
export * from './taproot.js';
|
|
14
|
+
export * from './types.js';
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
package/dist/esm/types.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export class
|
|
1
|
+
export class BitcoinRpcClientConfig {
|
|
2
2
|
network;
|
|
3
3
|
headers;
|
|
4
4
|
host;
|
|
@@ -31,7 +31,7 @@ export class RpcClientConfig {
|
|
|
31
31
|
this.allowDefaultWallet = options.allowDefaultWallet;
|
|
32
32
|
}
|
|
33
33
|
static initialize(options) {
|
|
34
|
-
return new
|
|
34
|
+
return new BitcoinRpcClientConfig(options);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
;
|
package/dist/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AA6CA,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AA6CA,MAAM,OAAO,sBAAsB;IACjC,OAAO,CAAU;IACjB,OAAO,CAA0B;IACjC,IAAI,CAAU;IAC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