@mr-zwets/bchn-api-wrapper 1.0.1 → 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 (74) hide show
  1. package/README.md +121 -129
  2. package/dist/interfaces/interfaces.d.ts +13 -0
  3. package/dist/interfaces/restInterfaces/interfaces.d.ts +124 -18
  4. package/dist/interfaces/rpcInterfaces/blockchain.d.ts +293 -102
  5. package/dist/interfaces/rpcInterfaces/control.d.ts +6 -0
  6. package/dist/interfaces/rpcInterfaces/generating.d.ts +2 -0
  7. package/dist/interfaces/rpcInterfaces/mining.d.ts +9 -0
  8. package/dist/interfaces/rpcInterfaces/network.d.ts +18 -0
  9. package/dist/interfaces/rpcInterfaces/rawtransactions.d.ts +21 -0
  10. package/dist/interfaces/rpcInterfaces/util.d.ts +5 -0
  11. package/dist/interfaces/rpcInterfaces/wallet.d.ts +54 -0
  12. package/dist/interfaces/rpcInterfaces/zmq.d.ts +1 -0
  13. package/dist/restClient.d.ts +13 -1
  14. package/dist/restClient.js +19 -6
  15. package/dist/rpcClient.d.ts +7 -0
  16. package/dist/rpcClient.js +7 -0
  17. package/dist/src/index.d.ts +4 -0
  18. package/dist/src/index.js +4 -0
  19. package/dist/src/interfaces/interfaces.d.ts +83 -0
  20. package/dist/src/interfaces/interfaces.js +1 -0
  21. package/dist/src/interfaces/restInterfaces/interfaces.d.ts +215 -0
  22. package/dist/src/interfaces/restInterfaces/interfaces.js +1 -0
  23. package/dist/src/interfaces/rpcInterfaces/blockchain.d.ts +883 -0
  24. package/dist/src/interfaces/rpcInterfaces/blockchain.js +3 -0
  25. package/dist/src/interfaces/rpcInterfaces/control.d.ts +60 -0
  26. package/dist/src/interfaces/rpcInterfaces/control.js +3 -0
  27. package/dist/src/interfaces/rpcInterfaces/generating.d.ts +19 -0
  28. package/dist/src/interfaces/rpcInterfaces/generating.js +3 -0
  29. package/dist/src/interfaces/rpcInterfaces/index.d.ts +9 -0
  30. package/{src/interfaces/rpcInterfaces/index.ts → dist/src/interfaces/rpcInterfaces/index.js} +12 -14
  31. package/dist/src/interfaces/rpcInterfaces/mining.d.ts +140 -0
  32. package/dist/src/interfaces/rpcInterfaces/mining.js +3 -0
  33. package/dist/src/interfaces/rpcInterfaces/network.d.ts +197 -0
  34. package/dist/src/interfaces/rpcInterfaces/network.js +3 -0
  35. package/dist/src/interfaces/rpcInterfaces/rawtransactions.d.ts +304 -0
  36. package/dist/src/interfaces/rpcInterfaces/rawtransactions.js +3 -0
  37. package/dist/src/interfaces/rpcInterfaces/util.d.ts +49 -0
  38. package/dist/src/interfaces/rpcInterfaces/util.js +3 -0
  39. package/dist/src/interfaces/rpcInterfaces/wallet.d.ts +674 -0
  40. package/dist/src/interfaces/rpcInterfaces/wallet.js +3 -0
  41. package/dist/src/interfaces/rpcInterfaces/zmq.d.ts +9 -0
  42. package/dist/src/interfaces/rpcInterfaces/zmq.js +3 -0
  43. package/dist/src/restClient.d.ts +29 -0
  44. package/dist/src/restClient.js +113 -0
  45. package/dist/src/rpcClient.d.ts +19 -0
  46. package/dist/src/rpcClient.js +92 -0
  47. package/dist/src/utils/errors.d.ts +3 -0
  48. package/dist/src/utils/errors.js +6 -0
  49. package/dist/src/utils/utils.d.ts +11 -0
  50. package/dist/src/utils/utils.js +49 -0
  51. package/package.json +11 -8
  52. package/CHANGELOG.md +0 -7
  53. package/src/index.ts +0 -4
  54. package/src/interfaces/interfaces.ts +0 -87
  55. package/src/interfaces/restInterfaces/interfaces.ts +0 -117
  56. package/src/interfaces/rpcInterfaces/blockchain.ts +0 -759
  57. package/src/interfaces/rpcInterfaces/control.ts +0 -62
  58. package/src/interfaces/rpcInterfaces/generating.ts +0 -21
  59. package/src/interfaces/rpcInterfaces/mining.ts +0 -143
  60. package/src/interfaces/rpcInterfaces/network.ts +0 -195
  61. package/src/interfaces/rpcInterfaces/rawtransactions.ts +0 -314
  62. package/src/interfaces/rpcInterfaces/util.ts +0 -52
  63. package/src/interfaces/rpcInterfaces/wallet.ts +0 -674
  64. package/src/interfaces/rpcInterfaces/zmq.ts +0 -11
  65. package/src/restClient.ts +0 -119
  66. package/src/rpcClient.ts +0 -93
  67. package/src/utils/errors.ts +0 -6
  68. package/src/utils/utils.ts +0 -55
  69. package/test/restClient.test.ts +0 -32
  70. package/test/rpcClient.test.ts +0 -115
  71. package/test/setupTests.ts +0 -54
  72. package/test/tsconfig.json +0 -4
  73. package/tsconfig.json +0 -13
  74. package/vitest.config.ts +0 -9
