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

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 (59) hide show
  1. package/dist/src/index.d.ts +4 -0
  2. package/dist/src/index.js +4 -0
  3. package/{src/interfaces/interfaces.ts → dist/src/interfaces/interfaces.d.ts} +51 -65
  4. package/dist/src/interfaces/interfaces.js +1 -0
  5. package/{src/interfaces/restInterfaces/interfaces.ts → dist/src/interfaces/restInterfaces/interfaces.d.ts} +145 -166
  6. package/dist/src/interfaces/restInterfaces/interfaces.js +1 -0
  7. package/dist/src/interfaces/rpcInterfaces/blockchain.d.ts +883 -0
  8. package/dist/src/interfaces/rpcInterfaces/blockchain.js +3 -0
  9. package/dist/src/interfaces/rpcInterfaces/control.d.ts +60 -0
  10. package/dist/src/interfaces/rpcInterfaces/control.js +3 -0
  11. package/dist/src/interfaces/rpcInterfaces/generating.d.ts +19 -0
  12. package/dist/src/interfaces/rpcInterfaces/generating.js +3 -0
  13. package/dist/src/interfaces/rpcInterfaces/index.d.ts +9 -0
  14. package/{src/interfaces/rpcInterfaces/index.ts → dist/src/interfaces/rpcInterfaces/index.js} +1 -3
  15. package/dist/src/interfaces/rpcInterfaces/mining.d.ts +140 -0
  16. package/dist/src/interfaces/rpcInterfaces/mining.js +3 -0
  17. package/dist/src/interfaces/rpcInterfaces/network.d.ts +197 -0
  18. package/dist/src/interfaces/rpcInterfaces/network.js +3 -0
  19. package/dist/src/interfaces/rpcInterfaces/rawtransactions.d.ts +304 -0
  20. package/dist/src/interfaces/rpcInterfaces/rawtransactions.js +3 -0
  21. package/dist/src/interfaces/rpcInterfaces/util.d.ts +49 -0
  22. package/dist/src/interfaces/rpcInterfaces/util.js +3 -0
  23. package/dist/src/interfaces/rpcInterfaces/wallet.d.ts +674 -0
  24. package/dist/src/interfaces/rpcInterfaces/wallet.js +3 -0
  25. package/dist/src/interfaces/rpcInterfaces/zmq.d.ts +9 -0
  26. package/dist/src/interfaces/rpcInterfaces/zmq.js +3 -0
  27. package/dist/src/restClient.d.ts +29 -0
  28. package/dist/src/restClient.js +113 -0
  29. package/dist/src/rpcClient.d.ts +19 -0
  30. package/dist/src/rpcClient.js +92 -0
  31. package/dist/src/utils/errors.d.ts +3 -0
  32. package/dist/src/utils/errors.js +6 -0
  33. package/dist/src/utils/utils.d.ts +11 -0
  34. package/dist/src/utils/utils.js +49 -0
  35. package/package.json +7 -3
  36. package/.claude/settings.local.json +0 -8
  37. package/.github/workflows/ci.yaml +0 -36
  38. package/CLAUDE.md +0 -70
  39. package/pnpm-lock.yaml +0 -1279
  40. package/src/index.ts +0 -4
  41. package/src/interfaces/rpcInterfaces/blockchain.ts +0 -933
  42. package/src/interfaces/rpcInterfaces/control.ts +0 -68
  43. package/src/interfaces/rpcInterfaces/generating.ts +0 -23
  44. package/src/interfaces/rpcInterfaces/mining.ts +0 -151
  45. package/src/interfaces/rpcInterfaces/network.ts +0 -213
  46. package/src/interfaces/rpcInterfaces/rawtransactions.ts +0 -332
  47. package/src/interfaces/rpcInterfaces/util.ts +0 -56
  48. package/src/interfaces/rpcInterfaces/wallet.ts +0 -728
  49. package/src/interfaces/rpcInterfaces/zmq.ts +0 -12
  50. package/src/restClient.ts +0 -134
  51. package/src/rpcClient.ts +0 -100
  52. package/src/utils/errors.ts +0 -6
  53. package/src/utils/utils.ts +0 -55
  54. package/test/restClient.test.ts +0 -34
  55. package/test/rpcClient.test.ts +0 -119
  56. package/test/setupTests.ts +0 -56
  57. package/test/tsconfig.json +0 -4
  58. package/tsconfig.json +0 -13
  59. package/vitest.config.ts +0 -9
@@ -1,728 +0,0 @@
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
- }
@@ -1,12 +0,0 @@
1
- /* --- Zmq Commands --- */
2
- // progress 1/1
3
-
4
- /** Returns active ZMQ notification endpoints. */
5
- export interface GetZmqNotifications {
6
- method: 'getzmqnotifications';
7
- params: [];
8
- response: {
9
- type: string;
10
- address: string;
11
- }[]
12
- }