@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.
Files changed (104) hide show
  1. package/dist/cjs/bitcoin.js +83 -84
  2. package/dist/cjs/bitcoin.js.map +1 -1
  3. package/dist/cjs/client/http.js +9 -0
  4. package/dist/cjs/client/http.js.map +1 -0
  5. package/dist/cjs/client/rest/address.js +20 -28
  6. package/dist/cjs/client/rest/address.js.map +1 -1
  7. package/dist/cjs/client/rest/block.js +23 -22
  8. package/dist/cjs/client/rest/block.js.map +1 -1
  9. package/dist/cjs/client/rest/index.js +31 -84
  10. package/dist/cjs/client/rest/index.js.map +1 -1
  11. package/dist/cjs/client/rest/protocol.js +129 -0
  12. package/dist/cjs/client/rest/protocol.js.map +1 -0
  13. package/dist/cjs/client/rest/transaction.js +19 -21
  14. package/dist/cjs/client/rest/transaction.js.map +1 -1
  15. package/dist/cjs/client/rpc/index.js +75 -337
  16. package/dist/cjs/client/rpc/index.js.map +1 -1
  17. package/dist/cjs/client/rpc/interface.js +1 -6
  18. package/dist/cjs/client/rpc/interface.js.map +1 -1
  19. package/dist/cjs/client/rpc/json-rpc.js +40 -63
  20. package/dist/cjs/client/rpc/json-rpc.js.map +1 -1
  21. package/dist/cjs/client/rpc/protocol.js +134 -0
  22. package/dist/cjs/client/rpc/protocol.js.map +1 -0
  23. package/dist/cjs/constants.js +16 -5
  24. package/dist/cjs/constants.js.map +1 -1
  25. package/dist/cjs/errors.js.map +1 -1
  26. package/dist/cjs/index.js +21 -13
  27. package/dist/cjs/index.js.map +1 -1
  28. package/dist/cjs/types.js +5 -55
  29. package/dist/cjs/types.js.map +1 -1
  30. package/dist/esm/bitcoin.js +83 -84
  31. package/dist/esm/bitcoin.js.map +1 -1
  32. package/dist/esm/client/http.js +9 -0
  33. package/dist/esm/client/http.js.map +1 -0
  34. package/dist/esm/client/rest/address.js +20 -28
  35. package/dist/esm/client/rest/address.js.map +1 -1
  36. package/dist/esm/client/rest/block.js +23 -22
  37. package/dist/esm/client/rest/block.js.map +1 -1
  38. package/dist/esm/client/rest/index.js +31 -84
  39. package/dist/esm/client/rest/index.js.map +1 -1
  40. package/dist/esm/client/rest/protocol.js +129 -0
  41. package/dist/esm/client/rest/protocol.js.map +1 -0
  42. package/dist/esm/client/rest/transaction.js +19 -21
  43. package/dist/esm/client/rest/transaction.js.map +1 -1
  44. package/dist/esm/client/rpc/index.js +75 -337
  45. package/dist/esm/client/rpc/index.js.map +1 -1
  46. package/dist/esm/client/rpc/interface.js +1 -6
  47. package/dist/esm/client/rpc/interface.js.map +1 -1
  48. package/dist/esm/client/rpc/json-rpc.js +40 -63
  49. package/dist/esm/client/rpc/json-rpc.js.map +1 -1
  50. package/dist/esm/client/rpc/protocol.js +134 -0
  51. package/dist/esm/client/rpc/protocol.js.map +1 -0
  52. package/dist/esm/constants.js +16 -5
  53. package/dist/esm/constants.js.map +1 -1
  54. package/dist/esm/errors.js.map +1 -1
  55. package/dist/esm/index.js +21 -13
  56. package/dist/esm/index.js.map +1 -1
  57. package/dist/esm/types.js +5 -55
  58. package/dist/esm/types.js.map +1 -1
  59. package/dist/types/bitcoin.d.ts +66 -45
  60. package/dist/types/bitcoin.d.ts.map +1 -1
  61. package/dist/types/client/http.d.ts +21 -0
  62. package/dist/types/client/http.d.ts.map +1 -0
  63. package/dist/types/client/rest/address.d.ts +16 -19
  64. package/dist/types/client/rest/address.d.ts.map +1 -1
  65. package/dist/types/client/rest/block.d.ts +24 -16
  66. package/dist/types/client/rest/block.d.ts.map +1 -1
  67. package/dist/types/client/rest/index.d.ts +20 -51
  68. package/dist/types/client/rest/index.d.ts.map +1 -1
  69. package/dist/types/client/rest/protocol.d.ts +58 -0
  70. package/dist/types/client/rest/protocol.d.ts.map +1 -0
  71. package/dist/types/client/rest/transaction.d.ts +16 -17
  72. package/dist/types/client/rest/transaction.d.ts.map +1 -1
  73. package/dist/types/client/rpc/index.d.ts +105 -253
  74. package/dist/types/client/rpc/index.d.ts.map +1 -1
  75. package/dist/types/client/rpc/interface.d.ts +1 -4
  76. package/dist/types/client/rpc/interface.d.ts.map +1 -1
  77. package/dist/types/client/rpc/json-rpc.d.ts +20 -18
  78. package/dist/types/client/rpc/json-rpc.d.ts.map +1 -1
  79. package/dist/types/client/rpc/protocol.d.ts +82 -0
  80. package/dist/types/client/rpc/protocol.d.ts.map +1 -0
  81. package/dist/types/constants.d.ts +16 -5
  82. package/dist/types/constants.d.ts.map +1 -1
  83. package/dist/types/errors.d.ts +4 -3
  84. package/dist/types/errors.d.ts.map +1 -1
  85. package/dist/types/index.d.ts +20 -13
  86. package/dist/types/index.d.ts.map +1 -1
  87. package/dist/types/types.d.ts +98 -696
  88. package/dist/types/types.d.ts.map +1 -1
  89. package/package.json +3 -3
  90. package/src/bitcoin.ts +105 -118
  91. package/src/client/http.ts +28 -0
  92. package/src/client/rest/address.ts +24 -30
  93. package/src/client/rest/block.ts +29 -26
  94. package/src/client/rest/index.ts +38 -94
  95. package/src/client/rest/protocol.ts +153 -0
  96. package/src/client/rest/transaction.ts +23 -23
  97. package/src/client/rpc/index.ts +140 -379
  98. package/src/client/rpc/interface.ts +42 -51
  99. package/src/client/rpc/json-rpc.ts +53 -60
  100. package/src/client/rpc/protocol.ts +160 -0
  101. package/src/constants.ts +17 -5
  102. package/src/errors.ts +10 -3
  103. package/src/index.ts +81 -13
  104. package/src/types.ts +332 -972
