thunder-bridge 2.2.1 → 3.0.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 +93 -412
- package/dist/bank.cjs +3 -0
- package/dist/bank.d.cts +3 -3
- package/dist/bank.d.ts +3 -3
- package/dist/bank.js +8 -0
- package/dist/index.cjs +253 -112
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +258 -111
- package/dist/{bank-BgA45yOU.d.ts → nwc-BivXGSPY.d.ts} +70 -114
- package/dist/{bank-DvcV85sa.d.cts → nwc-h_-cGvMb.d.cts} +70 -114
- package/dist/nwc.cjs +10 -424
- package/dist/nwc.d.cts +2 -18
- package/dist/nwc.d.ts +2 -18
- package/dist/nwc.js +10 -422
- package/openapi.yaml +1 -1
- package/package.json +8 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as Resolved, Q as QrOptions } from './qr-CF-YeXU1.js';
|
|
2
1
|
import { A as Amount, T as Ticker, C as Charge, f as MintedPayment, h as PaymentStatus, i as Priced, g as Msat, S as Settlement, P as Payment, Q as Quote, e as Held, H as Handover, j as SocketTicket } from './types-DYZ9EkmJ.js';
|
|
2
|
+
import { R as Resolved, Q as QrOptions } from './qr-CF-YeXU1.js';
|
|
3
3
|
|
|
4
4
|
type Sent = {
|
|
5
5
|
method?: string;
|
|
@@ -15,6 +15,47 @@ type Verified = {
|
|
|
15
15
|
/** Carries one request to an address ask() already verified, so nothing resolves the name again */
|
|
16
16
|
type Send = (url: string, sent: Sent, signal: AbortSignal, at: readonly Verified[]) => Promise<Response>;
|
|
17
17
|
|
|
18
|
+
/** The wallet's own LUD-21 URL and the hash its preimage has to match */
|
|
19
|
+
interface Relayed {
|
|
20
|
+
url: string;
|
|
21
|
+
hash: string;
|
|
22
|
+
}
|
|
23
|
+
/** Where your own verify endpoint is mounted, and the secret it was given */
|
|
24
|
+
interface VerifyThrough {
|
|
25
|
+
endpoint: string;
|
|
26
|
+
secret: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Who the gateway polls. `verifyThrough` is an endpoint of yours, which needs a
|
|
30
|
+
* server and keeps the wallet and the amount from the gateway. `gatewayMints`
|
|
31
|
+
* lets the gateway mint and poll the wallet itself, for a client with no server
|
|
32
|
+
*/
|
|
33
|
+
type VerifyPath = {
|
|
34
|
+
verifyThrough: VerifyThrough;
|
|
35
|
+
gatewayMints?: never;
|
|
36
|
+
} | {
|
|
37
|
+
gatewayMints: true;
|
|
38
|
+
verifyThrough?: never;
|
|
39
|
+
};
|
|
40
|
+
/** The verify endpoint that asks the wallet for the gateway, and how often it may be asked */
|
|
41
|
+
interface LightningVerifyConfig {
|
|
42
|
+
/** The secret the sealed wallet URL was made with, and nothing else uses it */
|
|
43
|
+
secret: string;
|
|
44
|
+
/**
|
|
45
|
+
* How often you want the gateway to ask, in seconds. It goes out as
|
|
46
|
+
* `Cache-Control: max-age`, so the pace is yours rather than the operator's.
|
|
47
|
+
* Five by default, which is what a Lightning checkout wants
|
|
48
|
+
*/
|
|
49
|
+
pollEverySecs?: number;
|
|
50
|
+
/** How the relay reaches the wallet, pinned to the address it verified unless you say otherwise */
|
|
51
|
+
send?: Send;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The URL to hand the gateway instead of the wallet's own, with the wallet's
|
|
55
|
+
* sealed inside it. Point it at wherever `serve.lightningVerify` is mounted
|
|
56
|
+
*/
|
|
57
|
+
declare function relayedVerifyUrl(endpoint: string, wallet: Relayed, secret: string): Promise<string>;
|
|
58
|
+
|
|
18
59
|
/** A wallet reachable over NIP-47, as its `nostr+walletconnect://` URI describes it */
|
|
19
60
|
interface NwcConnection {
|
|
20
61
|
/** The wallet service's public key, which is what its answers have to be signed by */
|
|
@@ -74,21 +115,9 @@ declare function nwcSettlement(connection: NwcConnection, paymentHash: string, t
|
|
|
74
115
|
* a lie rather than a receipt, so it throws instead of being passed on
|
|
75
116
|
*/
|
|
76
117
|
declare function nwcPay(connection: NwcConnection, bolt11: string, timeoutMs?: number): Promise<string>;
|
|
77
|
-
/**
|
|
78
|
-
* A verify endpoint of your own that asks your wallet over NIP-47, so the gateway
|
|
79
|
-
* polls you and never learns the connection, the relay, or which wallet it is.
|
|
80
|
-
*
|
|
81
|
-
* `nwcVerifyUrl` seals the payment hash into the query with your secret, which is
|
|
82
|
-
* what stops a stranger driving your wallet through this handler. It answers the
|
|
83
|
-
* LUD-21 shape the gateway already speaks, so nothing on that side changes.
|
|
84
|
-
*
|
|
85
|
-
* A wallet it cannot reach answers `502` rather than "not settled", because those
|
|
86
|
-
* are different claims and only one of them is true.
|
|
87
|
-
*/
|
|
88
|
-
declare function nwcVerifyEndpoint(config: NwcVerifyConfig): (request: Request) => Promise<Response>;
|
|
89
118
|
/**
|
|
90
119
|
* The URL to hand the gateway, with the payment hash sealed inside it. Point it at
|
|
91
|
-
* wherever `
|
|
120
|
+
* wherever `serve.nwcVerify` is mounted
|
|
92
121
|
*/
|
|
93
122
|
declare function nwcVerifyUrl(endpoint: string, paymentHash: string, secret: string): Promise<string>;
|
|
94
123
|
/**
|
|
@@ -109,25 +138,15 @@ interface NwcRailConfig extends RailConfig {
|
|
|
109
138
|
/** Where the default conversion gets its rate, the median of four venues by default */
|
|
110
139
|
rate?: Ticker;
|
|
111
140
|
/** Where `serve.nwcVerify` is mounted, and the secret the hash is sealed with */
|
|
112
|
-
verifyThrough:
|
|
113
|
-
endpoint: string;
|
|
114
|
-
secret: string;
|
|
115
|
-
};
|
|
141
|
+
verifyThrough: VerifyThrough;
|
|
116
142
|
/** What the payer's wallet shows, the order's reference by default */
|
|
117
143
|
description?: (order: Order) => string;
|
|
118
|
-
/** Sealed before the gateway sees it, the way the
|
|
144
|
+
/** Sealed before the gateway sees it, the way the Lightning rail does */
|
|
119
145
|
sealed?: {
|
|
120
146
|
secret: string;
|
|
121
147
|
data: (order: Order) => unknown;
|
|
122
148
|
};
|
|
123
149
|
}
|
|
124
|
-
/**
|
|
125
|
-
* Sell for Lightning against a wallet of your own over NIP-47, for a wallet that
|
|
126
|
-
* has no LUD-21 address to be watched at. Your node mints the invoice and releases
|
|
127
|
-
* the preimage, so the proof comes from one hop nearer than any hosted address can
|
|
128
|
-
* manage, and the gateway sees a hash and a URL of yours
|
|
129
|
-
*/
|
|
130
|
-
declare function nwcRail(gateway: ThunderBridge, config: NwcRailConfig): Rail;
|
|
131
150
|
|
|
132
151
|
/** What a shop knows about a sale before any rail exists */
|
|
133
152
|
interface Order {
|
|
@@ -167,8 +186,8 @@ interface RailConfig {
|
|
|
167
186
|
/** What `Leg.rail` says, so two rails of one kind can be told apart */
|
|
168
187
|
name?: string;
|
|
169
188
|
}
|
|
170
|
-
/**
|
|
171
|
-
interface
|
|
189
|
+
/** Who a Lightning rail pays and what one order costs there, whichever path verifies it */
|
|
190
|
+
interface LightningRailSettings extends RailConfig {
|
|
172
191
|
/** Priority list, the first address that can prove an invoice wins */
|
|
173
192
|
paidTo: string | string[];
|
|
174
193
|
/**
|
|
@@ -178,11 +197,8 @@ interface LightningRailConfig extends RailConfig {
|
|
|
178
197
|
amount?: (order: Order) => Amount;
|
|
179
198
|
/** Where the default conversion gets its rate, the median of four venues by default */
|
|
180
199
|
rate?: Ticker;
|
|
181
|
-
/** Makes the mint safe to retry,
|
|
200
|
+
/** Makes the gateway's mint safe to retry, so it applies with `gatewayMints` only */
|
|
182
201
|
idempotencyKey?: (order: Order) => string | undefined;
|
|
183
|
-
}
|
|
184
|
-
/** The same rail with the invoice resolved here, so the gateway is told neither address nor amount */
|
|
185
|
-
interface BlindLightningRailConfig extends LightningRailConfig {
|
|
186
202
|
/**
|
|
187
203
|
* What the watcher needs and the gateway must not read, sealed under `secret`
|
|
188
204
|
* for the invoice's payment hash before it goes anywhere near the gateway
|
|
@@ -191,18 +207,16 @@ interface BlindLightningRailConfig extends LightningRailConfig {
|
|
|
191
207
|
secret: string;
|
|
192
208
|
data: (order: Order) => unknown;
|
|
193
209
|
};
|
|
194
|
-
/**
|
|
195
|
-
* Where your own `serve.verify` endpoint is mounted, and its secret. Without
|
|
196
|
-
* it the gateway is handed the wallet's own URL, which a gateway enforcing its
|
|
197
|
-
* verify challenge will refuse to poll
|
|
198
|
-
*/
|
|
199
|
-
relayThrough?: {
|
|
200
|
-
endpoint: string;
|
|
201
|
-
secret: string;
|
|
202
|
-
};
|
|
203
210
|
/** How the rail reaches wallets, pinned to the address it verified unless you say otherwise */
|
|
204
211
|
send?: Send;
|
|
205
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* A Lightning rail, bound once and then given one order at a time. With
|
|
215
|
+
* `verifyThrough` the invoice is resolved here and the gateway polls your
|
|
216
|
+
* `serve.lightningVerify`, learning neither who is paid nor how much. With
|
|
217
|
+
* `gatewayMints` the gateway is told both, mints, and polls the wallet itself
|
|
218
|
+
*/
|
|
219
|
+
type LightningRailConfig = LightningRailSettings & VerifyPath;
|
|
206
220
|
/** A bank rail: the account the money lands in, and where its arrival is read back from */
|
|
207
221
|
interface BankRailConfig extends RailConfig {
|
|
208
222
|
/** Long lived and server side. Every preimage is derived from it, so losing it loses every proof */
|
|
@@ -213,7 +227,7 @@ interface BankRailConfig extends RailConfig {
|
|
|
213
227
|
verifyUrl: string;
|
|
214
228
|
/** When this leg stops being payable, in unix seconds */
|
|
215
229
|
expiresAt: (order: Order) => number;
|
|
216
|
-
/** Sealed before the gateway sees it, the way the
|
|
230
|
+
/** Sealed before the gateway sees it, the way the Lightning rail does */
|
|
217
231
|
sealed?: {
|
|
218
232
|
secret: string;
|
|
219
233
|
data: (order: Order) => unknown;
|
|
@@ -244,13 +258,11 @@ declare function invoiceFrom(paidTo: string | string[], amount: Amount, send?: S
|
|
|
244
258
|
declare class Rails {
|
|
245
259
|
private readonly gateway;
|
|
246
260
|
constructor(gateway: ThunderBridge);
|
|
247
|
-
/** Lightning, with the gateway minting against a priority list of addresses */
|
|
248
|
-
lightning(config: LightningRailConfig): Rail;
|
|
249
261
|
/**
|
|
250
|
-
* Lightning
|
|
251
|
-
*
|
|
262
|
+
* Lightning against a priority list of addresses, verified through your
|
|
263
|
+
* `serve.lightningVerify`, or minted by the gateway when you say `gatewayMints`
|
|
252
264
|
*/
|
|
253
|
-
|
|
265
|
+
lightning(config: LightningRailConfig): Rail;
|
|
254
266
|
/** A bank transfer, proved the way a Lightning payment is */
|
|
255
267
|
bank(config: BankRailConfig): Rail;
|
|
256
268
|
/**
|
|
@@ -325,32 +337,8 @@ interface PaymentRequest {
|
|
|
325
337
|
prove(): Promise<string | null>;
|
|
326
338
|
}
|
|
327
339
|
|
|
328
|
-
/** The wallet's own LUD-21 URL and the hash its preimage has to match */
|
|
329
|
-
interface Relayed {
|
|
330
|
-
url: string;
|
|
331
|
-
hash: string;
|
|
332
|
-
}
|
|
333
|
-
/** The verify endpoint that asks the wallet for the gateway, and how often it may be asked */
|
|
334
|
-
interface LightningVerifyConfig {
|
|
335
|
-
/** The secret the sealed wallet URL was made with, and nothing else uses it */
|
|
336
|
-
secret: string;
|
|
337
|
-
/**
|
|
338
|
-
* How often you want the gateway to ask, in seconds. It goes out as
|
|
339
|
-
* `Cache-Control: max-age`, so the pace is yours rather than the operator's.
|
|
340
|
-
* Five by default, which is what a Lightning checkout wants
|
|
341
|
-
*/
|
|
342
|
-
pollEverySecs?: number;
|
|
343
|
-
/** How the relay reaches the wallet, pinned to the address it verified unless you say otherwise */
|
|
344
|
-
send?: Send;
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* The URL to hand the gateway instead of the wallet's own, with the wallet's
|
|
348
|
-
* sealed inside it. Point it at wherever `lightningVerifyEndpoint` is mounted
|
|
349
|
-
*/
|
|
350
|
-
declare function relayedVerifyUrl(endpoint: string, wallet: Relayed, secret: string): Promise<string>;
|
|
351
|
-
|
|
352
340
|
/** An LNURL-pay endpoint of your own: whose wallets it stands for, and what it charges */
|
|
353
|
-
interface
|
|
341
|
+
interface TriggerSettings {
|
|
354
342
|
/** Priority list, quoted at payRequest and then pinned for the callback */
|
|
355
343
|
paidTo: string | string[];
|
|
356
344
|
/**
|
|
@@ -379,26 +367,6 @@ interface TriggerConfig {
|
|
|
379
367
|
send?: Send;
|
|
380
368
|
/** Override when a proxy hides the public URL from the request, no trailing slash */
|
|
381
369
|
baseUrl?: string;
|
|
382
|
-
/**
|
|
383
|
-
* Resolve the address here and hand the gateway only a hash and a URL to poll,
|
|
384
|
-
* instead of asking it to mint. It then cannot tell who is being paid beyond
|
|
385
|
-
* the domain in the verify URL, nor how much at all, so the only refusal left
|
|
386
|
-
* to it is refusing everyone. Costs one more round trip and gives up the
|
|
387
|
-
* gateway's CORS proxying, which a server does not need anyway.
|
|
388
|
-
*
|
|
389
|
-
* A gateway that enforces its verify challenge will not poll a wallet's own
|
|
390
|
-
* LUD-21 URL, so pass `relayThrough` as well and the poll comes to you
|
|
391
|
-
*/
|
|
392
|
-
blind?: boolean;
|
|
393
|
-
/**
|
|
394
|
-
* Where your own `serve.verify` endpoint is mounted, and the secret it was
|
|
395
|
-
* given. The wallet's URL is sealed inside the one the gateway is handed, so
|
|
396
|
-
* the gateway polls you and learns neither the wallet nor its provider
|
|
397
|
-
*/
|
|
398
|
-
relayThrough?: {
|
|
399
|
-
endpoint: string;
|
|
400
|
-
secret: string;
|
|
401
|
-
};
|
|
402
370
|
/**
|
|
403
371
|
* What the watcher needs and the gateway must not have. `data` returns it and
|
|
404
372
|
* `secret` encrypts it, so there is no way to hand the gateway something it
|
|
@@ -410,7 +378,13 @@ interface TriggerConfig {
|
|
|
410
378
|
data: (minted: Minted) => unknown;
|
|
411
379
|
};
|
|
412
380
|
}
|
|
413
|
-
/**
|
|
381
|
+
/**
|
|
382
|
+
* The endpoint's settings and who the gateway polls. With `verifyThrough` the
|
|
383
|
+
* address is resolved here and the gateway polls your `serve.lightningVerify`,
|
|
384
|
+
* learning neither who is paid nor how much. With `gatewayMints` it quotes and
|
|
385
|
+
* mints, and polls the wallet itself
|
|
386
|
+
*/
|
|
387
|
+
type TriggerConfig = TriggerSettings & VerifyPath;
|
|
414
388
|
/**
|
|
415
389
|
* What a payer may choose to send, when the endpoint lets them choose at all.
|
|
416
390
|
* Both ends are asked once per payRequest, so a fiat range moves with the rate
|
|
@@ -419,7 +393,7 @@ interface Range {
|
|
|
419
393
|
least: Amount;
|
|
420
394
|
most: Amount;
|
|
421
395
|
}
|
|
422
|
-
/** What a
|
|
396
|
+
/** What a mint through your endpoint produced, which is what the sealed payload is built from */
|
|
423
397
|
interface Minted {
|
|
424
398
|
lnAddress: string;
|
|
425
399
|
amountMsat: number;
|
|
@@ -486,12 +460,6 @@ type SelfConsistent<T extends Provable> = T & {
|
|
|
486
460
|
status: "paid";
|
|
487
461
|
preimage: string;
|
|
488
462
|
};
|
|
489
|
-
/**
|
|
490
|
-
* What `SelfConsistent` was called before 2.2.0
|
|
491
|
-
*
|
|
492
|
-
* @deprecated Use `SelfConsistent`, which says the report was checked against itself and nothing else
|
|
493
|
-
*/
|
|
494
|
-
type Proven<T extends Provable> = SelfConsistent<T>;
|
|
495
463
|
/**
|
|
496
464
|
* Whether a report agrees with itself: it says paid, and it carries a preimage
|
|
497
465
|
* that hashes to the payment hash it itself names. Where an invoice comes with it,
|
|
@@ -506,12 +474,6 @@ type Proven<T extends Provable> = SelfConsistent<T>;
|
|
|
506
474
|
* `proveSettlement` asks the recipient
|
|
507
475
|
*/
|
|
508
476
|
declare function agreesWithItself<T extends Provable>(report: T): report is SelfConsistent<T>;
|
|
509
|
-
/**
|
|
510
|
-
* What `agreesWithItself` was called before 2.2.0
|
|
511
|
-
*
|
|
512
|
-
* @deprecated Use `agreesWithItself`, because it proves nothing beyond the report itself
|
|
513
|
-
*/
|
|
514
|
-
declare const carriesProof: typeof agreesWithItself;
|
|
515
477
|
/**
|
|
516
478
|
* The most an operator may add over the recipient's own amount, in millisatoshi.
|
|
517
479
|
* The proportion is what routing and the liquidity behind it costs, and the base
|
|
@@ -626,12 +588,6 @@ declare class Serve {
|
|
|
626
588
|
* the gateway polls you and never the wallet
|
|
627
589
|
*/
|
|
628
590
|
lightningVerify(config: LightningVerifyConfig): Handler;
|
|
629
|
-
/**
|
|
630
|
-
* What `lightningVerify` was called before 2.2.0
|
|
631
|
-
*
|
|
632
|
-
* @deprecated Use `lightningVerify`, beside `bankVerify` and `nwcVerify`
|
|
633
|
-
*/
|
|
634
|
-
verify(config: LightningVerifyConfig): Handler;
|
|
635
591
|
/** The verify endpoint a bank rail is polled at, answering off your own statement */
|
|
636
592
|
bankVerify(config: BankVerifyConfig): Handler;
|
|
637
593
|
/**
|
|
@@ -952,7 +908,7 @@ interface BankTransferParams {
|
|
|
952
908
|
/** The account the money goes to, as an IBAN */
|
|
953
909
|
iban: string;
|
|
954
910
|
/**
|
|
955
|
-
* Where `
|
|
911
|
+
* Where `serve.bankVerify` is mounted, a public https URL with no query of
|
|
956
912
|
* its own. Not needed when `answerBy` is "agent", because then nothing is polled
|
|
957
913
|
*/
|
|
958
914
|
verifyUrl?: string;
|
|
@@ -1061,4 +1017,4 @@ interface BankAgentConfig {
|
|
|
1061
1017
|
*/
|
|
1062
1018
|
declare function bankAgent(config: BankAgentConfig): () => void;
|
|
1063
1019
|
|
|
1064
|
-
export {
|
|
1020
|
+
export { relayedVerifyUrl as $, type AttendOptions as A, type BankAgentConfig as B, type Credit as C, type VerifyThrough as D, type WatchTicketConfig as E, type FollowOptions as F, type WebhookCredential as G, type Handler as H, type WebhookHandlers as I, type WebhookOptions as J, type WrapAllowance as K, type Leg as L, type Minted as M, type NwcConnection as N, type Order as O, type PaymentRequest as P, agreesWithItself as Q, type Rail as R, type Statement as S, ThunderBridge as T, answerVerifyChallenge as U, type VerifyPath as V, type WaitOptions as W, invoiceFrom as X, proveOrigin as Y, proveSettlement as Z, proveWrapped as _, type BankOrder as a, wrapFeeCeiling as a0, type NwcInvoice as a1, askWallet as a2, nwcConnection as a3, nwcHoldInvoice as a4, nwcInvoice as a5, nwcPay as a6, nwcSettlement as a7, nwcVerifyUrl as a8, type BankTransfer as b, type BankTransferParams as c, type BankVerifyConfig as d, bankAgent as e, type ThunderBridgeOptions as f, type BankRailConfig as g, type CreateOptions as h, type LightningRailConfig as i, type LightningRailSettings as j, type LightningVerifyConfig as k, type NwcRailConfig as l, type NwcVerifyConfig as m, type PaymentRequestInit as n, type PaymentRequestOptions as o, type Provable as p, type RailConfig as q, Rails as r, type Range as s, type Relayed as t, type SelfConsistent as u, type Send as v, Serve as w, type TicketOptions as x, type TriggerConfig as y, type TriggerSettings as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as Resolved, Q as QrOptions } from './qr-CF-YeXU1.cjs';
|
|
2
1
|
import { A as Amount, T as Ticker, C as Charge, f as MintedPayment, h as PaymentStatus, i as Priced, g as Msat, S as Settlement, P as Payment, Q as Quote, e as Held, H as Handover, j as SocketTicket } from './types-DYZ9EkmJ.cjs';
|
|
2
|
+
import { R as Resolved, Q as QrOptions } from './qr-CF-YeXU1.cjs';
|
|
3
3
|
|
|
4
4
|
type Sent = {
|
|
5
5
|
method?: string;
|
|
@@ -15,6 +15,47 @@ type Verified = {
|
|
|
15
15
|
/** Carries one request to an address ask() already verified, so nothing resolves the name again */
|
|
16
16
|
type Send = (url: string, sent: Sent, signal: AbortSignal, at: readonly Verified[]) => Promise<Response>;
|
|
17
17
|
|
|
18
|
+
/** The wallet's own LUD-21 URL and the hash its preimage has to match */
|
|
19
|
+
interface Relayed {
|
|
20
|
+
url: string;
|
|
21
|
+
hash: string;
|
|
22
|
+
}
|
|
23
|
+
/** Where your own verify endpoint is mounted, and the secret it was given */
|
|
24
|
+
interface VerifyThrough {
|
|
25
|
+
endpoint: string;
|
|
26
|
+
secret: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Who the gateway polls. `verifyThrough` is an endpoint of yours, which needs a
|
|
30
|
+
* server and keeps the wallet and the amount from the gateway. `gatewayMints`
|
|
31
|
+
* lets the gateway mint and poll the wallet itself, for a client with no server
|
|
32
|
+
*/
|
|
33
|
+
type VerifyPath = {
|
|
34
|
+
verifyThrough: VerifyThrough;
|
|
35
|
+
gatewayMints?: never;
|
|
36
|
+
} | {
|
|
37
|
+
gatewayMints: true;
|
|
38
|
+
verifyThrough?: never;
|
|
39
|
+
};
|
|
40
|
+
/** The verify endpoint that asks the wallet for the gateway, and how often it may be asked */
|
|
41
|
+
interface LightningVerifyConfig {
|
|
42
|
+
/** The secret the sealed wallet URL was made with, and nothing else uses it */
|
|
43
|
+
secret: string;
|
|
44
|
+
/**
|
|
45
|
+
* How often you want the gateway to ask, in seconds. It goes out as
|
|
46
|
+
* `Cache-Control: max-age`, so the pace is yours rather than the operator's.
|
|
47
|
+
* Five by default, which is what a Lightning checkout wants
|
|
48
|
+
*/
|
|
49
|
+
pollEverySecs?: number;
|
|
50
|
+
/** How the relay reaches the wallet, pinned to the address it verified unless you say otherwise */
|
|
51
|
+
send?: Send;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The URL to hand the gateway instead of the wallet's own, with the wallet's
|
|
55
|
+
* sealed inside it. Point it at wherever `serve.lightningVerify` is mounted
|
|
56
|
+
*/
|
|
57
|
+
declare function relayedVerifyUrl(endpoint: string, wallet: Relayed, secret: string): Promise<string>;
|
|
58
|
+
|
|
18
59
|
/** A wallet reachable over NIP-47, as its `nostr+walletconnect://` URI describes it */
|
|
19
60
|
interface NwcConnection {
|
|
20
61
|
/** The wallet service's public key, which is what its answers have to be signed by */
|
|
@@ -74,21 +115,9 @@ declare function nwcSettlement(connection: NwcConnection, paymentHash: string, t
|
|
|
74
115
|
* a lie rather than a receipt, so it throws instead of being passed on
|
|
75
116
|
*/
|
|
76
117
|
declare function nwcPay(connection: NwcConnection, bolt11: string, timeoutMs?: number): Promise<string>;
|
|
77
|
-
/**
|
|
78
|
-
* A verify endpoint of your own that asks your wallet over NIP-47, so the gateway
|
|
79
|
-
* polls you and never learns the connection, the relay, or which wallet it is.
|
|
80
|
-
*
|
|
81
|
-
* `nwcVerifyUrl` seals the payment hash into the query with your secret, which is
|
|
82
|
-
* what stops a stranger driving your wallet through this handler. It answers the
|
|
83
|
-
* LUD-21 shape the gateway already speaks, so nothing on that side changes.
|
|
84
|
-
*
|
|
85
|
-
* A wallet it cannot reach answers `502` rather than "not settled", because those
|
|
86
|
-
* are different claims and only one of them is true.
|
|
87
|
-
*/
|
|
88
|
-
declare function nwcVerifyEndpoint(config: NwcVerifyConfig): (request: Request) => Promise<Response>;
|
|
89
118
|
/**
|
|
90
119
|
* The URL to hand the gateway, with the payment hash sealed inside it. Point it at
|
|
91
|
-
* wherever `
|
|
120
|
+
* wherever `serve.nwcVerify` is mounted
|
|
92
121
|
*/
|
|
93
122
|
declare function nwcVerifyUrl(endpoint: string, paymentHash: string, secret: string): Promise<string>;
|
|
94
123
|
/**
|
|
@@ -109,25 +138,15 @@ interface NwcRailConfig extends RailConfig {
|
|
|
109
138
|
/** Where the default conversion gets its rate, the median of four venues by default */
|
|
110
139
|
rate?: Ticker;
|
|
111
140
|
/** Where `serve.nwcVerify` is mounted, and the secret the hash is sealed with */
|
|
112
|
-
verifyThrough:
|
|
113
|
-
endpoint: string;
|
|
114
|
-
secret: string;
|
|
115
|
-
};
|
|
141
|
+
verifyThrough: VerifyThrough;
|
|
116
142
|
/** What the payer's wallet shows, the order's reference by default */
|
|
117
143
|
description?: (order: Order) => string;
|
|
118
|
-
/** Sealed before the gateway sees it, the way the
|
|
144
|
+
/** Sealed before the gateway sees it, the way the Lightning rail does */
|
|
119
145
|
sealed?: {
|
|
120
146
|
secret: string;
|
|
121
147
|
data: (order: Order) => unknown;
|
|
122
148
|
};
|
|
123
149
|
}
|
|
124
|
-
/**
|
|
125
|
-
* Sell for Lightning against a wallet of your own over NIP-47, for a wallet that
|
|
126
|
-
* has no LUD-21 address to be watched at. Your node mints the invoice and releases
|
|
127
|
-
* the preimage, so the proof comes from one hop nearer than any hosted address can
|
|
128
|
-
* manage, and the gateway sees a hash and a URL of yours
|
|
129
|
-
*/
|
|
130
|
-
declare function nwcRail(gateway: ThunderBridge, config: NwcRailConfig): Rail;
|
|
131
150
|
|
|
132
151
|
/** What a shop knows about a sale before any rail exists */
|
|
133
152
|
interface Order {
|
|
@@ -167,8 +186,8 @@ interface RailConfig {
|
|
|
167
186
|
/** What `Leg.rail` says, so two rails of one kind can be told apart */
|
|
168
187
|
name?: string;
|
|
169
188
|
}
|
|
170
|
-
/**
|
|
171
|
-
interface
|
|
189
|
+
/** Who a Lightning rail pays and what one order costs there, whichever path verifies it */
|
|
190
|
+
interface LightningRailSettings extends RailConfig {
|
|
172
191
|
/** Priority list, the first address that can prove an invoice wins */
|
|
173
192
|
paidTo: string | string[];
|
|
174
193
|
/**
|
|
@@ -178,11 +197,8 @@ interface LightningRailConfig extends RailConfig {
|
|
|
178
197
|
amount?: (order: Order) => Amount;
|
|
179
198
|
/** Where the default conversion gets its rate, the median of four venues by default */
|
|
180
199
|
rate?: Ticker;
|
|
181
|
-
/** Makes the mint safe to retry,
|
|
200
|
+
/** Makes the gateway's mint safe to retry, so it applies with `gatewayMints` only */
|
|
182
201
|
idempotencyKey?: (order: Order) => string | undefined;
|
|
183
|
-
}
|
|
184
|
-
/** The same rail with the invoice resolved here, so the gateway is told neither address nor amount */
|
|
185
|
-
interface BlindLightningRailConfig extends LightningRailConfig {
|
|
186
202
|
/**
|
|
187
203
|
* What the watcher needs and the gateway must not read, sealed under `secret`
|
|
188
204
|
* for the invoice's payment hash before it goes anywhere near the gateway
|
|
@@ -191,18 +207,16 @@ interface BlindLightningRailConfig extends LightningRailConfig {
|
|
|
191
207
|
secret: string;
|
|
192
208
|
data: (order: Order) => unknown;
|
|
193
209
|
};
|
|
194
|
-
/**
|
|
195
|
-
* Where your own `serve.verify` endpoint is mounted, and its secret. Without
|
|
196
|
-
* it the gateway is handed the wallet's own URL, which a gateway enforcing its
|
|
197
|
-
* verify challenge will refuse to poll
|
|
198
|
-
*/
|
|
199
|
-
relayThrough?: {
|
|
200
|
-
endpoint: string;
|
|
201
|
-
secret: string;
|
|
202
|
-
};
|
|
203
210
|
/** How the rail reaches wallets, pinned to the address it verified unless you say otherwise */
|
|
204
211
|
send?: Send;
|
|
205
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* A Lightning rail, bound once and then given one order at a time. With
|
|
215
|
+
* `verifyThrough` the invoice is resolved here and the gateway polls your
|
|
216
|
+
* `serve.lightningVerify`, learning neither who is paid nor how much. With
|
|
217
|
+
* `gatewayMints` the gateway is told both, mints, and polls the wallet itself
|
|
218
|
+
*/
|
|
219
|
+
type LightningRailConfig = LightningRailSettings & VerifyPath;
|
|
206
220
|
/** A bank rail: the account the money lands in, and where its arrival is read back from */
|
|
207
221
|
interface BankRailConfig extends RailConfig {
|
|
208
222
|
/** Long lived and server side. Every preimage is derived from it, so losing it loses every proof */
|
|
@@ -213,7 +227,7 @@ interface BankRailConfig extends RailConfig {
|
|
|
213
227
|
verifyUrl: string;
|
|
214
228
|
/** When this leg stops being payable, in unix seconds */
|
|
215
229
|
expiresAt: (order: Order) => number;
|
|
216
|
-
/** Sealed before the gateway sees it, the way the
|
|
230
|
+
/** Sealed before the gateway sees it, the way the Lightning rail does */
|
|
217
231
|
sealed?: {
|
|
218
232
|
secret: string;
|
|
219
233
|
data: (order: Order) => unknown;
|
|
@@ -244,13 +258,11 @@ declare function invoiceFrom(paidTo: string | string[], amount: Amount, send?: S
|
|
|
244
258
|
declare class Rails {
|
|
245
259
|
private readonly gateway;
|
|
246
260
|
constructor(gateway: ThunderBridge);
|
|
247
|
-
/** Lightning, with the gateway minting against a priority list of addresses */
|
|
248
|
-
lightning(config: LightningRailConfig): Rail;
|
|
249
261
|
/**
|
|
250
|
-
* Lightning
|
|
251
|
-
*
|
|
262
|
+
* Lightning against a priority list of addresses, verified through your
|
|
263
|
+
* `serve.lightningVerify`, or minted by the gateway when you say `gatewayMints`
|
|
252
264
|
*/
|
|
253
|
-
|
|
265
|
+
lightning(config: LightningRailConfig): Rail;
|
|
254
266
|
/** A bank transfer, proved the way a Lightning payment is */
|
|
255
267
|
bank(config: BankRailConfig): Rail;
|
|
256
268
|
/**
|
|
@@ -325,32 +337,8 @@ interface PaymentRequest {
|
|
|
325
337
|
prove(): Promise<string | null>;
|
|
326
338
|
}
|
|
327
339
|
|
|
328
|
-
/** The wallet's own LUD-21 URL and the hash its preimage has to match */
|
|
329
|
-
interface Relayed {
|
|
330
|
-
url: string;
|
|
331
|
-
hash: string;
|
|
332
|
-
}
|
|
333
|
-
/** The verify endpoint that asks the wallet for the gateway, and how often it may be asked */
|
|
334
|
-
interface LightningVerifyConfig {
|
|
335
|
-
/** The secret the sealed wallet URL was made with, and nothing else uses it */
|
|
336
|
-
secret: string;
|
|
337
|
-
/**
|
|
338
|
-
* How often you want the gateway to ask, in seconds. It goes out as
|
|
339
|
-
* `Cache-Control: max-age`, so the pace is yours rather than the operator's.
|
|
340
|
-
* Five by default, which is what a Lightning checkout wants
|
|
341
|
-
*/
|
|
342
|
-
pollEverySecs?: number;
|
|
343
|
-
/** How the relay reaches the wallet, pinned to the address it verified unless you say otherwise */
|
|
344
|
-
send?: Send;
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* The URL to hand the gateway instead of the wallet's own, with the wallet's
|
|
348
|
-
* sealed inside it. Point it at wherever `lightningVerifyEndpoint` is mounted
|
|
349
|
-
*/
|
|
350
|
-
declare function relayedVerifyUrl(endpoint: string, wallet: Relayed, secret: string): Promise<string>;
|
|
351
|
-
|
|
352
340
|
/** An LNURL-pay endpoint of your own: whose wallets it stands for, and what it charges */
|
|
353
|
-
interface
|
|
341
|
+
interface TriggerSettings {
|
|
354
342
|
/** Priority list, quoted at payRequest and then pinned for the callback */
|
|
355
343
|
paidTo: string | string[];
|
|
356
344
|
/**
|
|
@@ -379,26 +367,6 @@ interface TriggerConfig {
|
|
|
379
367
|
send?: Send;
|
|
380
368
|
/** Override when a proxy hides the public URL from the request, no trailing slash */
|
|
381
369
|
baseUrl?: string;
|
|
382
|
-
/**
|
|
383
|
-
* Resolve the address here and hand the gateway only a hash and a URL to poll,
|
|
384
|
-
* instead of asking it to mint. It then cannot tell who is being paid beyond
|
|
385
|
-
* the domain in the verify URL, nor how much at all, so the only refusal left
|
|
386
|
-
* to it is refusing everyone. Costs one more round trip and gives up the
|
|
387
|
-
* gateway's CORS proxying, which a server does not need anyway.
|
|
388
|
-
*
|
|
389
|
-
* A gateway that enforces its verify challenge will not poll a wallet's own
|
|
390
|
-
* LUD-21 URL, so pass `relayThrough` as well and the poll comes to you
|
|
391
|
-
*/
|
|
392
|
-
blind?: boolean;
|
|
393
|
-
/**
|
|
394
|
-
* Where your own `serve.verify` endpoint is mounted, and the secret it was
|
|
395
|
-
* given. The wallet's URL is sealed inside the one the gateway is handed, so
|
|
396
|
-
* the gateway polls you and learns neither the wallet nor its provider
|
|
397
|
-
*/
|
|
398
|
-
relayThrough?: {
|
|
399
|
-
endpoint: string;
|
|
400
|
-
secret: string;
|
|
401
|
-
};
|
|
402
370
|
/**
|
|
403
371
|
* What the watcher needs and the gateway must not have. `data` returns it and
|
|
404
372
|
* `secret` encrypts it, so there is no way to hand the gateway something it
|
|
@@ -410,7 +378,13 @@ interface TriggerConfig {
|
|
|
410
378
|
data: (minted: Minted) => unknown;
|
|
411
379
|
};
|
|
412
380
|
}
|
|
413
|
-
/**
|
|
381
|
+
/**
|
|
382
|
+
* The endpoint's settings and who the gateway polls. With `verifyThrough` the
|
|
383
|
+
* address is resolved here and the gateway polls your `serve.lightningVerify`,
|
|
384
|
+
* learning neither who is paid nor how much. With `gatewayMints` it quotes and
|
|
385
|
+
* mints, and polls the wallet itself
|
|
386
|
+
*/
|
|
387
|
+
type TriggerConfig = TriggerSettings & VerifyPath;
|
|
414
388
|
/**
|
|
415
389
|
* What a payer may choose to send, when the endpoint lets them choose at all.
|
|
416
390
|
* Both ends are asked once per payRequest, so a fiat range moves with the rate
|
|
@@ -419,7 +393,7 @@ interface Range {
|
|
|
419
393
|
least: Amount;
|
|
420
394
|
most: Amount;
|
|
421
395
|
}
|
|
422
|
-
/** What a
|
|
396
|
+
/** What a mint through your endpoint produced, which is what the sealed payload is built from */
|
|
423
397
|
interface Minted {
|
|
424
398
|
lnAddress: string;
|
|
425
399
|
amountMsat: number;
|
|
@@ -486,12 +460,6 @@ type SelfConsistent<T extends Provable> = T & {
|
|
|
486
460
|
status: "paid";
|
|
487
461
|
preimage: string;
|
|
488
462
|
};
|
|
489
|
-
/**
|
|
490
|
-
* What `SelfConsistent` was called before 2.2.0
|
|
491
|
-
*
|
|
492
|
-
* @deprecated Use `SelfConsistent`, which says the report was checked against itself and nothing else
|
|
493
|
-
*/
|
|
494
|
-
type Proven<T extends Provable> = SelfConsistent<T>;
|
|
495
463
|
/**
|
|
496
464
|
* Whether a report agrees with itself: it says paid, and it carries a preimage
|
|
497
465
|
* that hashes to the payment hash it itself names. Where an invoice comes with it,
|
|
@@ -506,12 +474,6 @@ type Proven<T extends Provable> = SelfConsistent<T>;
|
|
|
506
474
|
* `proveSettlement` asks the recipient
|
|
507
475
|
*/
|
|
508
476
|
declare function agreesWithItself<T extends Provable>(report: T): report is SelfConsistent<T>;
|
|
509
|
-
/**
|
|
510
|
-
* What `agreesWithItself` was called before 2.2.0
|
|
511
|
-
*
|
|
512
|
-
* @deprecated Use `agreesWithItself`, because it proves nothing beyond the report itself
|
|
513
|
-
*/
|
|
514
|
-
declare const carriesProof: typeof agreesWithItself;
|
|
515
477
|
/**
|
|
516
478
|
* The most an operator may add over the recipient's own amount, in millisatoshi.
|
|
517
479
|
* The proportion is what routing and the liquidity behind it costs, and the base
|
|
@@ -626,12 +588,6 @@ declare class Serve {
|
|
|
626
588
|
* the gateway polls you and never the wallet
|
|
627
589
|
*/
|
|
628
590
|
lightningVerify(config: LightningVerifyConfig): Handler;
|
|
629
|
-
/**
|
|
630
|
-
* What `lightningVerify` was called before 2.2.0
|
|
631
|
-
*
|
|
632
|
-
* @deprecated Use `lightningVerify`, beside `bankVerify` and `nwcVerify`
|
|
633
|
-
*/
|
|
634
|
-
verify(config: LightningVerifyConfig): Handler;
|
|
635
591
|
/** The verify endpoint a bank rail is polled at, answering off your own statement */
|
|
636
592
|
bankVerify(config: BankVerifyConfig): Handler;
|
|
637
593
|
/**
|
|
@@ -952,7 +908,7 @@ interface BankTransferParams {
|
|
|
952
908
|
/** The account the money goes to, as an IBAN */
|
|
953
909
|
iban: string;
|
|
954
910
|
/**
|
|
955
|
-
* Where `
|
|
911
|
+
* Where `serve.bankVerify` is mounted, a public https URL with no query of
|
|
956
912
|
* its own. Not needed when `answerBy` is "agent", because then nothing is polled
|
|
957
913
|
*/
|
|
958
914
|
verifyUrl?: string;
|
|
@@ -1061,4 +1017,4 @@ interface BankAgentConfig {
|
|
|
1061
1017
|
*/
|
|
1062
1018
|
declare function bankAgent(config: BankAgentConfig): () => void;
|
|
1063
1019
|
|
|
1064
|
-
export {
|
|
1020
|
+
export { relayedVerifyUrl as $, type AttendOptions as A, type BankAgentConfig as B, type Credit as C, type VerifyThrough as D, type WatchTicketConfig as E, type FollowOptions as F, type WebhookCredential as G, type Handler as H, type WebhookHandlers as I, type WebhookOptions as J, type WrapAllowance as K, type Leg as L, type Minted as M, type NwcConnection as N, type Order as O, type PaymentRequest as P, agreesWithItself as Q, type Rail as R, type Statement as S, ThunderBridge as T, answerVerifyChallenge as U, type VerifyPath as V, type WaitOptions as W, invoiceFrom as X, proveOrigin as Y, proveSettlement as Z, proveWrapped as _, type BankOrder as a, wrapFeeCeiling as a0, type NwcInvoice as a1, askWallet as a2, nwcConnection as a3, nwcHoldInvoice as a4, nwcInvoice as a5, nwcPay as a6, nwcSettlement as a7, nwcVerifyUrl as a8, type BankTransfer as b, type BankTransferParams as c, type BankVerifyConfig as d, bankAgent as e, type ThunderBridgeOptions as f, type BankRailConfig as g, type CreateOptions as h, type LightningRailConfig as i, type LightningRailSettings as j, type LightningVerifyConfig as k, type NwcRailConfig as l, type NwcVerifyConfig as m, type PaymentRequestInit as n, type PaymentRequestOptions as o, type Provable as p, type RailConfig as q, Rails as r, type Range as s, type Relayed as t, type SelfConsistent as u, type Send as v, Serve as w, type TicketOptions as x, type TriggerConfig as y, type TriggerSettings as z };
|