@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,293 +1,145 @@
1
- import { BitcoinRpcClientConfig, BlockResponse, ChainInfo, CreateRawTxInputs, CreateRawTxOutputs, DerivedAddresses, GetBlockParams, ListTransactionsParams, ListTransactionsResult, RawTransactionResponse, RawTransactionV2, RpcClientConfig, SignedRawTx, UnspentTxInfo, VerbosityLevel, WalletTransaction } from '../../types.js';
1
+ import { BlockResponse, ChainInfo, CreateRawTxInputs, CreateRawTxOutputs, DerivedAddresses, GetBlockParams, ListTransactionsParams, ListTransactionsResult, RawTransactionResponse, RawTransactionV2, RpcConfig, SignedRawTx, UnspentTxInfo, VerbosityLevel, WalletTransaction } from '../../types.js';
2
+ import { HttpExecutor } from '../http.js';
2
3
  import { BitcoinRpcClient } from './interface.js';
3
4
  import { JsonRpcTransport } from './json-rpc.js';
4
5
  /**
5
- * Class representing a Bitcoin Core RPC client.
6
- * @class BitcoinCoreRpcClient
7
- * @type {BitcoinCoreRpcClient}
6
+ * Maps Bitcoin Core JSON-RPC method names to their parameter and return types.
7
+ * Used by {@link BitcoinCoreRpcClient.executeRpc} for compile-time safety.
8
+ */
9
+ export interface RpcMethodMap {
10
+ getbestblockhash: {
11
+ params: [];
12
+ result: string;
13
+ };
14
+ getblock: {
15
+ params: [string, number?];
16
+ result: BlockResponse;
17
+ };
18
+ getblockchaininfo: {
19
+ params: [];
20
+ result: ChainInfo;
21
+ };
22
+ getblockcount: {
23
+ params: [];
24
+ result: number;
25
+ };
26
+ getblockhash: {
27
+ params: [number];
28
+ result: string;
29
+ };
30
+ getbalance: {
31
+ params: [];
32
+ result: number;
33
+ };
34
+ getnewaddress: {
35
+ params: [string?, string?];
36
+ result: string;
37
+ };
38
+ gettransaction: {
39
+ params: [string, boolean?];
40
+ result: WalletTransaction;
41
+ };
42
+ getrawtransaction: {
43
+ params: [string, number?, string?];
44
+ result: RawTransactionResponse;
45
+ };
46
+ createrawtransaction: {
47
+ params: [CreateRawTxInputs[], CreateRawTxOutputs[], number?, boolean?];
48
+ result: string;
49
+ };
50
+ signrawtransactionwithwallet: {
51
+ params: [string];
52
+ result: SignedRawTx;
53
+ };
54
+ sendrawtransaction: {
55
+ params: [string, (number | string)?, (number | string)?];
56
+ result: string;
57
+ };
58
+ listtransactions: {
59
+ params: [string?, number?, number?, boolean?];
60
+ result: ListTransactionsResult;
61
+ };
62
+ listunspent: {
63
+ params: [number?, number?, string[]?, boolean?];
64
+ result: UnspentTxInfo[];
65
+ };
66
+ sendtoaddress: {
67
+ params: [string, number];
68
+ result: string;
69
+ };
70
+ signmessage: {
71
+ params: [string, string];
72
+ result: string;
73
+ };
74
+ verifymessage: {
75
+ params: [string, string, string];
76
+ result: boolean;
77
+ };
78
+ deriveaddresses: {
79
+ params: [string, number[]?];
80
+ result: DerivedAddresses[];
81
+ };
82
+ }
83
+ /** Method names that have typed definitions in {@link RpcMethodMap}. */
84
+ export type TypedRpcMethod = keyof RpcMethodMap;
85
+ /**
86
+ * Bitcoin Core RPC client.
8
87
  * @implements {BitcoinRpcClient}
9
88
  */