@@ -1,433 +1,171 @@
1
1
  import { JSONUtils } from '@did-btcr2/common';
2
- import { DEFAULT_BITCOIN_NETWORK_CONFIG } from '../../constants.js';
3
2
  import { BitcoinRpcError } from '../../errors.js';
4
- import { BitcoinRpcClientConfig } from '../../types.js';
5
3
  import { JsonRpcTransport } from './json-rpc.js';
4
+ // ── Client ──────────────────────────────────────────────────────────
6
5
  /**
7
- * Class representing a Bitcoin Core RPC client.
8
- * @class BitcoinCoreRpcClient
9
- * @type {BitcoinCoreRpcClient}
6
+ * Bitcoin Core RPC client.
10
7
  * @implements {BitcoinRpcClient}
11
8
  */
12
9
  export class BitcoinCoreRpcClient {
13
- /**
14
- * The singleton instance of the BitcoinCoreRpcClient.
15
- * @type {BitcoinCoreRpcClient}
16
- * @private
17
- */
18
- static #instance;
19
- /**
20
- * The JSON-RPC transport layer.
21
- * @type {JsonRpcTransport}
22
- * @private
23
- */
24
10
  #transport;
25
- /**
26
- * The configuration for the RPC client.
27
- * @type {RpcClientConfig}
28
- * @private
29
- */
30
11
  #config;
31
- /**
32
- * Constructs a new {@link BitcoinCoreRpcClient} instance from a new {@link RpcClient | RpcClient}.
33
- * @param {RpcClientConfig} config The bitcoin-core client instance.
34
- * @example
35
- * ```
36
- * import BitcoinRpcClient from '@did-btcr2/method';
37
- * const bob = BitcoinRpcClient.connect(); // To use default polar config, pass no args. Polar must run locally.
38
- * ```
39
- */
40
- constructor(config) {
41
- this.#config = new BitcoinRpcClientConfig(config);
42
- this.#transport = new JsonRpcTransport(this.#config);
12
+ constructor(config, executor) {
13
+ this.#config = config;
14
+ this.#transport = new JsonRpcTransport(config, executor);
43
15
  }
44
- /**
45
- * Get the config for the current BitcoinRpcClient object.
46
- * @returns {BitcoinRpcClient} The encapsulated {@link BitcoinRpcClient} object.
47
- * @example
48
- * ```
49
- * import BitcoinRpcClient from '@did-btcr2/method';
50
- * const alice = BitcoinRpcClient.connect();
51
- * const config = alice.config;
52
- * ```
53
- */
54
16
  get config() {
55
- const config = this.#config;
56
- return config;
17
+ return this.#config;
57
18
  }
58
- /**
59
- * Get the client for the current BitcoinRpcClient object.
60
- * @returns {RpcClient} The encapsulated {@link RpcClient} object.
61
- * @example
62
- * ```
63
- * const alice = BitcoinRpcClient.connect();
64
- * const config = alice.client;
65
- * ```
66
- */
67
19
  get client() {
68
- const client = this.#transport;
69
- return client;
70
- }
71
- /**
72
- * Static method initializes a static instance of BitcoinCoreRpcClient with the given configuration.
73
- * The RpcClient returned by this method does not have any named methods.
74
- * Use this method to create and pass a new RpcClient instance to a BitcoinCoreRpcClient constructor.
75
- *
76
- * @param {RpcClientConfig} config The configuration object for the client (optional).
77
- * @returns {BitcoinCoreRpcClient} A new RpcClient instance.
78
- * @example
79
- * ```
80
- * const options: RpcClientConfig = {
81
- * host: 'http://localhost:18443',
82
- * username: 'alice',
83
- * password: 'alicepass',
84
- * version: '28.1.0',
85
- * }
86
- * const alice = BitcoinCoreRpcClient.initialize(options); // Client config required
87
- * ```
88
- */
89
- static initialize(config) {
90
- const cfg = new BitcoinRpcClientConfig(config);
91
- BitcoinCoreRpcClient.#instance = new BitcoinCoreRpcClient(cfg);
92
- return BitcoinCoreRpcClient.#instance;
20
+ return this.#transport;
93
21
  }
94
22
  /**
95
- * Static method connects to a bitcoin node running the bitcoin core daemon (bitcoind).
96
- * To use default polar config, do not pass a config. See {@link DEFAULT_BITCOIN_NETWORK_CONFIG} for default config.
97
- * @required A locally running {@link https://github.com/jamaljsr/polar | Polar Lightning} regtest node.
98
- *
99
- * @param {?RpcClientConfig} config The configuration object for the client (optional).
100
- * @returns A new {@link BitcoinRpcClient} instance.
101
- * @example
102
- * ```
103
- * const alice = BitcoinRpcClient.connect();
104
- * ```
105
- */
106
- static connect(config) {
107
- return new BitcoinCoreRpcClient(config ?? DEFAULT_BITCOIN_NETWORK_CONFIG.regtest.rpc);
108
- }
109
- /**
110
- * Check if the given error is a JSON-RPC error.
111
- * @param {unknown} e The error to check.
112
- * @returns {boolean} True if the error is a JSON-RPC error, false otherwise.
113
- */
114
- isJsonRpcError(e) {
115
- return (e instanceof Error &&
116
- e.name === 'RpcError' &&
117
- typeof e.code === 'number');
118
- }
119
- /**
120
- * Executes a JSON-RPC command on the bitcoind node.
121
- * @param {MethodNameInLowerCase} method The name of the method to call.
122
- * @param {Array<any>} parameters The parameters to pass to the method.
123
- * @returns {Promise<T>} A promise resolving to the result of the command.
23
+ * Executes a typed JSON-RPC command on the bitcoind node.
124
24
  */
125
25
  async executeRpc(method, parameters = []) {
126
26
  try {
127
- const raw = await this.client.command([{ method, parameters }]);
27
+ const raw = await this.#transport.call(method, parameters);
128
28
  const normalized = JSONUtils.isUnprototyped(raw) ? JSONUtils.normalize(raw) : raw;
129
- const result = Array.isArray(normalized)
130
- ? normalized[normalized.length - 1]
131
- : normalized;
132
- return result;
29
+ return normalized;
133
30
  }
134
31
  catch (err) {
135
- this.handleError(err, method, parameters);
136
- }
137
- }
138
- /**
139
- *
140
- * Map JSON-RPC error codes to HTTP status codes.
141
- * @param {number | undefined} code The JSON-RPC error code.
142
- * @returns {number} The corresponding HTTP status code.
143
- *
144
- * | Error type | HTTP code |
145
- * | -------------------------------| --------------------|
146
- * | Valid JSON-RPC failure | **400 / 404 / 422** |
147
- * | JSON-RPC authentication issues | **401 / 403** |
148
- * | Upstream bitcoind unreachable | **502** |
149
- * | Upstream timeout | **504** |
150
- * | Network transient errors | **503** |
151
- * | Unknown unexpected errors | **500** |
152
- */
153
- mapRpcCodeToHttp(code) {
154
- switch (code) {
155
- case -32700:
156
- case -32600:
157
- case -32602:
158
- return 400;
159
- case -32601:
160
- return 404;
161
- default:
162
- return 422;
163
- }
164
- }
165
- /**
166
- * Handle errors that occur while executing commands.
167
- * @param methods An array of {@link BatchOption} objects.
168
- * @param error The error that was thrown.
169
- * @throws Throws a {@link BitcoinRpcError} with the error message.
170
- */
171
- handleError(err, method, params) {
172
- if (this.isJsonRpcError(err)) {
173
- throw new BitcoinRpcError(err.name.toUpperCase(), this.mapRpcCodeToHttp(err.code), `RPC ${method} failed: ${err.message}`, { method, params });
32
+ if (err instanceof BitcoinRpcError)
33
+ throw err;
34
+ const cause = err instanceof Error ? err.message : String(err);
35
+ throw new BitcoinRpcError('UNKNOWN_ERROR', 500, `Unknown failure in ${method}: ${cause}`, { method });
174
36
  }
175
- throw new BitcoinRpcError('UNKNOWN_ERROR', 500, `Unknown failure in ${method}`, { method, params, err });
176
37
  }
177
38
  /**
178
39
  * Returns the block data associated with a `blockhash` of a valid block.
179
- * @param {GetBlockParams} params See {@link GetBlockParams} for details.
180
- * @param {?string} params.blockhash The blockhash of the block to query.
181
- * @param {?number} params.height The block height of the block to query.
182
- * @param {?VerbosityLevel} params.verbosity The verbosity level. See {@link VerbosityLevel}.
183
- * @returns {BlockResponse} A promise resolving to a {@link BlockResponse} formatted depending on `verbosity` level.
184
- * @throws {BitcoinRpcError} If neither `blockhash` nor `height` is provided.
185
40
  */
186
41
  async getBlock({ blockhash, height, verbosity }) {
187
- // Check if blockhash or height is provided, if neither throw an error
188
42
  if (!blockhash && height === undefined) {
189
43
  throw new BitcoinRpcError('INVALID_PARAMS_GET_BLOCK', 400, 'blockhash or height required', { blockhash, height });
190
44
  }
191
- // If height is provided, get the blockhash
192
45
  blockhash ??= await this.getBlockHash(height);
193
46
  if (!blockhash || typeof blockhash !== 'string') {
194
47
  return undefined;
195
48
  }
196
- // Get the block data
197
49
  const block = await this.executeRpc('getblock', [blockhash, verbosity ?? 3]);
198
- // Return the block data depending on verbosity level
199
50
  switch (verbosity) {
200
- case 0:
201
- return block;
202
- case 1:
203
- return block;
204
- case 2:
205
- return block;
206
- case 3:
207
- return block;
208
- default:
209
- return block;
51
+ case 0: return block;
52
+ case 1: return block;
53
+ case 2: return block;
54
+ case 3: return block;
55
+ default: return block;
210
56
  }
211
57
  }
212
- /**
213
- * Returns the blockheight of the most-work fully-validated chain. The genesis block has height 0.
214
- * @returns {Blockheight} The number of the blockheight with the most-work of the fully-validated chain.
215
- */
58
+ /** Returns the blockheight of the most-work fully-validated chain. */
216
59
  async getBlockCount() {
217
60
  return await this.executeRpc('getblockcount');
218
61
  }
219
- /**
220
- * Returns the blockhash of the block at the given height in the active chain.
221
- */
62
+ /** Returns the blockhash of the block at the given height. */
222
63
  async getBlockHash(height) {
223
64
  return await this.executeRpc('getblockhash', [height]);
224
65
  }
225
- /**
226
- * Returns an object containing various blockchain state info.
227
- */
66
+ /** Returns various blockchain state info. */
228
67
  async getBlockchainInfo() {
229
- return this.executeRpc('getblockchaininfo');
68
+ return await this.executeRpc('getblockchaininfo');
230
69
  }
231
- /**
232
- * Sign inputs for raw transaction (serialized, hex-encoded).
233
- * The second optional argument (may be null) is an array of previous transaction outputs that
234
- * this transaction depends on but may not yet be in the block chain.
235
- * Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.
236
- * @param {string} hexstring The hex-encoded transaction to send.
237
- */
70
+ /** Sign inputs for raw transaction (serialized, hex-encoded). */
238
71
  async signRawTransaction(hexstring) {
239
72
  return await this.executeRpc('signrawtransactionwithwallet', [hexstring]);
240
73
  }
241
- /**
242
- * Submit a raw transaction (serialized, hex-encoded) to local node and network.
243
- *
244
- * The transaction will be sent unconditionally to all peers, so using sendrawtransaction
245
- * for manual rebroadcast may degrade privacy by leaking the transaction's origin, as
246
- * nodes will normally not rebroadcast non-wallet transactions already in their mempool.
247
- *
248
- * @param {string} hexstring The hex-encoded transaction to send.
249
- * @param {numbner} [maxfeerate] If not passed, default is 0.10.
250
- * @returns {Promise<string>} A promise resolving to the transaction hash in hex.
251
- */
74
+ /** Submit a raw transaction (serialized, hex-encoded) to local node and network. */
252
75
  async sendRawTransaction(hexstring, maxfeerate, maxBurnAmount) {
253
76
  return await this.executeRpc('sendrawtransaction', [hexstring, maxfeerate ?? 0.10, maxBurnAmount ?? 0.00]);
254
77
  }
255
- /**
256
- * Combines calls to `signRawTransaction` and `sendRawTransaction`.
257
- * @param {string} params.hexstring The hex-encoded transaction to send.
258
- * @returns {Promise<string>} A promise resolving to the transaction hash in hex.
259
- */
78
+ /** Signs and sends a raw transaction. */
260
79
  async signAndSendRawTransaction(hexstring) {
261
80
  const signedRawTx = await this.signRawTransaction(hexstring);
81
+ if (!signedRawTx.complete) {
82
+ throw new BitcoinRpcError('SIGNING_INCOMPLETE', 400, 'Transaction signing incomplete', signedRawTx.errors);
83
+ }
262
84
  return await this.sendRawTransaction(signedRawTx.hex);
263
85
  }
264
- /**
265
- * Combines calls to `createRawTransaction`, `signRawTransaction` and `sendRawTransaction`.
266
- * @param {CreateRawTxInputs[]} inputs The inputs to the transaction (required).
267
- * @param {CreateRawTxOutputs[]} outputs The outputs of the transaction (required).
268
- * @returns {Promise<string>} A promise resolving to the transaction hash in hex.
269
- */
86
+ /** Creates, signs, and sends a raw transaction. */
270
87
  async createSignSendRawTransaction(inputs, outputs) {
271
88
  const rawTx = await this.createRawTransaction(inputs, outputs);
272
89
  const signedRawTx = await this.signRawTransaction(rawTx);
273
- const sentRawTx = await this.sendRawTransaction(signedRawTx.hex);
274
- return sentRawTx;
90
+ if (!signedRawTx.complete) {
91
+ throw new BitcoinRpcError('SIGNING_INCOMPLETE', 400, 'Transaction signing incomplete', signedRawTx.errors);
92
+ }
93
+ return await this.sendRawTransaction(signedRawTx.hex);
275
94
  }
276
- /**
277
- * Returns up to 'count' most recent transactions skipping the first 'from' transactions for account 'label'.
278
- * @param {ListTransactionsParams} params The parameters for the listTransactions command.
279
- * @returns {Promise<ListTransactionsResult>} A promise resolving to a {@link ListTransactionsResult} object.
280
- */
95
+ /** Returns up to 'count' most recent transactions. */
281
96
  async listTransactions(params) {
282
- return await this.executeRpc('listtransactions', [params]);
283
- }
284
- /**
285
- * Create a transaction spending the given inputs and creating new outputs.
286
- * Outputs can be addresses or data.
287
- * Returns hex-encoded raw transaction.
288
- * Note that the transaction's inputs are not signed, and
289
- * it is not stored in the wallet or transmitted to the network.
290
- * @param {TxInForCreateRaw[]} inputs The inputs to the transaction (required).
291
- * @param {CreateRawTxOutputs[]} outputs The outputs of the transaction (required).
292
- * @param {number} [locktime] The locktime of the transaction (optional).
293
- * @param {boolean} [replacable] Whether the transaction is replaceable (optional).
294
- * @returns {string} The hex-encoded raw transaction.
295
- */
97
+ return await this.executeRpc('listtransactions', [
98
+ params.account ?? '*',
99
+ params.count ?? 10,
100
+ params.skip ?? 0,
101
+ params.include_watchonly ?? false,
102
+ ]);
103
+ }
104
+ /** Create a transaction spending the given inputs and creating new outputs. */
296
105
  async createRawTransaction(inputs, outputs, locktime, replacable) {
297
106
  return await this.executeRpc('createrawtransaction', [inputs, outputs, locktime, replacable]);
298
107
  }
299
- /**
300
- * Derives one or more addresses corresponding to an output descriptor.
301
- * Examples of output descriptors are:
302
- * pkh(<pubkey>) P2PKH outputs for the given pubkey
303
- * wpkh(<pubkey>) Native segwit P2PKH outputs for the given pubkey
304
- * sh(multi(<n>,<pubkey>,<pubkey>,...)) P2SH-multisig outputs for the given threshold and pubkeys
305
- * raw(<hex script>) Outputs whose output script equals the specified hex-encoded bytes
306
- * tr(<pubkey>,multi_a(<n>,<pubkey>,<pubkey>,...)) P2TR-multisig outputs for the given threshold and pubkeys
307
- *
308
- * In the above, <pubkey> either refers to a fixed public key in hexadecimal notation, or to an xpub/xprv optionally followed by one
309
- * or more path elements separated by "/", where "h" represents a hardened child key.
310
- *
311
- * See {@link https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md | github.com/bitcoin/bitcoin/descriptors.md}
312
- * for more information.
313
- * @param {string} descriptor The descriptor.
314
- * @param {Array<number>} range If descriptor is ranged, must specify end or [begin,end] to derive.
315
- * @returns {Array<DerivedAddresses>} a list of derived addresses
316
- * @example First three native segwit receive addresses
317
- * ```
318
- * const bitcoind = BitcoinRpcClient.connect()
319
- * const addresses = bitcoind.deriveAddresses("wpkh([d34db33f/84h/0h/0h]xpub6DJ2dN.../0/*)#cjjspncu", [0,2])
320
- * ```
321
- */
108
+ /** Derives one or more addresses corresponding to an output descriptor. */
322
109
  async deriveAddresses(descriptor, range) {
323
110
  return await this.executeRpc('deriveaddresses', [descriptor, range]);
324
111
  }
325
- /**
326
- * Returns the total available balance. The available balance is what the wallet
327
- * considers currently spendable, and is thus affected by options which limit
328
- * spendability such as -spendzeroconfchange.
329
- * @returns {Promise<number>} A promise resolving to the total available balance in BTC.
330
- */
112
+ /** Returns the total available balance. */
331
113
  async getBalance() {
332
114
  return await this.executeRpc('getbalance');
333
115
  }
334
- /**
335
- * Returns a new Bitcoin address for receiving payments. If 'label' is specified,
336
- * it is added to the address book so payments received with the address will be associated with 'label'.
337
- * The 'address_type' can be one of "legacy", "p2sh-segwit", "bech32", or "bech32m".
338
- * @param {string} addressType The address type to use (required, options=["legacy", "p2sh-segwit", "bech32", "bech32m"], default="bech32").
339
- * @param {string} [label] The label to associate with the new address (optional).
340
- * @returns {Promise<string>} A promise resolving to the new address.
341
- */
116
+ /** Returns a new Bitcoin address for receiving payments. */
342
117
  async getNewAddress(addressType, label) {
343
118
  return await this.executeRpc('getnewaddress', [label ?? '', addressType]);
344
119
  }
345
- /**
346
- * Returns array of unspent transaction outputs with between minconf and maxconf (inclusive) confirmations.
347
- * Optionally filter to only include txouts paid to specified addresses.
348
- * @param {Object} params The parameters for the listUnspent command.
349
- * @param {number} [params.minconf=0] The minimum number of confirmations an output must have to be included.
350
- * @param {number} [params.maxconf=9999999] The maximum number of confirmations an output can have to be included.
351
- * @param {string[]} [params.address] Only include outputs paid to these addresses.
352
- * @param {boolean} [params.include_unsafe=true] Whether to include outputs that are not safe to spend.
353
- * @returns {Promise<UnspentTxInfo[]>} A promise resolving to an array of {@link UnspentTxInfo} objects.
354
- */
120
+ /** Returns array of unspent transaction outputs. */
355
121
  async listUnspent(params) {
356
- const args = { minconf: 0, maxconf: 9999999, include_unsafe: true, ...params };
357
- return await this.executeRpc('listunspent', [args]);
358
- }
359
- /**
360
- * Send an amount to a given address.
361
- * @param {string} address The address to send to.
362
- * @param {number} amount The amount to send in BTC.
363
- * @returns {Promise<SendToAddressResult>} A promise resolving to the transaction id.
364
- */
122
+ return await this.executeRpc('listunspent', [
123
+ params.minconf ?? 0,
124
+ params.maxconf ?? 9999999,
125
+ params.address ?? [],
126
+ params.include_unsafe ?? true,
127
+ ]);
128
+ }
129
+ /** Send an amount to a given address. */
365
130
  async sendToAddress(address, amount) {
366
131
  const txid = await this.executeRpc('sendtoaddress', [address, amount]);
367
132
  return await this.getRawTransaction(txid);
368
133
  }
