thunder-bridge 1.0.0 → 1.3.0
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/README.md +96 -4
- package/dist/index.cjs +1650 -1302
- package/dist/index.d.cts +214 -170
- package/dist/index.d.ts +214 -170
- package/dist/index.js +1646 -1301
- package/dist/{rail-CL9QkiHo.d.cts → rail-DZzlN-bi.d.cts} +166 -1
- package/dist/{rail-CL9QkiHo.d.ts → rail-DZzlN-bi.d.ts} +166 -1
- package/dist/server.cjs +976 -382
- package/dist/server.d.cts +47 -41
- package/dist/server.d.ts +47 -41
- package/dist/server.js +966 -382
- package/openapi.yaml +1 -1
- package/package.json +33 -13
package/dist/index.d.cts
CHANGED
|
@@ -1,45 +1,20 @@
|
|
|
1
|
-
import { T as ThunderBridge, a as ThunderBridgeOptions,
|
|
2
|
-
export { B as BankRailConfig, e as CreateOptions, f as CreateQuoteParams, F as FollowOptions, L as Leg, g as LightningRailConfig, O as Order, h as PaymentKind, i as PaymentStatus, Q as Quote, R as Rail, j as WalletReason, k as bankRail, l as lightningRail } from './rail-
|
|
1
|
+
import { T as ThunderBridge, W as WalletFailure, a as ThunderBridgeOptions, b as WatchPaymentParams, c as TriggerEvent, d as WaitOptions, P as Payment, C as CreatePaymentParams, S as Settlement } from './rail-DZzlN-bi.cjs';
|
|
2
|
+
export { B as BankRailConfig, e as CreateOptions, f as CreateQuoteParams, F as FollowOptions, L as Leg, g as LightningRailConfig, O as Order, h as PaymentKind, i as PaymentStatus, Q as Quote, R as Rail, j as WalletReason, k as bankRail, l as lightningRail, t as toLnurl } from './rail-DZzlN-bi.cjs';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*/
|
|
11
|
-
onRefused?: (baseUrl: string, refusal: unknown) => void;
|
|
4
|
+
/** What a BOLT11 invoice says about itself, every field null when it does not carry one */
|
|
5
|
+
interface Invoice {
|
|
6
|
+
paymentHash: string | null;
|
|
7
|
+
descriptionHash: string | null;
|
|
8
|
+
amountMsat: number | null;
|
|
9
|
+
expiresAt: number | null;
|
|
12
10
|
}
|
|
13
11
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* payment is named after the caller and not after any gateway, so the first
|
|
17
|
-
* delivery to arrive is the answer and the rest are the same news twice.
|
|
18
|
-
*
|
|
19
|
-
* For watching only. Two gateways asked to mint would fetch two different invoices
|
|
20
|
-
* from the wallet and only one of them could ever be paid
|
|
12
|
+
* Read a BOLT11 invoice without trusting anyone for its contents, an
|
|
13
|
+
* undecodable string or a BOLT12 offer yields an invoice with every field null
|
|
21
14
|
*/
|
|
22
|
-
declare
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
private readonly onRefused;
|
|
26
|
-
constructor(baseUrls: string[], options?: GatewaysOptions);
|
|
27
|
-
/** What this payment is called, which every gateway here will agree on */
|
|
28
|
-
nameFor(paymentHash: string): Promise<string | null>;
|
|
29
|
-
/**
|
|
30
|
-
* Hand the same invoice to every gateway. Throws only when none of them took it,
|
|
31
|
-
* carrying the first refusal, because one gateway that agreed is enough to be
|
|
32
|
-
* watched
|
|
33
|
-
*/
|
|
34
|
-
watchPayment(params: WatchPaymentParams): Promise<TriggerEvent>;
|
|
35
|
-
/**
|
|
36
|
-
* Wait for whichever gateway speaks first. A settlement from any of them is the
|
|
37
|
-
* settlement, and each has already proved the preimage against the hash before
|
|
38
|
-
* saying so. When they all end without a payment, the first ending is the answer,
|
|
39
|
-
* and when they all fail, the first failure is thrown
|
|
40
|
-
*/
|
|
41
|
-
waitForWatched(id: string, options?: WaitOptions): Promise<TriggerEvent>;
|
|
42
|
-
}
|
|
15
|
+
declare function decodeInvoice(bolt11: string): Invoice;
|
|
16
|
+
/** True when `preimage` is the secret behind `paymentHash` */
|
|
17
|
+
declare function preimageMatchesHash(preimage: string, paymentHash: string): boolean;
|
|
43
18
|
|
|
44
19
|
/**
|
|
45
20
|
* Encrypt what the watcher needs and the gateway must not have. The gateway
|
|
@@ -101,6 +76,8 @@ interface BankTransferParams {
|
|
|
101
76
|
* order the same secret and both rails arrive on one stream
|
|
102
77
|
*/
|
|
103
78
|
trigger?: string;
|
|
79
|
+
/** How many settlements of that trigger the gateway keeps replayable past the hour, needs `trigger` */
|
|
80
|
+
replay?: number;
|
|
104
81
|
/**
|
|
105
82
|
* Handed back untouched on that stream, so a watcher learns which order settled
|
|
106
83
|
* without asking anyone. `seal` it and the gateway cannot read it either
|
|
@@ -178,6 +155,110 @@ declare function bankTransfer(params: BankTransferParams): Promise<BankTransfer>
|
|
|
178
155
|
*/
|
|
179
156
|
declare function bankVerifyEndpoint(config: BankVerifyConfig): (request: Request) => Promise<Response>;
|
|
180
157
|
|
|
158
|
+
/**
|
|
159
|
+
* How many digits ISO 4217 gives the currency's minor unit, so 2 for a crown and a
|
|
160
|
+
* euro, 0 for a yen and 3 for a dinar.
|
|
161
|
+
*
|
|
162
|
+
* There is no sane default here, which is why an unlisted code throws rather than
|
|
163
|
+
* being treated as two. Assuming two turns 1000 yen into 10 and a dinar into a
|
|
164
|
+
* tenth of itself, and a payment library that guesses at this is a payment library
|
|
165
|
+
* that moves the wrong amount.
|
|
166
|
+
*/
|
|
167
|
+
declare function minorUnitsOf(currency: string): number;
|
|
168
|
+
/** The scale that minor unit implies, so 100 for a crown, 1 for a yen, 1000 for a dinar */
|
|
169
|
+
declare function minorScaleOf(currency: string): number;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* The way a gateway was caught out, every code is a check that held against the
|
|
173
|
+
* recipient's own server and failed against what the gateway returned
|
|
174
|
+
*/
|
|
175
|
+
type GatewayCheatCode = "address_not_requested" | "hash_mismatch" | "amount_mismatch" | "description_hash_mismatch" | "verify_url_foreign" | "invoice_not_issued" | "preimage_mismatch" | "id_not_mine";
|
|
176
|
+
/**
|
|
177
|
+
* Thrown when the gateway demonstrably misbehaved, the invoice it returned is
|
|
178
|
+
* not the one the address you asked for issued, or a settlement it reported
|
|
179
|
+
* carries a preimage that does not hash to the payment hash
|
|
180
|
+
*/
|
|
181
|
+
declare class GatewayCheatError extends Error {
|
|
182
|
+
readonly code: GatewayCheatCode;
|
|
183
|
+
readonly paymentId: string;
|
|
184
|
+
constructor(code: GatewayCheatCode, paymentId: string);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* The way a wrapping operator was caught out. Every code is the wrapped invoice
|
|
188
|
+
* failing to bind to the recipient's own, which is the only thing that makes
|
|
189
|
+
* paying the wrap the same act as paying the recipient
|
|
190
|
+
*/
|
|
191
|
+
type WrapRefusalCode = "undecodable" | "hash_mismatch" | "amount_below_recipient" | "fee_above_allowance" | "recipient_expires_first";
|
|
192
|
+
/**
|
|
193
|
+
* Thrown when a wrapped invoice does not bind to the recipient's. Paying it
|
|
194
|
+
* would be paying the operator on its word rather than on the shared payment
|
|
195
|
+
* hash, which is the whole of what makes wrapping safe
|
|
196
|
+
*/
|
|
197
|
+
declare class WrapRefusedError extends Error {
|
|
198
|
+
readonly code: WrapRefusalCode;
|
|
199
|
+
constructor(code: WrapRefusalCode, detail: string);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Thrown when the recipient's own server could not be reached to check the
|
|
203
|
+
* invoice against, a CORS-blocked browser or a provider that is down, this is
|
|
204
|
+
* not proof the gateway cheated and it is not proof it did not
|
|
205
|
+
*/
|
|
206
|
+
declare class UnverifiedRecipientError extends Error {
|
|
207
|
+
readonly lnAddress: string;
|
|
208
|
+
readonly paymentId: string;
|
|
209
|
+
constructor(lnAddress: string, paymentId: string, cause: unknown);
|
|
210
|
+
}
|
|
211
|
+
/** An RFC 9457 problem document the gateway answered with */
|
|
212
|
+
declare class ProblemError extends Error {
|
|
213
|
+
readonly type: string;
|
|
214
|
+
readonly title: string;
|
|
215
|
+
readonly status: number;
|
|
216
|
+
readonly detail: string | null;
|
|
217
|
+
constructor(problem: {
|
|
218
|
+
type?: string;
|
|
219
|
+
title?: string;
|
|
220
|
+
status?: number;
|
|
221
|
+
detail?: string;
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
/** Whether a problem document carries this type */
|
|
225
|
+
declare function isProblemType(problem: {
|
|
226
|
+
type?: string;
|
|
227
|
+
}, type: string): boolean;
|
|
228
|
+
declare const NO_WALLET_AVAILABLE = "urn:problem-type:thunder-bridge:no-wallet-available";
|
|
229
|
+
declare const REQUEST_IN_FLIGHT = "urn:problem-type:thunder-bridge:request-in-flight";
|
|
230
|
+
declare const IDEMPOTENCY_KEY_REUSED = "urn:problem-type:thunder-bridge:idempotency-key-reused";
|
|
231
|
+
declare const PAYMENT_ALREADY_WATCHED = "urn:problem-type:thunder-bridge:payment-already-watched";
|
|
232
|
+
/**
|
|
233
|
+
* Why an `Idempotency-Key` was refused, `request-in-flight` is the benign one and
|
|
234
|
+
* `key-reused` means the same key was sent for a different request
|
|
235
|
+
*/
|
|
236
|
+
type IdempotencyConflict = "request-in-flight" | "key-reused";
|
|
237
|
+
/**
|
|
238
|
+
* Thrown when an `Idempotency-Key` is held by another request. On
|
|
239
|
+
* `request-in-flight` the first attempt is still resolving, so wait and read the
|
|
240
|
+
* payment back rather than retrying. `key-reused` is a bug in the caller: the key
|
|
241
|
+
* is bound to the addresses, amount and webhook that claimed it
|
|
242
|
+
*/
|
|
243
|
+
declare class IdempotencyConflictError extends ProblemError {
|
|
244
|
+
readonly conflict: IdempotencyConflict;
|
|
245
|
+
constructor(problem: {
|
|
246
|
+
type?: string;
|
|
247
|
+
title?: string;
|
|
248
|
+
status?: number;
|
|
249
|
+
detail?: string;
|
|
250
|
+
}, conflict: IdempotencyConflict);
|
|
251
|
+
}
|
|
252
|
+
/** Thrown when no wallet on your list could issue a provable invoice, `wallets` says why each refused */
|
|
253
|
+
declare class NoWalletAvailableError extends ProblemError {
|
|
254
|
+
readonly wallets: WalletFailure[];
|
|
255
|
+
constructor(problem: {
|
|
256
|
+
title?: string;
|
|
257
|
+
status?: number;
|
|
258
|
+
detail?: string;
|
|
259
|
+
}, wallets: WalletFailure[]);
|
|
260
|
+
}
|
|
261
|
+
|
|
181
262
|
interface FioConfig {
|
|
182
263
|
/**
|
|
183
264
|
* A token with "Sledování účtu" rights, which is read only and cannot move
|
|
@@ -217,6 +298,46 @@ interface FioConfig {
|
|
|
217
298
|
*/
|
|
218
299
|
declare function fioStatement(config: FioConfig): Statement;
|
|
219
300
|
|
|
301
|
+
interface GatewaysOptions extends ThunderBridgeOptions {
|
|
302
|
+
/**
|
|
303
|
+
* Called for each gateway that would not take the watch, with the url and what
|
|
304
|
+
* it said. Registering at three and having one refuse still leaves you watched,
|
|
305
|
+
* so this is how you find out you are less covered than you asked to be, rather
|
|
306
|
+
* than finding out when the one that took it goes away
|
|
307
|
+
*/
|
|
308
|
+
onRefused?: (baseUrl: string, refusal: unknown) => void;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* The same payment watched at several gateways at once, which is what makes any
|
|
312
|
+
* one of them replaceable. They all answer with the same name for it, because a
|
|
313
|
+
* payment is named after the caller and not after any gateway, so the first
|
|
314
|
+
* delivery to arrive is the answer and the rest are the same news twice.
|
|
315
|
+
*
|
|
316
|
+
* For watching only. Two gateways asked to mint would fetch two different invoices
|
|
317
|
+
* from the wallet and only one of them could ever be paid
|
|
318
|
+
*/
|
|
319
|
+
declare class Gateways {
|
|
320
|
+
readonly each: readonly ThunderBridge[];
|
|
321
|
+
private readonly urls;
|
|
322
|
+
private readonly onRefused;
|
|
323
|
+
constructor(baseUrls: string[], options?: GatewaysOptions);
|
|
324
|
+
/** What this payment is called, which every gateway here will agree on */
|
|
325
|
+
nameFor(paymentHash: string): Promise<string | null>;
|
|
326
|
+
/**
|
|
327
|
+
* Hand the same invoice to every gateway. Throws only when none of them took it,
|
|
328
|
+
* carrying the first refusal, because one gateway that agreed is enough to be
|
|
329
|
+
* watched
|
|
330
|
+
*/
|
|
331
|
+
watchPayment(params: WatchPaymentParams): Promise<TriggerEvent>;
|
|
332
|
+
/**
|
|
333
|
+
* Wait for whichever gateway speaks first. A settlement from any of them is the
|
|
334
|
+
* settlement, and each has already proved the preimage against the hash before
|
|
335
|
+
* saying so. When they all end without a payment, the first ending is the answer,
|
|
336
|
+
* and when they all fail, the first failure is thrown
|
|
337
|
+
*/
|
|
338
|
+
waitForWatched(id: string, options?: WaitOptions): Promise<TriggerEvent>;
|
|
339
|
+
}
|
|
340
|
+
|
|
220
341
|
/**
|
|
221
342
|
* How many minor units of `currency` one bitcoin costs at one venue, so 134883815
|
|
222
343
|
* is 1,348,838.15 CZK. Throws when that venue does not quote that currency, which
|
|
@@ -286,57 +407,6 @@ declare function msatFor(amountMinor: number, priceMinorPerBtc: number, options?
|
|
|
286
407
|
spreadBps?: number;
|
|
287
408
|
}): number;
|
|
288
409
|
|
|
289
|
-
/**
|
|
290
|
-
* How many digits ISO 4217 gives the currency's minor unit, so 2 for a crown and a
|
|
291
|
-
* euro, 0 for a yen and 3 for a dinar.
|
|
292
|
-
*
|
|
293
|
-
* There is no sane default here, which is why an unlisted code throws rather than
|
|
294
|
-
* being treated as two. Assuming two turns 1000 yen into 10 and a dinar into a
|
|
295
|
-
* tenth of itself, and a payment library that guesses at this is a payment library
|
|
296
|
-
* that moves the wrong amount.
|
|
297
|
-
*/
|
|
298
|
-
declare function minorUnitsOf(currency: string): number;
|
|
299
|
-
/** The scale that minor unit implies, so 100 for a crown, 1 for a yen, 1000 for a dinar */
|
|
300
|
-
declare function minorScaleOf(currency: string): number;
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* Prove the invoice really is the one the recipient issued for what you asked,
|
|
304
|
-
* before the payer ever sees it, both fetches go straight to the recipient's own
|
|
305
|
-
* server and none of them goes back to the gateway
|
|
306
|
-
*
|
|
307
|
-
* Throws `GatewayCheatError` when a check fails and `UnverifiedRecipientError`
|
|
308
|
-
* when the recipient could not be reached to run one
|
|
309
|
-
*/
|
|
310
|
-
declare function proveOrigin(payment: Payment, request: CreatePaymentParams): Promise<void>;
|
|
311
|
-
/**
|
|
312
|
-
* Prove the money arrived by asking the recipient's own server, not the gateway,
|
|
313
|
-
* returns the preimage when the recipient says it settled and null when it says
|
|
314
|
-
* it has not, and runs the full origin proof first because a verify url the
|
|
315
|
-
* gateway made up would otherwise answer for itself
|
|
316
|
-
*/
|
|
317
|
-
declare function proveSettlement(payment: Payment, request: CreatePaymentParams): Promise<string | null>;
|
|
318
|
-
/**
|
|
319
|
-
* True when the gateway's own report of a settlement is at least self-consistent,
|
|
320
|
-
* the preimage hashes to the payment hash the invoice itself carries, this is a
|
|
321
|
-
* sanity check and not a proof, only `proveSettlement` asks the recipient
|
|
322
|
-
*/
|
|
323
|
-
declare function isProvablyPaid(payment: Payment): boolean;
|
|
324
|
-
|
|
325
|
-
/** What a BOLT11 invoice says about itself, every field null when it does not carry one */
|
|
326
|
-
interface Invoice {
|
|
327
|
-
paymentHash: string | null;
|
|
328
|
-
descriptionHash: string | null;
|
|
329
|
-
amountMsat: number | null;
|
|
330
|
-
expiresAt: number | null;
|
|
331
|
-
}
|
|
332
|
-
/**
|
|
333
|
-
* Read a BOLT11 invoice without trusting anyone for its contents, an
|
|
334
|
-
* undecodable string or a BOLT12 offer yields an invoice with every field null
|
|
335
|
-
*/
|
|
336
|
-
declare function decodeInvoice(bolt11: string): Invoice;
|
|
337
|
-
/** True when `preimage` is the secret behind `paymentHash` */
|
|
338
|
-
declare function preimageMatchesHash(preimage: string, paymentHash: string): boolean;
|
|
339
|
-
|
|
340
410
|
interface QrOptions {
|
|
341
411
|
/** SVG width and height in pixels, defaults to 256 */
|
|
342
412
|
size?: number;
|
|
@@ -373,11 +443,61 @@ declare function qrToSvg(payload: string, options?: QrOptions): string;
|
|
|
373
443
|
declare function qrToDataUrl(payload: string, options?: QrOptions): string;
|
|
374
444
|
|
|
375
445
|
/**
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
446
|
+
* What a wrapping operator may charge over the recipient's own amount. This is a
|
|
447
|
+
* ceiling the client sets rather than a price the operator names, so it sits
|
|
448
|
+
* above what any operator lists and refuses only the ones reaching past it
|
|
449
|
+
*/
|
|
450
|
+
interface WrapAllowance {
|
|
451
|
+
/** As a fraction of the recipient's amount, `0.01` by default */
|
|
452
|
+
proportion?: number;
|
|
453
|
+
/** The floor in millisatoshi whatever the fraction works out to, `1000` by default */
|
|
454
|
+
baseMsat?: number;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Prove the invoice really is the one the recipient issued for what you asked,
|
|
458
|
+
* before the payer ever sees it, both fetches go straight to the recipient's own
|
|
459
|
+
* server and none of them goes back to the gateway
|
|
460
|
+
*
|
|
461
|
+
* Throws `GatewayCheatError` when a check fails and `UnverifiedRecipientError`
|
|
462
|
+
* when the recipient could not be reached to run one
|
|
463
|
+
*/
|
|
464
|
+
declare function proveOrigin(payment: Payment, request: CreatePaymentParams): Promise<void>;
|
|
465
|
+
/**
|
|
466
|
+
* Prove the money arrived by asking the recipient's own server, not the gateway,
|
|
467
|
+
* returns the preimage when the recipient says it settled and null when it says
|
|
468
|
+
* it has not, and runs the full origin proof first because a verify url the
|
|
469
|
+
* gateway made up would otherwise answer for itself
|
|
470
|
+
*/
|
|
471
|
+
declare function proveSettlement(payment: Payment, request: CreatePaymentParams): Promise<string | null>;
|
|
472
|
+
/**
|
|
473
|
+
* True when the gateway's own report of a settlement is at least self-consistent,
|
|
474
|
+
* the preimage hashes to the payment hash the invoice itself carries, this is a
|
|
475
|
+
* sanity check and not a proof, only `proveSettlement` asks the recipient
|
|
379
476
|
*/
|
|
380
|
-
declare function
|
|
477
|
+
declare function isProvablyPaid(payment: Payment): boolean;
|
|
478
|
+
/**
|
|
479
|
+
* The most an operator may add over the recipient's own amount, in millisatoshi.
|
|
480
|
+
* The proportion is what routing and the liquidity behind it costs, and the base
|
|
481
|
+
* is the floor it never drops below, because a fraction of a small payment
|
|
482
|
+
* rounds to nothing the operator can work for
|
|
483
|
+
*/
|
|
484
|
+
declare function wrapFeeCeiling(amountMsat: number, allowance?: WrapAllowance): number;
|
|
485
|
+
/**
|
|
486
|
+
* Prove a wrapping operator's invoice is the recipient's own payment in
|
|
487
|
+
* disguise, so paying it can only settle by the operator paying the recipient.
|
|
488
|
+
*
|
|
489
|
+
* It compares two invoices and asks nobody anything, so it runs in a browser and
|
|
490
|
+
* costs no round trip. Prove the recipient's own invoice with `proveOrigin`
|
|
491
|
+
* first, because this says nothing about where that one came from.
|
|
492
|
+
*
|
|
493
|
+
* There is no settlement check here and there does not need to be. Both invoices
|
|
494
|
+
* carry one payment hash, so the preimage that settles the wrap is the preimage
|
|
495
|
+
* the recipient released, and `proveSettlement` already reads it from the
|
|
496
|
+
* recipient's own server.
|
|
497
|
+
*
|
|
498
|
+
* Throws `WrapRefusedError` naming which binding failed
|
|
499
|
+
*/
|
|
500
|
+
declare function proveWrapped(wrapped: string, recipient: string, allowance?: WrapAllowance): void;
|
|
381
501
|
|
|
382
502
|
/** How far the gateway's clock may drift from yours before a webhook is refused */
|
|
383
503
|
type WebhookOptions = {
|
|
@@ -447,80 +567,4 @@ declare function answerVerifyChallenge(body: string): string | null;
|
|
|
447
567
|
/** {@link answerVerifyChallenge} against a `Request`, leaving its body unread */
|
|
448
568
|
declare function answerVerifyChallengeRequest(request: Request): Promise<Response | null>;
|
|
449
569
|
|
|
450
|
-
|
|
451
|
-
* The way a gateway was caught out, every code is a check that held against the
|
|
452
|
-
* recipient's own server and failed against what the gateway returned
|
|
453
|
-
*/
|
|
454
|
-
type GatewayCheatCode = "address_not_requested" | "hash_mismatch" | "amount_mismatch" | "description_hash_mismatch" | "verify_url_foreign" | "invoice_not_issued" | "preimage_mismatch" | "id_not_mine";
|
|
455
|
-
/**
|
|
456
|
-
* Thrown when the gateway demonstrably misbehaved, the invoice it returned is
|
|
457
|
-
* not the one the address you asked for issued, or a settlement it reported
|
|
458
|
-
* carries a preimage that does not hash to the payment hash
|
|
459
|
-
*/
|
|
460
|
-
declare class GatewayCheatError extends Error {
|
|
461
|
-
readonly code: GatewayCheatCode;
|
|
462
|
-
readonly paymentId: string;
|
|
463
|
-
constructor(code: GatewayCheatCode, paymentId: string);
|
|
464
|
-
}
|
|
465
|
-
/**
|
|
466
|
-
* Thrown when the recipient's own server could not be reached to check the
|
|
467
|
-
* invoice against, a CORS-blocked browser or a provider that is down, this is
|
|
468
|
-
* not proof the gateway cheated and it is not proof it did not
|
|
469
|
-
*/
|
|
470
|
-
declare class UnverifiedRecipientError extends Error {
|
|
471
|
-
readonly lnAddress: string;
|
|
472
|
-
readonly paymentId: string;
|
|
473
|
-
constructor(lnAddress: string, paymentId: string, cause: unknown);
|
|
474
|
-
}
|
|
475
|
-
/** An RFC 9457 problem document the gateway answered with */
|
|
476
|
-
declare class ProblemError extends Error {
|
|
477
|
-
readonly type: string;
|
|
478
|
-
readonly title: string;
|
|
479
|
-
readonly status: number;
|
|
480
|
-
readonly detail: string | null;
|
|
481
|
-
constructor(problem: {
|
|
482
|
-
type?: string;
|
|
483
|
-
title?: string;
|
|
484
|
-
status?: number;
|
|
485
|
-
detail?: string;
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
/** Whether a problem document carries this type */
|
|
489
|
-
declare function isProblemType(problem: {
|
|
490
|
-
type?: string;
|
|
491
|
-
}, type: string): boolean;
|
|
492
|
-
declare const NO_WALLET_AVAILABLE = "urn:problem-type:thunder-bridge:no-wallet-available";
|
|
493
|
-
declare const REQUEST_IN_FLIGHT = "urn:problem-type:thunder-bridge:request-in-flight";
|
|
494
|
-
declare const IDEMPOTENCY_KEY_REUSED = "urn:problem-type:thunder-bridge:idempotency-key-reused";
|
|
495
|
-
declare const PAYMENT_ALREADY_WATCHED = "urn:problem-type:thunder-bridge:payment-already-watched";
|
|
496
|
-
/**
|
|
497
|
-
* Why an `Idempotency-Key` was refused, `request-in-flight` is the benign one and
|
|
498
|
-
* `key-reused` means the same key was sent for a different request
|
|
499
|
-
*/
|
|
500
|
-
type IdempotencyConflict = "request-in-flight" | "key-reused";
|
|
501
|
-
/**
|
|
502
|
-
* Thrown when an `Idempotency-Key` is held by another request. On
|
|
503
|
-
* `request-in-flight` the first attempt is still resolving, so wait and read the
|
|
504
|
-
* payment back rather than retrying. `key-reused` is a bug in the caller: the key
|
|
505
|
-
* is bound to the addresses, amount and webhook that claimed it
|
|
506
|
-
*/
|
|
507
|
-
declare class IdempotencyConflictError extends ProblemError {
|
|
508
|
-
readonly conflict: IdempotencyConflict;
|
|
509
|
-
constructor(problem: {
|
|
510
|
-
type?: string;
|
|
511
|
-
title?: string;
|
|
512
|
-
status?: number;
|
|
513
|
-
detail?: string;
|
|
514
|
-
}, conflict: IdempotencyConflict);
|
|
515
|
-
}
|
|
516
|
-
/** Thrown when no wallet on your list could issue a provable invoice, `wallets` says why each refused */
|
|
517
|
-
declare class NoWalletAvailableError extends ProblemError {
|
|
518
|
-
readonly wallets: WalletFailure[];
|
|
519
|
-
constructor(problem: {
|
|
520
|
-
title?: string;
|
|
521
|
-
status?: number;
|
|
522
|
-
detail?: string;
|
|
523
|
-
}, wallets: WalletFailure[]);
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
export { type BankTransfer, type BankTransferParams, type BankVerifyConfig, CreatePaymentParams, type Credit, type FioConfig, type GatewayCheatCode, GatewayCheatError, Gateways, type GatewaysOptions, IDEMPOTENCY_KEY_REUSED, type IdempotencyConflict, IdempotencyConflictError, type Invoice, type MedianOptions, NO_WALLET_AVAILABLE, NoWalletAvailableError, PAYMENT_ALREADY_WATCHED, Payment, ProblemError, type QrOptions, REQUEST_IN_FLIGHT, Settlement, type Statement, ThunderBridge, ThunderBridgeOptions, type Ticker, TriggerEvent, UnverifiedRecipientError, WaitOptions, WalletFailure, WatchPaymentParams, type WebhookCredential, type WebhookOptions, answerVerifyChallenge, answerVerifyChallengeRequest, answerWebhookChallenge, answerWebhookChallengeRequest, bankTransfer, bankVerifyEndpoint, bitstamp, coinbase, coinmate, decodeInvoice, fioStatement, invoiceToDataUrl, invoiceToSvg, isProblemType, isProvablyPaid, isProvablySettled, kraken, lnurlToDataUrl, lnurlToSvg, medianOf, minorScaleOf, minorUnitsOf, msatFor, parseSettlement, parseSettlementRequest, parseWatchedWebhook, parseWatchedWebhookRequest, parseWebhook, parseWebhookRequest, preimageMatchesHash, proveOrigin, proveSettlement, qrToDataUrl, qrToSvg, seal, spdToDataUrl, spdToSvg, toLnurl, unseal, verifyWebhookSignature };
|
|
570
|
+
export { type BankTransfer, type BankTransferParams, type BankVerifyConfig, CreatePaymentParams, type Credit, type FioConfig, type GatewayCheatCode, GatewayCheatError, Gateways, type GatewaysOptions, IDEMPOTENCY_KEY_REUSED, type IdempotencyConflict, IdempotencyConflictError, type Invoice, type MedianOptions, NO_WALLET_AVAILABLE, NoWalletAvailableError, PAYMENT_ALREADY_WATCHED, Payment, ProblemError, type QrOptions, REQUEST_IN_FLIGHT, Settlement, type Statement, ThunderBridge, ThunderBridgeOptions, type Ticker, TriggerEvent, UnverifiedRecipientError, WaitOptions, WalletFailure, WatchPaymentParams, type WebhookCredential, type WebhookOptions, type WrapAllowance, type WrapRefusalCode, WrapRefusedError, answerVerifyChallenge, answerVerifyChallengeRequest, answerWebhookChallenge, answerWebhookChallengeRequest, bankTransfer, bankVerifyEndpoint, bitstamp, coinbase, coinmate, decodeInvoice, fioStatement, invoiceToDataUrl, invoiceToSvg, isProblemType, isProvablyPaid, isProvablySettled, kraken, lnurlToDataUrl, lnurlToSvg, medianOf, minorScaleOf, minorUnitsOf, msatFor, parseSettlement, parseSettlementRequest, parseWatchedWebhook, parseWatchedWebhookRequest, parseWebhook, parseWebhookRequest, preimageMatchesHash, proveOrigin, proveSettlement, proveWrapped, qrToDataUrl, qrToSvg, seal, spdToDataUrl, spdToSvg, unseal, verifyWebhookSignature, wrapFeeCeiling };
|