@did-btcr2/bitcoin 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{bitcoin.browser.js → bitcoin.js} +40 -17
- package/dist/cjs/bitcoin.js.map +1 -0
- package/dist/cjs/client/rest/address.js +76 -0
- package/dist/cjs/client/rest/address.js.map +1 -0
- package/dist/cjs/client/rest/block.js +50 -0
- package/dist/cjs/client/rest/block.js.map +1 -0
- package/dist/cjs/client/rest/index.js +118 -0
- package/dist/cjs/client/rest/index.js.map +1 -0
- package/dist/cjs/client/rest/transaction.js +56 -0
- package/dist/cjs/client/rest/transaction.js.map +1 -0
- package/dist/cjs/client/rpc/index.js +394 -0
- package/dist/cjs/client/rpc/index.js.map +1 -0
- package/dist/cjs/client/rpc/interface.js.map +1 -0
- package/dist/cjs/client/rpc/json-rpc.js +78 -0
- package/dist/cjs/client/rpc/json-rpc.js.map +1 -0
- package/dist/cjs/client/utils.js +28 -0
- package/dist/cjs/client/utils.js.map +1 -0
- package/dist/cjs/constants.js +34 -13
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/errors.js +8 -0
- package/dist/cjs/errors.js.map +1 -1
- package/dist/cjs/index.js +15 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/types.js +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/esm/{bitcoin.browser.js → bitcoin.js} +40 -17
- package/dist/esm/bitcoin.js.map +1 -0
- package/dist/esm/client/rest/address.js +76 -0
- package/dist/esm/client/rest/address.js.map +1 -0
- package/dist/esm/client/rest/block.js +50 -0
- package/dist/esm/client/rest/block.js.map +1 -0
- package/dist/esm/client/rest/index.js +118 -0
- package/dist/esm/client/rest/index.js.map +1 -0
- package/dist/esm/client/rest/transaction.js +56 -0
- package/dist/esm/client/rest/transaction.js.map +1 -0
- package/dist/esm/client/rpc/index.js +394 -0
- package/dist/esm/client/rpc/index.js.map +1 -0
- package/dist/esm/client/rpc/interface.js.map +1 -0
- package/dist/esm/client/rpc/json-rpc.js +78 -0
- package/dist/esm/client/rpc/json-rpc.js.map +1 -0
- package/dist/esm/client/utils.js +28 -0
- package/dist/esm/client/utils.js.map +1 -0
- package/dist/esm/constants.js +34 -13
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/errors.js +8 -0
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/index.js +15 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types.js +2 -2
- package/dist/esm/types.js.map +1 -1
- package/dist/types/{bitcoin.browser.d.ts → bitcoin.d.ts} +24 -9
- package/dist/types/bitcoin.d.ts.map +1 -0
- package/dist/types/client/rest/address.d.ts +56 -0
- package/dist/types/client/rest/address.d.ts.map +1 -0
- package/dist/types/client/rest/block.d.ts +32 -0
- package/dist/types/client/rest/block.d.ts.map +1 -0
- package/dist/types/client/rest/index.d.ts +149 -0
- package/dist/types/client/rest/index.d.ts.map +1 -0
- package/dist/types/client/rest/transaction.d.ts +44 -0
- package/dist/types/client/rest/transaction.d.ts.map +1 -0
- package/dist/types/client/rpc/index.d.ts +276 -0
- package/dist/types/client/rpc/index.d.ts.map +1 -0
- package/dist/types/client/rpc/interface.d.ts +27 -0
- package/dist/types/client/rpc/interface.d.ts.map +1 -0
- package/dist/types/client/rpc/json-rpc.d.ts +24 -0
- package/dist/types/client/rpc/json-rpc.d.ts.map +1 -0
- package/dist/types/client/utils.d.ts +12 -0
- package/dist/types/client/utils.d.ts.map +1 -0
- package/dist/types/constants.d.ts +46 -13
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/errors.d.ts +4 -0
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types.d.ts +9 -9
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +9 -15
- package/src/{bitcoin.browser.ts → bitcoin.ts} +49 -17
- package/src/client/rest/address.ts +84 -0
- package/src/client/rest/block.ts +58 -0
- package/src/client/rest/index.ts +217 -0
- package/src/client/rest/transaction.ts +64 -0
- package/src/client/rpc/index.ts +479 -0
- package/src/client/rpc/interface.ts +58 -0
- package/src/client/rpc/json-rpc.ts +82 -0
- package/src/client/utils.ts +21 -0
- package/src/constants.ts +35 -14
- package/src/errors.ts +9 -0
- package/src/index.ts +14 -0
- package/src/types.ts +10 -10
- package/dist/cjs/bitcoin.browser.js.map +0 -1
- package/dist/cjs/bitcoin.node.js +0 -85
- package/dist/cjs/bitcoin.node.js.map +0 -1
- package/dist/cjs/index.browser.js +0 -10
- package/dist/cjs/index.browser.js.map +0 -1
- package/dist/cjs/index.node.js +0 -10
- package/dist/cjs/index.node.js.map +0 -1
- package/dist/cjs/interface.js.map +0 -1
- package/dist/cjs/rest-client.js +0 -294
- package/dist/cjs/rest-client.js.map +0 -1
- package/dist/cjs/rpc-client.js +0 -722
- package/dist/cjs/rpc-client.js.map +0 -1
- package/dist/esm/bitcoin.browser.js.map +0 -1
- package/dist/esm/bitcoin.node.js +0 -85
- package/dist/esm/bitcoin.node.js.map +0 -1
- package/dist/esm/index.browser.js +0 -10
- package/dist/esm/index.browser.js.map +0 -1
- package/dist/esm/index.node.js +0 -10
- package/dist/esm/index.node.js.map +0 -1
- package/dist/esm/interface.js.map +0 -1
- package/dist/esm/rest-client.js +0 -294
- package/dist/esm/rest-client.js.map +0 -1
- package/dist/esm/rpc-client.js +0 -722
- package/dist/esm/rpc-client.js.map +0 -1
- package/dist/types/bitcoin.browser.d.ts.map +0 -1
- package/dist/types/bitcoin.node.d.ts +0 -47
- package/dist/types/bitcoin.node.d.ts.map +0 -1
- package/dist/types/index.browser.d.ts +0 -9
- package/dist/types/index.browser.d.ts.map +0 -1
- package/dist/types/index.node.d.ts +0 -9
- package/dist/types/index.node.d.ts.map +0 -1
- package/dist/types/interface.d.ts +0 -86
- package/dist/types/interface.d.ts.map +0 -1
- package/dist/types/rest-client.d.ts +0 -273
- package/dist/types/rest-client.d.ts.map +0 -1
- package/dist/types/rpc-client.d.ts +0 -506
- package/dist/types/rpc-client.d.ts.map +0 -1
- package/src/bitcoin.node.ts +0 -121
- package/src/index.browser.ts +0 -9
- package/src/index.node.ts +0 -9
- package/src/interface.ts +0 -160
- package/src/rest-client.ts +0 -420
- package/src/rpc-client.ts +0 -888
- /package/dist/cjs/{interface.js → client/rpc/interface.js} +0 -0
- /package/dist/esm/{interface.js → client/rpc/interface.js} +0 -0
|
@@ -1,506 +0,0 @@
|
|
|
1
|
-
import { default as RpcClient } from 'bitcoin-core';
|
|
2
|
-
import { AddMultiSigAddressParams, BitcoinSignature, BlockHashOptions, BlockHeader, BlockResponse, BumpFeeOptions, BumpFeeResult, ChainInfo, CreateMultisigParams, CreateMultiSigResult, CreateRawTxInputs, CreateRawTxOutputs, CreateWalletDescriptorOptions, CreateWalletDescriptorsResult, CreateWalletParams, CreateWalletResult, DecodedRawTransaction, DerivedAddresses, FeeEstimateMode, FundRawTxOptions, FundRawTxResult, GetBlockParams, GetUTXOsResult, IClientConfig, ImportDescriptorRequest, ImportMultiOptions, ImportMultiRequest, ImportMultiResult, ListTransactionsParams, ListTransactionsResult, ListUnspentParams, MemoryStats, MempoolContent, MempoolInfo, MiningInfo, Outpoint, PeerInfo, RawTransactionResponse, RawTransactionV2, ReturnFormatOptions, RpcClientConfig, ScanBlocksParams, ScriptDecoded, SendAllParams, SendAllResult, SendManyParams, SignedRawTx, UnspentTxInfo, ValidateAddressResult, VerbosityLevel, WalletTransaction } from './types.js';
|
|
3
|
-
import { IBitcoinRpc } from './interface.js';
|
|
4
|
-
/**
|
|
5
|
-
* Encapsulates a {@link RpcClient | Client} object from {@link https://www.npmjs.com/package/bitcoin-core | `bitcoin-core`}.
|
|
6
|
-
* Implements a strongly-typed {@link IBitcoinRpc | IBitcoinRpc interface} for added expresivity and developer support.
|
|
7
|
-
* @class BitcoinRpc
|
|
8
|
-
* @type {BitcoinRpc}
|
|
9
|
-
*/
|
|
10
|
-
export declare class BitcoinRpc implements IBitcoinRpc {
|
|
11
|
-
/**
|
|
12
|
-
* The encapsulated {@link RpcClientConfig} object.
|
|
13
|
-
* @private
|
|
14
|
-
* @type {RpcClient} An instance of the Client class from {@link https://www.npmjs.com/package/bitcoin-core | `bitcoin-core`}.
|
|
15
|
-
* See {@link https://github.com/ruimarinho/bitcoin-core/blob/master/src/index.d.ts#L64 | `Client`} for more information.
|
|
16
|
-
*/
|
|
17
|
-
private _client;
|
|
18
|
-
/**
|
|
19
|
-
* The encapsulated {@link RpcClientConfig} object.
|
|
20
|
-
* @private
|
|
21
|
-
* @type {RpcClientConfig} ClientConfig from {@link https://www.npmjs.com/package/bitcoin-core | `bitcoin-core`}.
|
|
22
|
-
* See {@link https://github.com/ruimarinho/bitcoin-core/blob/master/src/index.d.ts#L39 | `ClientConfig`} for more information.
|
|
23
|
-
*/
|
|
24
|
-
private _config;
|
|
25
|
-
/**
|
|
26
|
-
* Constructs a new {@link BitcoinRpc} instance from a new {@link RpcClient | RpcClient}.
|
|
27
|
-
* @param {RpcClientConfig} config The bitcoin-core client instance.
|
|
28
|
-
* @example
|
|
29
|
-
* ```
|
|
30
|
-
* import BitcoinRpc from '@did-btcr2/method';
|
|
31
|
-
* const bob = BitcoinRpc.connect(); // To use default polar config, pass no args. Polar must run locally.
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
constructor(config: RpcClientConfig);
|
|
35
|
-
/**
|
|
36
|
-
* Get the config for the current BitcoinRpc object.
|
|
37
|
-
* @returns {RpcClientConfig} The encapsulated {@link RpcClientConfig} object.
|
|
38
|
-
* @example
|
|
39
|
-
* ```
|
|
40
|
-
* import BitcoinRpc from '@did-btcr2/method';
|
|
41
|
-
* const alice = BitcoinRpc.connect();
|
|
42
|
-
* const config = alice.config;
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
get config(): RpcClientConfig;
|
|
46
|
-
/**
|
|
47
|
-
* Get the client for the current BitcoinRpc object.
|
|
48
|
-
* @returns {RpcClient} The encapsulated {@link RpcClient} object.
|
|
49
|
-
* @example
|
|
50
|
-
* ```
|
|
51
|
-
* const alice = BitcoinRpc.connect();
|
|
52
|
-
* const config = alice.client;
|
|
53
|
-
* ```
|
|
54
|
-
*/
|
|
55
|
-
get client(): RpcClient;
|
|
56
|
-
/**
|
|
57
|
-
* Static method initializes a new BitcoinRpc client with the given configuration.
|
|
58
|
-
* The RpcClient returned by this method does not have any named methods.
|
|
59
|
-
* Use this method to create and pass a new RpcClient instance to a BitcoinRpc constructor.
|
|
60
|
-
*
|
|
61
|
-
* @param {IClientConfig} config The configuration object for the client (optional).
|
|
62
|
-
* @returns {RpcClient} A new RpcClient instance.
|
|
63
|
-
* @example
|
|
64
|
-
* ```
|
|
65
|
-
* const options: IClientConfig = {
|
|
66
|
-
* host: 'http://localhost:18443',
|
|
67
|
-
* username: 'alice',
|
|
68
|
-
* password: 'alicepass',
|
|
69
|
-
* version: '28.1.0',
|
|
70
|
-
* }
|
|
71
|
-
* const aliceClient = BitcoinRpc.initialize(options); // Client config required
|
|
72
|
-
* const alice = new BitcoinRpc(aliceClient);
|
|
73
|
-
* ```
|
|
74
|
-
*/
|
|
75
|
-
static initialize(config?: IClientConfig): RpcClient;
|
|
76
|
-
/**
|
|
77
|
-
* Static method connects to a bitcoin node running the bitcoin core daemon (bitcoind).
|
|
78
|
-
* To use default polar config, do not pass a config. See {@link DEFAULT_RPC_CLIENT_CONFIG} for default config.
|
|
79
|
-
* @required A locally running {@link https://github.com/jamaljsr/polar | Polar Lightning} regtest node.
|
|
80
|
-
*
|
|
81
|
-
* @param {?RpcClientConfig} config The configuration object for the client (optional).
|
|
82
|
-
* @returns A new {@link BitcoinRpc} instance.
|
|
83
|
-
* @example
|
|
84
|
-
* ```
|
|
85
|
-
* const alice = BitcoinRpc.connect();
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
|
-
static connect(config?: RpcClientConfig): BitcoinRpc;
|
|
89
|
-
/**
|
|
90
|
-
* Check if the given error is a JSON-RPC error.
|
|
91
|
-
* @param {unknown} e The error to check.
|
|
92
|
-
* @returns {boolean} True if the error is a JSON-RPC error, false otherwise.
|
|
93
|
-
*/
|
|
94
|
-
isJsonRpcError(e: unknown): e is Error & {
|
|
95
|
-
name: 'RpcError';
|
|
96
|
-
code?: number;
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* Executes a JSON-RPC command on the bitcoind node.
|
|
100
|
-
* @param {MethodNameInLowerCase} method The name of the method to call.
|
|
101
|
-
* @param {Array<any>} parameters The parameters to pass to the method.
|
|
102
|
-
* @returns {Promise<T>} A promise resolving to the result of the command.
|
|
103
|
-
*/
|
|
104
|
-
private executeRpc;
|
|
105
|
-
/**
|
|
106
|
-
* Handle errors that occur while executing commands.
|
|
107
|
-
* @param methods An array of {@link BatchOption} objects.
|
|
108
|
-
* @param error The error that was thrown.
|
|
109
|
-
* @throws Throws a {@link BitcoinRpcError} with the error message.
|
|
110
|
-
*/
|
|
111
|
-
private handleError;
|
|
112
|
-
/**
|
|
113
|
-
* TODO: Comments
|
|
114
|
-
*/
|
|
115
|
-
getUnspentTransactionOutputs(outpoints: Outpoint[]): Promise<GetUTXOsResult>;
|
|
116
|
-
/**
|
|
117
|
-
* TODO: Comments
|
|
118
|
-
*/
|
|
119
|
-
getTransactionByHash(hash: string, options?: ReturnFormatOptions): Promise<string>;
|
|
120
|
-
/**
|
|
121
|
-
* TODO: Comments
|
|
122
|
-
*/
|
|
123
|
-
getBlockHeadersByHash(hash: string, count: number, options?: ReturnFormatOptions): Promise<BlockHeader[]>;
|
|
124
|
-
/**
|
|
125
|
-
* TODO: Comments
|
|
126
|
-
*/
|
|
127
|
-
getMemoryPoolContent(): Promise<MempoolContent>;
|
|
128
|
-
/**
|
|
129
|
-
* TODO: Comments
|
|
130
|
-
*/
|
|
131
|
-
getMemoryPoolInformation(): Promise<MempoolInfo>;
|
|
132
|
-
/**
|
|
133
|
-
* Alias for `getblock <hash> 2`
|
|
134
|
-
*/
|
|
135
|
-
getBlockByHash(hash: string, options?: BlockHashOptions): Promise<BlockHeader>;
|
|
136
|
-
/**
|
|
137
|
-
* TODO: Comments
|
|
138
|
-
*/
|
|
139
|
-
abandonTransaction(txid: string): Promise<void>;
|
|
140
|
-
/**
|
|
141
|
-
* TODO: Comments
|
|
142
|
-
*/
|
|
143
|
-
abortRescan(): Promise<void>;
|
|
144
|
-
/**
|
|
145
|
-
* TODO: Comments
|
|
146
|
-
*/
|
|
147
|
-
addMultiSigAddress(params: AddMultiSigAddressParams): Promise<string>;
|
|
148
|
-
/**
|
|
149
|
-
* TODO: Comments
|
|
150
|
-
*/
|
|
151
|
-
addWitnessAddress(address: string): Promise<void>;
|
|
152
|
-
/**
|
|
153
|
-
* TODO: Comments
|
|
154
|
-
*/
|
|
155
|
-
backupWallet(destination: string): Promise<void>;
|
|
156
|
-
/**
|
|
157
|
-
* TODO: Comments
|
|
158
|
-
*/
|
|
159
|
-
bumpFee(txid: string, options?: BumpFeeOptions): Promise<BumpFeeResult>;
|
|
160
|
-
/**
|
|
161
|
-
* TODO: Comments
|
|
162
|
-
*/
|
|
163
|
-
createMultiSig(nrequired: number, keys: string[]): Promise<CreateMultiSigResult>;
|
|
164
|
-
/**
|
|
165
|
-
* TODO: Comments
|
|
166
|
-
*/
|
|
167
|
-
createWallet(params: CreateWalletParams): Promise<CreateWalletResult>;
|
|
168
|
-
/**
|
|
169
|
-
* TODO: Comments
|
|
170
|
-
*/
|
|
171
|
-
decodeScript(hexstring: string): Promise<ScriptDecoded>;
|
|
172
|
-
/**
|
|
173
|
-
* TODO: Comments
|
|
174
|
-
*/
|
|
175
|
-
getBestBlockHash(): Promise<string>;
|
|
176
|
-
/**
|
|
177
|
-
* 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
|
-
*/
|
|
185
|
-
getBlock({ blockhash, height, verbosity }: GetBlockParams): Promise<BlockResponse | undefined>;
|
|
186
|
-
/**
|
|
187
|
-
* Returns the blockheight of the most-work fully-validated chain. The genesis block has height 0.
|
|
188
|
-
* @returns {Blockheight} The number of the blockheight with the most-work of the fully-validated chain.
|
|
189
|
-
*/
|
|
190
|
-
getBlockCount(): Promise<number>;
|
|
191
|
-
/**
|
|
192
|
-
* Returns the blockhash of the block at the given height in the active chain.
|
|
193
|
-
*/
|
|
194
|
-
getBlockHash(height: number): Promise<string>;
|
|
195
|
-
/**
|
|
196
|
-
* TODO: Comments
|
|
197
|
-
*/
|
|
198
|
-
getBlockHeader(hash: string, verbose?: boolean): Promise<string | BlockHeader>;
|
|
199
|
-
/**
|
|
200
|
-
* TODO: Comments
|
|
201
|
-
*/
|
|
202
|
-
getBlockchainInfo(): Promise<ChainInfo>;
|
|
203
|
-
/**
|
|
204
|
-
* TODO: Comments
|
|
205
|
-
*/
|
|
206
|
-
getInfo(...args: any[]): Promise<void>;
|
|
207
|
-
/**
|
|
208
|
-
* TODO: Comments
|
|
209
|
-
*/
|
|
210
|
-
getMemoryInfo(mode?: 'stats' | 'mallocinfo'): Promise<MemoryStats | string>;
|
|
211
|
-
/**
|
|
212
|
-
* TODO: Comments
|
|
213
|
-
*/
|
|
214
|
-
scanBlocks(params: ScanBlocksParams): Promise<any>;
|
|
215
|
-
/**
|
|
216
|
-
* TODO: Comments
|
|
217
|
-
*/
|
|
218
|
-
fundRawTransaction(hexstring: string, options: FundRawTxOptions): Promise<FundRawTxResult>;
|
|
219
|
-
/**
|
|
220
|
-
* Sign inputs for raw transaction (serialized, hex-encoded).
|
|
221
|
-
* The second optional argument (may be null) is an array of previous transaction outputs that
|
|
222
|
-
* this transaction depends on but may not yet be in the block chain.
|
|
223
|
-
* Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.
|
|
224
|
-
* @param {string} hexstring The hex-encoded transaction to send.
|
|
225
|
-
*/
|
|
226
|
-
signRawTransaction(hexstring: string): Promise<SignedRawTx>;
|
|
227
|
-
/**
|
|
228
|
-
* Submit a raw transaction (serialized, hex-encoded) to local node and network.
|
|
229
|
-
*
|
|
230
|
-
* The transaction will be sent unconditionally to all peers, so using sendrawtransaction
|
|
231
|
-
* for manual rebroadcast may degrade privacy by leaking the transaction's origin, as
|
|
232
|
-
* nodes will normally not rebroadcast non-wallet transactions already in their mempool.
|
|
233
|
-
*
|
|
234
|
-
* @param {string} hexstring The hex-encoded transaction to send.
|
|
235
|
-
* @param {numbner} [maxfeerate] If not passed, default is 0.10.
|
|
236
|
-
* @returns {Promise<string>} A promise resolving to the transaction hash in hex.
|
|
237
|
-
*/
|
|
238
|
-
sendRawTransaction(hexstring: string, maxfeerate?: number | string, maxBurnAmount?: number | string): Promise<string>;
|
|
239
|
-
/**
|
|
240
|
-
* Combines calls to `signRawTransaction` and `sendRawTransaction`.
|
|
241
|
-
* @param {string} params.hexstring The hex-encoded transaction to send.
|
|
242
|
-
* @returns {Promise<string>} A promise resolving to the transaction hash in hex.
|
|
243
|
-
*/
|
|
244
|
-
signAndSendRawTransaction(hexstring: string): Promise<string>;
|
|
245
|
-
/**
|
|
246
|
-
* Combines calls to `createRawTransaction`, `signRawTransaction` and `sendRawTransaction`.
|
|
247
|
-
* @param {CreateRawTxInputs[]} inputs The inputs to the transaction (required).
|
|
248
|
-
* @param {CreateRawTxOutputs[]} outputs The outputs of the transaction (required).
|
|
249
|
-
* @returns {Promise<string>} A promise resolving to the transaction hash in hex.
|
|
250
|
-
*/
|
|
251
|
-
createSignSendRawTransaction(inputs: CreateRawTxInputs[], outputs: CreateRawTxOutputs[]): Promise<string>;
|
|
252
|
-
/**
|
|
253
|
-
* TODO: Comments
|
|
254
|
-
*/
|
|
255
|
-
listTransactions(params: ListTransactionsParams): Promise<ListTransactionsResult>;
|
|
256
|
-
/**
|
|
257
|
-
* TODO: Comments
|
|
258
|
-
*/
|
|
259
|
-
decodeRawTransaction(hexstring: string): Promise<DecodedRawTransaction>;
|
|
260
|
-
/**
|
|
261
|
-
* TODO: Comments
|
|
262
|
-
*/
|
|
263
|
-
combineRawTransaction(txs: string[]): Promise<string>;
|
|
264
|
-
/**
|
|
265
|
-
* Create a transaction spending the given inputs and creating new outputs.
|
|
266
|
-
* Outputs can be addresses or data.
|
|
267
|
-
* Returns hex-encoded raw transaction.
|
|
268
|
-
* Note that the transaction's inputs are not signed, and
|
|
269
|
-
* it is not stored in the wallet or transmitted to the network.
|
|
270
|
-
* @param {TxInForCreateRaw[]} inputs The inputs to the transaction (required).
|
|
271
|
-
* @param {CreateRawTxOutputs[]} outputs The outputs of the transaction (required).
|
|
272
|
-
* @param {number} [locktime] The locktime of the transaction (optional).
|
|
273
|
-
* @param {boolean} [replacable] Whether the transaction is replaceable (optional).
|
|
274
|
-
* @returns {string} The hex-encoded raw transaction.
|
|
275
|
-
*/
|
|
276
|
-
createRawTransaction(inputs: CreateRawTxInputs[], outputs: CreateRawTxOutputs[], locktime?: number, replacable?: boolean): Promise<string>;
|
|
277
|
-
/**
|
|
278
|
-
* Creates a multi-signature address with n signature of m keys required.
|
|
279
|
-
*
|
|
280
|
-
* @param {CreateMultisigParams} params The parameters for the createMultisig command.
|
|
281
|
-
* @param {number} params.nrequired The number of required signatures out of the n keys (required).
|
|
282
|
-
* @param {string[]} params.keys The hex-encoded public keys (required).
|
|
283
|
-
* @param {?string} params.address_type The address type to use (optional, options=["legacy", "p2sh-segwit", "bech32"], default="legacy").
|
|
284
|
-
* @returns {CreateMultiSigResult} json object with the address and redeemScript.
|
|
285
|
-
*
|
|
286
|
-
* @example Create a multisig address from 2 public keys
|
|
287
|
-
* ```
|
|
288
|
-
* const bob = BitcoinRpc.connect();
|
|
289
|
-
* const keys = [
|
|
290
|
-
* '03789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd',
|
|
291
|
-
* '03dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a61626'
|
|
292
|
-
* ];
|
|
293
|
-
* const multisig = await bob.createMultisig({ nrequired: 2, keys });
|
|
294
|
-
* ```
|
|
295
|
-
*/
|
|
296
|
-
createMultisig({ nrequired, keys, address_type }: CreateMultisigParams): Promise<CreateMultiSigResult>;
|
|
297
|
-
/**
|
|
298
|
-
* TODO: Comments
|
|
299
|
-
*/
|
|
300
|
-
getDescriptorInfo(descriptor: string): Promise<any>;
|
|
301
|
-
/**
|
|
302
|
-
* TODO: Comments
|
|
303
|
-
*/
|
|
304
|
-
signMessageWithPrivkey(privkey: string, message: string): Promise<BitcoinSignature>;
|
|
305
|
-
/**
|
|
306
|
-
* TODO: Comments
|
|
307
|
-
*/
|
|
308
|
-
validateAddress(address: string): Promise<ValidateAddressResult>;
|
|
309
|
-
/**
|
|
310
|
-
* TODO: Comments
|
|
311
|
-
*/
|
|
312
|
-
verifyMessage(address: string, signature: string, message: string): Promise<boolean>;
|
|
313
|
-
/**
|
|
314
|
-
* Derives one or more addresses corresponding to an output descriptor.
|
|
315
|
-
* Examples of output descriptors are:
|
|
316
|
-
* pkh(<pubkey>) P2PKH outputs for the given pubkey
|
|
317
|
-
* wpkh(<pubkey>) Native segwit P2PKH outputs for the given pubkey
|
|
318
|
-
* sh(multi(<n>,<pubkey>,<pubkey>,...)) P2SH-multisig outputs for the given threshold and pubkeys
|
|
319
|
-
* raw(<hex script>) Outputs whose output script equals the specified hex-encoded bytes
|
|
320
|
-
* tr(<pubkey>,multi_a(<n>,<pubkey>,<pubkey>,...)) P2TR-multisig outputs for the given threshold and pubkeys
|
|
321
|
-
*
|
|
322
|
-
* In the above, <pubkey> either refers to a fixed public key in hexadecimal notation, or to an xpub/xprv optionally followed by one
|
|
323
|
-
* or more path elements separated by "/", where "h" represents a hardened child key.
|
|
324
|
-
*
|
|
325
|
-
* See {@link https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md | github.com/bitcoin/bitcoin/descriptors.md}
|
|
326
|
-
* for more information.
|
|
327
|
-
* @async
|
|
328
|
-
* @param {string} descriptor The descriptor.
|
|
329
|
-
* @param {Array<number>} range If descriptor is ranged, must specify end or [begin,end] to derive.
|
|
330
|
-
* @returns {Array<DerivedAddresses>} a list of derived addresses
|
|
331
|
-
* @example First three native segwit receive addresses
|
|
332
|
-
* ```
|
|
333
|
-
* const bitcoind = BitcoinRpc.connect()
|
|
334
|
-
* const addresses = bitcoind.deriveAddresses("wpkh([d34db33f/84h/0h/0h]xpub6DJ2dN.../0/*)#cjjspncu", [0,2])
|
|
335
|
-
* ```
|
|
336
|
-
*/
|
|
337
|
-
deriveAddresses(descriptor: string, range?: Array<number>): Promise<Array<DerivedAddresses>>;
|
|
338
|
-
/**
|
|
339
|
-
* TODO: Comments
|
|
340
|
-
*/
|
|
341
|
-
addMultisigAddress(): Promise<any>;
|
|
342
|
-
/**
|
|
343
|
-
* Creates the wallet's descriptor for the given address type. The address type must be one that the
|
|
344
|
-
* wallet does not already have a descriptor for. Requires wallet passphrase to be set with walletpassphrase call
|
|
345
|
-
* if wallet is encrypted.
|
|
346
|
-
* @param type The address type the descriptor will produce. Options are "legacy", "p2sh-segwit", "bech32", and "bech32m". (string, required)
|
|
347
|
-
* @param options Options object that can be used to pass named arguments, listed below. (json object, optional)
|
|
348
|
-
* @param options.internal Whether to only make one descriptor that is internal (if parameter is true) or external (if parameter is false)
|
|
349
|
-
* (boolean, optional, default=Both external and internal will be generated unless this parameter is specified)
|
|
350
|
-
* @param options.hdkey The HD key that the wallet knows the private key of, listed using 'gethdkeys', to use for this descriptor's key.
|
|
351
|
-
* (string, optional, default=The HD key used by all other active descriptors)
|
|
352
|
-
* @returns A {@link CreateWalletDescriptorsResult} response object
|
|
353
|
-
*/
|
|
354
|
-
createWalletDescriptor(type: string, options: CreateWalletDescriptorOptions): Promise<CreateWalletDescriptorsResult>;
|
|
355
|
-
/**
|
|
356
|
-
* TODO: Comments
|
|
357
|
-
*/
|
|
358
|
-
getBalance(): Promise<any>;
|
|
359
|
-
/**
|
|
360
|
-
* TODO: Comments
|
|
361
|
-
*/
|
|
362
|
-
getNewAddress(account?: string): Promise<string>;
|
|
363
|
-
/**
|
|
364
|
-
* TODO: Comments
|
|
365
|
-
*/
|
|
366
|
-
importAddress(script: string, label?: string, rescan?: boolean, p2sh?: boolean): Promise<void>;
|
|
367
|
-
/**
|
|
368
|
-
* Import descriptors.
|
|
369
|
-
*
|
|
370
|
-
* This will trigger a rescan of the blockchain based on the earliest timestamp of all descriptors being imported.
|
|
371
|
-
* Requires a new wallet backup. Note: This call can take over an hour to complete if using an early timestamp;
|
|
372
|
-
* during that time, other rpc calls may report that the imported keys, addresses or scripts exist but related
|
|
373
|
-
* transactions are still missing. The rescan is significantly faster if block filters are available
|
|
374
|
-
* (using startup option "-blockfilterindex=1").
|
|
375
|
-
*
|
|
376
|
-
* @param requests Array of {@link ImportDescriptorRequest} objects to be imported
|
|
377
|
-
* @returns Array of {@link ImportDescriptorResult} objects
|
|
378
|
-
* @returns
|
|
379
|
-
*/
|
|
380
|
-
importDescriptors(requests: Array<ImportDescriptorRequest>): Promise<any>;
|
|
381
|
-
/**
|
|
382
|
-
* TODO: Comments
|
|
383
|
-
*/
|
|
384
|
-
importMulti(requests: ImportMultiRequest[], options?: ImportMultiOptions): Promise<Array<ImportMultiResult>>;
|
|
385
|
-
/**
|
|
386
|
-
* TODO: Comments
|
|
387
|
-
*/
|
|
388
|
-
listUnspent(params: ListUnspentParams): Promise<UnspentTxInfo[]>;
|
|
389
|
-
/**
|
|
390
|
-
* TODO: Comments
|
|
391
|
-
*/
|
|
392
|
-
rescanBlockchain(): Promise<any>;
|
|
393
|
-
/**
|
|
394
|
-
* Send an amount to a given address.
|
|
395
|
-
* @async
|
|
396
|
-
* @param {string} address The address to send to.
|
|
397
|
-
* @param {number} amount The amount to send in BTC.
|
|
398
|
-
* @returns {Promise<SendToAddressResult>} A promise resolving to the transaction id.
|
|
399
|
-
*/
|
|
400
|
-
sendToAddress(address: string, amount: number): Promise<RawTransactionV2>;
|
|
401
|
-
/**
|
|
402
|
-
* TODO: Comments
|
|
403
|
-
*/
|
|
404
|
-
signMessage(): Promise<any>;
|
|
405
|
-
/**
|
|
406
|
-
* TODO: Comments
|
|
407
|
-
*/
|
|
408
|
-
signRawTransactionWithWallet(): Promise<any>;
|
|
409
|
-
/**
|
|
410
|
-
* TODO: Comments
|
|
411
|
-
*/
|
|
412
|
-
send(): Promise<any>;
|
|
413
|
-
/**
|
|
414
|
-
* @warning EXPERIMENTAL this call may be changed in future releases.
|
|
415
|
-
*
|
|
416
|
-
* Spend the value of all (or specific) confirmed UTXOs & unconfirmed change in the wallet to one or
|
|
417
|
-
* more recipients. Unconfirmed inbound UTXOs and locked UTXOs will not be spent. Sendall will respect the
|
|
418
|
-
* avoid_reuse wallet flag. If your wallet contains many small inputs, either because it received tiny payments or as
|
|
419
|
-
* a result of accumulating change, consider using `send_max` to exclude inputs that are worth less than the fees
|
|
420
|
-
* needed to spend them.
|
|
421
|
-
*
|
|
422
|
-
* @param {SendAllParams} params The parameters for the sendAll command.
|
|
423
|
-
* @param {Recipients} params.recipients The recipient destination addresses.
|
|
424
|
-
* Each address may only appear once. Optionally some recipients can be specified with an
|
|
425
|
-
* amount to perform payments, but at least one address must appear without a specified amount.
|
|
426
|
-
* @param {SendAllOptions} params.options Options object that can be used to pass named arguments.
|
|
427
|
-
* @param {} params.options.conf_target Confirmation target in blocks. numeric, optional, default=wallet -txconfirmtarget.
|
|
428
|
-
* @param estimate_mode The fee estimate mode, must be one of (case insensitive). string, optional, default="unset".
|
|
429
|
-
* See {@link FeeEstimateMode} for possible values.
|
|
430
|
-
* @param fee_rate Specify a fee rate in sat/vB. numeric or string, optional, default=not set,
|
|
431
|
-
* falls back to wallet fee estimation
|
|
432
|
-
* @param options: Options object that can be used to pass named arguments. json object, optional
|
|
433
|
-
*
|
|
434
|
-
* @returns A promise resolving to a {@link SendAllResult} object
|
|
435
|
-
*
|
|
436
|
-
* @example
|
|
437
|
-
* Spend all UTXOs from the wallet with a fee rate of 1 sat/vB using named arguments
|
|
438
|
-
* const bob = BitcoinRpc.connect({
|
|
439
|
-
* username: 'bob',
|
|
440
|
-
* password: 'bobpass',
|
|
441
|
-
* host: 'http://127.0.0.1:18443',
|
|
442
|
-
* allowDefaultWallet: true,
|
|
443
|
-
* version: '28.1.0'
|
|
444
|
-
* });
|
|
445
|
-
* const sendall = await bob.sendAll({
|
|
446
|
-
* recipients: [
|
|
447
|
-
* 'bc1q09vm5lfy0j5reeulh4x5752q25uqqvz34hufdl',
|
|
448
|
-
* 'bc1q02ad21edsxd23d32dfgqqsz4vv4nmtfzuklhy3'
|
|
449
|
-
* ],
|
|
450
|
-
* options: { fee_rate: 1.1 }
|
|
451
|
-
* });
|
|
452
|
-
*/
|
|
453
|
-
sendAll(params: SendAllParams): Promise<SendAllResult>;
|
|
454
|
-
/**
|
|
455
|
-
* TODO: Comments
|
|
456
|
-
*/
|
|
457
|
-
sendMany(params: SendManyParams): Promise<string>;
|
|
458
|
-
/**
|
|
459
|
-
* Get detailed information about in-wallet transaction <txid>.
|
|
460
|
-
* @param txid: The transaction id. (string, required)
|
|
461
|
-
* @param {boolean} include_watchonly Whether to include watch-only addresses in balance calculation and details.
|
|
462
|
-
* @returns {WalletTransaction} A promise resolving to a {@link WalletTransaction} object.
|
|
463
|
-
*/
|
|
464
|
-
getTransaction(txid: string, include_watchonly?: boolean): Promise<WalletTransaction>;
|
|
465
|
-
/**
|
|
466
|
-
* Get detailed information about a transaction.
|
|
467
|
-
*
|
|
468
|
-
* By default, this call only returns a transaction if it is in the mempool. If -txindex is enabled
|
|
469
|
-
* and no blockhash argument is passed, it will return the transaction if it is in the mempool or any block.
|
|
470
|
-
* If a blockhash argument is passed, it will return the transaction if the specified block is available and
|
|
471
|
-
* the transaction is in that block.
|
|
472
|
-
* @async
|
|
473
|
-
* @param {string} txid The transaction id (required).
|
|
474
|
-
* @param {?VerbosityLevel} verbosity Response format: 0 (hex), 1 (json) or 2 (jsonext).
|
|
475
|
-
* @param {?string} blockhash The block in which to look for the transaction (optional).
|
|
476
|
-
* @returns {GetRawTransaction} A promise resolving to data about a transaction in the form specified by verbosity.
|
|
477
|
-
*/
|
|
478
|
-
getRawTransaction(txid: string, verbosity?: VerbosityLevel, blockhash?: string): Promise<RawTransactionResponse>;
|
|
479
|
-
/**
|
|
480
|
-
* Get detailed information about multiple transactions. An extension of {@link getRawTransaction}.
|
|
481
|
-
*
|
|
482
|
-
* @async
|
|
483
|
-
* @param {Array<string>} txids An array of transaction ids.
|
|
484
|
-
* @param {?VerbosityLevel} verbosity Response format: 0 (hex), 1 (json) or 2 (jsonext).
|
|
485
|
-
* @returns {Promise<Array<RawTransactionResponse>>}
|
|
486
|
-
*/
|
|
487
|
-
getRawTransactions(txids: string[], verbosity?: VerbosityLevel): Promise<RawTransactionResponse[]>;
|
|
488
|
-
clearBanned(): Promise<void>;
|
|
489
|
-
disconnectNode(address?: string, nodeid?: number): Promise<void>;
|
|
490
|
-
dumpPrivKey(address: string): Promise<string>;
|
|
491
|
-
dumpWallet(filename: string): Promise<{
|
|
492
|
-
filename: string;
|
|
493
|
-
}>;
|
|
494
|
-
encryptWallet(passphrase: string): Promise<void>;
|
|
495
|
-
estimateSmartFee(conf_target: number, estimate_mode?: FeeEstimateMode): Promise<{
|
|
496
|
-
feerate?: number;
|
|
497
|
-
errors?: string[];
|
|
498
|
-
blocks?: number;
|
|
499
|
-
}>;
|
|
500
|
-
getConnectionCount(): Promise<number>;
|
|
501
|
-
getDifficulty(): Promise<number>;
|
|
502
|
-
getMempoolInfo(): Promise<MempoolInfo>;
|
|
503
|
-
getMiningInfo(): Promise<MiningInfo>;
|
|
504
|
-
getPeerInfo(): Promise<PeerInfo[]>;
|
|
505
|
-
walletLock(passphrase: string, timeout: number): Promise<void>;
|
|
506
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-client.d.ts","sourceRoot":"","sources":["../../src/rpc-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,wBAAwB,EAExB,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,aAAa,EAKb,cAAc,EACd,aAAa,EACb,SAAS,EACT,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,6BAA6B,EAC7B,6BAA6B,EAC7B,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,cAAc,EACd,aAAa,EACb,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,WAAW,EAEX,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,sBAAsB,EAGtB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,aAAa,EACb,cAAc,EACd,WAAW,EACX,aAAa,EACb,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;;GAKG;AACH,qBAAa,UAAW,YAAW,WAAW;IAC5C;;;;;OAKG;IACH,OAAO,CAAC,OAAO,CAAY;IAE3B;;;;;OAKG;IACH,OAAO,CAAC,OAAO,CAAkB;IAEjC;;;;;;;;OAQG;gBACS,MAAM,EAAE,eAAe;IAKnC;;;;;;;;;OASG;IACH,IAAI,MAAM,IAAI,eAAe,CAG5B;IAED;;;;;;;;OAQG;IACH,IAAI,M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AAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhE,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI7C,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;KAAE,CAAC;IAI5D,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhD,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;KAAE,CAAC;IAI1I,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAIrC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAIhC,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC;IAItC,aAAa,IAAI,OAAO,CAAC,UAAU,CAAC;IAIpC,WAAW,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAIlC,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG/D"}
|
package/src/bitcoin.node.ts
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { MethodError } from '@did-btcr2/common';
|
|
2
|
-
import { networks } from 'bitcoinjs-lib';
|
|
3
|
-
import { DEFAULT_REST_CLIENT_CONFIG, DEFAULT_RPC_CLIENT_CONFIG } from './constants.js';
|
|
4
|
-
import { getNetwork } from './network.js';
|
|
5
|
-
import { BitcoinRest } from './rest-client.js';
|
|
6
|
-
import { BitcoinRpc } from './rpc-client.js';
|
|
7
|
-
import { AvailableNetworks, BitcoinClientConfig } from './types.js';
|
|
8
|
-
|
|
9
|
-
export type BitcoinNetworkConfig = {
|
|
10
|
-
name: keyof AvailableNetworks;
|
|
11
|
-
rpc: BitcoinRpc;
|
|
12
|
-
rest: BitcoinRest;
|
|
13
|
-
config: BitcoinClientConfig;
|
|
14
|
-
data: networks.Network;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export type BitcoinNetworkConfigMap = {
|
|
18
|
-
[key in keyof AvailableNetworks]?: BitcoinNetworkConfig;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* General class to house the Bitcoin client connections, client config and various utility methods.
|
|
23
|
-
* @name Bitcoin
|
|
24
|
-
* @type {Bitcoin}
|
|
25
|
-
*/
|
|
26
|
-
export class Bitcoin {
|
|
27
|
-
public network: BitcoinNetworkConfig;
|
|
28
|
-
public mainnet?: BitcoinNetworkConfig;
|
|
29
|
-
public testnet?: BitcoinNetworkConfig;
|
|
30
|
-
public signet?: BitcoinNetworkConfig;
|
|
31
|
-
public mutinynet?: BitcoinNetworkConfig;
|
|
32
|
-
public regtest?: BitcoinNetworkConfig;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Creates an instance of the Bitcoin class.
|
|
36
|
-
* @param {BitcoinNetworkConfigMap} configs Optional configuration object for the Bitcoin client. If not provided, it will
|
|
37
|
-
* be loaded from the BITCOIN_CLIENT_CONFIG environment variables.
|
|
38
|
-
* @throws {MethodError} If no configs is passed and BITCOIN_NETWORK_CONFIG is missing or invalid.
|
|
39
|
-
*/
|
|
40
|
-
constructor(configs?: BitcoinNetworkConfigMap) {
|
|
41
|
-
const BITCOIN_NETWORK_CONFIG = process.env.BITCOIN_NETWORK_CONFIG ?? JSON.stringify(configs ?? {
|
|
42
|
-
regtest : {
|
|
43
|
-
rpc : DEFAULT_RPC_CLIENT_CONFIG,
|
|
44
|
-
rest : DEFAULT_REST_CLIENT_CONFIG
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
if(!BITCOIN_NETWORK_CONFIG) {
|
|
49
|
-
throw new MethodError(
|
|
50
|
-
'No BITCOIN_NETWORK_CONFIG available: must pass `configs` to constructor or set `BITCOIN_NETWORK_CONFIG` in env',
|
|
51
|
-
'MISSING_BITCOIN_NETWORK_CONFIG',
|
|
52
|
-
{ BITCOIN_NETWORK_CONFIG }
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Check if BITCOIN_NETWORK_CONFIG is parsable JSON string
|
|
57
|
-
if (!JSON.parsable(BITCOIN_NETWORK_CONFIG)) {
|
|
58
|
-
throw new MethodError(
|
|
59
|
-
'Parsing failed: malformed BITCOIN_NETWORK_CONFIG',
|
|
60
|
-
'MISSING_MALFORMED_BITCOIN_NETWORK_CONFIG',
|
|
61
|
-
{ BITCOIN_NETWORK_CONFIG }
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Parse the BITCOIN_NETWORK_CONFIG
|
|
66
|
-
const networkConfigs: Record<string, BitcoinClientConfig> = JSON.parse(BITCOIN_NETWORK_CONFIG);
|
|
67
|
-
|
|
68
|
-
// Set a list of available networks
|
|
69
|
-
const networks: (keyof AvailableNetworks)[] = ['mainnet', 'testnet', 'signet', 'mutinynet', 'regtest'];
|
|
70
|
-
|
|
71
|
-
// Iterate over the networks and create the client connections
|
|
72
|
-
for (const network of networks) {
|
|
73
|
-
const networkConfig: BitcoinClientConfig = (configs?.[network] ?? networkConfigs[network]) as BitcoinClientConfig;
|
|
74
|
-
if (networkConfig) {
|
|
75
|
-
this[network] = {
|
|
76
|
-
name : network,
|
|
77
|
-
config : networkConfig,
|
|
78
|
-
rpc : new BitcoinRpc(networkConfig.rpc ?? DEFAULT_RPC_CLIENT_CONFIG),
|
|
79
|
-
rest : new BitcoinRest(networkConfig.rest ?? DEFAULT_REST_CLIENT_CONFIG) ,
|
|
80
|
-
data : getNetwork(network),
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Load and check the ACTIVE_NETWORK variable
|
|
86
|
-
const ACTIVE_NETWORK = (process.env.ACTIVE_NETWORK?.toLowerCase() ?? 'regtest') as keyof AvailableNetworks;
|
|
87
|
-
if (!ACTIVE_NETWORK) {
|
|
88
|
-
throw new MethodError('Missing ACTIVE_NETWORK environment variable', 'MISSING_ACTIVE_NETWORK', { ACTIVE_NETWORK });
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (!this[ACTIVE_NETWORK]) {
|
|
93
|
-
throw new MethodError(
|
|
94
|
-
`No configuration found for ACTIVE_NETWORK='${ACTIVE_NETWORK}'`,
|
|
95
|
-
'MISSING_CONFIG_FOR_NETWORK'
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
this.network = this[ACTIVE_NETWORK];
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Converts Bitcoin (BTC) to satoshis (SAT).
|
|
104
|
-
* @param {number} btc - The amount in BTC.
|
|
105
|
-
* @returns {number} The amount in SAT.
|
|
106
|
-
*/
|
|
107
|
-
public static btcToSats (btc: number): number {
|
|
108
|
-
return Math.round(btc * 1e8);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Converts satoshis (SAT) to Bitcoin (BTC).
|
|
113
|
-
* @param {number} sats - The amount in SAT.
|
|
114
|
-
* @returns {number} The amount in BTC.
|
|
115
|
-
*/
|
|
116
|
-
public static satsToBtc (sats: number): number {
|
|
117
|
-
return sats / 1e8;
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export const bitcoin = new Bitcoin();
|
package/src/index.browser.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from './bitcoin.browser.js';
|
|
2
|
-
export * from './constants.js';
|
|
3
|
-
export * from './errors.js';
|
|
4
|
-
export * from './interface.js';
|
|
5
|
-
export * from './network.js';
|
|
6
|
-
export * from './rest-client.js';
|
|
7
|
-
export * from './rpc-client.js';
|
|
8
|
-
export * from './taproot.js';
|
|
9
|
-
export * from './types.js';
|
package/src/index.node.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from './bitcoin.node.js';
|
|
2
|
-
export * from './constants.js';
|
|
3
|
-
export * from './errors.js';
|
|
4
|
-
export * from './interface.js';
|
|
5
|
-
export * from './network.js';
|
|
6
|
-
export * from './rest-client.js';
|
|
7
|
-
export * from './rpc-client.js';
|
|
8
|
-
export * from './taproot.js';
|
|
9
|
-
export * from './types.js';
|