369
- /**
370
- * Sign a message with the private key of an address.
371
- * @param {string} address The address to sign the message with.
372
- * @param {string} message The message to sign.
373
- * @returns {Promise<string>} A promise resolving to the signature in base64.
374
- */
134
+ /** Sign a message with the private key of an address. */
375
135
  async signMessage(address, message) {
376
136
  return await this.executeRpc('signmessage', [address, message]);
377
137
  }
378
- /**
379
- * Verify a signed message.
380
- * @param {string} address The address to verify the message with.
381
- * @param {string} signature The signature to verify in base64.
382
- * @param {string} message The message to verify.
383
- * @returns {Promise<boolean>} A promise resolving to true if the signature is valid, false otherwise.
384
- */
138
+ /** Verify a signed message. */
385
139
  async verifyMessage(address, signature, message) {
386
140
  return await this.executeRpc('verifymessage', [address, signature, message]);
387
141
  }
388
- /**
389
- * Get detailed information about in-wallet transaction <txid>.
390
- * @param txid: The transaction id. (string, required)
391
- * @param {boolean} include_watchonly Whether to include watch-only addresses in balance calculation and details.
392
- * @returns {WalletTransaction} A promise resolving to a {@link WalletTransaction} object.
393
- */
142
+ /** Get detailed information about in-wallet transaction. */
394
143
  async getTransaction(txid, include_watchonly) {
395
144
  return await this.executeRpc('gettransaction', [txid, include_watchonly]);
396
145
  }
