-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.d.ts
435 lines (378 loc) · 11.8 KB
/
index.d.ts
1
2
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
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
/* eslint-disable max-len */
/* eslint-disable indent */
export interface AdaptorPair {
signature: string;
proof: string;
}
/** Add signatures to a refund transaction */
export interface AddSignaturesToRefundTxRequest {
refundTxHex: string;
signatures: string[];
fundTxId: string;
fundVout?: number;
localFundPubkey: string;
remoteFundPubkey: string;
}
export interface AddSignaturesToRefundTxResponse {
hex: string;
}
/** Add a signature to fund transaction */
export interface AddSignatureToFundTransactionRequest {
fundTxHex: string;
signature: string;
prevTxId: string;
prevVout: number;
pubkey: string;
}
export interface AddSignatureToFundTransactionResponse {
hex: string;
}
/** Create an adaptor signature for a CET */
export interface CreateCetAdaptorSignatureRequest {
cetHex: string;
privkey: string;
fundTxId: string;
fundVout?: number;
localFundPubkey: string;
remoteFundPubkey: string;
oraclePubkey: string;
oracleRValues: string[];
fundInputAmount: bigint | number;
messages: string[];
}
export interface CreateCetAdaptorSignatureResponse {
signature: string;
proof: string;
}
/** Create an adaptor signature for a CET */
export interface CreateCetAdaptorSignaturesRequest {
cetsHex: string[];
privkey: string;
fundTxId: string;
fundVout?: number;
localFundPubkey: string;
remoteFundPubkey: string;
oraclePubkey: string;
oracleRValues: string[];
fundInputAmount: bigint | number;
messagesList: Messages[];
}
export interface CreateCetAdaptorSignaturesResponse {
adaptorPairs: AdaptorPair[];
}
/** Create a CET */
export interface CreateCetRequest {
localFundPubkey: string;
remoteFundPubkey: string;
localFinalAddress: string;
remoteFinalAddress: string;
localPayout: bigint | number;
remotePayout: bigint | number;
fundTxId: string;
fundVout?: number;
lockTime: bigint | number;
}
export interface CreateCetResponse {
hex: string;
}
/** Create Dlc transactions */
export interface CreateDlcTransactionsRequest {
payouts: PayoutRequest[];
localFundPubkey: string;
localFinalScriptPubkey: string;
remoteFundPubkey: string;
remoteFinalScriptPubkey: string;
localInputAmount: bigint | number;
localCollateralAmount: bigint | number;
remoteInputAmount: bigint | number;
remoteCollateralAmount: bigint | number;
refundLocktime: bigint | number;
localInputs: TxInInfoRequest[];
localChangeScriptPubkey: string;
remoteInputs: TxInInfoRequest[];
remoteChangeScriptPubkey: string;
feeRate: number;
cetLockTime?: bigint | number;
fundLockTime?: bigint | number;
optionDest?: string;
optionPremium?: bigint | number;
}
export interface CreateDlcTransactionsResponse {
fundTxHex: string;
cetsHex: string[];
refundTxHex: string;
}
/** Create a fund transaction */
export interface CreateFundTransactionRequest {
localPubkey: string;
remotePubkey: string;
outputAmount: bigint | number;
localInputs: TxInRequest[];
localChange: TxOutRequest;
remoteInputs: TxInRequest[];
remoteChange: TxOutRequest;
feeRate: bigint | number;
optionDest?: string;
optionPremium?: bigint | number;
}
export interface CreateFundTransactionResponse {
hex: string;
}
/** Create a refund transaction */
export interface CreateRefundTransactionRequest {
localFinalScriptPubkey: string;
remoteFinalScriptPubkey: string;
localAmount: bigint | number;
remoteAmount: bigint | number;
lockTime: bigint | number;
fundTxId: string;
fundVout?: number;
}
export interface CreateRefundTransactionResponse {
hex: string;
}
export interface ErrorResponse {
error: InnerErrorResponse;
}
/** Get a signature for a fund transaction input */
export interface GetRawFundTxSignatureRequest {
fundTxHex: string;
privkey: string;
prevTxId: string;
prevVout: number;
amount: bigint | number;
}
export interface GetRawFundTxSignatureResponse {
hex: string;
}
/** Get a signature for a CET */
export interface GetRawRefundTxSignatureRequest {
refundTxHex: string;
privkey: string;
fundTxId: string;
fundVout?: number;
localFundPubkey: string;
remoteFundPubkey: string;
fundInputAmount: bigint | number;
}
export interface GetRawRefundTxSignatureResponse {
hex: string;
}
export interface InnerErrorResponse {
code: number;
type: string;
message: string;
}
export interface Messages {
messages: string[];
}
export interface PayoutRequest {
local: bigint | number;
remote: bigint | number;
}
/** Sign a CET */
export interface SignCetRequest {
cetHex: string;
fundPrivkey: string;
fundTxId: string;
fundVout?: number;
localFundPubkey: string;
remoteFundPubkey: string;
fundInputAmount: bigint | number;
adaptorSignature: string;
oracleSignatures: string[];
}
export interface SignCetResponse {
hex: string;
}
/** Sign a fund transaction input */
export interface SignFundTransactionRequest {
fundTxHex: string;
privkey: string;
prevTxId: string;
prevVout: number;
amount: bigint | number;
}
export interface SignFundTransactionResponse {
hex: string;
}
export interface TxInInfoRequest {
txid: string;
vout: number;
redeemScript?: string;
maxWitnessLength: number;
}
export interface TxInRequest {
txid: string;
vout: number;
}
export interface TxOutRequest {
amount: bigint | number;
address: string;
}
/** Verify a signature for a CET */
export interface VerifyCetAdaptorSignatureRequest {
cetHex: string;
adaptorSignature: string;
adaptorProof: string;
messages: string[];
localFundPubkey: string;
remoteFundPubkey: string;
oraclePubkey: string;
oracleRValues: string[];
fundTxId: string;
fundVout?: number;
fundInputAmount: bigint | number;
verifyRemote: boolean;
}
export interface VerifyCetAdaptorSignatureResponse {
valid: boolean;
}
/** Verify a set of signatures for a set of CET */
export interface VerifyCetAdaptorSignaturesRequest {
cetsHex: string[];
adaptorPairs: AdaptorPair[];
messagesList: Messages[];
localFundPubkey: string;
remoteFundPubkey: string;
oraclePubkey: string;
oracleRValues: string[];
fundTxId: string;
fundVout?: number;
fundInputAmount: bigint | number;
verifyRemote: boolean;
}
export interface VerifyCetAdaptorSignaturesResponse {
valid: boolean;
}
/** Verify a signature for a mutual closing transaction */
export interface VerifyFundTxSignatureRequest {
fundTxHex: string;
signature: string;
pubkey: string;
prevTxId: string;
prevVout: number;
fundInputAmount: bigint | number;
}
export interface VerifyFundTxSignatureResponse {
valid: boolean;
}
/** Verify a signature for a refund transaction */
export interface VerifyRefundTxSignatureRequest {
refundTxHex: string;
signature: string;
localFundPubkey: string;
remoteFundPubkey: string;
fundTxId: string;
fundVout?: number;
fundInputAmount: bigint | number;
verifyRemote: boolean;
}
export interface VerifyRefundTxSignatureResponse {
valid: boolean;
}
/**
* @param {AddSignaturesToRefundTxRequest} jsonObject - request data.
* @return {AddSignaturesToRefundTxResponse} - response data.
*/
export function AddSignaturesToRefundTx(jsonObject: AddSignaturesToRefundTxRequest): AddSignaturesToRefundTxResponse;
/**
* @param {AddSignatureToFundTransactionRequest} jsonObject - request data.
* @return {AddSignatureToFundTransactionResponse} - response data.
*/
export function AddSignatureToFundTransaction(jsonObject: AddSignatureToFundTransactionRequest): AddSignatureToFundTransactionResponse;
/**
* @param {CreateCetRequest} jsonObject - request data.
* @return {CreateCetResponse} - response data.
*/
export function CreateCet(jsonObject: CreateCetRequest): CreateCetResponse;
/**
* @param {CreateCetAdaptorSignatureRequest} jsonObject - request data.
* @return {CreateCetAdaptorSignatureResponse} - response data.
*/
export function CreateCetAdaptorSignature(jsonObject: CreateCetAdaptorSignatureRequest): CreateCetAdaptorSignatureResponse;
/**
* @param {CreateCetAdaptorSignaturesRequest} jsonObject - request data.
* @return {CreateCetAdaptorSignaturesResponse} - response data.
*/
export function CreateCetAdaptorSignatures(jsonObject: CreateCetAdaptorSignaturesRequest): CreateCetAdaptorSignaturesResponse;
/**
* @param {CreateDlcTransactionsRequest} jsonObject - request data.
* @return {CreateDlcTransactionsResponse} - response data.
*/
export function CreateDlcTransactions(jsonObject: CreateDlcTransactionsRequest): CreateDlcTransactionsResponse;
/**
* @param {CreateFundTransactionRequest} jsonObject - request data.
* @return {CreateFundTransactionResponse} - response data.
*/
export function CreateFundTransaction(jsonObject: CreateFundTransactionRequest): CreateFundTransactionResponse;
/**
* @param {CreateRefundTransactionRequest} jsonObject - request data.
* @return {CreateRefundTransactionResponse} - response data.
*/
export function CreateRefundTransaction(jsonObject: CreateRefundTransactionRequest): CreateRefundTransactionResponse;
/**
* @param {GetRawFundTxSignatureRequest} jsonObject - request data.
* @return {GetRawFundTxSignatureResponse} - response data.
*/
export function GetRawFundTxSignature(jsonObject: GetRawFundTxSignatureRequest): GetRawFundTxSignatureResponse;
/**
* @param {GetRawRefundTxSignatureRequest} jsonObject - request data.
* @return {GetRawRefundTxSignatureResponse} - response data.
*/
export function GetRawRefundTxSignature(jsonObject: GetRawRefundTxSignatureRequest): GetRawRefundTxSignatureResponse;
/**
* @param {SignCetRequest} jsonObject - request data.
* @return {SignCetResponse} - response data.
*/
export function SignCet(jsonObject: SignCetRequest): SignCetResponse;
/**
* @param {SignFundTransactionRequest} jsonObject - request data.
* @return {SignFundTransactionResponse} - response data.
*/
export function SignFundTransaction(jsonObject: SignFundTransactionRequest): SignFundTransactionResponse;
/**
* @param {VerifyCetAdaptorSignatureRequest} jsonObject - request data.
* @return {VerifyCetAdaptorSignatureResponse} - response data.
*/
export function VerifyCetAdaptorSignature(jsonObject: VerifyCetAdaptorSignatureRequest): VerifyCetAdaptorSignatureResponse;
/**
* @param {VerifyCetAdaptorSignaturesRequest} jsonObject - request data.
* @return {VerifyCetAdaptorSignaturesResponse} - response data.
*/
export function VerifyCetAdaptorSignatures(jsonObject: VerifyCetAdaptorSignaturesRequest): VerifyCetAdaptorSignaturesResponse;
/**
* @param {VerifyFundTxSignatureRequest} jsonObject - request data.
* @return {VerifyFundTxSignatureResponse} - response data.
*/
export function VerifyFundTxSignature(jsonObject: VerifyFundTxSignatureRequest): VerifyFundTxSignatureResponse;
/**
* @param {VerifyRefundTxSignatureRequest} jsonObject - request data.
* @return {VerifyRefundTxSignatureResponse} - response data.
*/
export function VerifyRefundTxSignature(jsonObject: VerifyRefundTxSignatureRequest): VerifyRefundTxSignatureResponse;
/** error class. */
export class CfdDlcError extends Error {
/**
* constructor.
* @param {string} message - Error message.
* @param {InnerErrorResponse} errorInformation - Error information data.
* @param {Error} cause - Cause of the error.
*/
constructor(message: string, errorInformation: InnerErrorResponse, cause: Error);
/**
* get error string.
* @return {string} - string data.
*/
toString(): string;
/**
* get error information.
* @return {InnerErrorResponse} - InnerErrorResponse data.
*/
getErrorInformation(): InnerErrorResponse;
/**
* get error cause.
* @return {Error} - Error data.
*/
getCause(): Error;
}