@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,62 +1,68 @@
|
|
|
1
|
-
/* --- Control Commands --- */
|
|
2
|
-
// progress 6/6
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
1
|
+
/* --- Control Commands --- */
|
|
2
|
+
// progress 6/6
|
|
3
|
+
|
|
4
|
+
/** Returns memory usage information. */
|
|
5
|
+
export interface GetMemoryInfo {
|
|
6
|
+
method: 'getmemoryinfo';
|
|
7
|
+
params: [
|
|
8
|
+
mode?: 'stats' | 'mallocinfo'
|
|
9
|
+
];
|
|
10
|
+
response: {
|
|
11
|
+
locked: {
|
|
12
|
+
used: number;
|
|
13
|
+
free: number;
|
|
14
|
+
total: number;
|
|
15
|
+
locked: number;
|
|
16
|
+
chunks_used: number;
|
|
17
|
+
chunks_free: number;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Returns details about the RPC server. */
|
|
23
|
+
export interface GetRpcInfo {
|
|
24
|
+
method: 'getrpcinfo';
|
|
25
|
+
params: [];
|
|
26
|
+
response: {
|
|
27
|
+
active_commands: {
|
|
28
|
+
method: string;
|
|
29
|
+
duration: number;
|
|
30
|
+
}[];
|
|
31
|
+
logpath: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Returns help text for RPC commands. */
|
|
36
|
+
export interface Help {
|
|
37
|
+
method: 'help';
|
|
38
|
+
params: [
|
|
39
|
+
command?: string
|
|
40
|
+
];
|
|
41
|
+
response: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Gets or sets logging categories. */
|
|
45
|
+
export interface Logging {
|
|
46
|
+
method: 'logging';
|
|
47
|
+
params: [
|
|
48
|
+
include_category?: string[],
|
|
49
|
+
exclude_category?: string[]
|
|
50
|
+
];
|
|
51
|
+
response: {
|
|
52
|
+
[category: string]: boolean;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Stops the BCHN server. */
|
|
57
|
+
export interface Stop {
|
|
58
|
+
method: 'stop';
|
|
59
|
+
params: [];
|
|
60
|
+
response: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Returns server uptime in seconds. */
|
|
64
|
+
export interface Uptime {
|
|
65
|
+
method: 'uptime';
|
|
66
|
+
params: [];
|
|
67
|
+
response: number;
|
|
68
|
+
}
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
/* --- Generating Commands --- */
|
|
2
|
-
// progress 2/2
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
/* --- Generating Commands --- */
|
|
2
|
+
// progress 2/2
|
|
3
|
+
|
|
4
|
+
/** Mines blocks to the wallet (regtest only). */
|
|
5
|
+
export interface Generate {
|
|
6
|
+
method: 'generate';
|
|
7
|
+
params: [
|
|
8
|
+
nblocks: number,
|
|
9
|
+
maxtries?: number,
|
|
10
|
+
];
|
|
11
|
+
response: string[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Mines blocks to a specified address (regtest only). */
|
|
15
|
+
export interface GenerateToAddress {
|
|
16
|
+
method: 'generatetoaddress';
|
|
17
|
+
params: [
|
|
18
|
+
nblocks: number,
|
|
19
|
+
address: string,
|
|
20
|
+
maxtries?: number,
|
|
21
|
+
];
|
|
22
|
+
response: string[];
|
|
23
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
// For the full list of commands see the documentation on
|
|
2
|
-
// https://docs.bitcoincashnode.org/doc/json-rpc/
|
|
3
|
-
|
|
4
|
-
// Total progress 136/136 (100%)
|
|
5
|
-
|
|
6
|
-
export * from './blockchain.js';
|
|
7
|
-
export * from './control.js';
|
|
8
|
-
export * from './generating.js';
|
|
9
|
-
export * from './mining.js';
|
|
10
|
-
export * from './network.js';
|
|
11
|
-
export * from './rawtransactions.js';
|
|
12
|
-
export * from './util.js';
|
|
13
|
-
export * from './wallet.js';
|
|
1
|
+
// For the full list of commands see the documentation on
|
|
2
|
+
// https://docs.bitcoincashnode.org/doc/json-rpc/
|
|
3
|
+
|
|
4
|
+
// Total progress 136/136 (100%)
|
|
5
|
+
|
|
6
|
+
export * from './blockchain.js';
|
|
7
|
+
export * from './control.js';
|
|
8
|
+
export * from './generating.js';
|
|
9
|
+
export * from './mining.js';
|
|
10
|
+
export * from './network.js';
|
|
11
|
+
export * from './rawtransactions.js';
|
|
12
|
+
export * from './util.js';
|
|
13
|
+
export * from './wallet.js';
|
|
14
14
|
export * from './zmq.js'
|
|
@@ -1,143 +1,151 @@
|
|
|
1
|
-
/* --- Mining Commands --- */
|
|
2
|
-
// progress 9/9
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
1
|
+
/* --- Mining Commands --- */
|
|
2
|
+
// progress 9/9
|
|
3
|
+
|
|
4
|
+
/** Returns a block template for mining. */
|
|
5
|
+
export interface GetBlockTemplate {
|
|
6
|
+
method: 'getblocktemplate';
|
|
7
|
+
params: {
|
|
8
|
+
mode?: 'template' | 'proposal';
|
|
9
|
+
capabilities?: ('longpoll' | 'coinbasetxn' | 'coinbasevalue' | 'proposal' | 'serverlist' | 'workid')[];
|
|
10
|
+
longpollid?: string;
|
|
11
|
+
checkvalidity?: boolean;
|
|
12
|
+
ignorecache?: boolean;
|
|
13
|
+
};
|
|
14
|
+
response: {
|
|
15
|
+
version: number;
|
|
16
|
+
previousblockhash: string;
|
|
17
|
+
transactions: {
|
|
18
|
+
data: string;
|
|
19
|
+
txid: string;
|
|
20
|
+
hash: string;
|
|
21
|
+
depends: number[];
|
|
22
|
+
fee: number;
|
|
23
|
+
sigops: number;
|
|
24
|
+
required: boolean;
|
|
25
|
+
}[];
|
|
26
|
+
coinbaseaux: {
|
|
27
|
+
flags: string;
|
|
28
|
+
};
|
|
29
|
+
coinbasevalue: number;
|
|
30
|
+
coinbasetxn?: object;
|
|
31
|
+
target: string;
|
|
32
|
+
mintime: number;
|
|
33
|
+
mutable: string[];
|
|
34
|
+
noncerange: string;
|
|
35
|
+
sigoplimit: number;
|
|
36
|
+
sizelimit: number;
|
|
37
|
+
curtime: number;
|
|
38
|
+
bits: string;
|
|
39
|
+
height: number;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Returns a lightweight block template (for mining pools). */
|
|
44
|
+
export interface GetBlockTemplateLight {
|
|
45
|
+
method: 'getblocktemplatelight';
|
|
46
|
+
params: [
|
|
47
|
+
{
|
|
48
|
+
mode?: 'template' | 'proposal';
|
|
49
|
+
capabilities?: ('longpoll' | 'coinbasetxn' | 'coinbasevalue' | 'proposal' | 'serverlist' | 'workid')[];
|
|
50
|
+
longpollid?: string;
|
|
51
|
+
checkvalidity?: boolean;
|
|
52
|
+
ignorecache?: boolean;
|
|
53
|
+
},
|
|
54
|
+
additional_txs?: string[]
|
|
55
|
+
];
|
|
56
|
+
response: {
|
|
57
|
+
version: number;
|
|
58
|
+
previousblockhash: string;
|
|
59
|
+
job_id: string;
|
|
60
|
+
merkle: string[];
|
|
61
|
+
coinbaseaux: {
|
|
62
|
+
flags: string;
|
|
63
|
+
};
|
|
64
|
+
coinbasevalue: number;
|
|
65
|
+
coinbasetxn: object;
|
|
66
|
+
target: string;
|
|
67
|
+
mintime: number;
|
|
68
|
+
mutable: string[];
|
|
69
|
+
noncerange: string;
|
|
70
|
+
sigoplimit: number;
|
|
71
|
+
sizelimit: number;
|
|
72
|
+
curtime: number;
|
|
73
|
+
bits: string;
|
|
74
|
+
height: number;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Returns mining-related information. */
|
|
79
|
+
export interface GetMiningInfo {
|
|
80
|
+
method: 'getmininginfo';
|
|
81
|
+
params: [];
|
|
82
|
+
response: {
|
|
83
|
+
blocks: number;
|
|
84
|
+
currentblocksize: number;
|
|
85
|
+
currentblocktx: number;
|
|
86
|
+
difficulty: number;
|
|
87
|
+
networkhashps: number;
|
|
88
|
+
miningblocksizelimit: number;
|
|
89
|
+
pooledtx: number;
|
|
90
|
+
chain: string;
|
|
91
|
+
warnings: string;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Returns estimated network hash rate. */
|
|
96
|
+
export interface GetNetworkHashps {
|
|
97
|
+
method: 'getnetworkhashps';
|
|
98
|
+
params: [
|
|
99
|
+
nblocks?: number,
|
|
100
|
+
height?: number
|
|
101
|
+
];
|
|
102
|
+
response: number
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Modifies a mempool transaction's priority. */
|
|
106
|
+
export interface PrioritiseTransaction {
|
|
107
|
+
method: 'prioritisetransaction';
|
|
108
|
+
params: [
|
|
109
|
+
txid: string,
|
|
110
|
+
fee_delta: number
|
|
111
|
+
];
|
|
112
|
+
response: true
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Submits a mined block to the network. */
|
|
116
|
+
export interface SubmitBlock {
|
|
117
|
+
method: 'submitblock';
|
|
118
|
+
params: [
|
|
119
|
+
hexdata: string,
|
|
120
|
+
dummy?: string
|
|
121
|
+
];
|
|
122
|
+
response: {}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Submits a lightweight block (for mining pools). */
|
|
126
|
+
export interface SubmitBlockLight {
|
|
127
|
+
method: 'submitblocklight';
|
|
128
|
+
params: [
|
|
129
|
+
hexdata: string,
|
|
130
|
+
job_id: string
|
|
131
|
+
];
|
|
132
|
+
response: {}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Submits a block header for validation. */
|
|
136
|
+
export interface SubmitHeader {
|
|
137
|
+
method: 'submitheader';
|
|
138
|
+
params: [
|
|
139
|
+
hexdata: string
|
|
140
|
+
];
|
|
141
|
+
response: {}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Validates a block template without mining. */
|
|
145
|
+
export interface ValidateBlockTemplate {
|
|
146
|
+
method: 'validateblocktemplate';
|
|
147
|
+
params: [
|
|
148
|
+
hexdata: string
|
|
149
|
+
];
|
|
150
|
+
response: true
|
|
151
|
+
}
|