@mr-zwets/bchn-api-wrapper 1.0.1
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/CHANGELOG.md +7 -0
- package/README.md +129 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/interfaces/interfaces.d.ts +70 -0
- package/dist/interfaces/interfaces.js +1 -0
- package/dist/interfaces/restInterfaces/interfaces.d.ts +109 -0
- package/dist/interfaces/restInterfaces/interfaces.js +1 -0
- package/dist/interfaces/rpcInterfaces/blockchain.d.ts +692 -0
- package/dist/interfaces/rpcInterfaces/blockchain.js +3 -0
- package/dist/interfaces/rpcInterfaces/control.d.ts +54 -0
- package/dist/interfaces/rpcInterfaces/control.js +3 -0
- package/dist/interfaces/rpcInterfaces/generating.d.ts +17 -0
- package/dist/interfaces/rpcInterfaces/generating.js +3 -0
- package/dist/interfaces/rpcInterfaces/index.d.ts +9 -0
- package/dist/interfaces/rpcInterfaces/index.js +12 -0
- package/dist/interfaces/rpcInterfaces/mining.d.ts +131 -0
- package/dist/interfaces/rpcInterfaces/mining.js +3 -0
- package/dist/interfaces/rpcInterfaces/network.d.ts +179 -0
- package/dist/interfaces/rpcInterfaces/network.js +3 -0
- package/dist/interfaces/rpcInterfaces/rawtransactions.d.ts +283 -0
- package/dist/interfaces/rpcInterfaces/rawtransactions.js +3 -0
- package/dist/interfaces/rpcInterfaces/util.d.ts +44 -0
- package/dist/interfaces/rpcInterfaces/util.js +3 -0
- package/dist/interfaces/rpcInterfaces/wallet.d.ts +620 -0
- package/dist/interfaces/rpcInterfaces/wallet.js +3 -0
- package/dist/interfaces/rpcInterfaces/zmq.d.ts +8 -0
- package/dist/interfaces/rpcInterfaces/zmq.js +3 -0
- package/dist/restClient.d.ts +17 -0
- package/dist/restClient.js +100 -0
- package/dist/rpcClient.d.ts +12 -0
- package/dist/rpcClient.js +85 -0
- package/dist/utils/errors.d.ts +3 -0
- package/dist/utils/errors.js +6 -0
- package/dist/utils/utils.d.ts +11 -0
- package/dist/utils/utils.js +49 -0
- package/package.json +40 -0
- package/src/index.ts +4 -0
- package/src/interfaces/interfaces.ts +87 -0
- package/src/interfaces/restInterfaces/interfaces.ts +117 -0
- package/src/interfaces/rpcInterfaces/blockchain.ts +759 -0
- package/src/interfaces/rpcInterfaces/control.ts +62 -0
- package/src/interfaces/rpcInterfaces/generating.ts +21 -0
- package/src/interfaces/rpcInterfaces/index.ts +14 -0
- package/src/interfaces/rpcInterfaces/mining.ts +143 -0
- package/src/interfaces/rpcInterfaces/network.ts +195 -0
- package/src/interfaces/rpcInterfaces/rawtransactions.ts +314 -0
- package/src/interfaces/rpcInterfaces/util.ts +52 -0
- package/src/interfaces/rpcInterfaces/wallet.ts +674 -0
- package/src/interfaces/rpcInterfaces/zmq.ts +11 -0
- package/src/restClient.ts +119 -0
- package/src/rpcClient.ts +93 -0
- package/src/utils/errors.ts +6 -0
- package/src/utils/utils.ts +55 -0
- package/test/restClient.test.ts +32 -0
- package/test/rpcClient.test.ts +115 -0
- package/test/setupTests.ts +54 -0
- package/test/tsconfig.json +4 -0
- package/tsconfig.json +13 -0
- package/vitest.config.ts +9 -0
|
@@ -0,0 +1,314 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/* --- Util Commands --- */
|
|
2
|
+
// progress 5/5
|
|
3
|
+
|
|
4
|
+
export interface CreateMultisig {
|
|
5
|
+
method: 'createmultisig';
|
|
6
|
+
params: [
|
|
7
|
+
nrequired: number,
|
|
8
|
+
keys: string[]
|
|
9
|
+
];
|
|
10
|
+
response: {
|
|
11
|
+
address: string;
|
|
12
|
+
redeemScript: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface EstimateFee {
|
|
17
|
+
method: 'estimatefee';
|
|
18
|
+
params: [];
|
|
19
|
+
response: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
export interface SignMessageWithPrivKey {
|
|
24
|
+
method: 'signmessagewithprivkey';
|
|
25
|
+
params: [
|
|
26
|
+
privkey: string,
|
|
27
|
+
message: string
|
|
28
|
+
];
|
|
29
|
+
response: string; // The signature of the message encoded in base 64
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ValidateAddress {
|
|
33
|
+
method: 'validateaddress';
|
|
34
|
+
params: [string];
|
|
35
|
+
response: {
|
|
36
|
+
isvalid: boolean;
|
|
37
|
+
address: string;
|
|
38
|
+
scriptPubKey?: string;
|
|
39
|
+
isscript: boolean;
|
|
40
|
+
istokenaware: boolean;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface VerifyMessage {
|
|
45
|
+
method: 'verifymessage';
|
|
46
|
+
params: [
|
|
47
|
+
address:string,
|
|
48
|
+
signature: string,
|
|
49
|
+
message:string
|
|
50
|
+
];
|
|
51
|
+
response: boolean;
|
|
52
|
+
}
|