@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.
- package/.claude/settings.local.json +8 -0
- package/.github/workflows/ci.yaml +36 -0
- package/CLAUDE.md +70 -0
- package/README.md +121 -129
- package/dist/interfaces/interfaces.d.ts +13 -0
- package/dist/interfaces/restInterfaces/interfaces.d.ts +124 -18
- package/dist/interfaces/rpcInterfaces/blockchain.d.ts +293 -102
- package/dist/interfaces/rpcInterfaces/control.d.ts +6 -0
- package/dist/interfaces/rpcInterfaces/generating.d.ts +2 -0
- package/dist/interfaces/rpcInterfaces/mining.d.ts +9 -0
- package/dist/interfaces/rpcInterfaces/network.d.ts +18 -0
- package/dist/interfaces/rpcInterfaces/rawtransactions.d.ts +21 -0
- package/dist/interfaces/rpcInterfaces/util.d.ts +5 -0
- package/dist/interfaces/rpcInterfaces/wallet.d.ts +54 -0
- package/dist/interfaces/rpcInterfaces/zmq.d.ts +1 -0
- package/dist/restClient.d.ts +13 -1
- package/dist/restClient.js +19 -6
- package/dist/rpcClient.d.ts +7 -0
- package/dist/rpcClient.js +7 -0
- package/package.json +7 -8
- package/pnpm-lock.yaml +1279 -0
- package/src/index.ts +3 -3
- package/src/interfaces/interfaces.ts +96 -86
- package/src/interfaces/restInterfaces/interfaces.ts +235 -116
- package/src/interfaces/rpcInterfaces/blockchain.ts +932 -758
- package/src/interfaces/rpcInterfaces/control.ts +68 -62
- package/src/interfaces/rpcInterfaces/generating.ts +23 -21
- package/src/interfaces/rpcInterfaces/index.ts +13 -13
- package/src/interfaces/rpcInterfaces/mining.ts +151 -143
- package/src/interfaces/rpcInterfaces/network.ts +213 -195
- package/src/interfaces/rpcInterfaces/rawtransactions.ts +332 -314
- package/src/interfaces/rpcInterfaces/util.ts +56 -52
- package/src/interfaces/rpcInterfaces/wallet.ts +728 -674
- package/src/interfaces/rpcInterfaces/zmq.ts +12 -11
- package/src/restClient.ts +134 -119
- package/src/rpcClient.ts +100 -93
- package/src/utils/errors.ts +6 -6
- package/src/utils/utils.ts +55 -55
- package/test/restClient.test.ts +33 -31
- package/test/rpcClient.test.ts +119 -115
- package/test/setupTests.ts +56 -54
- package/test/tsconfig.json +4 -4
- package/tsconfig.json +13 -13
- package/vitest.config.ts +8 -8
- package/CHANGELOG.md +0 -7
|
@@ -1,195 +1,213 @@
|
|
|
1
|
-
/* --- Network Commands --- */
|
|
2
|
-
// progress 14/14
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
export interface
|
|
59
|
-
method: '
|
|
60
|
-
params: [];
|
|
61
|
-
response:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
response: {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
1
|
+
/* --- Network Commands --- */
|
|
2
|
+
// progress 14/14
|
|
3
|
+
|
|
4
|
+
/** Adds or removes a node from the addnode list. */
|
|
5
|
+
export interface AddNode {
|
|
6
|
+
method: 'addnode';
|
|
7
|
+
params: [
|
|
8
|
+
node: string,
|
|
9
|
+
command: 'add' | 'remove' | 'onetry'
|
|
10
|
+
];
|
|
11
|
+
response: null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Clears all banned IPs. */
|
|
15
|
+
export interface ClearBanned {
|
|
16
|
+
method: 'clearbanned';
|
|
17
|
+
params: [
|
|
18
|
+
manual?: boolean,
|
|
19
|
+
automatic?: boolean
|
|
20
|
+
];
|
|
21
|
+
response: null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Disconnects a node by address or node ID. */
|
|
25
|
+
export interface DisconnectNode {
|
|
26
|
+
method: 'disconnectnode';
|
|
27
|
+
params: [
|
|
28
|
+
address?: string,
|
|
29
|
+
nodeid?: number
|
|
30
|
+
];
|
|
31
|
+
response: null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Returns info about manually added nodes. */
|
|
35
|
+
export interface GetAddedNodeInfo {
|
|
36
|
+
method: 'getaddednodeinfo';
|
|
37
|
+
params: [
|
|
38
|
+
node?: string
|
|
39
|
+
];
|
|
40
|
+
response: {
|
|
41
|
+
addednode: string;
|
|
42
|
+
connected: boolean;
|
|
43
|
+
addresses?: {
|
|
44
|
+
address: string;
|
|
45
|
+
connected: string;
|
|
46
|
+
}[];
|
|
47
|
+
}[];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Returns the number of connections to other nodes. */
|
|
51
|
+
export interface GetConnectionCount {
|
|
52
|
+
method: 'getconnectioncount';
|
|
53
|
+
params: [];
|
|
54
|
+
response: number
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Returns the excessive block size setting. */
|
|
58
|
+
export interface GetExcessiveBlock {
|
|
59
|
+
method: 'getexcessiveblock';
|
|
60
|
+
params: [];
|
|
61
|
+
response: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Returns network traffic statistics. */
|
|
65
|
+
export interface GetNetTotals {
|
|
66
|
+
method: 'getnettotals';
|
|
67
|
+
params: [];
|
|
68
|
+
response: {
|
|
69
|
+
totalbytesrecv: number;
|
|
70
|
+
totalbytessent: number;
|
|
71
|
+
timemillis: number;
|
|
72
|
+
uploadtarget: {
|
|
73
|
+
timeframe: number;
|
|
74
|
+
target: number;
|
|
75
|
+
target_reached: boolean;
|
|
76
|
+
serve_historical_blocks: boolean;
|
|
77
|
+
bytes_left_in_cycle: number;
|
|
78
|
+
time_left_in_cycle: number;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Returns network configuration and status. */
|
|
84
|
+
export interface GetNetworkInfo {
|
|
85
|
+
method: 'getnetworkinfo';
|
|
86
|
+
params: [];
|
|
87
|
+
response: {
|
|
88
|
+
version: number;
|
|
89
|
+
subversion: string;
|
|
90
|
+
protocolversion: number;
|
|
91
|
+
localservices: string;
|
|
92
|
+
localrelay: boolean;
|
|
93
|
+
timeoffset: number;
|
|
94
|
+
connections: number;
|
|
95
|
+
connections_in: number;
|
|
96
|
+
connections_out: number;
|
|
97
|
+
networkactive: boolean;
|
|
98
|
+
networks: {
|
|
99
|
+
name: string;
|
|
100
|
+
limited: boolean;
|
|
101
|
+
reachable: boolean;
|
|
102
|
+
proxy: string;
|
|
103
|
+
proxy_randomize_credentials: boolean;
|
|
104
|
+
}[];
|
|
105
|
+
relayfee: number;
|
|
106
|
+
excessutxocharge: number;
|
|
107
|
+
localaddresses: {
|
|
108
|
+
address: string;
|
|
109
|
+
port: number;
|
|
110
|
+
score: number;
|
|
111
|
+
}[]
|
|
112
|
+
warnings: string;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Returns known peer addresses from the address manager. */
|
|
117
|
+
export interface GetNodeAddresses {
|
|
118
|
+
method: 'getnodeaddresses';
|
|
119
|
+
params: [
|
|
120
|
+
count?: number
|
|
121
|
+
];
|
|
122
|
+
response: {
|
|
123
|
+
time: number;
|
|
124
|
+
services: number;
|
|
125
|
+
address: string;
|
|
126
|
+
port: number;
|
|
127
|
+
}[];
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Returns detailed info about each connected peer. */
|
|
131
|
+
export interface GetPeerInfo {
|
|
132
|
+
method: 'getpeerinfo';
|
|
133
|
+
params: [];
|
|
134
|
+
response: {
|
|
135
|
+
id: number;
|
|
136
|
+
addr: string;
|
|
137
|
+
addrbind: string;
|
|
138
|
+
addrlocal: string;
|
|
139
|
+
mapped_as: string;
|
|
140
|
+
services: string;
|
|
141
|
+
relaytxes: boolean;
|
|
142
|
+
lastsend: number;
|
|
143
|
+
lastrecv: number;
|
|
144
|
+
bytessent: number;
|
|
145
|
+
bytesrecv: number;
|
|
146
|
+
conntime: number;
|
|
147
|
+
timeoffset: number;
|
|
148
|
+
pingtime: number;
|
|
149
|
+
minping: number;
|
|
150
|
+
pingwait: number;
|
|
151
|
+
version: number;
|
|
152
|
+
subver: string;
|
|
153
|
+
inbound: boolean;
|
|
154
|
+
addnode: boolean;
|
|
155
|
+
startingheight: number;
|
|
156
|
+
banscore: number;
|
|
157
|
+
synced_headers: number;
|
|
158
|
+
synced_blocks: number;
|
|
159
|
+
inflight: number[];
|
|
160
|
+
addr_processed: number;
|
|
161
|
+
addr_rate_limited: number;
|
|
162
|
+
whitelisted: boolean;
|
|
163
|
+
minfeefilter: number;
|
|
164
|
+
bip152_hb_to: boolean;
|
|
165
|
+
bip152_hb_from: boolean;
|
|
166
|
+
bytessent_per_msg: {
|
|
167
|
+
[msg: string]: number;
|
|
168
|
+
};
|
|
169
|
+
bytesrecv_per_msg: {
|
|
170
|
+
[msg: string]: number;
|
|
171
|
+
};
|
|
172
|
+
}[];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Returns list of banned IPs/subnets. */
|
|
176
|
+
export interface ListBanned {
|
|
177
|
+
method: 'listbanned';
|
|
178
|
+
params: [];
|
|
179
|
+
response: {
|
|
180
|
+
address: string;
|
|
181
|
+
banned_until: number;
|
|
182
|
+
ban_created: number;
|
|
183
|
+
ban_reason: string;
|
|
184
|
+
}[];
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** Pings all connected nodes to measure latency. */
|
|
188
|
+
export interface Ping {
|
|
189
|
+
method: 'ping';
|
|
190
|
+
params: [];
|
|
191
|
+
response: null;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** Bans or unbans a node by subnet. */
|
|
195
|
+
export interface SetBan {
|
|
196
|
+
method: 'setban';
|
|
197
|
+
params: [
|
|
198
|
+
subnet: string,
|
|
199
|
+
command: 'add' | 'remove',
|
|
200
|
+
bantime?: number,
|
|
201
|
+
absolute?: boolean
|
|
202
|
+
];
|
|
203
|
+
response: null;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** Enables or disables all P2P network activity. */
|
|
207
|
+
export interface SetNetworkActive {
|
|
208
|
+
method: 'setnetworkactive';
|
|
209
|
+
params: [
|
|
210
|
+
state: boolean
|
|
211
|
+
];
|
|
212
|
+
response: null;
|
|
213
|
+
}
|