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