@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,3 +1,4 @@
1
+ /** Returns memory usage information. */
1
2
  export interface GetMemoryInfo {
2
3
  method: 'getmemoryinfo';
3
4
  params: [
@@ -14,6 +15,7 @@ export interface GetMemoryInfo {
14
15
  };
15
16
  };
16
17
  }
18
+ /** Returns details about the RPC server. */
17
19
  export interface GetRpcInfo {
18
20
  method: 'getrpcinfo';
19
21
  params: [];
@@ -25,6 +27,7 @@ export interface GetRpcInfo {
25
27
  logpath: string;
26
28
  };
27
29
  }
30
+ /** Returns help text for RPC commands. */
28
31
  export interface Help {
29
32
  method: 'help';
30
33
  params: [
@@ -32,6 +35,7 @@ export interface Help {
32
35
  ];
33
36
  response: string;
34
37
  }
38
+ /** Gets or sets logging categories. */
35
39
  export interface Logging {
36
40
  method: 'logging';
37
41
  params: [
@@ -42,11 +46,13 @@ export interface Logging {
42
46
  [category: string]: boolean;
43
47
  };
44
48
  }
49
+ /** Stops the BCHN server. */
45
50
  export interface Stop {
46
51
  method: 'stop';
47
52
  params: [];
48
53
  response: string;
49
54
  }
55
+ /** Returns server uptime in seconds. */
50
56
  export interface Uptime {
51
57
  method: 'uptime';
52
58
  params: [];
@@ -1,3 +1,4 @@
1
+ /** Mines blocks to the wallet (regtest only). */
1
2
  export interface Generate {
2
3
  method: 'generate';
3
4
  params: [
@@ -6,6 +7,7 @@ export interface Generate {
6
7
  ];
7
8
  response: string[];
8
9
  }
10
+ /** Mines blocks to a specified address (regtest only). */
9
11
  export interface GenerateToAddress {
10
12
  method: 'generatetoaddress';
11
13
  params: [
@@ -1,3 +1,4 @@
1
+ /** Returns a block template for mining. */
1
2
  export interface GetBlockTemplate {
2
3
  method: 'getblocktemplate';
3
4
  params: {
@@ -35,6 +36,7 @@ export interface GetBlockTemplate {
35
36
  height: number;
36
37
  };
37
38
  }
39
+ /** Returns a lightweight block template (for mining pools). */
38
40
  export interface GetBlockTemplateLight {
39
41
  method: 'getblocktemplatelight';
40
42
  params: [
@@ -68,6 +70,7 @@ export interface GetBlockTemplateLight {
68
70
  height: number;
69
71
  };
70
72
  }
73
+ /** Returns mining-related information. */
71
74
  export interface GetMiningInfo {
72
75
  method: 'getmininginfo';
73
76
  params: [];
@@ -83,6 +86,7 @@ export interface GetMiningInfo {
83
86
  warnings: string;
84
87
  };
85
88
  }
89
+ /** Returns estimated network hash rate. */
86
90
  export interface GetNetworkHashps {
87
91
  method: 'getnetworkhashps';
88
92
  params: [
@@ -91,6 +95,7 @@ export interface GetNetworkHashps {
91
95
  ];
92
96
  response: number;
93
97
  }
98
+ /** Modifies a mempool transaction's priority. */
94
99
  export interface PrioritiseTransaction {
95
100
  method: 'prioritisetransaction';
96
101
  params: [
@@ -99,6 +104,7 @@ export interface PrioritiseTransaction {
99
104
  ];
100
105
  response: true;
101
106
  }
107
+ /** Submits a mined block to the network. */
102
108
  export interface SubmitBlock {
103
109
  method: 'submitblock';
104
110
  params: [
@@ -107,6 +113,7 @@ export interface SubmitBlock {
107
113
  ];
108
114
  response: {};
109
115
  }
116
+ /** Submits a lightweight block (for mining pools). */
110
117
  export interface SubmitBlockLight {
111
118
  method: 'submitblocklight';
112
119
  params: [
@@ -115,6 +122,7 @@ export interface SubmitBlockLight {
115
122
  ];
116
123
  response: {};
117
124
  }
125
+ /** Submits a block header for validation. */
118
126
  export interface SubmitHeader {
119
127
  method: 'submitheader';
120
128
  params: [
@@ -122,6 +130,7 @@ export interface SubmitHeader {
122
130
  ];
123
131
  response: {};
124
132
  }
133
+ /** Validates a block template without mining. */
125
134
  export interface ValidateBlockTemplate {
126
135
  method: 'validateblocktemplate';
127
136
  params: [
@@ -1,3 +1,4 @@
1
+ /** Adds or removes a node from the addnode list. */
1
2
  export interface AddNode {
2
3
  method: 'addnode';
3
4
  params: [
@@ -6,6 +7,7 @@ export interface AddNode {
6
7
  ];
7
8
  response: null;
8
9
  }
10
+ /** Clears all banned IPs. */
9
11
  export interface ClearBanned {
10
12
  method: 'clearbanned';
11
13
  params: [
@@ -14,6 +16,7 @@ export interface ClearBanned {
14
16
  ];
15
17
  response: null;
16
18
  }
19
+ /** Disconnects a node by address or node ID. */
17
20
  export interface DisconnectNode {
18
21
  method: 'disconnectnode';
19
22
  params: [
@@ -22,6 +25,7 @@ export interface DisconnectNode {
22
25
  ];
23
26
  response: null;
24
27
  }
28
+ /** Returns info about manually added nodes. */
25
29
  export interface GetAddedNodeInfo {
26
30
  method: 'getaddednodeinfo';
27
31
  params: [
@@ -36,16 +40,19 @@ export interface GetAddedNodeInfo {
36
40
  }[];
37
41
  }[];
38
42
  }
43
+ /** Returns the number of connections to other nodes. */
39
44
  export interface GetConnectionCount {
40
45
  method: 'getconnectioncount';
41
46
  params: [];
42
47
  response: number;
43
48
  }
49
+ /** Returns the excessive block size setting. */
44
50
  export interface GetExcessiveBlock {
45
51
  method: 'getexcessiveblock';
46
52
  params: [];
47
53
  response: number;
48
54
  }
55
+ /** Returns network traffic statistics. */
49
56
  export interface GetNetTotals {
50
57
  method: 'getnettotals';
51
58
  params: [];
@@ -63,6 +70,7 @@ export interface GetNetTotals {
63
70
  };
64
71
  };
65
72
  }
73
+ /** Returns network configuration and status. */
66
74
  export interface GetNetworkInfo {
67
75
  method: 'getnetworkinfo';
68
76
  params: [];
@@ -74,6 +82,8 @@ export interface GetNetworkInfo {
74
82
  localrelay: boolean;
75
83
  timeoffset: number;
76
84
  connections: number;
85
+ connections_in: number;
86
+ connections_out: number;
77
87
  networkactive: boolean;
78
88
  networks: {
79
89
  name: string;
@@ -92,6 +102,7 @@ export interface GetNetworkInfo {
92
102
  warnings: string;
93
103
  };
94
104
  }
105
+ /** Returns known peer addresses from the address manager. */
95
106
  export interface GetNodeAddresses {
96
107
  method: 'getnodeaddresses';
97
108
  params: [
@@ -104,6 +115,7 @@ export interface GetNodeAddresses {
104
115
  port: number;
105
116
  }[];
106
117
  }
118
+ /** Returns detailed info about each connected peer. */
107
119
  export interface GetPeerInfo {
108
120
  method: 'getpeerinfo';
109
121
  params: [];
@@ -137,6 +149,8 @@ export interface GetPeerInfo {
137
149
  addr_rate_limited: number;
138
150
  whitelisted: boolean;
139
151
  minfeefilter: number;
152
+ bip152_hb_to: boolean;
153
+ bip152_hb_from: boolean;
140
154
  bytessent_per_msg: {
141
155
  [msg: string]: number;
142
156
  };
@@ -145,6 +159,7 @@ export interface GetPeerInfo {
145
159
  };
146
160
  }[];
147
161
  }
162
+ /** Returns list of banned IPs/subnets. */
148
163
  export interface ListBanned {
149
164
  method: 'listbanned';
150
165
  params: [];
@@ -155,11 +170,13 @@ export interface ListBanned {
155
170
  ban_reason: string;
156
171
  }[];
157
172
  }
173
+ /** Pings all connected nodes to measure latency. */
158
174
  export interface Ping {
159
175
  method: 'ping';
160
176
  params: [];
161
177
  response: null;
162
178
  }
179
+ /** Bans or unbans a node by subnet. */
163
180
  export interface SetBan {
164
181
  method: 'setban';
165
182
  params: [
@@ -170,6 +187,7 @@ export interface SetBan {
170
187
  ];
171
188
  response: null;
172
189
  }
190
+ /** Enables or disables all P2P network activity. */
173
191
  export interface SetNetworkActive {
174
192
  method: 'setnetworkactive';
175
193
  params: [
@@ -1,4 +1,5 @@
1
1
  import type { TokenData, Transaction, TransactionInput, TransactionOutput } from "../interfaces.js";
2
+ /** Combines multiple PSBTs into one. */
2
3
  export interface CombinePsbt {
3
4
  method: 'decoderawtransaction';
4
5
  params: [
@@ -6,6 +7,7 @@ export interface CombinePsbt {
6
7
  ];
7
8
  response: string;
8
9
  }
10
+ /** Combines multiple raw transactions into one. */
9
11
  export interface CombineRawTransaction {
10
12
  method: 'combinerawtransaction';
11
13
  params: [
@@ -13,6 +15,7 @@ export interface CombineRawTransaction {
13
15
  ];
14
16
  response: string;
15
17
  }
18
+ /** Converts a raw transaction to PSBT format. */
16
19
  export interface ConvertToPsbt {
17
20
  method: 'converttopsbt';
18
21
  params: [
@@ -21,6 +24,7 @@ export interface ConvertToPsbt {
21
24
  ];
22
25
  response: string;
23
26
  }
27
+ /** Creates an unsigned PSBT. */
24
28
  export interface CreatePsbt {
25
29
  method: 'createpsbt';
26
30
  params: [
@@ -41,6 +45,7 @@ export interface CreatePsbt {
41
45
  ];
42
46
  response: string;
43
47
  }
48
+ /** Creates an unsigned raw transaction. */
44
49
  export interface CreateRawTransaction {
45
50
  method: 'createrawtransaction';
46
51
  params: [
@@ -61,6 +66,7 @@ export interface CreateRawTransaction {
61
66
  ];
62
67
  response: string;
63
68
  }
69
+ /** Decodes a PSBT to inspect its contents. */
64
70
  export interface DecodePsbt {
65
71
  method: 'decodepsbt';
66
72
  params: [
@@ -74,6 +80,7 @@ export interface DecodePsbt {
74
80
  fee?: number;
75
81
  };
76
82
  }
83
+ /** PSBT input structure. */
77
84
  interface PsbtInput {
78
85
  utxo?: {
79
86
  amount: number;
@@ -95,21 +102,25 @@ interface PsbtInput {
95
102
  };
96
103
  unknown?: Record<string, string>;
97
104
  }
105
+ /** PSBT output structure. */
98
106
  interface PsbtOutput {
99
107
  redeem_script?: RedeemScript;
100
108
  bip32_derivs?: Bip32Derivation[];
101
109
  unknown?: Record<string, string>;
102
110
  }
111
+ /** Redeem script in PSBT. */
103
112
  interface RedeemScript {
104
113
  asm: string;
105
114
  hex: string;
106
115
  type: string;
107
116
  }
117
+ /** BIP32 derivation path info. */
108
118
  interface Bip32Derivation {
109
119
  pubkey: string;
110
120
  master_fingerprint: string;
111
121
  path: string;
112
122
  }
123
+ /** Decodes a raw transaction hex string. */
113
124
  export interface DecodeRawTransaction {
114
125
  method: 'decoderawtransaction';
115
126
  params: [
@@ -117,6 +128,7 @@ export interface DecodeRawTransaction {
117
128
  ];
118
129
  response: Transaction;
119
130
  }
131
+ /** Decodes a script hex string. */
120
132
  export interface DecodeScript {
121
133
  method: 'decodescript';
122
134
  params: [
@@ -130,6 +142,7 @@ export interface DecodeScript {
130
142
  p2sh: string;
131
143
  };
132
144
  }
145
+ /** Finalizes a PSBT, extracting the raw transaction if complete. */
133
146
  export interface FinalizePsbt {
134
147
  method: 'finalizepsbt';
135
148
  params: [
@@ -142,6 +155,7 @@ export interface FinalizePsbt {
142
155
  complete: boolean;
143
156
  };
144
157
  }
158
+ /** Adds inputs to a raw transaction to meet output value. */
145
159
  export interface FundRawTransaction {
146
160
  method: 'fundrawtransaction';
147
161
  params: [
@@ -170,6 +184,7 @@ interface GetRawTransactionBase {
170
184
  blockhash?: string
171
185
  ];
172
186
  }
187
+ /** Verbosity 0: Returns raw transaction as hex string. */
173
188
  export interface GetRawTransactionVerbosity0 extends GetRawTransactionBase {
174
189
  params: [
175
190
  txid: string,
@@ -178,6 +193,7 @@ export interface GetRawTransactionVerbosity0 extends GetRawTransactionBase {
178
193
  ];
179
194
  response: string;
180
195
  }
196
+ /** Verbosity 1: Returns decoded transaction with basic info. */
181
197
  export interface GetRawTransactionVerbosity1 extends GetRawTransactionBase {
182
198
  params: [
183
199
  txid: string,
@@ -200,6 +216,7 @@ export interface GetRawTransactionVerbosity1 extends GetRawTransactionBase {
200
216
  in_active_chain?: boolean;
201
217
  };
202
218
  }
219
+ /** Verbosity 2: Returns decoded transaction with input values and fee. */
203
220
  export interface GetRawTransactionVerbosity2 extends GetRawTransactionBase {
204
221
  params: [
205
222
  txid: string,
@@ -223,6 +240,7 @@ export interface GetRawTransactionVerbosity2 extends GetRawTransactionBase {
223
240
  fee?: number;
224
241
  };
225
242
  }
243
+ /** Transaction input with previous output value (verbosity 2). */
226
244
  interface TransactionInputVerbosity2 extends TransactionInput {
227
245
  value?: number;
228
246
  scriptPubKey?: {
@@ -233,6 +251,7 @@ interface TransactionInputVerbosity2 extends TransactionInput {
233
251
  };
234
252
  tokenData?: TokenData;
235
253
  }
254
+ /** Broadcasts a signed raw transaction. */
236
255
  export interface SendRawTransaction {
237
256
  method: 'sendrawtransaction';
238
257
  params: [
@@ -241,6 +260,7 @@ export interface SendRawTransaction {
241
260
  ];
242
261
  response: string;
243
262
  }
263
+ /** Signs a raw transaction with provided private keys. */
244
264
  export interface SignRawTransactionWithKey {
245
265
  method: 'signrawtransactionwithkey';
246
266
  params: [
@@ -268,6 +288,7 @@ export interface SignRawTransactionWithKey {
268
288
  }[];
269
289
  };
270
290
  }
291
+ /** Tests if raw transactions would be accepted to mempool. */
271
292
  export interface TestMempoolAccept {
272
293
  method: 'testmempoolaccept';
273
294
  params: [
@@ -1,3 +1,4 @@
1
+ /** Creates a multisig address (without adding to wallet). */
1
2
  export interface CreateMultisig {
2
3
  method: 'createmultisig';
3
4
  params: [
@@ -9,11 +10,13 @@ export interface CreateMultisig {
9
10
  redeemScript: string;
10
11
  };
11
12
  }
13
+ /** Returns estimated fee rate in BCH/kB. */
12
14
  export interface EstimateFee {
13
15
  method: 'estimatefee';
14
16
  params: [];
15
17
  response: number;
16
18
  }
19
+ /** Signs a message with a private key (returns base64 signature). */
17
20
  export interface SignMessageWithPrivKey {
18
21
  method: 'signmessagewithprivkey';
19
22
  params: [
@@ -22,6 +25,7 @@ export interface SignMessageWithPrivKey {
22
25
  ];
23
26
  response: string;
24
27
  }
28
+ /** Validates a Bitcoin Cash address. */
25
29
  export interface ValidateAddress {
26
30
  method: 'validateaddress';
27
31
  params: [string];
@@ -33,6 +37,7 @@ export interface ValidateAddress {
33
37
  istokenaware: boolean;
34
38
  };
35
39
  }
40
+ /** Verifies a signed message. */
36
41
  export interface VerifyMessage {
37
42
  method: 'verifymessage';
38
43
  params: [