@mr-zwets/bchn-api-wrapper 1.0.1 → 1.0.2

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 (45) hide show
  1. package/.claude/settings.local.json +8 -0
  2. package/.github/workflows/ci.yaml +36 -0
  3. package/CLAUDE.md +70 -0
  4. package/README.md +121 -129
  5. package/dist/interfaces/interfaces.d.ts +13 -0
  6. package/dist/interfaces/restInterfaces/interfaces.d.ts +124 -18
  7. package/dist/interfaces/rpcInterfaces/blockchain.d.ts +293 -102
  8. package/dist/interfaces/rpcInterfaces/control.d.ts +6 -0
  9. package/dist/interfaces/rpcInterfaces/generating.d.ts +2 -0
  10. package/dist/interfaces/rpcInterfaces/mining.d.ts +9 -0
  11. package/dist/interfaces/rpcInterfaces/network.d.ts +18 -0
  12. package/dist/interfaces/rpcInterfaces/rawtransactions.d.ts +21 -0
  13. package/dist/interfaces/rpcInterfaces/util.d.ts +5 -0
  14. package/dist/interfaces/rpcInterfaces/wallet.d.ts +54 -0
  15. package/dist/interfaces/rpcInterfaces/zmq.d.ts +1 -0
  16. package/dist/restClient.d.ts +13 -1
  17. package/dist/restClient.js +19 -6
  18. package/dist/rpcClient.d.ts +7 -0
  19. package/dist/rpcClient.js +7 -0
  20. package/package.json +7 -8
  21. package/pnpm-lock.yaml +1279 -0
  22. package/src/index.ts +3 -3
  23. package/src/interfaces/interfaces.ts +96 -86
  24. package/src/interfaces/restInterfaces/interfaces.ts +235 -116
  25. package/src/interfaces/rpcInterfaces/blockchain.ts +932 -758
  26. package/src/interfaces/rpcInterfaces/control.ts +68 -62
  27. package/src/interfaces/rpcInterfaces/generating.ts +23 -21
  28. package/src/interfaces/rpcInterfaces/index.ts +13 -13
  29. package/src/interfaces/rpcInterfaces/mining.ts +151 -143
  30. package/src/interfaces/rpcInterfaces/network.ts +213 -195
  31. package/src/interfaces/rpcInterfaces/rawtransactions.ts +332 -314
  32. package/src/interfaces/rpcInterfaces/util.ts +56 -52
  33. package/src/interfaces/rpcInterfaces/wallet.ts +728 -674
  34. package/src/interfaces/rpcInterfaces/zmq.ts +12 -11
  35. package/src/restClient.ts +134 -119
  36. package/src/rpcClient.ts +100 -93
  37. package/src/utils/errors.ts +6 -6
  38. package/src/utils/utils.ts +55 -55
  39. package/test/restClient.test.ts +33 -31
  40. package/test/rpcClient.test.ts +119 -115
  41. package/test/setupTests.ts +56 -54
  42. package/test/tsconfig.json +4 -4
  43. package/tsconfig.json +13 -13
  44. package/vitest.config.ts +8 -8
  45. package/CHANGELOG.md +0 -7
