@mr-zwets/bchn-api-wrapper 1.0.2 → 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 (59) hide show
  1. package/dist/src/index.d.ts +4 -0
  2. package/dist/src/index.js +4 -0
  3. package/{src/interfaces/interfaces.ts → dist/src/interfaces/interfaces.d.ts} +51 -65
  4. package/dist/src/interfaces/interfaces.js +1 -0
  5. package/{src/interfaces/restInterfaces/interfaces.ts → dist/src/interfaces/restInterfaces/interfaces.d.ts} +145 -166
  6. package/dist/src/interfaces/restInterfaces/interfaces.js +1 -0
  7. package/dist/src/interfaces/rpcInterfaces/blockchain.d.ts +883 -0
  8. package/dist/src/interfaces/rpcInterfaces/blockchain.js +3 -0
  9. package/dist/src/interfaces/rpcInterfaces/control.d.ts +60 -0
  10. package/dist/src/interfaces/rpcInterfaces/control.js +3 -0
  11. package/dist/src/interfaces/rpcInterfaces/generating.d.ts +19 -0
  12. package/dist/src/interfaces/rpcInterfaces/generating.js +3 -0
  13. package/dist/src/interfaces/rpcInterfaces/index.d.ts +9 -0
  14. package/{src/interfaces/rpcInterfaces/index.ts → dist/src/interfaces/rpcInterfaces/index.js} +1 -3
  15. package/dist/src/interfaces/rpcInterfaces/mining.d.ts +140 -0
  16. package/dist/src/interfaces/rpcInterfaces/mining.js +3 -0
  17. package/dist/src/interfaces/rpcInterfaces/network.d.ts +197 -0
  18. package/dist/src/interfaces/rpcInterfaces/network.js +3 -0
  19. package/dist/src/interfaces/rpcInterfaces/rawtransactions.d.ts +304 -0
  20. package/dist/src/interfaces/rpcInterfaces/rawtransactions.js +3 -0
  21. package/dist/src/interfaces/rpcInterfaces/util.d.ts +49 -0
  22. package/dist/src/interfaces/rpcInterfaces/util.js +3 -0
  23. package/dist/src/interfaces/rpcInterfaces/wallet.d.ts +674 -0
  24. package/dist/src/interfaces/rpcInterfaces/wallet.js +3 -0
  25. package/dist/src/interfaces/rpcInterfaces/zmq.d.ts +9 -0
  26. package/dist/src/interfaces/rpcInterfaces/zmq.js +3 -0
  27. package/dist/src/restClient.d.ts +29 -0
  28. package/dist/src/restClient.js +113 -0
  29. package/dist/src/rpcClient.d.ts +19 -0
  30. package/dist/src/rpcClient.js +92 -0
  31. package/dist/src/utils/errors.d.ts +3 -0
  32. package/dist/src/utils/errors.js +6 -0
  33. package/dist/src/utils/utils.d.ts +11 -0
  34. package/dist/src/utils/utils.js +49 -0
  35. package/package.json +7 -3
  36. package/.claude/settings.local.json +0 -8
  37. package/.github/workflows/ci.yaml +0 -36
  38. package/CLAUDE.md +0 -70
  39. package/pnpm-lock.yaml +0 -1279
  40. package/src/index.ts +0 -4
  41. package/src/interfaces/rpcInterfaces/blockchain.ts +0 -933
  42. package/src/interfaces/rpcInterfaces/control.ts +0 -68
  43. package/src/interfaces/rpcInterfaces/generating.ts +0 -23
  44. package/src/interfaces/rpcInterfaces/mining.ts +0 -151
  45. package/src/interfaces/rpcInterfaces/network.ts +0 -213
  46. package/src/interfaces/rpcInterfaces/rawtransactions.ts +0 -332
  47. package/src/interfaces/rpcInterfaces/util.ts +0 -56
  48. package/src/interfaces/rpcInterfaces/wallet.ts +0 -728
  49. package/src/interfaces/rpcInterfaces/zmq.ts +0 -12
  50. package/src/restClient.ts +0 -134
  51. package/src/rpcClient.ts +0 -100
  52. package/src/utils/errors.ts +0 -6
  53. package/src/utils/utils.ts +0 -55
  54. package/test/restClient.test.ts +0 -34
  55. package/test/rpcClient.test.ts +0 -119
  56. package/test/setupTests.ts +0 -56
  57. package/test/tsconfig.json +0 -4
  58. package/tsconfig.json +0 -13
  59. package/vitest.config.ts +0 -9