10
89
  export declare class BitcoinCoreRpcClient implements BitcoinRpcClient {
11
90
  #private;
12
- /**
13
- * Constructs a new {@link BitcoinCoreRpcClient} instance from a new {@link RpcClient | RpcClient}.
14
- * @param {RpcClientConfig} config The bitcoin-core client instance.
15
- * @example
16
- * ```
17
- * import BitcoinRpcClient from '@did-btcr2/method';
18
- * const bob = BitcoinRpcClient.connect(); // To use default polar config, pass no args. Polar must run locally.
19
- * ```
20
- */
21
- constructor(config: RpcClientConfig);
22
- /**
23
- * Get the config for the current BitcoinRpcClient object.
24
- * @returns {BitcoinRpcClient} The encapsulated {@link BitcoinRpcClient} object.
25
- * @example
26
- * ```
27
- * import BitcoinRpcClient from '@did-btcr2/method';
28
- * const alice = BitcoinRpcClient.connect();
29
- * const config = alice.config;
30
- * ```
31
- */
32
- get config(): BitcoinRpcClientConfig;
33
- /**
34
- * Get the client for the current BitcoinRpcClient object.
35
- * @returns {RpcClient} The encapsulated {@link RpcClient} object.
36
- * @example
37
- * ```
38
- * const alice = BitcoinRpcClient.connect();
39
- * const config = alice.client;
40
- * ```
41
- */
91
+ constructor(config: RpcConfig, executor?: HttpExecutor);
92
+ get config(): RpcConfig;
42
93
  get client(): JsonRpcTransport;
43
94
  /**
44
- * Static method initializes a static instance of BitcoinCoreRpcClient with the given configuration.
45
- * The RpcClient returned by this method does not have any named methods.
46
- * Use this method to create and pass a new RpcClient instance to a BitcoinCoreRpcClient constructor.
47
- *
48
- * @param {RpcClientConfig} config The configuration object for the client (optional).
49
- * @returns {BitcoinCoreRpcClient} A new RpcClient instance.
50
- * @example
51
- * ```
52
- * const options: RpcClientConfig = {
53
- * host: 'http://localhost:18443',
54
- * username: 'alice',
55
- * password: 'alicepass',
56
- * version: '28.1.0',
57
- * }
58
- * const alice = BitcoinCoreRpcClient.initialize(options); // Client config required
59
- * ```
60
- */
61
- static initialize(config?: RpcClientConfig): BitcoinCoreRpcClient;
62
- /**
63
- * Static method connects to a bitcoin node running the bitcoin core daemon (bitcoind).
64
- * To use default polar config, do not pass a config. See {@link DEFAULT_BITCOIN_NETWORK_CONFIG} for default config.
65
- * @required A locally running {@link https://github.com/jamaljsr/polar | Polar Lightning} regtest node.
66
- *
67
- * @param {?RpcClientConfig} config The configuration object for the client (optional).
68
- * @returns A new {@link BitcoinRpcClient} instance.
69
- * @example
70
- * ```
71
- * const alice = BitcoinRpcClient.connect();
72
- * ```
73
- */
74
- static connect(config?: RpcClientConfig): BitcoinCoreRpcClient;
75
- /**
76
- * Check if the given error is a JSON-RPC error.
77
- * @param {unknown} e The error to check.
78
- * @returns {boolean} True if the error is a JSON-RPC error, false otherwise.
79
- */
80
- isJsonRpcError(e: unknown): e is Error & {
81
- name: 'RpcError';
82
- code?: number;
83
- };
84
- /**
85
- * Executes a JSON-RPC command on the bitcoind node.
86
- * @param {MethodNameInLowerCase} method The name of the method to call.
87
- * @param {Array<any>} parameters The parameters to pass to the method.
88
- * @returns {Promise<T>} A promise resolving to the result of the command.
95
+ * Executes a typed JSON-RPC command on the bitcoind node.
89
96
  */
90
97
  private executeRpc;
91
- /**
92
- *
93
- * Map JSON-RPC error codes to HTTP status codes.
94
- * @param {number | undefined} code The JSON-RPC error code.
95
- * @returns {number} The corresponding HTTP status code.
96
- *
97
- * | Error type | HTTP code |
98
- * | -------------------------------| --------------------|
99
- * | Valid JSON-RPC failure | **400 / 404 / 422** |
100
- * | JSON-RPC authentication issues | **401 / 403** |
101
- * | Upstream bitcoind unreachable | **502** |
102
- * | Upstream timeout | **504** |
103
- * | Network transient errors | **503** |
104
- * | Unknown unexpected errors | **500** |
105
- */
106
- private mapRpcCodeToHttp;
107
- /**
108
- * Handle errors that occur while executing commands.
109
- * @param methods An array of {@link BatchOption} objects.
110
- * @param error The error that was thrown.
111
- * @throws Throws a {@link BitcoinRpcError} with the error message.
112
- */
113
- private handleError;
114
98
  /**
115
99
  * Returns the block data associated with a `blockhash` of a valid block.
116
- * @param {GetBlockParams} params See {@link GetBlockParams} for details.
117
- * @param {?string} params.blockhash The blockhash of the block to query.
118
- * @param {?number} params.height The block height of the block to query.
119
- * @param {?VerbosityLevel} params.verbosity The verbosity level. See {@link VerbosityLevel}.
120
- * @returns {BlockResponse} A promise resolving to a {@link BlockResponse} formatted depending on `verbosity` level.
121
- * @throws {BitcoinRpcError} If neither `blockhash` nor `height` is provided.
122
100
  */
123
101
  getBlock({ blockhash, height, verbosity }: GetBlockParams): Promise<BlockResponse | undefined>;
124
- /**
125
- * Returns the blockheight of the most-work fully-validated chain. The genesis block has height 0.
126
- * @returns {Blockheight} The number of the blockheight with the most-work of the fully-validated chain.
127
- */
102
+ /** Returns the blockheight of the most-work fully-validated chain. */
128
103
  getBlockCount(): Promise<number>;
129
- /**
130
- * Returns the blockhash of the block at the given height in the active chain.
131
- */
104
+ /** Returns the blockhash of the block at the given height. */
132
105
  getBlockHash(height: number): Promise<string>;
133
- /**
134
- * Returns an object containing various blockchain state info.
135
- */
106
+ /** Returns various blockchain state info. */
136
107
  getBlockchainInfo(): Promise<ChainInfo>;
137
- /**
138
- * Sign inputs for raw transaction (serialized, hex-encoded).
139
- * The second optional argument (may be null) is an array of previous transaction outputs that
140
- * this transaction depends on but may not yet be in the block chain.
141
- * Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.
142
- * @param {string} hexstring The hex-encoded transaction to send.
143
- */
108
+ /** Sign inputs for raw transaction (serialized, hex-encoded). */
144
109
  signRawTransaction(hexstring: string): Promise<SignedRawTx>;
145
- /**
146
- * Submit a raw transaction (serialized, hex-encoded) to local node and network.
147
- *
148
- * The transaction will be sent unconditionally to all peers, so using sendrawtransaction
149
- * for manual rebroadcast may degrade privacy by leaking the transaction's origin, as
150
- * nodes will normally not rebroadcast non-wallet transactions already in their mempool.
151
- *
152
- * @param {string} hexstring The hex-encoded transaction to send.
153
- * @param {numbner} [maxfeerate] If not passed, default is 0.10.
154
- * @returns {Promise<string>} A promise resolving to the transaction hash in hex.
155
- */
110
+ /** Submit a raw transaction (serialized, hex-encoded) to local node and network. */
156
111
  sendRawTransaction(hexstring: string, maxfeerate?: number | string, maxBurnAmount?: number | string): Promise<string>;
157
- /**
158
- * Combines calls to `signRawTransaction` and `sendRawTransaction`.
159
- * @param {string} params.hexstring The hex-encoded transaction to send.
160
- * @returns {Promise<string>} A promise resolving to the transaction hash in hex.
161
- */
112
+ /** Signs and sends a raw transaction. */
162
113
  signAndSendRawTransaction(hexstring: string): Promise<string>;
163
- /**
164
- * Combines calls to `createRawTransaction`, `signRawTransaction` and `sendRawTransaction`.
165
- * @param {CreateRawTxInputs[]} inputs The inputs to the transaction (required).
166
- * @param {CreateRawTxOutputs[]} outputs The outputs of the transaction (required).
167
- * @returns {Promise<string>} A promise resolving to the transaction hash in hex.
168
- */
114
+ /** Creates, signs, and sends a raw transaction. */
169
115
  createSignSendRawTransaction(inputs: CreateRawTxInputs[], outputs: CreateRawTxOutputs[]): Promise<string>;
170
- /**
171
- * Returns up to 'count' most recent transactions skipping the first 'from' transactions for account 'label'.
172
- * @param {ListTransactionsParams} params The parameters for the listTransactions command.
173
- * @returns {Promise<ListTransactionsResult>} A promise resolving to a {@link ListTransactionsResult} object.
174
- */
116
+ /** Returns up to 'count' most recent transactions. */
175
117
  listTransactions(params: ListTransactionsParams): Promise<ListTransactionsResult>;
176
- /**
177
- * Create a transaction spending the given inputs and creating new outputs.
178
- * Outputs can be addresses or data.
179
- * Returns hex-encoded raw transaction.
180
- * Note that the transaction's inputs are not signed, and
181
- * it is not stored in the wallet or transmitted to the network.
182
- * @param {TxInForCreateRaw[]} inputs The inputs to the transaction (required).
183
- * @param {CreateRawTxOutputs[]} outputs The outputs of the transaction (required).
184
- * @param {number} [locktime] The locktime of the transaction (optional).
185
- * @param {boolean} [replacable] Whether the transaction is replaceable (optional).
186
- * @returns {string} The hex-encoded raw transaction.
187
- */
118
+ /** Create a transaction spending the given inputs and creating new outputs. */
188
119
  createRawTransaction(inputs: CreateRawTxInputs[], outputs: CreateRawTxOutputs[], locktime?: number, replacable?: boolean): Promise<string>;
189
- /**
190
- * Derives one or more addresses corresponding to an output descriptor.
191
- * Examples of output descriptors are:
192
- * pkh(<pubkey>) P2PKH outputs for the given pubkey
193
- * wpkh(<pubkey>) Native segwit P2PKH outputs for the given pubkey
194
- * sh(multi(<n>,<pubkey>,<pubkey>,...)) P2SH-multisig outputs for the given threshold and pubkeys
195
- * raw(<hex script>) Outputs whose output script equals the specified hex-encoded bytes
196
- * tr(<pubkey>,multi_a(<n>,<pubkey>,<pubkey>,...)) P2TR-multisig outputs for the given threshold and pubkeys
197
- *
198
- * In the above, <pubkey> either refers to a fixed public key in hexadecimal notation, or to an xpub/xprv optionally followed by one
199
- * or more path elements separated by "/", where "h" represents a hardened child key.
200
- *
201
- * See {@link https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md | github.com/bitcoin/bitcoin/descriptors.md}
202
- * for more information.
203
- * @param {string} descriptor The descriptor.
204
- * @param {Array<number>} range If descriptor is ranged, must specify end or [begin,end] to derive.
205
- * @returns {Array<DerivedAddresses>} a list of derived addresses
206
- * @example First three native segwit receive addresses
207
- * ```
208
- * const bitcoind = BitcoinRpcClient.connect()
209
- * const addresses = bitcoind.deriveAddresses("wpkh([d34db33f/84h/0h/0h]xpub6DJ2dN.../0/*)#cjjspncu", [0,2])
210
- * ```
211
- */
120
+ /** Derives one or more addresses corresponding to an output descriptor. */
212
121
  deriveAddresses(descriptor: string, range?: Array<number>): Promise<Array<DerivedAddresses>>;
213
- /**
214
- * Returns the total available balance. The available balance is what the wallet
215
- * considers currently spendable, and is thus affected by options which limit
216
- * spendability such as -spendzeroconfchange.
217
- * @returns {Promise<number>} A promise resolving to the total available balance in BTC.
218
- */
122
+ /** Returns the total available balance. */
219
123
  getBalance(): Promise<number>;
220
- /**
221
- * Returns a new Bitcoin address for receiving payments. If 'label' is specified,
222
- * it is added to the address book so payments received with the address will be associated with 'label'.
223
- * The 'address_type' can be one of "legacy", "p2sh-segwit", "bech32", or "bech32m".
224
- * @param {string} addressType The address type to use (required, options=["legacy", "p2sh-segwit", "bech32", "bech32m"], default="bech32").
225
- * @param {string} [label] The label to associate with the new address (optional).
226
- * @returns {Promise<string>} A promise resolving to the new address.
227
- */
124
+ /** Returns a new Bitcoin address for receiving payments. */
228
125
  getNewAddress(addressType: string, label?: string): Promise<string>;
229
- /**
230
- * Returns array of unspent transaction outputs with between minconf and maxconf (inclusive) confirmations.
231
- * Optionally filter to only include txouts paid to specified addresses.
232
- * @param {Object} params The parameters for the listUnspent command.
233
- * @param {number} [params.minconf=0] The minimum number of confirmations an output must have to be included.
234
- * @param {number} [params.maxconf=9999999] The maximum number of confirmations an output can have to be included.
235
- * @param {string[]} [params.address] Only include outputs paid to these addresses.
236
- * @param {boolean} [params.include_unsafe=true] Whether to include outputs that are not safe to spend.
237
- * @returns {Promise<UnspentTxInfo[]>} A promise resolving to an array of {@link UnspentTxInfo} objects.
238
- */
126
+ /** Returns array of unspent transaction outputs. */
239
127
  listUnspent(params: {
240
128
  minconf?: number;
241
129
  maxconf?: number;
242
130
  address?: string[];
243
131
  include_unsafe?: boolean;
244
132
  }): Promise<UnspentTxInfo[]>;
245
- /**
246
- * Send an amount to a given address.
247
- * @param {string} address The address to send to.
248
- * @param {number} amount The amount to send in BTC.
249
- * @returns {Promise<SendToAddressResult>} A promise resolving to the transaction id.
250
- */
133
+ /** Send an amount to a given address. */
251
134
  sendToAddress(address: string, amount: number): Promise<RawTransactionV2>;
252
- /**
253
- * Sign a message with the private key of an address.
254
- * @param {string} address The address to sign the message with.
255
- * @param {string} message The message to sign.
256
- * @returns {Promise<string>} A promise resolving to the signature in base64.
257
- */
135
+ /** Sign a message with the private key of an address. */
258
136
  signMessage(address: string, message: string): Promise<string>;
259
- /**
260
- * Verify a signed message.
261
- * @param {string} address The address to verify the message with.
262
- * @param {string} signature The signature to verify in base64.
263
- * @param {string} message The message to verify.
264
- * @returns {Promise<boolean>} A promise resolving to true if the signature is valid, false otherwise.
265
- */
137
+ /** Verify a signed message. */
266
138
  verifyMessage(address: string, signature: string, message: string): Promise<boolean>;
267
- /**
268
- * Get detailed information about in-wallet transaction <txid>.
269
- * @param txid: The transaction id. (string, required)
270
- * @param {boolean} include_watchonly Whether to include watch-only addresses in balance calculation and details.
271
- * @returns {WalletTransaction} A promise resolving to a {@link WalletTransaction} object.
272
- */
139
+ /** Get detailed information about in-wallet transaction. */
273
140
  getTransaction(txid: string, include_watchonly?: boolean): Promise<WalletTransaction>;
274
- /**
275
- * Get detailed information about a transaction.
276
- * By default, this call only returns a transaction if it is in the mempool. If -txindex is enabled
277
- * and no blockhash argument is passed, it will return the transaction if it is in the mempool or any block.
278
- * If a blockhash argument is passed, it will return the transaction if the specified block is available and
279
- * the transaction is in that block.
280
- * @param {string} txid The transaction id (required).
281
- * @param {?VerbosityLevel} verbosity Response format: 0 (hex), 1 (json) or 2 (jsonext).
282
- * @param {?string} blockhash The block in which to look for the transaction (optional).
283
- * @returns {GetRawTransaction} A promise resolving to data about a transaction in the form specified by verbosity.
284
- */
141
+ /** Get detailed information about a transaction. */
285
142
  getRawTransaction(txid: string, verbosity?: VerbosityLevel, blockhash?: string): Promise<RawTransactionResponse>;
286
- /**
287
- * Get detailed information about multiple transactions. An extension of {@link getRawTransaction}.
288
- * @param {Array<string>} txids An array of transaction ids.
289
- * @param {?VerbosityLevel} verbosity Response format: 0 (hex), 1 (json) or 2 (jsonext).
290
- * @returns {Promise<Array<RawTransactionResponse>>}
291
- */
143
+ /** Get detailed information about multiple transactions using JSON-RPC batching. */
292
144
  getRawTransactions(txids: string[], verbosity?: VerbosityLevel): Promise<RawTransactionResponse[]>;
293
145
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/rpc/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,sBAAsB,EACtB,aAAa,EAKb,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACtB,sBAAsB,EAEtB,sBAAsB,EAGtB,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,aAAa,EACb,cAAc,EACd,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD;;;;;GAKG;AACH,qBAAa,oBAAqB,YAAW,gBAAgB;;IAsB3D;;;;;;;;OAQG;gBACS,MAAM,EAAE,eAAe;IAKnC;;;;;;;;;OASG;IACH,IAAI,MAAM,IAAI,sBAAsB,CAGnC;IAED;;;;;;;;OAQG;IACH,IAAI,MAAM,IAAI,gBAAgB,CAG7B;IAED;;;;;;;;;;;;;;;;;OAiBG;WACW,UAAU,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,oBAAoB;IAMxE;;;;;;;;;;;OAWG;WACW,OAAO,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,oBAAoB;IAIrE;;;;OAIG;IACI,cAAc,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,KAAK,GAAG;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE;IAQnF;;;;;OAKG;YACW,UAAU;IAaxB;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,gBAAgB;IAexB;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IAkBnB;;;;;;;;OAQG;IACU,QAAQ,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,cAAc,G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AAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIjG,4DAA4D;IAC/C,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAIlG,oDAAoD;IACvC,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,cAAc,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAU7H,oFAAoF;IACvE,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,sBAAsB,EAAE,CAAC;CAehH"}
@@ -1,8 +1,6 @@
1
1
  import { BlockResponse, ChainInfo, CreateRawTxInputs, CreateRawTxOutputs, FeeEstimateMode, GetBlockParams, RawTransactionResponse } from '../../types.js';
2
2
  /**
3
- * General interface for a Bitcoin Core RPC client.\
4
- * @name BitcoinRpcClient
5
- * @type {BitcoinRpcClient}
3
+ * General interface for a Bitcoin Core RPC client.
6
4
  */
7
5
  export interface BitcoinRpcClient {
8
6
  /** Creates a raw transaction spending specified inputs to specified outputs. */
@@ -25,4 +23,3 @@ export interface BitcoinRpcClient {
25
23
  verifyMessage(address: string, signature: string, message: string): Promise<boolean>;
26
24
  signMessage(address: string, message: string): Promise<string>;
27
25
  }
28
- export declare function isBitcoinRpcClient(obj: any): obj is BitcoinRpcClient;
@@ -1 +1 @@
1
- {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../../src/client/rpc/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AAExB;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC7B,gFAAgF;IAChF,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,EAAE,EAAE,OAAO,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,MAAM,EACf,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,EACnB,sBAAsB,CAAC,EAAE,OAAO,EAChC,WAAW,CAAC,EAAE,OAAO,EACrB,WAAW,CAAC,EAAE,MAAM,EACpB,aAAa,CAAC,EAAE,eAAe,GAC9B,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAEnC,iCAAiC;IACjC,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAErF,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAChE"}
@@ -1,24 +1,26 @@
1
- import { BatchOption, RpcClientConfig } from '../../types.js';
1
+ import { RpcConfig } from '../../types.js';
2
+ import { HttpExecutor } from '../http.js';
3
+ import { JsonRpcProtocol } from './protocol.js';
2
4
  export declare class JsonRpcTransport {
3
- private url;
4
- private authHeader?;
5
- private id;
6
- constructor(cfg: RpcClientConfig);
7
5
  /**
8
- * Make a JSON-RPC call or batch of calls to the Bitcoin node.
9
- * @param {BatchOption[] | { method: string; parameters?: any[] }} batch A single RPC call or an array of calls to be made.
10
- * @returns {Promise<any[] | any>} The result of the RPC call(s).
11
- * @example
6
+ * The sans-I/O protocol layer. Use this to build {@link HttpRequest}
7
+ * descriptors without performing any I/O.
12
8
  */
13
- command(batch: BatchOption[] | {
14
- method: string;
15
- parameters?: any[];
16
- }): Promise<any[] | any>;
9
+ readonly protocol: JsonRpcProtocol;
10
+ private readonly execute;
11
+ constructor(cfg: RpcConfig, executor?: HttpExecutor);
12
+ /** @internal Expose URL for tests that inspect transport state. */
13
+ get url(): string;
14
+ /**
15
+ * Execute a single JSON-RPC call.
16
+ */
17
+ call(method: string, params?: unknown[]): Promise<unknown>;
17
18
  /**
18
- * Internal method to perform the actual JSON-RPC call.
19
- * @param {string} method The RPC method to call.
20
- * @param {any[]} params The parameters for the RPC method.
21
- * @returns {Promise<any>} The result of the RPC call.
19
+ * Execute a JSON-RPC batch in a single HTTP request.
20
+ * Returns results in the same order as the input calls.
22
21
  */
23
- private call;
22
+ batch(calls: Array<{
23
+ method: string;
24
+ params: unknown[];
25
+ }>): Promise<unknown[]>;
24
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"json-rpc.d.ts","sourceRoot":"","sources":["../../../../src/client/rpc/json-rpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAG9D,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,UAAU,CAAC,CAAS;IAC5B,OAAO,CAAC,EAAE,CAAK;gBAEH,GAAG,EAAE,eAAe;IAmBhC;;;;;OAKG;IACG,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,GAAG,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC;IAYlG;;;;;OAKG;YACW,IAAI;CA6BnB"}
1
+ {"version":3,"file":"json-rpc.d.ts","sourceRoot":"","sources":["../../../../src/client/rpc/json-rpc.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAuB,MAAM,YAAY,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,qBAAa,gBAAgB;IAC3B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;IAEnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;gBAE3B,GAAG,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,YAAY;IAKnD,mEAAmE;IACnE,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED;;OAEG;IACG,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,EAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAkBpE;;;OAGG;IACG,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CAuBrF"}
@@ -0,0 +1,82 @@
1
+ import { RpcConfig } from '../../types.js';
2
+ import { HttpRequest } from '../http.js';
3
+ /**
4
+ * Sans-I/O JSON-RPC protocol for Bitcoin Core.
5
+ *
6
+ * Builds {@link HttpRequest} descriptors for JSON-RPC method calls and
7
+ * provides response parsing — without performing any I/O.
8
+ *
9
+ * **Security note:** Built requests include an `Authorization` header when
10
+ * credentials are configured. Do not log or persist {@link HttpRequest}
11
+ * objects without redacting the `Authorization` header.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const protocol = new JsonRpcProtocol({
16
+ * host: 'http://localhost:18443',
17
+ * username: 'user',
18
+ * password: 'pass',
19
+ * });
20
+ *
21
+ * // Build a request descriptor (no I/O)
22
+ * const req = protocol.buildRequest('getblockcount', []);
23
+ *
24
+ * // Execute with any HTTP client
25
+ * const res = await fetch(req.url, req);
26
+ * const json = await res.json();
27
+ *
28
+ * // Parse the JSON-RPC response (throws on errors)
29
+ * const blockCount = protocol.parseResponse(json, 'getblockcount', []);
30
+ * ```
31
+ */
32
+ export declare class JsonRpcProtocol {
33
+ readonly url: string;
34
+ /** Whether this protocol instance has credentials configured. */
35
+ readonly hasAuth: boolean;
36
+ private readonly _headers;
37
+ private _id;
38
+ constructor(cfg: RpcConfig);
39
+ /**
40
+ * Build an {@link HttpRequest} for a JSON-RPC method call.
41
+ */
42
+ buildRequest(method: string, params: unknown[]): HttpRequest;
43
+ /**
44
+ * Build an {@link HttpRequest} for a JSON-RPC batch call.
45
+ * Sends all calls in a single HTTP request per the JSON-RPC 2.0 spec.
46
+ */
47
+ buildBatchRequest(calls: Array<{
48
+ method: string;
49
+ params: unknown[];
50
+ }>): HttpRequest;
51
+ /**
52
+ * Parse a JSON-RPC response payload, throwing {@link BitcoinRpcError}
53
+ * if the response contains an error.
54
+ */
55
+ parseResponse(payload: {
56
+ result?: unknown;
57
+ error?: {
58
+ code: number;
59
+ message: string;
60
+ };
61
+ }, method: string): unknown;
62
+ /**
63
+ * Parse a JSON-RPC batch response payload.
64
+ * Returns results in the same order as the original calls.
65
+ */
66
+ parseBatchResponse(payloads: Array<{
67
+ id: number;
68
+ result?: unknown;
69
+ error?: {
70
+ code: number;
71
+ message: string;
72
+ };
73
+ }>, calls: Array<{
74
+ method: string;
75
+ params: unknown[];
76
+ }>): unknown[];
77
+ /**
78
+ * Return a copy of the headers with the Authorization value redacted.
79
+ * Use this for logging or debugging.
80
+ */
81
+ redactedHeaders(): Record<string, string>;
82
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../../../src/client/rpc/protocol.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,eAAe;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB,iEAAiE;IACjE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyB;IAClD,OAAO,CAAC,GAAG,CAAK;gBAEJ,GAAG,EAAE,SAAS;IA2B1B;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,WAAW;IAU5D;;;OAGG;IACH,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC,GAAG,WAAW;IAenF;;;OAGG;IACH,aAAa,CACX,OAAO,EAAE;QAAE,MAAM,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,EACxE,MAAM,EAAE,MAAM,GACb,OAAO;IAYV;;;OAGG;IACH,kBAAkB,CAChB,QAAQ,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC,EAC5F,KAAK,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC,GAClD,OAAO,EAAE;IAoBZ;;;OAGG;IACH,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAO1C"}
@@ -4,6 +4,22 @@ export declare const COINBASE_MATURITY_DELAY = 100;
4
4
  export declare const DEFAULT_BLOCK_CONFIRMATIONS = 7;
5
5
  export declare const TXIN_WITNESS_COINBASE = "0000000000000000000000000000000000000000000000000000000000000000";
6
6
  export declare const GENESIS_TX_ID = "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b";
7
+ /**
8
+ * Default endpoint configuration per Bitcoin network.
9
+ *
10
+ * **Regtest RPC:** Credentials are intentionally omitted — callers must
11
+ * provide `username` and `password` via overrides or explicit config.
12
+ * This prevents accidentally using hardcoded credentials in non-local
13
+ * environments.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * // Provide credentials explicitly
18
+ * BitcoinConnection.forNetwork('regtest', {
19
+ * rpc: { username: 'polaruser', password: 'polarpass' },
20
+ * });
21
+ * ```
22
+ */
7
23
  export declare const DEFAULT_BITCOIN_NETWORK_CONFIG: {
8
24
  readonly bitcoin: {
9
25
  readonly rpc: undefined;
@@ -37,13 +53,8 @@ export declare const DEFAULT_BITCOIN_NETWORK_CONFIG: {
37
53
  };
38
54
  readonly regtest: {
39
55
  readonly rpc: {
40
- readonly network: "regtest";
41
56
  readonly host: "http://localhost:18443";
42
- readonly port: 18443;
43
- readonly username: "polaruser";
44
- readonly password: "polarpass";
45
57
  readonly allowDefaultWallet: true;
46
- readonly version: "28.1.0";
47
58
  };
48
59
  readonly rest: {
49
60
  readonly host: "http://localhost:3000";
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,eAAO,MAAM,gBAAgB,MAAM,CAAC;AACpC,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAC7C,eAAO,MAAM,qBAAqB,qEAAqE,CAAC;AACxG,eAAO,MAAM,aAAa,qEAAqE,CAAC;AAChG,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCjC,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,eAAO,MAAM,gBAAgB,MAAM,CAAC;AACpC,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAC7C,eAAO,MAAM,qBAAqB,qEAAqE,CAAC;AACxG,eAAO,MAAM,aAAa,qEAAqE,CAAC;AAEhG;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BjC,CAAC"}
@@ -1,11 +1,12 @@
1
+ export type RpcErrorType = 'HTTP_ERROR' | 'RPC_ERROR' | 'INVALID_PARAMS_GET_BLOCK' | 'SIGNING_INCOMPLETE' | 'UNKNOWN_ERROR';
1
2
  /**
2
3
  * Custom Error class for handling Bitcoin RPC errors.
3
4
  */
4
5
  export declare class BitcoinRpcError extends Error {
5
- readonly type: string;
6
+ readonly type: RpcErrorType;
6
7
  readonly code: number;
7
- readonly data?: any;
8
- constructor(type: string, code: number, message: string, data?: any);
8
+ readonly data?: unknown;
9
+ constructor(type: RpcErrorType, code: number, message: string, data?: unknown);
9
10
  }
10
11
  export declare class BitcoinRestError extends Error {
11
12
  readonly data?: any;