thunder-bridge 0.8.2 → 0.8.4
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 +51 -6
- package/dist/index.cjs +97 -408
- package/dist/index.d.cts +18 -434
- package/dist/index.d.ts +18 -434
- package/dist/index.js +95 -406
- package/dist/rail-QZtUN1D-.d.cts +381 -0
- package/dist/rail-QZtUN1D-.d.ts +381 -0
- package/dist/server.cjs +807 -0
- package/dist/server.d.cts +64 -0
- package/dist/server.d.ts +64 -0
- package/dist/server.js +769 -0
- package/package.json +11 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,269 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/** A payment as the gateway reports it, every field is checkable against the recipient */
|
|
4
|
-
interface Payment {
|
|
5
|
-
id: string;
|
|
6
|
-
lnAddress: string;
|
|
7
|
-
amountMsat: number;
|
|
8
|
-
status: PaymentStatus;
|
|
9
|
-
paymentHash: string;
|
|
10
|
-
bolt11: string;
|
|
11
|
-
preimage: string | null;
|
|
12
|
-
expiresAt: number;
|
|
13
|
-
createdAt: number;
|
|
14
|
-
verifyUrl: string;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* `lnAddresses` is a priority list, the gateway takes the first one that can
|
|
18
|
-
* issue a provable invoice for `amountMsat` and the rest are the fallback
|
|
19
|
-
*/
|
|
20
|
-
interface CreatePaymentParams {
|
|
21
|
-
lnAddresses: string[];
|
|
22
|
-
amountMsat: number;
|
|
23
|
-
webhookUrl?: string;
|
|
24
|
-
webhookSecret?: string;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* `lnAddresses` is the same priority list `createPayment` takes, and quoting it
|
|
28
|
-
* mints nothing and charges the recipient's wallet nothing
|
|
29
|
-
*/
|
|
30
|
-
interface CreateQuoteParams {
|
|
31
|
-
lnAddresses: string[];
|
|
32
|
-
amountMsat: number;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Which address would serve an amount, and what the ones ahead of it refused.
|
|
36
|
-
* `feeMsat` is always zero, the payer pays the recipient's own invoice and the
|
|
37
|
-
* gateway is never in the money's path
|
|
38
|
-
*/
|
|
39
|
-
interface Quote {
|
|
40
|
-
lnAddress: string;
|
|
41
|
-
amountMsat: number;
|
|
42
|
-
feeMsat: number;
|
|
43
|
-
minMsat: number;
|
|
44
|
-
maxMsat: number;
|
|
45
|
-
metadata: string;
|
|
46
|
-
refusals: WalletFailure[];
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* What the gateway reports about a payment it is watching, for a trigger stream
|
|
50
|
-
* or for one you minted yourself. `lnAddress` and `amountMsat` are null when the
|
|
51
|
-
* gateway was never told them, which is the point of `watchPayment`: what the
|
|
52
|
-
* watcher needs but the gateway should not know travels in `sealed` instead
|
|
53
|
-
*/
|
|
54
|
-
interface TriggerEvent {
|
|
55
|
-
id: string;
|
|
56
|
-
paymentHash: string;
|
|
57
|
-
verifyUrl: string;
|
|
58
|
-
status: PaymentStatus;
|
|
59
|
-
preimage: string | null;
|
|
60
|
-
expiresAt: number;
|
|
61
|
-
createdAt: number;
|
|
62
|
-
sealed: string | null;
|
|
63
|
-
lnAddress: string | null;
|
|
64
|
-
amountMsat: number | null;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* An invoice you obtained yourself, handed over to be watched. The gateway is
|
|
68
|
-
* given no address and no amount, so it cannot refuse one recipient rather than
|
|
69
|
-
* all of them
|
|
70
|
-
*/
|
|
71
|
-
interface WatchPaymentParams {
|
|
72
|
-
paymentHash: string;
|
|
73
|
-
verifyUrl: string;
|
|
74
|
-
expiresAt: number;
|
|
75
|
-
trigger?: string;
|
|
76
|
-
sealed?: string;
|
|
77
|
-
}
|
|
78
|
-
/** Why one wallet in the list could not be used */
|
|
79
|
-
type WalletReason = "address-unusable" | "unreachable" | "amount-not-accepted" | "cannot-prove-delivery" | "invoice-refused";
|
|
80
|
-
interface WalletFailure {
|
|
81
|
-
address: string;
|
|
82
|
-
reason: WalletReason;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
interface ThunderBridgeOptions {
|
|
86
|
-
/**
|
|
87
|
-
* Prove every payment against the recipient's own server before handing it
|
|
88
|
-
* back, and refuse a reported settlement whose preimage does not hash to the
|
|
89
|
-
* payment hash, defaults to true
|
|
90
|
-
*/
|
|
91
|
-
verify?: boolean;
|
|
92
|
-
/**
|
|
93
|
-
* Sent as `Authorization: Bearer`, which a gateway started with
|
|
94
|
-
* `GATEWAY_TOKEN` requires on every call, the socket handshake included. No
|
|
95
|
-
* browser WebSocket can carry a header, so setting this also puts every socket
|
|
96
|
-
* through a ticket
|
|
97
|
-
*/
|
|
98
|
-
token?: string;
|
|
99
|
-
}
|
|
100
|
-
interface WaitOptions {
|
|
101
|
-
/** Give up when this aborts, `AbortSignal.timeout(ms)` covers the usual case */
|
|
102
|
-
signal?: AbortSignal;
|
|
103
|
-
/**
|
|
104
|
-
* Mint a short-lived ticket and put that in the socket URL instead of the
|
|
105
|
-
* payment id. Implied by `token`. The id stays readable inside the ticket,
|
|
106
|
-
* what changes is that a URL out of a log stops opening anything after a
|
|
107
|
-
* minute
|
|
108
|
-
*/
|
|
109
|
-
tickets?: boolean;
|
|
110
|
-
}
|
|
111
|
-
interface CreateOptions {
|
|
112
|
-
/**
|
|
113
|
-
* Makes the POST safe to retry. A repeat of a finished request replays its
|
|
114
|
-
* payment instead of asking a wallet for a second invoice, a repeat that
|
|
115
|
-
* arrives while the first is still resolving throws
|
|
116
|
-
* `IdempotencyConflictError`, and the key is held for 24 hours
|
|
117
|
-
*/
|
|
118
|
-
idempotencyKey?: string;
|
|
119
|
-
/**
|
|
120
|
-
* Groups this payment with every other one carrying the same secret, so
|
|
121
|
-
* `followTrigger` can watch the place rather than the payment. Registering
|
|
122
|
-
* sends only its sha256, which is also all the gateway stores, so a stolen
|
|
123
|
-
* ledger cannot subscribe. Following sends the secret itself, because the
|
|
124
|
-
* gateway hashes what it is given to find the stream, so the operator of a
|
|
125
|
-
* gateway you do not own learns it the first time you connect. Keep it apart
|
|
126
|
-
* from any URL a payer sees
|
|
127
|
-
*/
|
|
128
|
-
trigger?: string;
|
|
129
|
-
}
|
|
130
|
-
interface FollowOptions {
|
|
131
|
-
/** Called for the recent settlements replayed on connect, then for each new one */
|
|
132
|
-
onPayment: (settled: TriggerEvent) => void;
|
|
133
|
-
/** Called when a connection drops or a frame is refused, the follow keeps going */
|
|
134
|
-
onError?: (error: unknown) => void;
|
|
135
|
-
/** Reconnect after a drop, defaults to true */
|
|
136
|
-
reconnect?: boolean;
|
|
137
|
-
/**
|
|
138
|
-
* The first wait after a drop, doubling up to 30 seconds and jittered so a
|
|
139
|
-
* fleet does not come back in lockstep, defaults to 3000. A connection that
|
|
140
|
-
* opens puts it back to the first wait
|
|
141
|
-
*/
|
|
142
|
-
reconnectDelayMs?: number;
|
|
143
|
-
/**
|
|
144
|
-
* Mint a short-lived ticket and put that in the socket URL instead of the
|
|
145
|
-
* secret, one per connection. Keeps the secret out of access logs, at the cost
|
|
146
|
-
* of a POST before each connect. Implied by `token`. Leave it off for a
|
|
147
|
-
* microcontroller, where one hardcoded URL and a dumb reconnect loop is the
|
|
148
|
-
* whole point
|
|
149
|
-
*/
|
|
150
|
-
tickets?: boolean;
|
|
151
|
-
}
|
|
152
|
-
/** Talks to a Thunder Bridge gateway and trusts it for nothing it can check itself */
|
|
153
|
-
declare class ThunderBridge {
|
|
154
|
-
private readonly baseUrl;
|
|
155
|
-
private readonly verify;
|
|
156
|
-
private readonly token;
|
|
157
|
-
private strangers;
|
|
158
|
-
constructor(baseUrl: string, options?: ThunderBridgeOptions);
|
|
159
|
-
/**
|
|
160
|
-
* Whether a token was given, which is what makes an instance yours: a gateway
|
|
161
|
-
* started with `GATEWAY_TOKEN` answers nobody else, so anything you hand it
|
|
162
|
-
* stays between you and it
|
|
163
|
-
*/
|
|
164
|
-
get isPrivate(): boolean;
|
|
165
|
-
/**
|
|
166
|
-
* Whether the gateway turns away a caller carrying no token, asked by making
|
|
167
|
-
* one unauthenticated read it would have to refuse. `isPrivate` answers only
|
|
168
|
-
* whether you configured a token, which is your side of the arrangement and
|
|
169
|
-
* says nothing about the gateway's, so a made-up token against a public
|
|
170
|
-
* instance reads as private and is not. Asked once and remembered, because an
|
|
171
|
-
* instance does not change its mind. Anything other than a refusal counts as
|
|
172
|
-
* open, so an unreachable gateway fails closed
|
|
173
|
-
*/
|
|
174
|
-
refusesStrangers(): Promise<boolean>;
|
|
175
|
-
/**
|
|
176
|
-
* Ask the gateway for an invoice payable to the first address on your list
|
|
177
|
-
* that can issue a provable one, throws `NoWalletAvailableError` when none can
|
|
178
|
-
* and `GatewayCheatError` when what comes back is not what you asked for
|
|
179
|
-
*/
|
|
180
|
-
createPayment(params: CreatePaymentParams, options?: CreateOptions): Promise<Payment>;
|
|
181
|
-
/**
|
|
182
|
-
* Ask which address would serve an amount without minting anything, throws
|
|
183
|
-
* `NoWalletAvailableError` when none would. A quote is a probe and not a
|
|
184
|
-
* promise: the address it names can still be refused at create time, because
|
|
185
|
-
* whether a wallet returns a provable invoice cannot be known without asking
|
|
186
|
-
* it for one, and asking mints it
|
|
187
|
-
*/
|
|
188
|
-
createQuote(params: CreateQuoteParams): Promise<Quote>;
|
|
189
|
-
/** Read a payment back, null when the gateway has never heard of it */
|
|
190
|
-
getPayment(id: string): Promise<Payment | null>;
|
|
191
|
-
/**
|
|
192
|
-
* Read back a payment the gateway is only watching, null when it has never
|
|
193
|
-
* heard of it. A watched payment carries no address, amount or invoice, so
|
|
194
|
-
* `getPayment` refuses it and this reads the shape both rails share
|
|
195
|
-
*/
|
|
196
|
-
getWatched(id: string): Promise<TriggerEvent | null>;
|
|
197
|
-
/**
|
|
198
|
-
* List what this gateway is watching, newest first. Only a gateway started
|
|
199
|
-
* with `GATEWAY_TOKEN` serves this, because on a shared one it would hand
|
|
200
|
-
* every caller everyone else's payments, so a public gateway answers 404.
|
|
201
|
-
*
|
|
202
|
-
* `scanned` says how many settled records were looked at to build the page.
|
|
203
|
-
* Anything older than that window is not in the answer, and the list does not
|
|
204
|
-
* pretend otherwise
|
|
205
|
-
*/
|
|
206
|
-
listPayments(limit?: number): Promise<{
|
|
207
|
-
payments: TriggerEvent[];
|
|
208
|
-
scanned: number;
|
|
209
|
-
}>;
|
|
210
|
-
/**
|
|
211
|
-
* Follow a payment over WebSocket until it is paid or expired, reconnecting
|
|
212
|
-
* through a drop. A payment that never answers gives up after a few tries, and
|
|
213
|
-
* one that has answered is followed until its own expiry, so the wait always
|
|
214
|
-
* ends by itself
|
|
215
|
-
*/
|
|
216
|
-
waitForPayment(id: string, options?: WaitOptions): Promise<Payment>;
|
|
217
|
-
/**
|
|
218
|
-
* Follow a payment the gateway is only watching, one it did not mint, until it
|
|
219
|
-
* is paid or expired.
|
|
220
|
-
*
|
|
221
|
-
* A watched payment carries no address, no amount and no invoice, because the
|
|
222
|
-
* gateway was told none of them, so it reads back as the shape a trigger
|
|
223
|
-
* streams rather than as a `Payment`. That is every bank transfer, and every
|
|
224
|
-
* Lightning invoice registered with `watchPayment` instead of `createPayment`.
|
|
225
|
-
*/
|
|
226
|
-
waitForWatched(id: string, options?: WaitOptions): Promise<TriggerEvent>;
|
|
227
|
-
private followed;
|
|
228
|
-
/**
|
|
229
|
-
* Wait on several payments and keep the first one that is really paid, then stop
|
|
230
|
-
* waiting on the losers, which closes their sockets.
|
|
231
|
-
*
|
|
232
|
-
* This is how one order offers two rails. A Lightning invoice and a bank
|
|
233
|
-
* transfer for the same thing are two payments here, and the payer picks one, so
|
|
234
|
-
* what you want is the one that arrives and nothing further from the other.
|
|
235
|
-
*
|
|
236
|
-
* A leg that expires is a loser, not a winner, which is the whole reason this is
|
|
237
|
-
* not a race: `waitForPayment` ends on `paid` and on `expired` alike, and a
|
|
238
|
-
* Lightning invoice expires in an hour while a bank transfer takes days. `null`
|
|
239
|
-
* means every leg ended without being paid.
|
|
240
|
-
*
|
|
241
|
-
* Stopping the wait is not revoking the invoice. Nobody can revoke one, because
|
|
242
|
-
* the recipient's own wallet minted it, so a payer who pays the loser afterwards
|
|
243
|
-
* really does pay twice and that shows up on `followTrigger` as a second
|
|
244
|
-
* settlement to refund.
|
|
245
|
-
*/
|
|
246
|
-
firstToSettle(ids: string[], options?: WaitOptions): Promise<TriggerEvent | null>;
|
|
247
|
-
/**
|
|
248
|
-
* Hand over an invoice you obtained yourself so the gateway watches it without
|
|
249
|
-
* being told the address or the amount. It can then only refuse everyone
|
|
250
|
-
* rather than one recipient, which is what makes leaving it cheap. Anything
|
|
251
|
-
* the watcher needs goes in `sealed`, which the gateway cannot read
|
|
252
|
-
*/
|
|
253
|
-
watchPayment(params: WatchPaymentParams): Promise<TriggerEvent>;
|
|
254
|
-
/**
|
|
255
|
-
* Follow every payment made to one trigger, replayed from the recent ones on
|
|
256
|
-
* connect and then live, reconnecting on its own until the returned function
|
|
257
|
-
* is called. A trigger has no terminal state, so this never resolves
|
|
258
|
-
*/
|
|
259
|
-
followTrigger(secret: string, options: FollowOptions): () => void;
|
|
260
|
-
private needsTicket;
|
|
261
|
-
private wsTicket;
|
|
262
|
-
private sending;
|
|
263
|
-
private reading;
|
|
264
|
-
private proven;
|
|
265
|
-
private checked;
|
|
266
|
-
}
|
|
1
|
+
import { T as ThunderBridge, P as Payment, C as CreatePaymentParams, a as TriggerEvent, W as WalletFailure } from './rail-QZtUN1D-.cjs';
|
|
2
|
+
export { B as BankRailConfig, b as CreateOptions, c as CreateQuoteParams, F as FollowOptions, L as Leg, d as LightningRailConfig, O as Order, e as PaymentStatus, Q as Quote, R as Rail, f as ThunderBridgeOptions, g as WaitOptions, h as WalletReason, i as WatchPaymentParams, j as bankRail, l as lightningRail } from './rail-QZtUN1D-.cjs';
|
|
267
3
|
|
|
268
4
|
/**
|
|
269
5
|
* Encrypt what the watcher needs and the gateway must not have. The gateway
|
|
@@ -278,66 +14,6 @@ declare function seal(secret: string, plaintext: string): Promise<string>;
|
|
|
278
14
|
*/
|
|
279
15
|
declare function unseal(secret: string, sealed: string): Promise<string | null>;
|
|
280
16
|
|
|
281
|
-
interface TriggerConfig {
|
|
282
|
-
/** The gateway that quotes the addresses and mints the invoice */
|
|
283
|
-
gateway: ThunderBridge;
|
|
284
|
-
/** Priority list, quoted at payRequest and then pinned for the callback */
|
|
285
|
-
lnAddresses: string[];
|
|
286
|
-
/**
|
|
287
|
-
* What this trigger costs right now, called once per payRequest. A plain
|
|
288
|
-
* function, so a fiat peg or a time of day rule is just code you write
|
|
289
|
-
*/
|
|
290
|
-
amountMsat: () => number | Promise<number>;
|
|
291
|
-
/**
|
|
292
|
-
* Signs the callback URL. Without it anyone could call the callback and make
|
|
293
|
-
* this endpoint mint invoices on wallets of their choosing
|
|
294
|
-
*/
|
|
295
|
-
secret: string;
|
|
296
|
-
/** Groups every payment here so `followTrigger` can watch the place, keep it off the QR */
|
|
297
|
-
watchSecret?: string;
|
|
298
|
-
/** Override when a proxy hides the public URL from the request, no trailing slash */
|
|
299
|
-
baseUrl?: string;
|
|
300
|
-
/**
|
|
301
|
-
* Resolve the address here and hand the gateway only a hash and a URL to poll,
|
|
302
|
-
* instead of asking it to mint. It then cannot tell who is being paid beyond
|
|
303
|
-
* the domain in the verify URL, nor how much at all, so the only refusal left
|
|
304
|
-
* to it is refusing everyone. Costs one more round trip and gives up the
|
|
305
|
-
* gateway's CORS proxying, which a server does not need anyway
|
|
306
|
-
*/
|
|
307
|
-
blind?: boolean;
|
|
308
|
-
/**
|
|
309
|
-
* What the watcher needs and the gateway must not have. `data` returns it and
|
|
310
|
-
* `secret` encrypts it, so there is no way to hand the gateway something it
|
|
311
|
-
* can read. Needs 32 characters of randomness, not a passphrase, and every
|
|
312
|
-
* watcher of this trigger holds the same one
|
|
313
|
-
*/
|
|
314
|
-
sealed?: {
|
|
315
|
-
secret: string;
|
|
316
|
-
data: (minted: Minted) => unknown;
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
interface Minted {
|
|
320
|
-
lnAddress: string;
|
|
321
|
-
amountMsat: number;
|
|
322
|
-
bolt11: string;
|
|
323
|
-
paymentHash: string;
|
|
324
|
-
verifyUrl: string;
|
|
325
|
-
expiresAt: number;
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* An LNURL-pay endpoint standing in front of a priority list of addresses, as a
|
|
329
|
-
* Fetch handler so it runs on Deno Deploy, Workers, Hono, Next and Node alike.
|
|
330
|
-
*
|
|
331
|
-
* It answers both halves of the flow on one path. A bare request is the
|
|
332
|
-
* payRequest and quotes the list, and a signed one is the callback and mints.
|
|
333
|
-
* The winner is chosen at payRequest and pinned into the callback URL because
|
|
334
|
-
* LUD-06 binds the invoice to the metadata already served: if the callback
|
|
335
|
-
* picked a different address the payer's wallet would refuse the invoice.
|
|
336
|
-
*
|
|
337
|
-
* Nothing is stored between the two, so this holds no state of its own.
|
|
338
|
-
*/
|
|
339
|
-
declare function lnurlPayEndpoint(config: TriggerConfig): (request: Request) => Promise<Response>;
|
|
340
|
-
|
|
341
17
|
/** One incoming payment as the bank booked it, in the smallest unit of its currency */
|
|
342
18
|
interface Credit {
|
|
343
19
|
amountMinor: number;
|
|
@@ -390,6 +66,13 @@ interface BankTransferParams {
|
|
|
390
66
|
* without asking anyone. `seal` it and the gateway cannot read it either
|
|
391
67
|
*/
|
|
392
68
|
sealed?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Where the gateway posts once the money lands, a public https URL. Without one
|
|
71
|
+
* a transfer is only ever learned by following the trigger or asking
|
|
72
|
+
*/
|
|
73
|
+
webhookUrl?: string;
|
|
74
|
+
/** Signs that delivery, so `verifyWebhookSignature` can tell it came from the gateway */
|
|
75
|
+
webhookSecret?: string;
|
|
393
76
|
/**
|
|
394
77
|
* Register on a gateway you do not own anyway. The verify URL names the amount
|
|
395
78
|
* and the reference, so its operator ends up reading your order book, and the
|
|
@@ -489,113 +172,6 @@ interface FioConfig {
|
|
|
489
172
|
*/
|
|
490
173
|
declare function fioStatement(config: FioConfig): Statement;
|
|
491
174
|
|
|
492
|
-
/** What a shop knows about a sale before any rail exists */
|
|
493
|
-
interface Order {
|
|
494
|
-
/** The bank matches it on the statement, and Lightning keys idempotency on it */
|
|
495
|
-
reference: string;
|
|
496
|
-
/** The price in the smallest unit of `currency`, so 48055 is 480.55 CZK */
|
|
497
|
-
amountMinor: number;
|
|
498
|
-
/** ISO 4217. The bank rail moves this, Lightning reads it only through your own `amountMsat` */
|
|
499
|
-
currency: string;
|
|
500
|
-
}
|
|
501
|
-
/** One way to pay one order, already registered with the gateway */
|
|
502
|
-
interface Leg {
|
|
503
|
-
/** The watched payment's id, which is what `firstToSettle`, `getWatched` and `waitForWatched` take */
|
|
504
|
-
id: string;
|
|
505
|
-
/** Which rail made it, so a shop can label a leg without knowing how it was built */
|
|
506
|
-
rail: string;
|
|
507
|
-
/** What the payer reads, a BOLT11 invoice or a Short Payment Descriptor */
|
|
508
|
-
scan: string;
|
|
509
|
-
/** The same thing as a QR has to encode it, which is not always `scan` itself */
|
|
510
|
-
qr: string;
|
|
511
|
-
expiresAt: number;
|
|
512
|
-
}
|
|
513
|
-
/**
|
|
514
|
-
* A payment method. Everything that differs between rails is bound once when the
|
|
515
|
-
* rail is built, so the only thing passed per sale is which sale it is
|
|
516
|
-
*/
|
|
517
|
-
type Rail = (order: Order) => Promise<Leg>;
|
|
518
|
-
interface BankRailConfig {
|
|
519
|
-
/** The gateway that will watch these transfers. It has to be one of your own */
|
|
520
|
-
gateway: ThunderBridge;
|
|
521
|
-
/** Long lived and server side. Every preimage is derived from it, so losing it loses every proof */
|
|
522
|
-
secret: string;
|
|
523
|
-
/** The account the money goes to, as an IBAN */
|
|
524
|
-
iban: string;
|
|
525
|
-
/** Where `bankVerifyEndpoint` is mounted, a public https URL with no query of its own */
|
|
526
|
-
verifyUrl: string;
|
|
527
|
-
/**
|
|
528
|
-
* When this order stops being payable, in unix seconds. Re-offering one order
|
|
529
|
-
* has to return the same second every time, because the gateway compares the
|
|
530
|
-
* expiry to decide whether a repeated watch is the same watch
|
|
531
|
-
*/
|
|
532
|
-
expiresAt: (order: Order) => number;
|
|
533
|
-
/** Groups every leg on the same secret, so one `followTrigger` socket hears them all */
|
|
534
|
-
trigger?: string;
|
|
535
|
-
/** Handed back untouched on that stream. Stable across re-offers, for the reason `expiresAt` is */
|
|
536
|
-
sealed?: (order: Order) => string | Promise<string>;
|
|
537
|
-
/** Up to ten digits, for accounting systems that still want one */
|
|
538
|
-
variableSymbol?: (order: Order) => string | undefined;
|
|
539
|
-
/** Register on a gateway you do not own anyway, on the terms `bankTransfer` sets out */
|
|
540
|
-
allowPublicGateway?: boolean;
|
|
541
|
-
/** What `Leg.rail` reads, for a shop running more than one account */
|
|
542
|
-
name?: string;
|
|
543
|
-
}
|
|
544
|
-
interface LightningRailConfig {
|
|
545
|
-
/** The gateway that mints the invoice */
|
|
546
|
-
gateway: ThunderBridge;
|
|
547
|
-
/** Priority list, the gateway takes the first that can issue a provable invoice */
|
|
548
|
-
lnAddresses: string[];
|
|
549
|
-
/** What this order costs in millisatoshi. A shop pricing in fiat writes `msatFor` and its own ticker */
|
|
550
|
-
amountMsat: (order: Order) => number | Promise<number>;
|
|
551
|
-
/** Groups every leg on the same secret, so one `followTrigger` socket hears them all */
|
|
552
|
-
trigger?: string;
|
|
553
|
-
/**
|
|
554
|
-
* Makes the mint safe to retry. Unset nothing is sent, because a key stable
|
|
555
|
-
* across re-offers is one the gateway can join against the bank leg's reference
|
|
556
|
-
*/
|
|
557
|
-
idempotencyKey?: (order: Order) => string | undefined;
|
|
558
|
-
webhookUrl?: string;
|
|
559
|
-
webhookSecret?: string;
|
|
560
|
-
/** What `Leg.rail` reads, for a shop running more than one wallet */
|
|
561
|
-
name?: string;
|
|
562
|
-
}
|
|
563
|
-
interface BlindLightningRailConfig {
|
|
564
|
-
/** The gateway that watches an invoice it was never allowed to mint */
|
|
565
|
-
gateway: ThunderBridge;
|
|
566
|
-
/** Priority list, resolved here rather than by the gateway */
|
|
567
|
-
lnAddresses: string[];
|
|
568
|
-
/** What this order costs in millisatoshi */
|
|
569
|
-
amountMsat: (order: Order) => number | Promise<number>;
|
|
570
|
-
/** Groups every leg on the same secret, so one `followTrigger` socket hears them all */
|
|
571
|
-
trigger?: string;
|
|
572
|
-
/** Only a watched leg has anywhere to carry this */
|
|
573
|
-
sealed?: (order: Order) => string | Promise<string>;
|
|
574
|
-
/** What `Leg.rail` reads, for a shop running more than one wallet */
|
|
575
|
-
name?: string;
|
|
576
|
-
}
|
|
577
|
-
/**
|
|
578
|
-
* Sell for a bank transfer. The money moves straight to your account and the
|
|
579
|
-
* gateway is told a hash, a URL and an expiry, never the amount or the reference.
|
|
580
|
-
*
|
|
581
|
-
* Which bank is read back is `bankVerifyEndpoint`'s business, not this one's, so
|
|
582
|
-
* a rail built here serves Fio and anything else behind a `Statement`.
|
|
583
|
-
*/
|
|
584
|
-
declare function bankRail(config: BankRailConfig): Rail;
|
|
585
|
-
/**
|
|
586
|
-
* Sell for Lightning, with the gateway minting the invoice. It is told the
|
|
587
|
-
* address list and the amount, which is the round trip `blindLightningRail`
|
|
588
|
-
* spends to avoid.
|
|
589
|
-
*/
|
|
590
|
-
declare function lightningRail(config: LightningRailConfig): Rail;
|
|
591
|
-
/**
|
|
592
|
-
* Sell for Lightning, resolving the address here and handing the gateway only a
|
|
593
|
-
* hash and a URL to poll. It costs one more round trip and the gateway learns
|
|
594
|
-
* neither who is being paid nor how much, so the only refusal left to it is
|
|
595
|
-
* refusing everyone.
|
|
596
|
-
*/
|
|
597
|
-
declare function blindLightningRail(config: BlindLightningRailConfig): Rail;
|
|
598
|
-
|
|
599
175
|
/**
|
|
600
176
|
* How many minor units of `currency` one bitcoin costs at one venue, so 134883815
|
|
601
177
|
* is 1,348,838.15 CZK. Throws when that venue does not quote that currency, which
|
|
@@ -771,6 +347,14 @@ declare function parseWebhook(body: string | Uint8Array, signature: string, secr
|
|
|
771
347
|
* Cloudflare Workers and Deno, WebCrypto only so it runs anywhere fetch does
|
|
772
348
|
*/
|
|
773
349
|
declare function parseWebhookRequest(request: Request, secret: string, options?: WebhookOptions): Promise<Payment | null>;
|
|
350
|
+
/**
|
|
351
|
+
* The same, for a payment the gateway only watched. A bank transfer and a blind
|
|
352
|
+
* Lightning leg carry no address, amount or invoice, so they arrive in the shape
|
|
353
|
+
* `followTrigger` and `getWatched` hand back rather than the minted one
|
|
354
|
+
*/
|
|
355
|
+
declare function parseWatchedWebhook(body: string | Uint8Array, signature: string, secret: string, timestamp: string, options?: WebhookOptions): Promise<TriggerEvent | null>;
|
|
356
|
+
/** `parseWatchedWebhook` from a Fetch API `Request`, the way `parseWebhookRequest` is */
|
|
357
|
+
declare function parseWatchedWebhookRequest(request: Request, secret: string, options?: WebhookOptions): Promise<TriggerEvent | null>;
|
|
774
358
|
|
|
775
359
|
/**
|
|
776
360
|
* The way a gateway was caught out, every code is a check that held against the
|
|
@@ -848,4 +432,4 @@ declare class NoWalletAvailableError extends ProblemError {
|
|
|
848
432
|
}, wallets: WalletFailure[]);
|
|
849
433
|
}
|
|
850
434
|
|
|
851
|
-
export { type
|
|
435
|
+
export { type BankTransfer, type BankTransferParams, type BankVerifyConfig, CreatePaymentParams, type Credit, type FioConfig, type GatewayCheatCode, GatewayCheatError, IDEMPOTENCY_KEY_REUSED, type IdempotencyConflict, IdempotencyConflictError, type Invoice, type MedianOptions, NO_WALLET_AVAILABLE, NoWalletAvailableError, PAYMENT_ALREADY_WATCHED, Payment, ProblemError, type QrOptions, REQUEST_IN_FLIGHT, type Statement, ThunderBridge, type Ticker, TriggerEvent, UnverifiedRecipientError, WalletFailure, type WebhookOptions, bankTransfer, bankVerifyEndpoint, bitstamp, coinbase, coinmate, decodeInvoice, fioStatement, invoiceToDataUrl, invoiceToSvg, isProblemType, isProvablyPaid, kraken, lnurlToDataUrl, lnurlToSvg, medianOf, minorScaleOf, minorUnitsOf, msatFor, parseWatchedWebhook, parseWatchedWebhookRequest, parseWebhook, parseWebhookRequest, preimageMatchesHash, proveOrigin, proveSettlement, qrToDataUrl, qrToSvg, seal, spdToDataUrl, spdToSvg, toLnurl, unseal, verifyWebhookSignature };
|