@@ -1,332 +0,0 @@
1
- /* --- Rawtransactions Commands --- */
2
- // progress 14/14
3
-
4
- import type { TokenData, Transaction, TransactionInput, TransactionOutput } from "../interfaces.js";
5
-
6
- /** Combines multiple PSBTs into one. */
7
- export interface CombinePsbt {
8
- method: 'decoderawtransaction';
9
- params: [
10
- txs: string[]
11
- ];
12
- response: string
13
- }
14
-
15
- /** Combines multiple raw transactions into one. */
16
- export interface CombineRawTransaction {
17
- method: 'combinerawtransaction';
18
- params: [
19
- txs: string[]
20
- ];
21
- response: string;
22
- }
23
-
24
- /** Converts a raw transaction to PSBT format. */
25
- export interface ConvertToPsbt {
26
- method: 'converttopsbt';
27
- params: [
28
- hexstring: string,
29
- permitsigdata?: boolean
30
- ];
31
- response: string;
32
- }
33
-
34
- /** Creates an unsigned PSBT. */
35
- export interface CreatePsbt {
36
- method: 'createpsbt';
37
- params: [
38
- inputs: {
39
- txid: string;
40
- vout: number;
41
- sequence?: number;
42
- }[],
43
- outputs: {
44
- [address: string]: number
45
- | {
46
- amount: number;
47
- tokendata: TokenData;
48
- }
49
- | {
50
- data: string;
51
- }
52
- }[],
53
- locktime?: number
54
- ];
55
- response: string;
56
- }
57
-
58
- /** Creates an unsigned raw transaction. */
59
- export interface CreateRawTransaction {
60
- method: 'createrawtransaction';
61
- params: [
62
- inputs: {
63
- txid: string;
64
- vout: number;
65
- sequence?: number;
66
- }[],
67
- outputs: {
68
- [address: string]: number
69
- | {
70
- amount: number;
71
- tokendata: TokenData;
72
- }
73
- | {
74
- data: string;
75
- }
76
- }[],
77
- locktime?: number,
78
- ];
79
- response: string;
80
- }
81
-
82
- /** Decodes a PSBT to inspect its contents. */
83
- export interface DecodePsbt {
84
- method: 'decodepsbt';
85
- params: [
86
- psbt: string
87
- ];
88
- response: {
89
- tx: Transaction;
90
- unknown: Record<string, string>;
91
- inputs: PsbtInput[];
92
- outputs: PsbtOutput[];
93
- fee?: number;
94
- };
95
- }
96
-
97
- /** PSBT input structure. */
98
- interface PsbtInput {
99
- utxo?: {
100
- amount: number;
101
- scriptPubKey: {
102
- asm: string;
103
- hex: string;
104
- type: string;
105
- addresses?: string[];
106
- };
107
- tokenData?: TokenData;
108
- };
109
- partial_signatures?: Record<string, string>;
110
- sighash?: string;
111
- redeem_script?: RedeemScript;
112
- bip32_derivs?: Bip32Derivation[];
113
- final_scriptsig?: {
114
- asm: string;
115
- hex: string;
116
- };
117
- unknown?: Record<string, string>;
118
- }
119
-
120
- /** PSBT output structure. */
121
- interface PsbtOutput {
122
- redeem_script?: RedeemScript;
123
- bip32_derivs?: Bip32Derivation[];
124
- unknown?: Record<string, string>;
125
- }
126
-
127
- /** Redeem script in PSBT. */
128
- interface RedeemScript {
129
- asm: string;
130
- hex: string;
131
- type: string;
132
- }
133
-
134
- /** BIP32 derivation path info. */
135
- interface Bip32Derivation {
136
- pubkey: string;
137
- master_fingerprint: string;
138
- path: string;
139
- }
140
-
141
- /** Decodes a raw transaction hex string. */
142
- export interface DecodeRawTransaction {
143
- method: 'decoderawtransaction';
144
- params: [
145
- hexstring: string
146
- ];
147
- response: Transaction
148
- }
149
-
150
- /** Decodes a script hex string. */
151
- export interface DecodeScript {
152
- method: 'decodescript';
153
- params: [
154
- hexstring: string
155
- ];
156
- response: {
157
- asm: string;
158
- type: string;
159
- reqSigs: number;
160
- addresses: string[]
161
- p2sh: string;
162
- };
163
- }
164
-
165
- /** Finalizes a PSBT, extracting the raw transaction if complete. */
166
- export interface FinalizePsbt {
167
- method: 'finalizepsbt';
168
- params: [
169
- psbt: string,
170
- extract?: boolean
171
- ];
172
- response: {
173
- psbt: string;
174
- hex: string;
175
- complete: boolean;
176
- }
177
- }
178
-
179
- /** Adds inputs to a raw transaction to meet output value. */
180
- export interface FundRawTransaction {
181
- method: 'fundrawtransaction';
182
- params: [
183
- hexstring: string,
184
- options?: {
185
- include_unsafe?: boolean;
186
- changeAddress?: string;
187
- changePosition?: number;
188
- includeWatching?: boolean;
189
- lockUnspents?: boolean;
190
- feeRate?: number | string;
191
- subtractFeeFromOutputs?: number[];
192
- }
193
- ];
194
- response: {
195
- hex: string;
196
- fee: number;
197
- changepos: number;
198
- };
199
- }
200
-
201
- interface GetRawTransactionBase {
202
- method: 'getrawtransaction';
203
- params: [
204
- txid: string,
205
- verbose?: boolean | number,
206
- blockhash?: string
207
- ];
208
- }
209
-
210
- /** Verbosity 0: Returns raw transaction as hex string. */
211
- export interface GetRawTransactionVerbosity0 extends GetRawTransactionBase {
212
- params: [
213
- txid: string,
214
- verbose?: false | 0,
215
- blockhash?: string
216
- ];
217
- response: string;
218
- }
219
-
220
- /** Verbosity 1: Returns decoded transaction with basic info. */
221
- export interface GetRawTransactionVerbosity1 extends GetRawTransactionBase {
222
- params: [
223
- txid: string,
224
- verbose?: true | 1,
225
- blockhash?: string
226
- ];
227
- response: {
228
- hex: string;
229
- txid: string;
230
- hash: string;
231
- size: number;
232
- version: number;
233
- locktime: number;
234
- vin: TransactionInput[];
235
- vout: TransactionOutput[];
236
- blockhash?: string;
237
- confirmations?: number;
238
- time?: number;
239
- blocktime?: number;
240
- in_active_chain?: boolean;
241
- };
242
- }
243
-
244
- /** Verbosity 2: Returns decoded transaction with input values and fee. */
245
- export interface GetRawTransactionVerbosity2 extends GetRawTransactionBase {
246
- params: [
247
- txid: string,
248
- verbose?: 2,
249
- blockhash?: string
250
- ];
251
- response: {
252
- hex: string;
253
- txid: string;
254
- hash: string;
255
- size: number;
256
- version: number;
257
- locktime: number;
258
- vin: TransactionInputVerbosity2[];
259
- vout: TransactionOutput[];
260
- blockhash?: string;
261
- confirmations?: number;
262
- time?: number;
263
- blocktime?: number;
264
- in_active_chain?: boolean;
265
- fee?: number;
266
- };
267
- }
268
-
269
- /** Transaction input with previous output value (verbosity 2). */
270
- interface TransactionInputVerbosity2 extends TransactionInput {
271
- value?: number;
272
- scriptPubKey?: {
273
- asm: string;
274
- hex: string;
275
- type: string;
276
- address?: string;
277
- };
278
- tokenData?: TokenData;
279
- }
280
-
281
- /** Broadcasts a signed raw transaction. */
282
- export interface SendRawTransaction {
283
- method: 'sendrawtransaction';
284
- params: [
285
- hexstring: string,
286
- allowhighfees?: boolean
287
- ];
288
- response: string;
289
- }
290
-
291
- /** Signs a raw transaction with provided private keys. */
292
- export interface SignRawTransactionWithKey {
293
- method: 'signrawtransactionwithkey';
294
- params: [
295
- hexstring: string,
296
- privkeys: string[],
297
- prevtxs?: {
298
- txid: string;
299
- vout: number;
300
- scriptPubKey: string;
301
- redeemScript?: string;
302
- amount: number | string;
303
- tokenData?: TokenData;
304
- }[],
305
- sighashtype?: string
306
- ];
307
- response: {
308
- hex: string;
309
- complete: boolean;
310
- errors?: {
311
- txid: string;
312
- vout: number;
313
- scriptSig: string;
314
- sequence: number;
315
- error: string;
316
- }[];
317
- };
318
- }
319
-
320
- /** Tests if raw transactions would be accepted to mempool. */
321
- export interface TestMempoolAccept {
322
- method: 'testmempoolaccept';
323
- params: [
324
- rawtxs: string[],
325
- allowhighfees?: boolean
326
- ];
327
- response: {
328
- txid: string
329
- allowed: boolean
330
- 'reject-reason': string
331
- }[];
332
- }
@@ -1,56 +0,0 @@
1
- /* --- Util Commands --- */
2
- // progress 5/5
3
-
4
- /** Creates a multisig address (without adding to wallet). */
5
- export interface CreateMultisig {
6
- method: 'createmultisig';
7
- params: [
8
- nrequired: number,
9
- keys: string[]
10
- ];
11
- response: {
12
- address: string;
13
- redeemScript: string;
14
- };
15
- }
16
-
17
- /** Returns estimated fee rate in BCH/kB. */
18
- export interface EstimateFee {
19
- method: 'estimatefee';
20
- params: [];
21
- response: number;
22
- }
23
-
24
- /** Signs a message with a private key (returns base64 signature). */
25
- export interface SignMessageWithPrivKey {
26
- method: 'signmessagewithprivkey';
27
- params: [
28
- privkey: string,
29
- message: string
30
- ];
31
- response: string;
32
- }
33
-
34
- /** Validates a Bitcoin Cash address. */
35
- export interface ValidateAddress {
36
- method: 'validateaddress';
37
- params: [string];
38
- response: {
39
- isvalid: boolean;
40
- address: string;
41
- scriptPubKey?: string;
42
- isscript: boolean;
43
- istokenaware: boolean;
44
- };
45
- }
46
-
47
- /** Verifies a signed message. */
48
- export interface VerifyMessage {
49
- method: 'verifymessage';
50
- params: [
51
- address:string,
52
- signature: string,
53
- message:string
54
- ];
55
- response: boolean;
56
- }