397
- /**
398
- * Get detailed information about a transaction.
399
- * By default, this call only returns a transaction if it is in the mempool. If -txindex is enabled
400
- * and no blockhash argument is passed, it will return the transaction if it is in the mempool or any block.
401
- * If a blockhash argument is passed, it will return the transaction if the specified block is available and
402
- * the transaction is in that block.
403
- * @param {string} txid The transaction id (required).
404
- * @param {?VerbosityLevel} verbosity Response format: 0 (hex), 1 (json) or 2 (jsonext).
405
- * @param {?string} blockhash The block in which to look for the transaction (optional).
406
- * @returns {GetRawTransaction} A promise resolving to data about a transaction in the form specified by verbosity.
407
- */
146
+ /** Get detailed information about a transaction. */
408
147
  async getRawTransaction(txid, verbosity, blockhash) {
409
- // Get the raw transaction
410
148
  const rawTransaction = await this.executeRpc('getrawtransaction', [txid, verbosity ?? 2, blockhash]);
411
- // Return the raw transaction based on verbosity
412
149
  switch (verbosity) {
413
- case 0:
414
- return rawTransaction;
415
- case 1:
416
- return rawTransaction;
417
- case 2:
418
- return rawTransaction;
419
- default:
420
- return rawTransaction;
150
+ case 0: return rawTransaction;
151
+ case 1: return rawTransaction;
152
+ case 2: return rawTransaction;
153
+ default: return rawTransaction;
421
154
  }
422
155
  }
