@did-btcr2/bitcoin 0.3.4 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/dist/cjs/bitcoin.js +83 -84
  2. package/dist/cjs/bitcoin.js.map +1 -1
  3. package/dist/cjs/client/http.js +9 -0
  4. package/dist/cjs/client/http.js.map +1 -0
  5. package/dist/cjs/client/rest/address.js +20 -28
  6. package/dist/cjs/client/rest/address.js.map +1 -1
  7. package/dist/cjs/client/rest/block.js +23 -22
  8. package/dist/cjs/client/rest/block.js.map +1 -1
  9. package/dist/cjs/client/rest/index.js +31 -84
  10. package/dist/cjs/client/rest/index.js.map +1 -1
  11. package/dist/cjs/client/rest/protocol.js +129 -0
  12. package/dist/cjs/client/rest/protocol.js.map +1 -0
  13. package/dist/cjs/client/rest/transaction.js +19 -21
  14. package/dist/cjs/client/rest/transaction.js.map +1 -1
  15. package/dist/cjs/client/rpc/index.js +75 -337
  16. package/dist/cjs/client/rpc/index.js.map +1 -1
  17. package/dist/cjs/client/rpc/interface.js +1 -6
  18. package/dist/cjs/client/rpc/interface.js.map +1 -1
  19. package/dist/cjs/client/rpc/json-rpc.js +40 -63
  20. package/dist/cjs/client/rpc/json-rpc.js.map +1 -1
  21. package/dist/cjs/client/rpc/protocol.js +134 -0
  22. package/dist/cjs/client/rpc/protocol.js.map +1 -0
  23. package/dist/cjs/constants.js +16 -5
  24. package/dist/cjs/constants.js.map +1 -1
  25. package/dist/cjs/errors.js.map +1 -1
  26. package/dist/cjs/index.js +21 -13
  27. package/dist/cjs/index.js.map +1 -1
  28. package/dist/cjs/types.js +5 -55
  29. package/dist/cjs/types.js.map +1 -1
  30. package/dist/esm/bitcoin.js +83 -84
  31. package/dist/esm/bitcoin.js.map +1 -1
  32. package/dist/esm/client/http.js +9 -0
  33. package/dist/esm/client/http.js.map +1 -0
  34. package/dist/esm/client/rest/address.js +20 -28
  35. package/dist/esm/client/rest/address.js.map +1 -1
  36. package/dist/esm/client/rest/block.js +23 -22
  37. package/dist/esm/client/rest/block.js.map +1 -1
  38. package/dist/esm/client/rest/index.js +31 -84
  39. package/dist/esm/client/rest/index.js.map +1 -1
  40. package/dist/esm/client/rest/protocol.js +129 -0
  41. package/dist/esm/client/rest/protocol.js.map +1 -0
  42. package/dist/esm/client/rest/transaction.js +19 -21
  43. package/dist/esm/client/rest/transaction.js.map +1 -1
  44. package/dist/esm/client/rpc/index.js +75 -337
  45. package/dist/esm/client/rpc/index.js.map +1 -1
  46. package/dist/esm/client/rpc/interface.js +1 -6
  47. package/dist/esm/client/rpc/interface.js.map +1 -1
  48. package/dist/esm/client/rpc/json-rpc.js +40 -63
  49. package/dist/esm/client/rpc/json-rpc.js.map +1 -1
  50. package/dist/esm/client/rpc/protocol.js +134 -0
  51. package/dist/esm/client/rpc/protocol.js.map +1 -0
  52. package/dist/esm/constants.js +16 -5
  53. package/dist/esm/constants.js.map +1 -1
  54. package/dist/esm/errors.js.map +1 -1
  55. package/dist/esm/index.js +21 -13
  56. package/dist/esm/index.js.map +1 -1
  57. package/dist/esm/types.js +5 -55
  58. package/dist/esm/types.js.map +1 -1
  59. package/dist/types/bitcoin.d.ts +66 -45
  60. package/dist/types/bitcoin.d.ts.map +1 -1
  61. package/dist/types/client/http.d.ts +21 -0
  62. package/dist/types/client/http.d.ts.map +1 -0
  63. package/dist/types/client/rest/address.d.ts +16 -19
  64. package/dist/types/client/rest/address.d.ts.map +1 -1
  65. package/dist/types/client/rest/block.d.ts +24 -16
  66. package/dist/types/client/rest/block.d.ts.map +1 -1
  67. package/dist/types/client/rest/index.d.ts +20 -51
  68. package/dist/types/client/rest/index.d.ts.map +1 -1
  69. package/dist/types/client/rest/protocol.d.ts +58 -0
  70. package/dist/types/client/rest/protocol.d.ts.map +1 -0
  71. package/dist/types/client/rest/transaction.d.ts +16 -17
  72. package/dist/types/client/rest/transaction.d.ts.map +1 -1
  73. package/dist/types/client/rpc/index.d.ts +105 -253
  74. package/dist/types/client/rpc/index.d.ts.map +1 -1
  75. package/dist/types/client/rpc/interface.d.ts +1 -4
  76. package/dist/types/client/rpc/interface.d.ts.map +1 -1
  77. package/dist/types/client/rpc/json-rpc.d.ts +20 -18
  78. package/dist/types/client/rpc/json-rpc.d.ts.map +1 -1
  79. package/dist/types/client/rpc/protocol.d.ts +82 -0
  80. package/dist/types/client/rpc/protocol.d.ts.map +1 -0
  81. package/dist/types/constants.d.ts +16 -5
  82. package/dist/types/constants.d.ts.map +1 -1
  83. package/dist/types/errors.d.ts +4 -3
  84. package/dist/types/errors.d.ts.map +1 -1
  85. package/dist/types/index.d.ts +20 -13
  86. package/dist/types/index.d.ts.map +1 -1
  87. package/dist/types/types.d.ts +98 -696
  88. package/dist/types/types.d.ts.map +1 -1
  89. package/package.json +3 -3
  90. package/src/bitcoin.ts +105 -118
  91. package/src/client/http.ts +28 -0
  92. package/src/client/rest/address.ts +24 -30
  93. package/src/client/rest/block.ts +29 -26
  94. package/src/client/rest/index.ts +38 -94
  95. package/src/client/rest/protocol.ts +153 -0
  96. package/src/client/rest/transaction.ts +23 -23
  97. package/src/client/rpc/index.ts +140 -379
  98. package/src/client/rpc/interface.ts +42 -51
  99. package/src/client/rpc/json-rpc.ts +53 -60
  100. package/src/client/rpc/protocol.ts +160 -0
  101. package/src/constants.ts +17 -5
  102. package/src/errors.ts +10 -3
  103. package/src/index.ts +81 -13
  104. package/src/types.ts +332 -972
