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