@@ -1,62 +0,0 @@
1
- /* --- Control Commands --- */
2
- // progress 6/6
3
-
4
- export interface GetMemoryInfo {
5
- method: 'getmemoryinfo';
6
- params: [
7
- mode?: 'stats' | 'mallocinfo'
8
- ];
9
- response: {
10
- locked: {
11
- used: number;
12
- free: number;
13
- total: number;
14
- locked: number;
15
- chunks_used: number;
16
- chunks_free: number;
17
- };
18
- };
19
- }
20
-
21
- export interface GetRpcInfo {
22
- method: 'getrpcinfo';
23
- params: [];
24
- response: {
25
- active_commands: {
26
- method: string;
27
- duration: number;
28
- }[];
29
- logpath: string;
30
- };
31
- }
32
-
33
- export interface Help {
34
- method: 'help';
35
- params: [
36
- command?: string
37
- ];
38
- response: string;
39
- }
40
-
41
- export interface Logging {
42
- method: 'logging';
43
- params: [
44
- include_category?: string[],
45
- exclude_category?: string[]
46
- ];
47
- response: {
48
- [category: string]: boolean;
49
- };
50
- }
51
-
52
- export interface Stop {
53
- method: 'stop';
54
- params: [];
55
- response: string;
56
- }
57
-
58
- export interface Uptime {
59
- method: 'uptime';
60
- params: [];
61
- response: number;
62
- }
@@ -1,21 +0,0 @@
1
- /* --- Generating Commands --- */
2
- // progress 2/2
3
-
4
- export interface Generate {
5
- method: 'generate';
6
- params: [
7
- nblocks: number,
8
- maxtries?: number,
9
- ];
10
- response: string[];
11
- }
12
-
13
- export interface GenerateToAddress {
14
- method: 'generatetoaddress';
15
- params: [
16
- nblocks: number,
17
- address: string,
18
- maxtries?: number,
19
- ];
20
- response: string[];
21
- }
@@ -1,143 +0,0 @@
1
- /* --- Mining Commands --- */
2
- // progress 9/9
3
-
4
- export interface GetBlockTemplate {
5
- method: 'getblocktemplate';
6
- params: {
7
- mode?: 'template' | 'proposal';
8
- capabilities?: ('longpoll' | 'coinbasetxn' | 'coinbasevalue' | 'proposal' | 'serverlist' | 'workid')[];
9
- longpollid?: string;
10
- checkvalidity?: boolean;
11
- ignorecache?: boolean;
12
- };
13
- response: {
14
- version: number;
15
- previousblockhash: string;
16
- transactions: {
17
- data: string;
18
- txid: string;
19
- hash: string;
20
- depends: number[];
21
- fee: number;
22
- sigops: number;
23
- required: boolean;
24
- }[];
25
- coinbaseaux: {
26
- flags: string;
27
- };
28
- coinbasevalue: number;
29
- coinbasetxn?: object;
30
- target: string;
31
- mintime: number;
32
- mutable: string[];
33
- noncerange: string;
34
- sigoplimit: number;
35
- sizelimit: number;
36
- curtime: number;
37
- bits: string;
38
- height: number;
39
- }
40
- }
41
-
42
- export interface GetBlockTemplateLight {
43
- method: 'getblocktemplatelight';
44
- params: [
45
- {
46
- mode?: 'template' | 'proposal';
47
- capabilities?: ('longpoll' | 'coinbasetxn' | 'coinbasevalue' | 'proposal' | 'serverlist' | 'workid')[];
48
- longpollid?: string;
49
- checkvalidity?: boolean;
50
- ignorecache?: boolean;
51
- },
52
- additional_txs?: string[]
53
- ];
54
- response: {
55
- version: number;
56
- previousblockhash: string;
57
- job_id: string;
58
- merkle: string[];
59
- coinbaseaux: {
60
- flags: string;
61
- };
62
- coinbasevalue: number;
63
- coinbasetxn: object;
64
- target: string;
65
- mintime: number;
66
- mutable: string[];
67
- noncerange: string;
68
- sigoplimit: number;
69
- sizelimit: number;
70
- curtime: number;
71
- bits: string;
72
- height: number;
73
- };
74
- }
75
-
76
-
77
- export interface GetMiningInfo {
78
- method: 'getmininginfo';
79
- params: [];
80
- response: {
81
- blocks: number;
82
- currentblocksize: number;
83
- currentblocktx: number;
84
- difficulty: number;
85
- networkhashps: number;
86
- miningblocksizelimit: number;
87
- pooledtx: number;
88
- chain: string;
89
- warnings: string;
90
- }
91
- }
92
-
93
- export interface GetNetworkHashps {
94
- method: 'getnetworkhashps';
95
- params: [
96
- nblocks?: number,
97
- height?: number
98
- ];
99
- response: number
100
- }
101
-
102
- export interface PrioritiseTransaction {
103
- method: 'prioritisetransaction';
104
- params: [
105
- txid: string,
106
- fee_delta: number
107
- ];
108
- response: true
109
- }
110
-
111
- export interface SubmitBlock {
112
- method: 'submitblock';
113
- params: [
114
- hexdata: string,
115
- dummy?: string
116
- ];
117
- response: {}
118
- }
119
-
120
- export interface SubmitBlockLight {
121
- method: 'submitblocklight';
122
- params: [
123
- hexdata: string,
124
- job_id: string
125
- ];
126
- response: {}
127
- }
128
-
129
- export interface SubmitHeader {
130
- method: 'submitheader';
131
- params: [
132
- hexdata: string
133
- ];
134
- response: {}
135
- }
136
-
137
- export interface ValidateBlockTemplate {
138
- method: 'validateblocktemplate';
139
- params: [
140
- hexdata: string
141
- ];
142
- response: true
143
- }
@@ -1,195 +0,0 @@
1
- /* --- Network Commands --- */
2
- // progress 14/14
3
-
4
- export interface AddNode {
5
- method: 'addnode';
6
- params: [
7
- node: string,
8
- command: 'add' | 'remove' | 'onetry'
9
- ];
10
- response: null;
11
- }
12
-
13
- export interface ClearBanned {
14
- method: 'clearbanned';
15
- params: [
16
- manual?: boolean,
17
- automatic?: boolean
18
- ];
19
- response: null;
20
- }
21
-
22
- export interface DisconnectNode {
23
- method: 'disconnectnode';
24
- params: [
25
- address?: string,
26
- nodeid?: number
27
- ];
28
- response: null;
29
- }
30
-
31
- export interface GetAddedNodeInfo {
32
- method: 'getaddednodeinfo';
33
- params: [
34
- node?: string
35
- ];
36
- response: {
37
- addednode: string;
38
- connected: boolean;
39
- addresses?: {
40
- address: string;
41
- connected: string;
42
- }[];
43
- }[];
44
- }
45
-
46
- export interface GetConnectionCount {
47
- method: 'getconnectioncount';
48
- params: [];
49
- response: number
50
- }
51
-
52
- export interface GetExcessiveBlock {
53
- method: 'getexcessiveblock';
54
- params: [];
55
- response: number;
56
- }
57
-
58
- export interface GetNetTotals {
59
- method: 'getnettotals';
60
- params: [];
61
- response: {
62
- totalbytesrecv: number;
63
- totalbytessent: number;
64
- timemillis: number;
65
- uploadtarget: {
66
- timeframe: number;
67
- target: number;
68
- target_reached: boolean;
69
- serve_historical_blocks: boolean;
70
- bytes_left_in_cycle: number;
71
- time_left_in_cycle: number;
72
- };
73
- };
74
- }
75
-
76
- export interface GetNetworkInfo {
77
- method: 'getnetworkinfo';
78
- params: [];
79
- response: {
80
- version: number;
81
- subversion: string;
82
- protocolversion: number;
83
- localservices: string;
84
- localrelay: boolean;
85
- timeoffset: number;
86
- connections: number;
87
- networkactive: boolean;
88
- networks: {
89
- name: string;
90
- limited: boolean;
91
- reachable: boolean;
92
- proxy: string;
93
- proxy_randomize_credentials: boolean;
94
- }[];
95
- relayfee: number;
96
- excessutxocharge: number;
97
- localaddresses: {
98
- address: string;
99
- port: number;
100
- score: number;
101
- }[]
102
- warnings: string;
103
- }
104
- }
105
-
106
- export interface GetNodeAddresses {
107
- method: 'getnodeaddresses';
108
- params: [
109
- count?: number
110
- ];
111
- response: {
112
- time: number;
113
- services: number;
114
- address: string;
115
- port: number;
116
- }[];
117
- }
118
-
119
- export interface GetPeerInfo {
120
- method: 'getpeerinfo';
121
- params: [];
122
- response: {
123
- id: number;
124
- addr: string;
125
- addrbind: string;
126
- addrlocal: string;
127
- mapped_as: string;
128
- services: string;
129
- relaytxes: boolean;
130
- lastsend: number;
131
- lastrecv: number;
132
- bytessent: number;
133
- bytesrecv: number;
134
- conntime: number;
135
- timeoffset: number;
136
- pingtime: number;
137
- minping: number;
138
- pingwait: number;
139
- version: number;
140
- subver: string;
141
- inbound: boolean;
142
- addnode: boolean;
143
- startingheight: number;
144
- banscore: number;
145
- synced_headers: number;
146
- synced_blocks: number;
147
- inflight: number[];
148
- addr_processed: number;
149
- addr_rate_limited: number;
150
- whitelisted: boolean;
151
- minfeefilter: number;
152
- bytessent_per_msg: {
153
- [msg: string]: number;
154
- };
155
- bytesrecv_per_msg: {
156
- [msg: string]: number;
157
- };
158
- }[];
159
- }
160
-
161
- export interface ListBanned {
162
- method: 'listbanned';
163
- params: [];
164
- response: {
165
- address: string;
166
- banned_until: number;
167
- ban_created: number;
168
- ban_reason: string;
169
- }[];
170
- }
171
-
172
- export interface Ping {
173
- method: 'ping';
174
- params: [];
175
- response: null;
176
- }
177
-
178
- export interface SetBan {
179
- method: 'setban';
180
- params: [
181
- subnet: string,
182
- command: 'add' | 'remove',
183
- bantime?: number,
184
- absolute?: boolean
185
- ];
186
- response: null;
187
- }
188
-
189
- export interface SetNetworkActive {
190
- method: 'setnetworkactive';
191
- params: [
192
- state: boolean
193
- ];
194
- response: null;
195
- }
@@ -1,314 +0,0 @@
1
- /* --- Rawtransactions Commands --- */
2
- // progress 14/14
3
-
4
- import type { TokenData, Transaction, TransactionInput, TransactionOutput } from "../interfaces.js";
5
-
6
- export interface CombinePsbt {
7
- method: 'decoderawtransaction';
8
- params: [
9
- txs: string[]
10
- ];
11
- response: string
12
- }
13
-
14
- export interface CombineRawTransaction {
15
- method: 'combinerawtransaction';
16
- params: [
17
- txs: string[]
18
- ];
19
- response: string;
20
- }
21
-
22
- export interface ConvertToPsbt {
23
- method: 'converttopsbt';
24
- params: [
25
- hexstring: string,
26
- permitsigdata?: boolean
27
- ];
28
- response: string;
29
- }
30
-
31
- export interface CreatePsbt {
32
- method: 'createpsbt';
33
- params: [
34
- inputs: {
35
- txid: string;
36
- vout: number;
37
- sequence?: number;
38
- }[],
39
- outputs: {
40
- [address: string]: number
41
- | {
42
- amount: number;
43
- tokendata: TokenData;
44
- }
45
- | {
46
- data: string;
47
- }
48
- }[],
49
- locktime?: number
50
- ];
51
- response: string;
52
- }
53
-
54
- export interface CreateRawTransaction {
55
- method: 'createrawtransaction';
56
- params: [
57
- inputs: {
58
- txid: string;
59
- vout: number;
60
- sequence?: number;
61
- }[],
62
- outputs: {
63
- [address: string]: number
64
- | {
65
- amount: number;
66
- tokendata: TokenData;
67
- }
68
- | {
69
- data: string;
70
- }
71
- }[],
72
- locktime?: number,
73
- ];
74
- response: string;
75
- }
76
-
77
- export interface DecodePsbt {
78
- method: 'decodepsbt';
79
- params: [
80
- psbt: string
81
- ];
82
- response: {
83
- tx: Transaction;
84
- unknown: Record<string, string>;
85
- inputs: PsbtInput[];
86
- outputs: PsbtOutput[];
87
- fee?: number;
88
- };
89
- }
90
-
91
- interface PsbtInput {
92
- utxo?: {
93
- amount: number;
94
- scriptPubKey: {
95
- asm: string;
96
- hex: string;
97
- type: string;
98
- addresses?: string[];
99
- };
100
- tokenData?: TokenData;
101
- };
102
- partial_signatures?: Record<string, string>;
103
- sighash?: string;
104
- redeem_script?: RedeemScript;
105
- bip32_derivs?: Bip32Derivation[];
106
- final_scriptsig?: {
107
- asm: string;
108
- hex: string;
109
- };
110
- unknown?: Record<string, string>;
111
- }
112
-
113
- interface PsbtOutput {
114
- redeem_script?: RedeemScript;
115
- bip32_derivs?: Bip32Derivation[];
116
- unknown?: Record<string, string>;
117
- }
118
-
119
- interface RedeemScript {
120
- asm: string;
121
- hex: string;
122
- type: string;
123
- }
124
-
125
- interface Bip32Derivation {
126
- pubkey: string;
127
- master_fingerprint: string;
128
- path: string;
129
- }
130
-
131
- export interface DecodeRawTransaction {
132
- method: 'decoderawtransaction';
133
- params: [
134
- hexstring: string
135
- ];
136
- response: Transaction
137
- }
138
-
139
- export interface DecodeScript {
140
- method: 'decodescript';
141
- params: [
142
- hexstring: string
143
- ];
144
- response: {
145
- asm: string;
146
- type: string;
147
- reqSigs: number;
148
- addresses: string[]
149
- p2sh: string;
150
- };
151
- }
152
-
153
- export interface FinalizePsbt {
154
- method: 'finalizepsbt';
155
- params: [
156
- psbt: string,
157
- extract?: boolean
158
- ];
159
- response: {
160
- psbt: string;
161
- hex: string;
162
- complete: boolean;
163
- }
164
- }
165
-
166
- export interface FundRawTransaction {
167
- method: 'fundrawtransaction';
168
- params: [
169
- hexstring: string,
170
- options?: {
171
- include_unsafe?: boolean;
172
- changeAddress?: string;
173
- changePosition?: number;
174
- includeWatching?: boolean;
175
- lockUnspents?: boolean;
176
- feeRate?: number | string;
177
- subtractFeeFromOutputs?: number[];
178
- }
179
- ];
180
- response: {
181
- hex: string;
182
- fee: number;
183
- changepos: number;
184
- };
185
- }
186
-
187
- interface GetRawTransactionBase {
188
- method: 'getrawtransaction';
189
- params: [
190
- txid: string,
191
- verbose?: boolean | number,
192
- blockhash?: string
193
- ];
194
- }
195
-
196
- export interface GetRawTransactionVerbosity0 extends GetRawTransactionBase {
197
- params: [
198
- txid: string,
199
- verbose?: false | 0,
200
- blockhash?: string
201
- ];
202
- response: string;
203
- }
204
-
205
- // Verbosity 1 (basic transaction info)
206
- export interface GetRawTransactionVerbosity1 extends GetRawTransactionBase {
207
- params: [
208
- txid: string,
209
- verbose?: true | 1,
210
- blockhash?: string
211
- ];
212
- response: {
213
- hex: string;
214
- txid: string;
215
- hash: string;
216
- size: number;
217
- version: number;
218
- locktime: number;
219
- vin: TransactionInput[];
220
- vout: TransactionOutput[];
221
- blockhash?: string;
222
- confirmations?: number;
223
- time?: number;
224
- blocktime?: number;
225
- in_active_chain?: boolean;
226
- };
227
- }
228
-
229
- // Verbosity 2 (includes input values and transaction fee)
230
- export interface GetRawTransactionVerbosity2 extends GetRawTransactionBase {
231
- params: [
232
- txid: string,
233
- verbose?: 2,
234
- blockhash?: string
235
- ];
236
- response: {
237
- hex: string;
238
- txid: string;
239
- hash: string;
240
- size: number;
241
- version: number;
242
- locktime: number;
243
- vin: TransactionInputVerbosity2[];
244
- vout: TransactionOutput[];
245
- blockhash?: string;
246
- confirmations?: number;
247
- time?: number;
248
- blocktime?: number;
249
- in_active_chain?: boolean;
250
- fee?: number;
251
- };
252
- }
253
-
254
- interface TransactionInputVerbosity2 extends TransactionInput {
255
- value?: number;
256
- scriptPubKey?: {
257
- asm: string;
258
- hex: string;
259
- type: string;
260
- address?: string;
261
- };
262
- tokenData?: TokenData;
263
- }
264
-
265
-
266
- export interface SendRawTransaction {
267
- method: 'sendrawtransaction';
268
- params: [
269
- hexstring: string,
270
- allowhighfees?: boolean
271
- ];
272
- response: string;
273
- }
274
-
275
- export interface SignRawTransactionWithKey {
276
- method: 'signrawtransactionwithkey';
277
- params: [
278
- hexstring: string,
279
- privkeys: string[],
280
- prevtxs?: {
281
- txid: string;
282
- vout: number;
283
- scriptPubKey: string;
284
- redeemScript?: string;
285
- amount: number | string;
286
- tokenData?: TokenData;
287
- }[],
288
- sighashtype?: string
289
- ];
290
- response: {
291
- hex: string;
292
- complete: boolean;
293
- errors?: {
294
- txid: string;
295
- vout: number;
296
- scriptSig: string;
297
- sequence: number;
298
- error: string;
299
- }[];
300
- };
301
- }
302
-
303
- export interface TestMempoolAccept {
304
- method: 'testmempoolaccept';
305
- params: [
306
- rawtxs: string[],
307
- allowhighfees?: boolean
308
- ];
309
- response: {
310
- txid: string
311
- allowed: boolean
312
- 'reject-reason': string
313
- }[];
314
- }