@@ -1,674 +1,728 @@
1
- /* --- Wallet Commands --- */
2
- // progress 52/52
3
-
4
- import type { TokenData } from "../interfaces.js";
5
-
6
- export interface AbandonTransaction {
7
- method: 'abandontransaction';
8
- params: [
9
- txid: string
10
- ];
11
- response: null;
12
- }
13
-
14
- export interface AbortRescan {
15
- method: 'abortrescan';
16
- params: [];
17
- response: null;
18
- }
19
-
20
- export interface AddMultisigAddress {
21
- method: 'addmultisigaddress';
22
- params: [
23
- nrequired: number,
24
- keys: string[],
25
- label?: string
26
- ];
27
- response: {
28
- address: string;
29
- redeemScript: string;
30
- };
31
- }
32
-
33
- export interface BackupWallet {
34
- method: 'backupwallet';
35
- params: [
36
- destination: string
37
- ];
38
- response: null;
39
- }
40
-
41
- export interface CreateWallet {
42
- method: 'createwallet';
43
- params: [
44
- wallet_name: string,
45
- disable_private_keys?: boolean,
46
- blank?: boolean
47
- ];
48
- response: {
49
- name: string;
50
- warning?: string;
51
- };
52
- }
53
-
54
- export interface DumpWallet {
55
- method: 'dumpwallet';
56
- params: [
57
- filename: string
58
- ];
59
- response: {
60
- filename: string;
61
- };
62
- }
63
-
64
- export interface DumpPrivKey {
65
- method: 'dumpprivkey';
66
- params: [
67
- address: string,
68
- ];
69
- response: string;
70
- }
71
-
72
- export interface EncryptWallet {
73
- method: 'encryptwallet';
74
- params: [
75
- passphrase: string
76
- ];
77
- response: string;
78
- }
79
-
80
- export interface GetAddressesByLabel {
81
- method: 'getaddressesbylabel';
82
- params: [
83
- label: string
84
- ];
85
- response: {
86
- [address: string]: {
87
- purpose: string;
88
- };
89
- };
90
- }
91
-
92
- export interface GetAddressInfo {
93
- method: 'getaddressinfo';
94
- params: [string];
95
- response: {
96
- address: string;
97
- scriptPubKey: string;
98
- ismine: boolean;
99
- iswatchonly: boolean;
100
- isscript: boolean;
101
- ischange: boolean;
102
- script?: 'nonstandard' | 'pubkey' | 'pubkeyhash' | 'scripthash' | 'multisig' | 'nulldata';
103
- hex?: string;
104
- pubkeys?: string[];
105
- sigsrequired?: number;
106
- pubkey?: string;
107
- embedded?: object;
108
- iscompressed: boolean;
109
- label: string;
110
- timestamp?: number;
111
- hdkeypath?: string;
112
- hdseedid?: string;
113
- hdmasterkeyid?: string;
114
- labels: {
115
- name: string;
116
- purpose: 'send' | 'receive';
117
- }[];
118
- };
119
- }
120
-
121
- export interface GetBalance {
122
- method: 'getbalance';
123
- params: [
124
- dummy?: string,
125
- minconf?: number,
126
- include_watchonly?: boolean
127
- ];
128
- response: number;
129
- }
130
-
131
- export interface GetNewAddress {
132
- method: 'getnewaddress';
133
- params: [
134
- label?: string,
135
- ];
136
- response: string;
137
- }
138
-
139
- export interface GetRawChangeAddress {
140
- method: 'getrawchangeaddress';
141
- params: [];
142
- response: string;
143
- }
144
-
145
- export interface GetReceivedByAddress {
146
- method: 'getreceivedbyaddress';
147
- params: [
148
- address: string,
149
- minconf?: number
150
- ];
151
- response: number;
152
- }
153
-
154
- export interface GetReceivedByLabel {
155
- method: 'getreceivedbylabel';
156
- params: [
157
- label: string,
158
- minconf?: number
159
- ];
160
- response: number;
161
- }
162
-
163
- export interface GetTransaction {
164
- method: 'gettransaction';
165
- params: [
166
- txid: string,
167
- include_watchonly?: boolean
168
- ];
169
- response: {
170
- amount: number;
171
- fee?: number;
172
- confirmations: number;
173
- blockhash?: string;
174
- blockindex?: number;
175
- blocktime?: number;
176
- txid: string;
177
- time: number;
178
- timereceived: number;
179
- 'bip125-replaceable': 'yes' | 'no' | 'unknown';
180
- details: {
181
- address: string;
182
- category: 'send' | 'receive';
183
- amount: number;
184
- label?: string;
185
- vout: number;
186
- fee?: number;
187
- abandoned?: boolean;
188
- }[];
189
- hex: string;
190
- };
191
- }
192
-
193
- export interface GetUnconfirmedBalance {
194
- method: 'getunconfirmedbalance';
195
- params: [];
196
- response: number;
197
- }
198
-
199
- export interface GetWalletInfo {
200
- method: 'getwalletinfo';
201
- params: [];
202
- response: {
203
- walletname: string,
204
- walletversion: number;
205
- balance: number;
206
- unconfirmed_balance: number;
207
- immature_balance: number;
208
- txcount: number;
209
- keypoololdest: number;
210
- keypoolsize: number;
211
- keypoolsize_hd_internal: number;
212
- unlocked_until: number;
213
- paytxfee: number;
214
- hdseedid?: string;
215
- hdmasterkeyid?: string;
216
- private_keys_enabled: boolean;
217
- }
218
- }
219
-
220
- export interface ImportAddress {
221
- method: 'importaddress';
222
- params: [
223
- address: string,
224
- label?: string,
225
- rescan?: boolean,
226
- p2sh?: boolean
227
- ];
228
- response: number;
229
- }
230
-
231
- export interface ImportMulti {
232
- method: 'importmulti';
233
- params: [
234
- requests: {
235
- scriptPubKey: string | { address: string };
236
- timestamp: number | 'now';
237
- redeemscript?: string;
238
- pubkeys?: string[];
239
- keys?: string[];
240
- internal?: boolean;
241
- watchonly?: boolean;
242
- label?: string;
243
- }[],
244
- options?: {
245
- rescan?: boolean;
246
- }
247
- ];
248
- response: {
249
- success: boolean;
250
- error?: {
251
- code: number;
252
- message: string;
253
- };
254
- }[];
255
- }
256
-
257
- export interface ImportPrivKey {
258
- method: 'importprivkey';
259
- params: [
260
- privkey: string,
261
- label?: string,
262
- rescan?: boolean
263
- ];
264
- response: null;
265
- }
266
-
267
- export interface ImportPrunedFunds {
268
- method: 'importprunedfunds';
269
- params: [
270
- rawtransaction: string,
271
- txoutproof: string
272
- ];
273
- response: null;
274
- }
275
-
276
- export interface ImportPubKey {
277
- method: 'importpubkey';
278
- params: [
279
- pubkey: string,
280
- label?: string,
281
- rescan?: boolean
282
- ];
283
- response: null;
284
- }
285
-
286
- export interface ImportWallet {
287
- method: 'importwallet';
288
- params: [
289
- filename: string
290
- ];
291
- response: null;
292
- }
293
-
294
- export interface KeyPoolRefill {
295
- method: 'keypoolrefill';
296
- params: [
297
- newsize?: number
298
- ];
299
- response: null;
300
- }
301
-
302
- export interface ListAddressGroupings {
303
- method: 'listaddressgroupings';
304
- params: [];
305
- response: [
306
- [
307
- {
308
- address: string;
309
- amount: number;
310
- label?: string;
311
- }[]
312
- ][]
313
- ];
314
- }
315
-
316
- export interface ListLabels {
317
- method: 'listlabels';
318
- params: [
319
- purpose?: string
320
- ];
321
- response: string[];
322
- }
323
-
324
- export interface ListLockUnspent {
325
- method: 'listlockunspent';
326
- params: [];
327
- response: {
328
- txid: string;
329
- vout: number;
330
- }[];
331
- }
332
-
333
- export interface ListReceivedByAddress {
334
- method: 'listreceivedbyaddress';
335
- params: [
336
- minconf?: number,
337
- include_empty?: boolean,
338
- include_watchonly?: boolean,
339
- address_filter?: string
340
- ];
341
- response: {
342
- involvesWatchonly?: boolean;
343
- address: string;
344
- amount: number;
345
- confirmations: number;
346
- label: string;
347
- txids: string[];
348
- }[];
349
- }
350
-
351
- export interface ListReceivedByLabel {
352
- method: 'listreceivedbylabel';
353
- params: [
354
- minconf?: number,
355
- include_empty?: boolean,
356
- include_watchonly?: boolean
357
- ];
358
- response: {
359
- involvesWatchonly?: boolean;
360
- amount: number;
361
- confirmations: number;
362
- label: string;
363
- }[];
364
- }
365
-
366
- interface TransactionWallet {
367
- address?: string;
368
- category: 'send' | 'receive';
369
- amount: number;
370
- vout: number;
371
- fee?: number;
372
- confirmations: number;
373
- blockhash?: string;
374
- blockindex?: number;
375
- blocktime?: number;
376
- txid: string;
377
- time: number;
378
- timereceived: number;
379
- abandoned?: boolean;
380
- comment?: string;
381
- label?: string;
382
- to?: string;
383
- }
384
-
385
- export interface ListSinceBlock {
386
- method: 'listsinceblock';
387
- params: [
388
- blockhash?: string,
389
- target_confirmations?: number,
390
- include_watchonly?: boolean,
391
- include_removed?: boolean
392
- ];
393
- response: {
394
- transactions: TransactionWallet[];
395
- removed?: TransactionWallet[];
396
- lastblock: string;
397
- };
398
- }
399
-
400
- export interface ListTransactions {
401
- method: 'listtransactions';
402
- params: [
403
- label?: string,
404
- count?: number,
405
- skip?: number,
406
- include_watchonly?: boolean
407
- ];
408
- response: TransactionWallet[];
409
- }
410
-
411
- export interface ListUnspent {
412
- method: 'listunspent';
413
- params: [
414
- minconf?: number,
415
- maxconf?: number,
416
- addresses?: string[],
417
- include_unsafe?: boolean,
418
- query_options?: {
419
- minimumAmount?: number | string;
420
- maximumAmount?: number | string;
421
- maximumCount?: number;
422
- minimumSumAmount?: number | string;
423
- includeTokens?: boolean;
424
- tokensOnly?: boolean;
425
- }
426
- ];
427
- response: ListUnspentItem[];
428
- }
429
-
430
- export interface ListUnspentItem {
431
- txid: string;
432
- vout: number;
433
- address: string;
434
- label: string;
435
- scriptPubKey: string;
436
- amount: number;
437
- tokenData?: TokenData;
438
- confirmations: number;
439
- redeemScript: string;
440
- spendable: boolean;
441
- solvable: boolean;
442
- safe: boolean;
443
- }
444
-
445
- export interface ListWalletDir {
446
- method: 'listwalletdir';
447
- params: [];
448
- response: {
449
- wallets: {
450
- name: string;
451
- }[];
452
- };
453
- }
454
-
455
- export interface ListWallets {
456
- method: 'importaddress';
457
- params: [];
458
- response: string[];
459
- }
460
-
461
- export interface LoadWallet {
462
- method: 'loadwallet';
463
- params: [
464
- filename: string
465
- ];
466
- response: {
467
- name: string;
468
- warning?: string;
469
- };
470
- }
471
-
472
- export interface LockUnspent {
473
- method: 'lockunspent';
474
- params: [
475
- unlock: boolean,
476
- transactions?: {
477
- txid: string;
478
- vout: number;
479
- }[]
480
- ];
481
- response: boolean;
482
- }
483
-
484
- export interface RemovePrunedFunds {
485
- method: 'removeprunedfunds';
486
- params: [
487
- txid: string
488
- ];
489
- response: null;
490
- }
491
-
492
- export interface RescanBlockchain {
493
- method: 'rescanblockchain';
494
- params: [
495
- start_height?: number,
496
- stop_height?: number
497
- ];
498
- response: {
499
- start_height: number;
500
- stop_height: number;
501
- };
502
- }
503
-
504
- export interface SendMany {
505
- method: 'sendmany';
506
- params: [
507
- dummy: string,
508
- amounts: {
509
- [address: string]: number | string
510
- },
511
- minconf?: number,
512
- comment?: string,
513
- subtractfeefrom?: string[],
514
- coinsel?: number,
515
- include_unsafe?: boolean
516
- ];
517
- response: string;
518
- }
519
-
520
- export interface SendToAddress {
521
- method: 'sendtoaddress';
522
- params: [
523
- address: string,
524
- amount: number | string,
525
- comment?: string,
526
- comment_to?: string,
527
- subtractfeefromamount?: boolean,
528
- coinsel?: number,
529
- include_unsafe?: boolean
530
- ];
531
- response: string;
532
- }
533
-
534
- export interface SetHdSeed {
535
- method: 'sethdseed';
536
- params: [
537
- newkeypool?: boolean,
538
- seed?: string
539
- ];
540
- response: null;
541
- }
542
-
543
- export interface SetLabel {
544
- method: 'setlabel';
545
- params: [
546
- address: string,
547
- label: string
548
- ];
549
- response: null;
550
- }
551
-
552
- export interface SetTxFee {
553
- method: 'settxfee';
554
- params: [
555
- amount: number | string
556
- ];
557
- response: boolean;
558
- }
559
-
560
- export interface SignMessage {
561
- method: 'signmessage';
562
- params: [
563
- address: string,
564
- message: string
565
- ];
566
- response: string;
567
- }
568
-
569
- export interface SignRawTransactionWithWallet {
570
- method: 'signrawtransactionwithwallet';
571
- params: [
572
- hexstring: string,
573
- prevtxs?: {
574
- txid: string;
575
- vout: number;
576
- scriptPubKey: string;
577
- redeemScript?: string;
578
- amount: number | string;
579
- tokenData?: TokenData
580
- }[],
581
- sighashtype?: string
582
- ];
583
- response: {
584
- hex: string;
585
- complete: boolean;
586
- errors?: {
587
- txid: string;
588
- vout: number;
589
- scriptSig: string;
590
- sequence: number;
591
- error: string;
592
- }[];
593
- };
594
- }
595
-
596
- export interface UnloadWallet {
597
- method: 'unloadwallet';
598
- params: [
599
- wallet_name?: string
600
- ];
601
- response: null;
602
- }
603
-
604
- export interface WalletCreateFundedPsbt {
605
- method: 'walletcreatefundedpsbt';
606
- params: [
607
- inputs: {
608
- txid: string;
609
- vout: number;
610
- sequence: number;
611
- }[],
612
- outputs: {
613
- address?: number | string | {
614
- amount: number | string;
615
- tokenData?: TokenData;
616
- };
617
- data?: string | string[];
618
- }[],
619
- locktime?: number,
620
- options?: {
621
- include_unsafe?: boolean;
622
- changeAddress?: string;
623
- changePosition?: number;
624
- includeWatching?: boolean;
625
- lockUnspents?: boolean;
626
- feeRate?: number | string;
627
- subtractFeeFromOutputs?: number[];
628
- },
629
- bip32derivs?: boolean
630
- ];
631
- response: {
632
- psbt: string;
633
- fee: number;
634
- changepos: number;
635
- };
636
- }
637
-
638
- export interface WalletLock {
639
- method: 'walletlock';
640
- params: [];
641
- response: null;
642
- }
643
-
644
- export interface WalletPassphrase {
645
- method: 'walletpassphrase';
646
- params: [
647
- passphrase: string,
648
- timeout: number
649
- ];
650
- response: null;
651
- }
652
-
653
- export interface WalletPassphraseChange {
654
- method: 'walletpassphrasechange';
655
- params: [
656
- oldpassphrase: string,
657
- newpassphrase: string
658
- ];
659
- response: null;
660
- }
661
-
662
- export interface WalletProcessPsbt {
663
- method: 'walletprocesspsbt';
664
- params: [
665
- psbt: string,
666
- sign?: boolean,
667
- sighashtype?: string,
668
- bip32derivs?: boolean
669
- ];
670
- response: {
671
- psbt: string;
672
- complete: boolean;
673
- };
674
- }
1
+ /* --- Wallet Commands --- */
2
+ // progress 52/52
3
+
4
+ import type { TokenData } from "../interfaces.js";
5
+
6
+ /** Marks an in-wallet transaction as abandoned (only works on unconfirmed tx). */
7
+ export interface AbandonTransaction {
8
+ method: 'abandontransaction';
9
+ params: [
10
+ txid: string
11
+ ];
12
+ response: null;
13
+ }
14
+
15
+ /** Stops current wallet rescan. */
16
+ export interface AbortRescan {
17
+ method: 'abortrescan';
18
+ params: [];
19
+ response: null;
20
+ }
21
+
22
+ /** Adds a multisig address to the wallet. */
23
+ export interface AddMultisigAddress {
24
+ method: 'addmultisigaddress';
25
+ params: [
26
+ nrequired: number,
27
+ keys: string[],
28
+ label?: string
29
+ ];
30
+ response: {
31
+ address: string;
32
+ redeemScript: string;
33
+ };
34
+ }
35
+
36
+ /** Backs up wallet to specified file. */
37
+ export interface BackupWallet {
38
+ method: 'backupwallet';
39
+ params: [
40
+ destination: string
41
+ ];
42
+ response: null;
43
+ }
44
+
45
+ /** Creates a new wallet. */
46
+ export interface CreateWallet {
47
+ method: 'createwallet';
48
+ params: [
49
+ wallet_name: string,
50
+ disable_private_keys?: boolean,
51
+ blank?: boolean
52
+ ];
53
+ response: {
54
+ name: string;
55
+ warning?: string;
56
+ };
57
+ }
58
+
59
+ /** Dumps all wallet keys to a file. */
60
+ export interface DumpWallet {
61
+ method: 'dumpwallet';
62
+ params: [
63
+ filename: string
64
+ ];
65
+ response: {
66
+ filename: string;
67
+ };
68
+ }
69
+
70
+ /** Returns private key for an address. */
71
+ export interface DumpPrivKey {
72
+ method: 'dumpprivkey';
73
+ params: [
74
+ address: string,
75
+ ];
76
+ response: string;
77
+ }
78
+
79
+ /** Encrypts wallet with passphrase (requires restart). */
80
+ export interface EncryptWallet {
81
+ method: 'encryptwallet';
82
+ params: [
83
+ passphrase: string
84
+ ];
85
+ response: string;
86
+ }
87
+
88
+ /** Returns addresses assigned to a label. */
89
+ export interface GetAddressesByLabel {
90
+ method: 'getaddressesbylabel';
91
+ params: [
92
+ label: string
93
+ ];
94
+ response: {
95
+ [address: string]: {
96
+ purpose: string;
97
+ };
98
+ };
99
+ }
100
+
101
+ /** Returns detailed information about an address. */
102
+ export interface GetAddressInfo {
103
+ method: 'getaddressinfo';
104
+ params: [string];
105
+ response: {
106
+ address: string;
107
+ scriptPubKey: string;
108
+ ismine: boolean;
109
+ iswatchonly: boolean;
110
+ isscript: boolean;
111
+ ischange: boolean;
112
+ script?: 'nonstandard' | 'pubkey' | 'pubkeyhash' | 'scripthash' | 'multisig' | 'nulldata';
113
+ hex?: string;
114
+ pubkeys?: string[];
115
+ sigsrequired?: number;
116
+ pubkey?: string;
117
+ embedded?: object;
118
+ iscompressed: boolean;
119
+ label: string;
120
+ timestamp?: number;
121
+ hdkeypath?: string;
122
+ hdseedid?: string;
123
+ hdmasterkeyid?: string;
124
+ labels: {
125
+ name: string;
126
+ purpose: 'send' | 'receive';
127
+ }[];
128
+ };
129
+ }
130
+
131
+ /** Returns wallet balance. */
132
+ export interface GetBalance {
133
+ method: 'getbalance';
134
+ params: [
135
+ dummy?: string,
136
+ minconf?: number,
137
+ include_watchonly?: boolean
138
+ ];
139
+ response: number;
140
+ }
141
+
142
+ /** Generates a new address for receiving payments. */
143
+ export interface GetNewAddress {
144
+ method: 'getnewaddress';
145
+ params: [
146
+ label?: string,
147
+ ];
148
+ response: string;
149
+ }
150
+
151
+ /** Returns a new address for receiving change. */
152
+ export interface GetRawChangeAddress {
153
+ method: 'getrawchangeaddress';
154
+ params: [];
155
+ response: string;
156
+ }
157
+
158
+ /** Returns total amount received by an address. */
159
+ export interface GetReceivedByAddress {
160
+ method: 'getreceivedbyaddress';
161
+ params: [
162
+ address: string,
163
+ minconf?: number
164
+ ];
165
+ response: number;
166
+ }
167
+
168
+ /** Returns total amount received by addresses with a label. */
169
+ export interface GetReceivedByLabel {
170
+ method: 'getreceivedbylabel';
171
+ params: [
172
+ label: string,
173
+ minconf?: number
174
+ ];
175
+ response: number;
176
+ }
177
+
178
+ /** Returns detailed information about an in-wallet transaction. */
179
+ export interface GetTransaction {
180
+ method: 'gettransaction';
181
+ params: [
182
+ txid: string,
183
+ include_watchonly?: boolean
184
+ ];
185
+ response: {
186
+ amount: number;
187
+ fee?: number;
188
+ confirmations: number;
189
+ blockhash?: string;
190
+ blockindex?: number;
191
+ blocktime?: number;
192
+ txid: string;
193
+ time: number;
194
+ timereceived: number;
195
+ 'bip125-replaceable': 'yes' | 'no' | 'unknown';
196
+ details: {
197
+ address: string;
198
+ category: 'send' | 'receive';
199
+ amount: number;
200
+ label?: string;
201
+ vout: number;
202
+ fee?: number;
203
+ abandoned?: boolean;
204
+ }[];
205
+ hex: string;
206
+ };
207
+ }
208
+
209
+ /** Returns unconfirmed balance. */
210
+ export interface GetUnconfirmedBalance {
211
+ method: 'getunconfirmedbalance';
212
+ params: [];
213
+ response: number;
214
+ }
215
+
216
+ /** Returns wallet state info. */
217
+ export interface GetWalletInfo {
218
+ method: 'getwalletinfo';
219
+ params: [];
220
+ response: {
221
+ walletname: string,
222
+ walletversion: number;
223
+ balance: number;
224
+ unconfirmed_balance: number;
225
+ immature_balance: number;
226
+ txcount: number;
227
+ keypoololdest: number;
228
+ keypoolsize: number;
229
+ keypoolsize_hd_internal: number;
230
+ unlocked_until: number;
231
+ paytxfee: number;
232
+ hdseedid?: string;
233
+ hdmasterkeyid?: string;
234
+ private_keys_enabled: boolean;
235
+ }
236
+ }
237
+
238
+ /** Imports an address or script for watching (without private key). */
239
+ export interface ImportAddress {
240
+ method: 'importaddress';
241
+ params: [
242
+ address: string,
243
+ label?: string,
244
+ rescan?: boolean,
245
+ p2sh?: boolean
246
+ ];
247
+ response: number;
248
+ }
249
+
250
+ /** Imports multiple addresses/scripts/keys. */
251
+ export interface ImportMulti {
252
+ method: 'importmulti';
253
+ params: [
254
+ requests: {
255
+ scriptPubKey: string | { address: string };
256
+ timestamp: number | 'now';
257
+ redeemscript?: string;
258
+ pubkeys?: string[];
259
+ keys?: string[];
260
+ internal?: boolean;
261
+ watchonly?: boolean;
262
+ label?: string;
263
+ }[],
264
+ options?: {
265
+ rescan?: boolean;
266
+ }
267
+ ];
268
+ response: {
269
+ success: boolean;
270
+ error?: {
271
+ code: number;
272
+ message: string;
273
+ };
274
+ }[];
275
+ }
276
+
277
+ /** Imports a private key. */
278
+ export interface ImportPrivKey {
279
+ method: 'importprivkey';
280
+ params: [
281
+ privkey: string,
282
+ label?: string,
283
+ rescan?: boolean
284
+ ];
285
+ response: null;
286
+ }
287
+
288
+ /** Imports funds without rescan (requires merkle proof). */
289
+ export interface ImportPrunedFunds {
290
+ method: 'importprunedfunds';
291
+ params: [
292
+ rawtransaction: string,
293
+ txoutproof: string
294
+ ];
295
+ response: null;
296
+ }
297
+
298
+ /** Imports a public key for watching. */
299
+ export interface ImportPubKey {
300
+ method: 'importpubkey';
301
+ params: [
302
+ pubkey: string,
303
+ label?: string,
304
+ rescan?: boolean
305
+ ];
306
+ response: null;
307
+ }
308
+
309
+ /** Imports keys from a wallet dump file. */
310
+ export interface ImportWallet {
311
+ method: 'importwallet';
312
+ params: [
313
+ filename: string
314
+ ];
315
+ response: null;
316
+ }
317
+
318
+ /** Refills the keypool. */
319
+ export interface KeyPoolRefill {
320
+ method: 'keypoolrefill';
321
+ params: [
322
+ newsize?: number
323
+ ];
324
+ response: null;
325
+ }
326
+
327
+ /** Returns addresses grouped by common ownership. */
328
+ export interface ListAddressGroupings {
329
+ method: 'listaddressgroupings';
330
+ params: [];
331
+ response: [
332
+ [
333
+ {
334
+ address: string;
335
+ amount: number;
336
+ label?: string;
337
+ }[]
338
+ ][]
339
+ ];
340
+ }
341
+
342
+ /** Returns all labels in the wallet. */
343
+ export interface ListLabels {
344
+ method: 'listlabels';
345
+ params: [
346
+ purpose?: string
347
+ ];
348
+ response: string[];
349
+ }
350
+
351
+ /** Returns list of locked unspent outputs. */
352
+ export interface ListLockUnspent {
353
+ method: 'listlockunspent';
354
+ params: [];
355
+ response: {
356
+ txid: string;
357
+ vout: number;
358
+ }[];
359
+ }
360
+
361
+ /** Lists transactions received by address. */
362
+ export interface ListReceivedByAddress {
363
+ method: 'listreceivedbyaddress';
364
+ params: [
365
+ minconf?: number,
366
+ include_empty?: boolean,
367
+ include_watchonly?: boolean,
368
+ address_filter?: string
369
+ ];
370
+ response: {
371
+ involvesWatchonly?: boolean;
372
+ address: string;
373
+ amount: number;
374
+ confirmations: number;
375
+ label: string;
376
+ txids: string[];
377
+ }[];
378
+ }
379
+
380
+ /** Lists transactions received by label. */
381
+ export interface ListReceivedByLabel {
382
+ method: 'listreceivedbylabel';
383
+ params: [
384
+ minconf?: number,
385
+ include_empty?: boolean,
386
+ include_watchonly?: boolean
387
+ ];
388
+ response: {
389
+ involvesWatchonly?: boolean;
390
+ amount: number;
391
+ confirmations: number;
392
+ label: string;
393
+ }[];
394
+ }
395
+
396
+ /** Wallet transaction representation. */
397
+ interface TransactionWallet {
398
+ address?: string;
399
+ category: 'send' | 'receive';
400
+ amount: number;
401
+ vout: number;
402
+ fee?: number;
403
+ confirmations: number;
404
+ blockhash?: string;
405
+ blockindex?: number;
406
+ blocktime?: number;
407
+ txid: string;
408
+ time: number;
409
+ timereceived: number;
410
+ abandoned?: boolean;
411
+ comment?: string;
412
+ label?: string;
413
+ to?: string;
414
+ }
415
+
416
+ /** Returns transactions since a block. */
417
+ export interface ListSinceBlock {
418
+ method: 'listsinceblock';
419
+ params: [
420
+ blockhash?: string,
421
+ target_confirmations?: number,
422
+ include_watchonly?: boolean,
423
+ include_removed?: boolean
424
+ ];
425
+ response: {
426
+ transactions: TransactionWallet[];
427
+ removed?: TransactionWallet[];
428
+ lastblock: string;
429
+ };
430
+ }
431
+
432
+ /** Returns recent transactions for the wallet. */
433
+ export interface ListTransactions {
434
+ method: 'listtransactions';
435
+ params: [
436
+ label?: string,
437
+ count?: number,
438
+ skip?: number,
439
+ include_watchonly?: boolean
440
+ ];
441
+ response: TransactionWallet[];
442
+ }
443
+
444
+ /** Returns unspent outputs in the wallet. */
445
+ export interface ListUnspent {
446
+ method: 'listunspent';
447
+ params: [
448
+ minconf?: number,
449
+ maxconf?: number,
450
+ addresses?: string[],
451
+ include_unsafe?: boolean,
452
+ query_options?: {
453
+ minimumAmount?: number | string;
454
+ maximumAmount?: number | string;
455
+ maximumCount?: number;
456
+ minimumSumAmount?: number | string;
457
+ includeTokens?: boolean;
458
+ tokensOnly?: boolean;
459
+ }
460
+ ];
461
+ response: ListUnspentItem[];
462
+ }
463
+
464
+ /** Single UTXO from listunspent. */
465
+ export interface ListUnspentItem {
466
+ txid: string;
467
+ vout: number;
468
+ address: string;
469
+ label: string;
470
+ scriptPubKey: string;
471
+ amount: number;
472
+ tokenData?: TokenData;
473
+ confirmations: number;
474
+ redeemScript: string;
475
+ spendable: boolean;
476
+ solvable: boolean;
477
+ safe: boolean;
478
+ }
479
+
480
+ /** Returns list of available wallets. */
481
+ export interface ListWalletDir {
482
+ method: 'listwalletdir';
483
+ params: [];
484
+ response: {
485
+ wallets: {
486
+ name: string;
487
+ }[];
488
+ };
489
+ }
490
+
491
+ /** Returns list of loaded wallets. */
492
+ export interface ListWallets {
493
+ method: 'importaddress';
494
+ params: [];
495
+ response: string[];
496
+ }
497
+
498
+ /** Loads a wallet from file. */
499
+ export interface LoadWallet {
500
+ method: 'loadwallet';
501
+ params: [
502
+ filename: string
503
+ ];
504
+ response: {
505
+ name: string;
506
+ warning?: string;
507
+ };
508
+ }
509
+
510
+ /** Locks or unlocks unspent outputs. */
511
+ export interface LockUnspent {
512
+ method: 'lockunspent';
513
+ params: [
514
+ unlock: boolean,
515
+ transactions?: {
516
+ txid: string;
517
+ vout: number;
518
+ }[]
519
+ ];
520
+ response: boolean;
521
+ }
522
+
523
+ /** Removes imported pruned funds from wallet. */
524
+ export interface RemovePrunedFunds {
525
+ method: 'removeprunedfunds';
526
+ params: [
527
+ txid: string
528
+ ];
529
+ response: null;
530
+ }
531
+
532
+ /** Rescans blockchain for wallet transactions. */
533
+ export interface RescanBlockchain {
534
+ method: 'rescanblockchain';
535
+ params: [
536
+ start_height?: number,
537
+ stop_height?: number
538
+ ];
539
+ response: {
540
+ start_height: number;
541
+ stop_height: number;
542
+ };
543
+ }
544
+
545
+ /** Sends to multiple recipients. */
546
+ export interface SendMany {
547
+ method: 'sendmany';
548
+ params: [
549
+ dummy: string,
550
+ amounts: {
551
+ [address: string]: number | string
552
+ },
553
+ minconf?: number,
554
+ comment?: string,
555
+ subtractfeefrom?: string[],
556
+ coinsel?: number,
557
+ include_unsafe?: boolean
558
+ ];
559
+ response: string;
560
+ }
561
+
562
+ /** Sends to a single address. */
563
+ export interface SendToAddress {
564
+ method: 'sendtoaddress';
565
+ params: [
566
+ address: string,
567
+ amount: number | string,
568
+ comment?: string,
569
+ comment_to?: string,
570
+ subtractfeefromamount?: boolean,
571
+ coinsel?: number,
572
+ include_unsafe?: boolean
573
+ ];
574
+ response: string;
575
+ }
576
+
577
+ /** Sets the HD seed for the wallet. */
578
+ export interface SetHdSeed {
579
+ method: 'sethdseed';
580
+ params: [
581
+ newkeypool?: boolean,
582
+ seed?: string
583
+ ];
584
+ response: null;
585
+ }
586
+
587
+ /** Sets the label for an address. */
588
+ export interface SetLabel {
589
+ method: 'setlabel';
590
+ params: [
591
+ address: string,
592
+ label: string
593
+ ];
594
+ response: null;
595
+ }
596
+
597
+ /** Sets the transaction fee per kB. */
598
+ export interface SetTxFee {
599
+ method: 'settxfee';
600
+ params: [
601
+ amount: number | string
602
+ ];
603
+ response: boolean;
604
+ }
605
+
606
+ /** Signs a message with an address's private key. */
607
+ export interface SignMessage {
608
+ method: 'signmessage';
609
+ params: [
610
+ address: string,
611
+ message: string
612
+ ];
613
+ response: string;
614
+ }
615
+
616
+ /** Signs a raw transaction with wallet keys. */
617
+ export interface SignRawTransactionWithWallet {
618
+ method: 'signrawtransactionwithwallet';
619
+ params: [
620
+ hexstring: string,
621
+ prevtxs?: {
622
+ txid: string;
623
+ vout: number;
624
+ scriptPubKey: string;
625
+ redeemScript?: string;
626
+ amount: number | string;
627
+ tokenData?: TokenData
628
+ }[],
629
+ sighashtype?: string
630
+ ];
631
+ response: {
632
+ hex: string;
633
+ complete: boolean;
634
+ errors?: {
635
+ txid: string;
636
+ vout: number;
637
+ scriptSig: string;
638
+ sequence: number;
639
+ error: string;
640
+ }[];
641
+ };
642
+ }
643
+
644
+ /** Unloads a wallet. */
645
+ export interface UnloadWallet {
646
+ method: 'unloadwallet';
647
+ params: [
648
+ wallet_name?: string
649
+ ];
650
+ response: null;
651
+ }
652
+
653
+ /** Creates and funds a PSBT. */
654
+ export interface WalletCreateFundedPsbt {
655
+ method: 'walletcreatefundedpsbt';
656
+ params: [
657
+ inputs: {
658
+ txid: string;
659
+ vout: number;
660
+ sequence: number;
661
+ }[],
662
+ outputs: {
663
+ address?: number | string | {
664
+ amount: number | string;
665
+ tokenData?: TokenData;
666
+ };
667
+ data?: string | string[];
668
+ }[],
669
+ locktime?: number,
670
+ options?: {
671
+ include_unsafe?: boolean;
672
+ changeAddress?: string;
673
+ changePosition?: number;
674
+ includeWatching?: boolean;
675
+ lockUnspents?: boolean;
676
+ feeRate?: number | string;
677
+ subtractFeeFromOutputs?: number[];
678
+ },
679
+ bip32derivs?: boolean
680
+ ];
681
+ response: {
682
+ psbt: string;
683
+ fee: number;
684
+ changepos: number;
685
+ };
686
+ }
687
+
688
+ /** Locks the encrypted wallet. */
689
+ export interface WalletLock {
690
+ method: 'walletlock';
691
+ params: [];
692
+ response: null;
693
+ }
694
+
695
+ /** Unlocks the wallet for a specified time. */
696
+ export interface WalletPassphrase {
697
+ method: 'walletpassphrase';
698
+ params: [
699
+ passphrase: string,
700
+ timeout: number
701
+ ];
702
+ response: null;
703
+ }
704
+
705
+ /** Changes the wallet passphrase. */
706
+ export interface WalletPassphraseChange {
707
+ method: 'walletpassphrasechange';
708
+ params: [
709
+ oldpassphrase: string,
710
+ newpassphrase: string
711
+ ];
712
+ response: null;
713
+ }
714
+
715
+ /** Processes a PSBT with wallet data. */
716
+ export interface WalletProcessPsbt {
717
+ method: 'walletprocesspsbt';
718
+ params: [
719
+ psbt: string,
720
+ sign?: boolean,
721
+ sighashtype?: string,
722
+ bip32derivs?: boolean
723
+ ];
724
+ response: {
725
+ psbt: string;
726
+ complete: boolean;
727
+ };
728
+ }