@mr-zwets/bchn-api-wrapper 1.0.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +129 -0
  3. package/dist/index.d.ts +4 -0
  4. package/dist/index.js +4 -0
  5. package/dist/interfaces/interfaces.d.ts +70 -0
  6. package/dist/interfaces/interfaces.js +1 -0
  7. package/dist/interfaces/restInterfaces/interfaces.d.ts +109 -0
  8. package/dist/interfaces/restInterfaces/interfaces.js +1 -0
  9. package/dist/interfaces/rpcInterfaces/blockchain.d.ts +692 -0
  10. package/dist/interfaces/rpcInterfaces/blockchain.js +3 -0
  11. package/dist/interfaces/rpcInterfaces/control.d.ts +54 -0
  12. package/dist/interfaces/rpcInterfaces/control.js +3 -0
  13. package/dist/interfaces/rpcInterfaces/generating.d.ts +17 -0
  14. package/dist/interfaces/rpcInterfaces/generating.js +3 -0
  15. package/dist/interfaces/rpcInterfaces/index.d.ts +9 -0
  16. package/dist/interfaces/rpcInterfaces/index.js +12 -0
  17. package/dist/interfaces/rpcInterfaces/mining.d.ts +131 -0
  18. package/dist/interfaces/rpcInterfaces/mining.js +3 -0
  19. package/dist/interfaces/rpcInterfaces/network.d.ts +179 -0
  20. package/dist/interfaces/rpcInterfaces/network.js +3 -0
  21. package/dist/interfaces/rpcInterfaces/rawtransactions.d.ts +283 -0
  22. package/dist/interfaces/rpcInterfaces/rawtransactions.js +3 -0
  23. package/dist/interfaces/rpcInterfaces/util.d.ts +44 -0
  24. package/dist/interfaces/rpcInterfaces/util.js +3 -0
  25. package/dist/interfaces/rpcInterfaces/wallet.d.ts +620 -0
  26. package/dist/interfaces/rpcInterfaces/wallet.js +3 -0
  27. package/dist/interfaces/rpcInterfaces/zmq.d.ts +8 -0
  28. package/dist/interfaces/rpcInterfaces/zmq.js +3 -0
  29. package/dist/restClient.d.ts +17 -0
  30. package/dist/restClient.js +100 -0
  31. package/dist/rpcClient.d.ts +12 -0
  32. package/dist/rpcClient.js +85 -0
  33. package/dist/utils/errors.d.ts +3 -0
  34. package/dist/utils/errors.js +6 -0
  35. package/dist/utils/utils.d.ts +11 -0
  36. package/dist/utils/utils.js +49 -0
  37. package/package.json +40 -0
  38. package/src/index.ts +4 -0
  39. package/src/interfaces/interfaces.ts +87 -0
  40. package/src/interfaces/restInterfaces/interfaces.ts +117 -0
  41. package/src/interfaces/rpcInterfaces/blockchain.ts +759 -0
  42. package/src/interfaces/rpcInterfaces/control.ts +62 -0
  43. package/src/interfaces/rpcInterfaces/generating.ts +21 -0
  44. package/src/interfaces/rpcInterfaces/index.ts +14 -0
  45. package/src/interfaces/rpcInterfaces/mining.ts +143 -0
  46. package/src/interfaces/rpcInterfaces/network.ts +195 -0
  47. package/src/interfaces/rpcInterfaces/rawtransactions.ts +314 -0
  48. package/src/interfaces/rpcInterfaces/util.ts +52 -0
  49. package/src/interfaces/rpcInterfaces/wallet.ts +674 -0
  50. package/src/interfaces/rpcInterfaces/zmq.ts +11 -0
  51. package/src/restClient.ts +119 -0
  52. package/src/rpcClient.ts +93 -0
  53. package/src/utils/errors.ts +6 -0
  54. package/src/utils/utils.ts +55 -0
  55. package/test/restClient.test.ts +32 -0
  56. package/test/rpcClient.test.ts +115 -0
  57. package/test/setupTests.ts +54 -0
  58. package/test/tsconfig.json +4 -0
  59. package/tsconfig.json +13 -0
  60. package/vitest.config.ts +9 -0
@@ -0,0 +1,674 @@
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
+ }
@@ -0,0 +1,11 @@
1
+ /* --- Zmq Commands --- */
2
+ // progress 1/1
3
+
4
+ export interface GetZmqNotifications {
5
+ method: 'getzmqnotifications';
6
+ params: [];
7
+ response: {
8
+ type: string;
9
+ address: string;
10
+ }[]
11
+ }