@@ -1,4 +1,6 @@
1
- import { Hex, UnixTimestamp } from '@did-btcr2/common';
1
+ import { UnixTimestamp } from '@did-btcr2/common';
2
+ /** Bitcoin network names supported by this package. */
3
+ export type NetworkName = 'bitcoin' | 'testnet3' | 'testnet4' | 'signet' | 'mutinynet' | 'regtest';
2
4
  export type TransactionStatus = {
3
5
  confirmed: boolean;
4
6
  block_height: number;
@@ -58,224 +60,81 @@ export interface AddressUtxo {
58
60
  status: TransactionStatus;
59
61
  value: number;
60
62
  }
61
- export interface RestClientConfigParams {
62
- host: string;
63
- headers?: {
64
- [key: string]: string;
65
- };
63
+ /** Block data as returned by the Esplora REST API. */
64
+ export interface EsploraBlock {
65
+ id: string;
66
+ height: number;
67
+ version: number;
68
+ timestamp: number;
69
+ tx_count: number;
70
+ size: number;
71
+ weight: number;
72
+ merkle_root: string;
73
+ previousblockhash: string;
74
+ mediantime: number;
75
+ nonce: number;
76
+ bits: number;
77
+ difficulty: number;
66
78
  }
67
- export declare class RestClientConfig {
79
+ export interface RestConfig {
68
80
  host: string;
69
- headers?: {
70
- [key: string]: string;
71
- };
72
- constructor({ host, headers }: RestClientConfigParams);
81
+ headers?: Record<string, string>;
73
82
  }
74
83
  export interface RestApiCallParams {
75
84
  path: string;
76
85
  url?: string;
77
- method?: string;
78
- body?: any;
79
- headers?: any;
80
- }
81
- export interface RestResponse extends Response {
82
- [key: string]: any;
83
- }
84
- export type BitcoinClientConfig = {
85
- rpc: {
86
- username: string;
87
- password: string;
88
- host: string;
89
- version: string;
90
- allowDefaultWallet: boolean;
91
- };
92
- rest: {
93
- host: string;
94
- headers?: Record<string, string>;
95
- };
96
- };
97
- export type AvailableNetworks = {
98
- bitcoin: true;
99
- testnet3: true;
100
- testnet4: true;
101
- signet: true;
102
- mutinynet: true;
103
- regtest: true;
104
- };
105
- export interface ReturnFormatOptions {
106
- extension?: 'json' | 'bin' | 'hex';
107
- }
108
- export type TxId = string;
109
- export interface BlockHashOptions extends ReturnFormatOptions {
110
- summary?: boolean;
111
- }
112
- export interface RpcClientConfig {
86
+ method?: 'GET' | 'POST';
87
+ body?: string | Record<string, unknown>;
113
88
  headers?: Record<string, string>;
114
- host?: string;
115
- logger?: any;
116
- password?: string;
117
- timeout?: number;
118
- username?: string;
119
- version?: string;
120
- wallet?: string;
121
- allowDefaultWallet?: boolean;
122
89
  }
123
- export declare class BitcoinRpcClientConfig implements RpcClientConfig {
124
- network?: string;
90
+ export type RestResponse = Response;
91
+ export interface RpcConfig {
125
92
  headers?: Record<string, string>;
126
93
  host?: string;
127
- logger?: any;
128
94
  password?: string;
129
- timeout?: number;
130
95
  username?: string;
131
- version?: string;
132
96
  wallet?: string;
133
97
  allowDefaultWallet?: boolean;
134
- constructor(options?: RpcClientConfig);
135
- }
136
- export interface ClientConstructorOption {
137
- agentOptions?: any;
138
- headers?: boolean;
139
- host?: string;
140
- logger?: Function;
141
- network?: 'mainnet' | 'regtest' | 'testnet';
142
- password?: string;
143
- port?: string | number;
144
- ssl?: any;
145
- timeout?: number;
146
- username?: string;
147
- version?: string;
148
98
  }
149
- export type ScriptDecoded = {
150
- asm: string;
151
- hex: string;
152
- type: string;
153
- reqSigs: number;
154
- addresses: string[];
155
- ps2h?: string;
156
- };
157
- export type FundRawTxOptions = {
158
- changeAddress?: string;
159
- chnagePosition?: number;
160
- includeWatching?: boolean;
161
- lockUnspents?: boolean;
162
- feeRate?: number;
163
- subtractFeeFromOutputs?: number[];
164
- replaceable?: boolean;
165
- conf_target?: number;
166
- estimate_mode: FeeEstimateMode;
167
- };
168
- /**
169
- * unset
170
- * - no mode set
171
- * economical
172
- * - used if the transaction is replaceable
173
- * - uses shorter time horizon to estimate
174
- * - more responsive to short-term drops in the prevailing fee market
175
- * - potentially returns a lower fee rate estimate
176
- * conservative
177
- * - used is the transaction is not replaceable
178
- * - use a longer time horizon to estimate
179
- * - less responsive to short-term drops in the prevailing fee market
180
- * - potentially returns a higher fee rate estimate
181
- */
182
99
  export type FeeEstimateMode = 'UNSET' | 'ECONOMICAL' | 'CONSERVATIVE';
183
- export type TxStats = {
184
- time: number;
185
- txcount: number;
186
- window_final_block_hash?: string;
187
- window_block_count?: number;
188
- window_tx_count?: number;
189
- window_interval?: number;
190
- txrate: number;
191
- };
192
- export type AddedNodeInfo = {
193
- addednode: string;
194
- connected: boolean;
195
- addresses: {
196
- address: string;
197
- connected: 'inbound' | 'outbound';
198
- }[];
199
- };
200
- export type MemoryStats = {
201
- locked: {
202
- used: number;
203
- free: number;
204
- total: number;
205
- locked: number;
206
- chunks_used: number;
207
- chunks_free: number;
100
+ export type TxIn = {
101
+ coinbase?: string;
102
+ txid?: string;
103
+ vout?: number;
104
+ scriptSig?: {
105
+ asm: string;
106
+ hex: string;
208
107
  };
108
+ txinwitness?: string[];
109
+ sequence: number;
209
110
  };
210
- export type NetworkInfo = {
211
- version: number;
212
- subversion: string;
213
- protocolversion: number;
214
- localservices: string;
215
- localrelay: boolean;
216
- timeoffset: number;
217
- connections: number;
218
- networkactive: boolean;
219
- networks: {
220
- name: string;
221
- limited: boolean;
222
- reachable: boolean;
223
- proxy: string;
224
- proxy_randomize_credentials: boolean;
225
- }[];
226
- relayfee: number;
227
- incrementalfee: number;
228
- localaddresses: {
229
- address: string;
230
- port: number;
231
- score: number;
232
- }[];
233
- warnings?: string;
234
- };
235
- export type PeerInfo = {
236
- id: number;
237
- addr: string;
238
- addrbind: string;
239
- addrlocal: string;
240
- services: string;
241
- relaytxs: boolean;
242
- lastsend: number;
243
- lastrecv: number;
244
- bytessent: number;
245
- bytesrecv: number;
246
- conntime: number;
247
- timeoffset: number;
248
- pingtime: number;
249
- minping: number;
250
- version: number;
251
- subver: string;
252
- inbound: boolean;
253
- addnode: boolean;
254
- startinheight: number;
255
- banscore: number;
256
- synced_headers: number;
257
- synced_blocks: number;
258
- inflight: number[];
259
- whitelisted: boolean;
260
- bytessent_per_msg: {
261
- [key: string]: number;
262
- };
263
- byterecv_per_msg: {
264
- [key: string]: number;
111
+ export type TxInPrevout = {
112
+ generated: boolean;
113
+ height: number;
114
+ value: number;
115
+ scriptPubKey?: {
116
+ asm: string;
117
+ desc: string;
118
+ hex: string;
119
+ address?: string;
120
+ type: string;
265
121
  };
266
122
  };
267
- export type NetTotals = {
268
- totalbytesrecv: number;
269
- totalbytessent: number;
270
- timemlillis: number;
271
- uploadtarget: {
272
- timeframe: number;
273
- target: number;
274
- target_reached: boolean;
275
- save_historical_blocks: boolean;
276
- bytes_left_in_cycle: number;
277
- time_lef_in_cycle: number;
278
- };
123
+ export interface TxInExt extends TxIn {
124
+ prevout: TxInPrevout;
125
+ }
126
+ export type ScriptPubKey = {
127
+ asm: string;
128
+ hex: string;
129
+ reqSigs: number;
130
+ type: string;
131
+ address?: string;
132
+ desc: string;
133
+ };
134
+ export type TxOut = {
135
+ value: number;
136
+ n: number;
137
+ scriptPubKey: ScriptPubKey;
279
138
  };
280
139
  export type ChainInfo = {
281
140
  chain: string;
@@ -306,125 +165,6 @@ export type ChainInfo = {
306
165
  }[];
307
166
  warnings?: string;
308
167
  };
309
- export type ChainTip = {
310
- height: number;
311
- hash: string;
312
- branchlen: number;
313
- status: 'active' | 'valid-fork' | 'valid-headers' | 'headers-only' | 'invalid';
314
- };
315
- export type Outpoint = {
316
- id: string;
317
- index: number;
318
- };
319
- export type UTXO = {
320
- height: number;
321
- value: number;
322
- scriptPubkey: {
323
- asm: string;
324
- hex: string;
325
- reqSigs: number;
326
- type: string;
327
- addresses: string[];
328
- };
329
- };
330
- export type UnspentTxInfo = {
331
- txid: string;
332
- vout: number;
333
- address: string;
334
- acount: string;
335
- scriptPubKey: string;
336
- amount: number;
337
- confirmations: number;
338
- redeemScript: string;
339
- spendable: boolean;
340
- solvable: boolean;
341
- safe: boolean;
342
- };
343
- export type PrevOut = {
344
- txid: string;
345
- vout: number;
346
- scriptPubKey: string;
347
- redeemScript?: string;
348
- amount: number;
349
- };
350
- export type UTXOStats = {
351
- height: number;
352
- bestblock: string;
353
- transactions: number;
354
- txouts: number;
355
- bogosize: number;
356
- hash_serialized_2: string;
357
- disk_size: number;
358
- total_amount: number;
359
- };
360
- export type MempoolContent = {
361
- [key: string]: {
362
- size: number;
363
- fee: number;
364
- modifiedfee: number;
365
- time: number;
366
- height: number;
367
- descendantcount: number;
368
- descendantsize: number;
369
- descendantfees: number;
370
- ancestorcount: number;
371
- ancestorsize: number;
372
- ancestorfees: number;
373
- wtxid: string;
374
- depends: string[];
375
- };
376
- };
377
- export type DecodedRawTransaction = {
378
- txid: string;
379
- hash: string;
380
- size: number;
381
- vsize: number;
382
- version: number;
383
- locktime: number;
384
- vin: TxIn[];
385
- vout: TxOut[];
386
- };
387
- export interface FetchedRawTransaction extends DecodedRawTransaction {
388
- hex: string;
389
- blockhash: string;
390
- confirmations: number;
391
- time: number;
392
- blocktime: number;
393
- }
394
- export type MiningInfo = {
395
- blocks: number;
396
- currentblockweight: number;
397
- currentblocktx: number;
398
- difficulty: number;
399
- networkhashps: number;
400
- pooledtx: number;
401
- chain: 'main' | 'test' | 'regtest';
402
- warnings?: string;
403
- };
404
- export type MempoolInfo = {
405
- size: number;
406
- bytes: number;
407
- usage: number;
408
- maxmempol: number;
409
- mempoolminfee: number;
410
- minrelaytxfee: number;
411
- };
412
- export type BlockHeader = {
413
- hash: string;
414
- confirmations: number;
415
- height: number;
416
- version: number;
417
- versionHex: string;
418
- merkleroot: string;
419
- time: number;
420
- mediantime: number;
421
- nonce: number;
422
- bits: string;
423
- difficulty: number;
424
- chainwork: string;
425
- previoutsblockchash: string;
426
- };
427
- /** Block and GetBlock */
428
168
  export type Block = {
429
169
  hash: string;
430
170
  confirmations: number;
@@ -456,7 +196,6 @@ export interface BlockV3 extends Block {
456
196
  tx: Array<RawTransactionV2>;
457
197
  }
458
198
  export type BlockResponse = BlockV0 | BlockV1 | BlockV2 | BlockV3;
459
- /** Transaction and RawTransaction */
460
199
  export type Transaction = {
461
200
  hex: string;
462
201
  txid: string;
@@ -467,45 +206,6 @@ export type Transaction = {
467
206
  version: number;
468
207
  locktime: number;
469
208
  };
470
- export type TxIn = {
471
- coinbase?: string;
472
- txid?: string;
473
- vout?: number;
474
- scriptSig?: {
475
- asm: string;
476
- hex: string;
477
- };
478
- txinwitness?: string[];
479
- sequence: number;
480
- };
481
- export type TxInPrevout = {
482
- generated: boolean;
483
- height: number;
484
- value: number;
485
- scriptPubKey?: {
486
- asm: string;
487
- desc: string;
488
- hex: string;
489
- address?: string;
490
- type: string;
491
- };
492
- };
493
- export interface TxInExt extends TxIn {
494
- prevout: TxInPrevout;
495
- }
496
- export type ScriptPubKey = {
497
- asm: string;
498
- hex: string;
499
- reqSigs: number;
500
- type: string;
501
- address?: string;
502
- desc: string;
503
- };
504
- export type TxOut = {
505
- value: number;
506
- n: number;
507
- scriptPubKey: ScriptPubKey;
508
- };
509
209
  export type RawTransactionV0 = string;
510
210
  export interface RawTransactionV1 extends Transaction {
511
211
  vin: TxIn[];
@@ -522,30 +222,34 @@ export type CreateRawTxInputs = {
522
222
  vout: number;
523
223
  sequence?: number;
524
224
  };
525
- export type TxOutForCreateRaw = {
526
- address: string;
225
+ export type CreateRawTxOutputs = {
226
+ [address: string]: number;
227
+ } | {
527
228
  data: string;
528
229
  };
529
- export type TxOutInBlock = {
530
- bestblock: string;
531
- confirmations: number;
532
- value: number;
533
- scriptPubKey: {
534
- asm: string;
535
- hex: string;
536
- reqSigs: number;
537
- type: string;
538
- addresses: string[];
539
- };
540
- coinbase: boolean;
541
- };
542
- export type DecodedScript = {
543
- asm: string;
230
+ export type SignedRawTx = {
544
231
  hex: string;
545
- type: string;
546
- reqSigs: number;
547
- addresses: string[];
548
- p2sh: string;
232
+ complete: boolean;
233
+ errors?: {
234
+ txid: string;
235
+ vout: number;
236
+ scriptSig: string;
237
+ sequence: number;
238
+ error: string;
239
+ }[];
240
+ };
241
+ export type UnspentTxInfo = {
242
+ txid: string;
243
+ vout: number;
244
+ address: string;
245
+ account: string;
246
+ scriptPubKey: string;
247
+ amount: number;
248
+ confirmations: number;
249
+ redeemScript: string;
250
+ spendable: boolean;
251
+ solvable: boolean;
252
+ safe: boolean;
549
253
  };
550
254
  export type WalletTransaction = {
551
255
  amount: number;
@@ -570,133 +274,17 @@ export type WalletTransaction = {
570
274
  }[];
571
275
  hex: string;
572
276
  };
573
- export type WalletInfo = {
574
- walletname: string;
575
- walletversion: number;
576
- balance: number;
577
- unconfirmed_balance: number;
578
- immature_balance: number;
579
- txcount: number;
580
- keypoololdest: number;
581
- keypoolsize: number;
582
- paytxfee: number;
583
- hdmasterkeyid: string;
584
- };
585
- export type SigHashType = 'ALL' | 'NONE' | 'SINGLE' | 'ALL|ANYONECANPAY' | 'NONE|ANYONECANPAY' | 'SINGLE|ANYONECANPAY';
586
- export type SignedRawTx = {
587
- hex: string;
588
- complete: boolean;
589
- errors?: {
590
- txid: string;
591
- vout: number;
592
- scriptSig: string;
593
- sequence: number;
594
- error: string;
595
- }[];
596
- };
597
- export type ValidateAddressResult = {
598
- isvalid: boolean;
599
- address?: string;
600
- scriptPubKey?: string;
601
- ismine?: boolean;
602
- iswatchonly?: boolean;
603
- isscript?: boolean;
604
- script?: string;
605
- hex?: string;
606
- addresses?: string[];
607
- sigsrequired?: number;
608
- pubkey?: string;
609
- iscompressed?: boolean;
277
+ export type DerivedAddresses = Array<string>;
278
+ export type ListTransactionsParams = {
610
279
  account?: string;
611
- timestamp?: number;
612
- hdkeypath?: string;
613
- hdmasterkeyid?: string;
614
- };
615
- export type ImportMultiRequest = {
616
- scriptPubKey: string | {
617
- address: string;
618
- };
619
- timestamp: number | 'now';
620
- redeemScript?: string;
621
- pubkeys?: string[];
622
- keys?: string[];
623
- internal?: boolean;
624
- watchonly?: boolean;
625
- label?: string;
626
- };
627
- export type ImportMultiResult = {
628
- success: boolean;
629
- error?: {
630
- code: string;
631
- message: string;
632
- };
633
- };
634
- export type ImportMultiOptions = {
635
- rescan?: boolean;
636
- };
637
- export type ImportDescriptorRequest = {
638
- /** (string, required) Descriptor to import. */
639
- desc: string;
640
- /**
641
- * (integer / string, required) Time from which to start rescanning the blockchain for this descriptor, in UNIX epoch time
642
- * Use the string "now" to substitute the current synced blockchain time.
643
- * "now" can be specified to bypass scanning, for outputs which are known to never have been used, and
644
- * 0 can be specified to scan the entire blockchain. Blocks up to 2 hours before the earliest timestamp
645
- * of all descriptors being imported will be scanned as well as the mempool.
646
- */
647
- timestamp: number | string;
648
- /** (boolean, optional, default=false) Make descriptor "active" for corresponding output type/externality */
649
- active?: boolean;
650
- /** (numeric or array, optional) If a ranged descriptor is used, this specifies the end or the range (in the form [begin,end]) to import */
651
- range?: number | Array<number>;
652
- /** (numeric, optional) If a ranged descriptor is set to active, this specifies the next index to generate addresses from */
653
- next_index?: number;
654
- /** (boolean, optional, default=false) Whether matching outputs should be treated as not incoming payments (e.g. change) */
655
- internal?: boolean;
656
- /** (string, optional, default="") Label to assign to the address, only allowed with internal=false. Disabled for ranged descriptors */
657
- label?: string;
658
- };
659
- export type JsonRPCError = {
660
- code: number;
661
- message: string;
662
- };
663
- export type ImportDescriptorResult = {
664
- success: boolean;
665
- warnings?: string;
666
- error: JsonRPCError;
667
- };
668
- export type Received = {
669
- involvesWatchonly?: boolean;
670
- account: string;
671
- amount: number;
672
- confirmations: number;
673
- label: string;
674
- };
675
- export type ListUnspentOptions = {
676
- minimumAmount: number | string;
677
- maximumAmount: number | string;
678
- maximumCount: number | string;
679
- minimumSumAmount: number | string;
680
- };
681
- export type ReceivedByAccount = Received;
682
- export type ReceivedByAddress = {
683
- address: string;
684
- txids: string[];
685
- } & Received;
686
- export type RestExtension = 'json' | 'bin' | 'hex';
687
- export type MethodNameInLowerCase = 'getbestblockhash' | 'getblock' | 'getblockchaininfo' | 'getblockcount' | 'getblockhash' | 'getblockheader' | 'getchaintips' | 'getchaintxstats' | 'getdifficulty' | 'getmempoolancestors' | 'getmempooldescendants' | 'getmempoolentry' | 'getmempoolinfo' | 'getrawmempool' | 'gettxout' | 'gettxoutproof' | 'gettxoutsetinfo' | 'preciousblock' | 'pruneblockchain' | 'verifychain' | 'verifytxoutproof' | 'getinfo' | 'getmemoryinfo' | 'help' | 'stop' | 'uptime' | 'generate' | 'generatetoaddress' | 'getblocktemplate' | 'getmininginfo' | 'getnetworkhashps' | 'prioritisetransaction' | 'submitblock' | 'addnode' | 'clearbanned' | 'disconnectnode' | 'getaddednodeinfo' | 'getconnectioncount' | 'getnettotals' | 'getnetworkinfo' | 'getpeerinfo' | 'istbanned' | 'ping' | 'setban' | 'setnetworkactive' | 'combinerawtransaction' | 'createrawtransaction' | 'createwallet' | 'decoderawtransaction' | 'decodescript' | 'fundrawtransaction' | 'getrawtransaction' | 'sendrawtransaction' | 'signrawtransaction' | 'createmultisig' | 'estimatefee' | 'estimatesmartfee' | 'signmessagewithprivkey' | 'validateaddress' | 'verifymessage' | 'abandontransaction' | 'abortrescan' | 'addmultisigaddress' | 'addwitnessaddress' | 'backupwallet' | 'bumpfee' | 'dumpprivkey' | 'dumpwallet' | 'encryptwallet' | 'getaccount' | 'getaccountaddress' | 'getaddressesbyaccount' | 'getbalance' | 'getnewaddress' | 'getrawchangeaddress' | 'getreceivedbyaccount' | 'getreceivedbyaddress' | 'gettransaction' | 'getunconfirmedbalance' | 'getwalletinfo' | 'importaddress' | 'importmulti' | 'importprivkey' | 'importprunedfunds' | 'importpubkey' | 'importwallet' | 'keypoolrefill' | 'listaccounts' | 'listaddressgroupings' | 'listlockunspent' | 'listreceivedbyaccount' | 'listreceivedbyaddress' | 'listsinceblock' | 'listtransactions' | 'listunspent' | 'listwallets' | 'lockunspent' | 'move' | 'removeprunedfunds' | 'sendfrom' | 'sendmany' | 'sendtoaddress' | 'setaccount' | 'settxfee' | 'signmessage' | 'scanblocks' | 'getdescriptorinfo' | 'deriveaddresses' | 'importdescriptors' | 'createwalletdescriptor' | 'signrawtransactionwithwallet' | 'send' | 'sendmany' | 'sendall';
688
- export type BatchOption = {
689
- method: MethodNameInLowerCase;
690
- parameters?: Array<any>;
691
- };
692
- export type ReturnType<T> = T extends (...args: any[]) => infer R ? R : any;
693
- export type BumpFeeOption = {
694
- confTarget?: number;
695
- totalFee?: number;
696
- replaceable?: boolean;
697
- estimate_mode?: FeeEstimateMode;
280
+ count?: number;
281
+ skip?: number;
282
+ include_watchonly?: boolean;
698
283
  };
699
- export type WalletTxBase = {
284
+ export type ListTransactionsResult = {
285
+ trusted: boolean;
286
+ otheraccount?: string;
287
+ abandoned?: boolean;
700
288
  account: string;
701
289
  address: string;
702
290
  category: 'send' | 'receive';
@@ -712,211 +300,25 @@ export type WalletTxBase = {
712
300
  timereceived: number;
713
301
  walletconflicts: string[];
714
302
  'bip125-replaceable': 'yes' | 'no' | 'unknown';
715
- abandoned?: boolean;
716
- comment?: string;
717
303
  label: string;
718
- to?: string;
719
- };
720
- export type TransactionInListSinceBlock = WalletTxBase;
721
- export type ListSinceBlockResult = {
722
- transactions: TransactionInListSinceBlock[];
723
- removed?: TransactionInListSinceBlock[];
724
- lastblock: string;
725
- };
726
- export type ListTransactionsResult = {
727
- trusted: boolean;
728
- otheraccount?: string;
729
- abandoned?: boolean;
730
- } & WalletTxBase;
731
- export type AddressGrouping = [string, number] | [string, number, string];
732
- export type RawOutputAddr = {
733
- [address: string]: number;
734
- };
735
- export type RawOutputData = {
736
- data: string;
737
- };
738
- export type CreateRawTxOutputs = RawOutputAddr | RawOutputData;
739
- export type GetUTXOsResult = {
740
- chainHeight: number;
741
- chaintipHash: string;
742
- bipmap: string;
743
- utxos: UTXO[];
744
- };
745
- export type BumpFeeOptions = {
746
- confTarget?: number;
747
- totalFee?: number;
748
- replaceable?: boolean;
749
- estimate_mode?: FeeEstimateMode;
750
- };
751
- export type BumpFeeResult = {
752
- txid: string;
753
- origfee: number;
754
- fee: number;
755
- error?: string[];
756
- };
757
- export type AddMultiSigAddressParams = {
758
- nrequired: number;
759
- keys: string[];
760
- account?: string;
761
- };
762
- export type SignRawTxParams = {
763
- hexstring: string;
764
- prevtxs?: PrevOut[];
765
- privkeys?: string[];
766
- sighashtype?: SigHashType;
767
- };
768
- export type BitcoinSignature = {
769
- signature: string;
770
- };
771
- export type CreateMultiSigResult = {
772
- address: string;
773
- redeemScript: string;
774
- };
775
- export type CreateRawTxParams = {
776
- inputs: CreateRawTxInputs[];
777
- outputs: CreateRawTxOutputs[];
778
- locktime?: number;
779
- replacable?: boolean;
780
- };
781
- export type CreateWalletParams = {
782
- wallet_name: string;
783
- disable_private_keys?: boolean;
784
- blank?: boolean;
785
- passphrase?: string;
786
- avoid_reuse?: boolean;
787
- descriptors?: boolean;
788
- load_on_startup?: boolean;
789
- };
790
- export type CreateWalletResult = {
791
- name: string;
792
- warning: string;
793
- };
794
- export type ScanBlocksParams = {
795
- action: 'start' | 'abort' | 'status';
796
- start_height?: number;
797
- stop_height?: number;
798
- filtertype?: string;
799
- options?: {
800
- filter_false_positives: boolean;
801
- };
802
- };
803
- export type ListTransactionsParams = {
804
- account?: string;
805
- count?: number;
806
- skip?: number;
807
- include_watchonly?: boolean;
808
- };
809
- export type FundRawTxResult = {
810
- hex: string;
811
- fee: number;
812
- changepos: number;
813
- };
814
- export type DerivedAddresses = Array<string>;
815
- export type CreateWalletDescriptorOptions = {
816
- internal: boolean;
817
- hdkey: string;
818
- };
819
- export type WalletDescriptor = string;
820
- export type CreateWalletDescriptorsResult = {
821
- descs: Array<WalletDescriptor>;
822
- };
823
- export type SendManyParams = {
824
- fromaccount: string;
825
- amounts: {
826
- address: string;
827
- };
828
- minconf?: number;
829
- comment?: string;
830
- subtractfeefrom?: string[];
831
- replaeable?: boolean;
832
- conf_target?: number;
833
- estimate_mode?: FeeEstimateMode;
834
- };
835
- export type ListUnspentParams = {
836
- minconf?: number;
837
- maxconf?: number;
838
- address?: string[];
839
- include_unsafe?: boolean;
840
- query_options?: ListUnspentOptions;
841
- };
842
- export type BitcoinRecipient = string | Record<string, number | string>;
843
- export type Input = {
844
- txid: string;
845
- vout: number;
846
- sequence?: number;
847
- };
848
- export type SolvingData = {
849
- pubkeys: string[];
850
- scripts: string[];
851
- descriptors: string[];
852
- };
853
- export type Recipients = Array<BitcoinRecipient>;
854
- export type SendAllOptions = {
855
- add_to_wallet?: boolean;
856
- fee_rate?: number | string;
857
- include_watching?: boolean;
858
- inputs?: Input[];
859
- locktime?: number;
860
- lock_unspents?: boolean;
861
- psbt?: boolean;
862
- send_max?: boolean;
863
- minconf?: number;
864
- maxconf?: number;
865
- conf_target?: number;
866
- estimate_mode?: FeeEstimateMode;
867
- replaceable?: boolean;
868
- solving_data?: SolvingData;
869
- };
870
- export type SendAllParams = {
871
- recipients: Recipients;
872
- options?: SendAllOptions;
873
- };
874
- export type SendAllResult = {
875
- txid: Hex;
876
- hex: Hex;
877
- psbt: string;
878
- complete: boolean;
879
- };
880
- export type SendToAddressResult = {
881
- txid: string;
882
- fee_reason?: string;
883
- };
884
- export type CreateMultisigParams = {
885
- nrequired: number;
886
- keys: string[];
887
- address_type?: string;
888
- };
889
- export type CreateMultisigResult = {
890
- address: string;
891
- redeemScript: Hex;
892
- descriptor: string;
893
- warnings?: string[];
894
304
  };
895
305
  /**
896
306
  * Defines verbosity levels for block and transaction outputs.
897
- * Used to specify the format of returned block or transaction data.
898
- * @enum {number} VerbosityLevel for block and transaction outputs.
307
+ * @enum {number}
899
308
  */
900
309
  export declare enum VerbosityLevel {
901
- /** Return block or transaction data in raw hex-encoded format */
310
+ /** Return data in raw hex-encoded format */
902
311
  hex = 0,
903
- /** Return block or transaction data in JSON object format */
312
+ /** Return data in JSON object format */
904
313
  json = 1,
905
- /**
906
- * Return block or transaction data in JSON object format with additional information.
907
- * Returns block data with information about each transaction.
908
- * Returns transaction data with information about the transaction including fee and prevout information.
909
- */
314
+ /** Return data in JSON format with additional information */
910
315
  jsonext = 2,
911
- /**
912
- * Return block data in JSON object format with additional information.
913
- * Returns block data with information about each transaction, including prevout information for inputs.
914
- */
316
+ /** Return block data in JSON format with prevout information for inputs */
915
317
  jsonextprev = 3
916
318
  }
917
- export type BlockHeight = number;
918
319
  export interface GetBlockParams {
919
320
  blockhash?: string;
920
321
  height?: number;
921
322
  verbosity?: VerbosityLevel;
922
323
  }
324
+ export type MethodNameInLowerCase = 'getbestblockhash' | 'getblock' | 'getblockchaininfo' | 'getblockcount' | 'getblockhash' | 'getblockheader' | 'getchaintips' | 'getchaintxstats' | 'getdifficulty' | 'getmempoolancestors' | 'getmempooldescendants' | 'getmempoolentry' | 'getmempoolinfo' | 'getrawmempool' | 'gettxout' | 'gettxoutproof' | 'gettxoutsetinfo' | 'preciousblock' | 'pruneblockchain' | 'verifychain' | 'verifytxoutproof' | 'getinfo' | 'getmemoryinfo' | 'help' | 'stop' | 'uptime' | 'generate' | 'generatetoaddress' | 'getblocktemplate' | 'getmininginfo' | 'getnetworkhashps' | 'prioritisetransaction' | 'submitblock' | 'addnode' | 'clearbanned' | 'disconnectnode' | 'getaddednodeinfo' | 'getconnectioncount' | 'getnettotals' | 'getnetworkinfo' | 'getpeerinfo' | 'istbanned' | 'ping' | 'setban' | 'setnetworkactive' | 'combinerawtransaction' | 'createrawtransaction' | 'createwallet' | 'decoderawtransaction' | 'decodescript' | 'fundrawtransaction' | 'getrawtransaction' | 'sendrawtransaction' | 'signrawtransaction' | 'createmultisig' | 'estimatefee' | 'estimatesmartfee' | 'signmessagewithprivkey' | 'validateaddress' | 'verifymessage' | 'abandontransaction' | 'abortrescan' | 'addmultisigaddress' | 'addwitnessaddress' | 'backupwallet' | 'bumpfee' | 'dumpprivkey' | 'dumpwallet' | 'encryptwallet' | 'getaccount' | 'getaccountaddress' | 'getaddressesbyaccount' | 'getbalance' | 'getnewaddress' | 'getrawchangeaddress' | 'getreceivedbyaccount' | 'getreceivedbyaddress' | 'gettransaction' | 'getunconfirmedbalance' | 'getwalletinfo' | 'importaddress' | 'importmulti' | 'importprivkey' | 'importprunedfunds' | 'importpubkey' | 'importwallet' | 'keypoolrefill' | 'listaccounts' | 'listaddressgroupings' | 'listlockunspent' | 'listreceivedbyaccount' | 'listreceivedbyaddress' | 'listsinceblock' | 'listtransactions' | 'listunspent' | 'listwallets' | 'lockunspent' | 'move' | 'removeprunedfunds' | 'sendfrom' | 'sendmany' | 'sendtoaddress' | 'setaccount' | 'settxfee' | 'signmessage' | 'scanblocks' | 'getdescriptorinfo' | 'deriveaddresses' | 'importdescriptors' | 'createwalletdescriptor' | 'signrawtransactionwithwallet' | 'send' | 'sendall';