423
- /**
424
- * Get detailed information about multiple transactions. An extension of {@link getRawTransaction}.
425
- * @param {Array<string>} txids An array of transaction ids.
426
- * @param {?VerbosityLevel} verbosity Response format: 0 (hex), 1 (json) or 2 (jsonext).
427
- * @returns {Promise<Array<RawTransactionResponse>>}
428
- */
156
+ /** Get detailed information about multiple transactions using JSON-RPC batching. */
429
157
  async getRawTransactions(txids, verbosity) {
430
- return await Promise.all(txids.map(async (txid) => await this.getRawTransaction(txid, verbosity ?? 2)));
158
+ const v = verbosity ?? 2;
159
+ const results = await this.#transport.batch(txids.map(txid => ({ method: 'getrawtransaction', params: [txid, v] })));
160
+ return results.map(raw => {
161
+ const normalized = JSONUtils.isUnprototyped(raw) ? JSONUtils.normalize(raw) : raw;
162
+ switch (v) {
163
+ case 0: return normalized;
164
+ case 1: return normalized;
165
+ case 2: return normalized;
166
+ default: return normalized;
167
+ }
168
+ });
431
169
  }
432
170
  }
433
171
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/client/rpc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,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;IAC/B;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAuB;IAEvC;;;;OAIG;IACM,UAAU,CAAmB;IAEtC;;;;OAIG;IACM,OAAO,CAAkB;IAElC;;;;;;;;OAQG;IACH,YAA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C,CAAC;YACnD,KAAK,CAAC,CAAC,CAAE,OAAO,cAAkC,CAAC;YACnD,KAAK,CAAC,CAAC,CAAE,OAAO,cAAkC,CAAC;YACnD,OAAO,CAAC,CAAC,OAAO,cAAkC,CAAC;QACrD,CAAC;IACH,CAAC;IAED,oFAAoF;IAC7E,KAAK,CAAC,kBAAkB,CAAC,KAAe,EAAE,SAA0B;QACzE,MAAM,CAAC,GAAG,SAAS,IAAI,CAAC,CAAC;QACzB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CACzC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,CAAc,EAAE,CAAC,CAAC,CACrF,CAAC;QACF,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YACvB,MAAM,UAAU,GAAG,SAAS,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;YAClF,QAAQ,CAAC,EAAE,CAAC;gBACV,KAAK,CAAC,CAAC,CAAE,OAAO,UAA8B,CAAC;gBAC/C,KAAK,CAAC,CAAC,CAAE,OAAO,UAA8B,CAAC;gBAC/C,KAAK,CAAC,CAAC,CAAE,OAAO,UAA8B,CAAC;gBAC/C,OAAO,CAAC,CAAC,OAAO,UAA8B,CAAC;YACjD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -1,7 +1,2 @@
1
- export function isBitcoinRpcClient(obj) {
2
- return obj &&
3
- typeof obj.getBlockCount === 'function' &&
4
- typeof obj.getBlockHash === 'function' &&
5
- typeof obj.getBlockchainInfo === 'function';
6
- }
1
+ export {};
7
2
  //# sourceMappingURL=interface.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../../src/client/rpc/interface.ts"],"names":[],"mappings":"AA2DA,MAAM,UAAU,kBAAkB,CAAC,GAAQ;IACzC,OAAO,GAAG;QACR,OAAO,GAAG,CAAC,aAAa,KAAK,UAAU;QACvC,OAAO,GAAG,CAAC,YAAY,KAAK,UAAU;QACtC,OAAO,GAAG,CAAC,iBAAiB,KAAK,UAAU,CAAC;AAChD,CAAC"}
1
+ {"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../../src/client/rpc/interface.ts"],"names":[],"mappings":""}