thunder-bridge 0.8.0 → 0.8.2
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 +219 -781
- package/dist/index.cjs +759 -49
- package/dist/index.d.cts +424 -8
- package/dist/index.d.ts +424 -8
- package/dist/index.js +740 -49
- package/openapi.yaml +307 -0
- package/package.json +5 -4
package/dist/index.d.ts
CHANGED
|
@@ -118,9 +118,12 @@ interface CreateOptions {
|
|
|
118
118
|
idempotencyKey?: string;
|
|
119
119
|
/**
|
|
120
120
|
* Groups this payment with every other one carrying the same secret, so
|
|
121
|
-
* `followTrigger` can watch the place rather than the payment.
|
|
122
|
-
*
|
|
123
|
-
*
|
|
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
|
|
124
127
|
*/
|
|
125
128
|
trigger?: string;
|
|
126
129
|
}
|
|
@@ -151,7 +154,24 @@ declare class ThunderBridge {
|
|
|
151
154
|
private readonly baseUrl;
|
|
152
155
|
private readonly verify;
|
|
153
156
|
private readonly token;
|
|
157
|
+
private strangers;
|
|
154
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>;
|
|
155
175
|
/**
|
|
156
176
|
* Ask the gateway for an invoice payable to the first address on your list
|
|
157
177
|
* that can issue a provable one, throws `NoWalletAvailableError` when none can
|
|
@@ -168,6 +188,12 @@ declare class ThunderBridge {
|
|
|
168
188
|
createQuote(params: CreateQuoteParams): Promise<Quote>;
|
|
169
189
|
/** Read a payment back, null when the gateway has never heard of it */
|
|
170
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>;
|
|
171
197
|
/**
|
|
172
198
|
* List what this gateway is watching, newest first. Only a gateway started
|
|
173
199
|
* with `GATEWAY_TOKEN` serves this, because on a shared one it would hand
|
|
@@ -188,6 +214,36 @@ declare class ThunderBridge {
|
|
|
188
214
|
* ends by itself
|
|
189
215
|
*/
|
|
190
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>;
|
|
191
247
|
/**
|
|
192
248
|
* Hand over an invoice you obtained yourself so the gateway watches it without
|
|
193
249
|
* being told the address or the amount. It can then only refuse everyone
|
|
@@ -282,6 +338,346 @@ interface Minted {
|
|
|
282
338
|
*/
|
|
283
339
|
declare function lnurlPayEndpoint(config: TriggerConfig): (request: Request) => Promise<Response>;
|
|
284
340
|
|
|
341
|
+
/** One incoming payment as the bank booked it, in the smallest unit of its currency */
|
|
342
|
+
interface Credit {
|
|
343
|
+
amountMinor: number;
|
|
344
|
+
currency: string;
|
|
345
|
+
/** Whatever the payer wrote, wherever this bank puts it. Matching is a substring, so noise around it is fine */
|
|
346
|
+
reference: string;
|
|
347
|
+
/**
|
|
348
|
+
* Unix seconds. A bank that books a day rather than an instant, as Fio does,
|
|
349
|
+
* gives the day's midnight in its own zone, so rendering this in UTC can show
|
|
350
|
+
* the day before. Nothing here matches on it, it is yours to read
|
|
351
|
+
*/
|
|
352
|
+
bookedAt: number;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Recent credits on one account, oldest or newest first, it makes no difference.
|
|
356
|
+
* This is the whole plugin seam: a bank is a function of this shape, and
|
|
357
|
+
* `fioStatement` is one implementation of it
|
|
358
|
+
*/
|
|
359
|
+
type Statement = (sinceUnix: number) => Promise<Credit[]>;
|
|
360
|
+
interface BankTransferParams {
|
|
361
|
+
/**
|
|
362
|
+
* The gateway that will watch this transfer. It has to be one of your own,
|
|
363
|
+
* meaning one you gave a token, unless `allowPublicGateway` says otherwise
|
|
364
|
+
*/
|
|
365
|
+
gateway: ThunderBridge;
|
|
366
|
+
/** Long lived and server side. The preimage is derived from it, so losing it loses every proof */
|
|
367
|
+
secret: string;
|
|
368
|
+
/** What the payer must leave on the transfer, an order id or a nonce. It is matched, not stored */
|
|
369
|
+
reference: string;
|
|
370
|
+
/** The price in the smallest unit, so 48055 is 480.55 CZK */
|
|
371
|
+
amountMinor: number;
|
|
372
|
+
/** The account the money goes to, as an IBAN */
|
|
373
|
+
iban: string;
|
|
374
|
+
/** Where `bankVerifyEndpoint` is mounted, a public https URL with no query of its own */
|
|
375
|
+
verifyUrl: string;
|
|
376
|
+
/** When the offer dies, in unix seconds. Money in a bank moves on banking days, so give it days */
|
|
377
|
+
expiresAt: number;
|
|
378
|
+
/** Defaults to CZK */
|
|
379
|
+
currency?: string;
|
|
380
|
+
/** Up to ten digits, for accounting systems that still want one */
|
|
381
|
+
variableSymbol?: string;
|
|
382
|
+
/**
|
|
383
|
+
* Groups this transfer with everything else paid to the same secret, so one
|
|
384
|
+
* `followTrigger` socket hears about it. Give the Lightning leg of the same
|
|
385
|
+
* order the same secret and both rails arrive on one stream
|
|
386
|
+
*/
|
|
387
|
+
trigger?: string;
|
|
388
|
+
/**
|
|
389
|
+
* Handed back untouched on that stream, so a watcher learns which order settled
|
|
390
|
+
* without asking anyone. `seal` it and the gateway cannot read it either
|
|
391
|
+
*/
|
|
392
|
+
sealed?: string;
|
|
393
|
+
/**
|
|
394
|
+
* Register on a gateway you do not own anyway. The verify URL names the amount
|
|
395
|
+
* and the reference, so its operator ends up reading your order book, and the
|
|
396
|
+
* URL itself answers whether that order was paid. Say true only when the order
|
|
397
|
+
* book is not worth hiding
|
|
398
|
+
*/
|
|
399
|
+
allowPublicGateway?: boolean;
|
|
400
|
+
}
|
|
401
|
+
interface BankTransfer {
|
|
402
|
+
/** The watched payment's id at the gateway, which is how you read this order back */
|
|
403
|
+
id: string;
|
|
404
|
+
/** What the gateway was given, and what the preimage has to hash to */
|
|
405
|
+
paymentHash: string;
|
|
406
|
+
/** The same URL you mounted, carrying what to look for and a signature over it */
|
|
407
|
+
verifyUrl: string;
|
|
408
|
+
/** The payer scans this, it is a Short Payment Descriptor, the Czech QR platba format */
|
|
409
|
+
spd: string;
|
|
410
|
+
}
|
|
411
|
+
interface BankVerifyConfig {
|
|
412
|
+
/** The same secret `bankTransfer` was given */
|
|
413
|
+
secret: string;
|
|
414
|
+
/** The account to read */
|
|
415
|
+
statement: Statement;
|
|
416
|
+
/** How far back a credit still counts, seven days by default */
|
|
417
|
+
lookBackSecs?: number;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Ask for a bank transfer and put it under the gateway's watch, so it settles
|
|
421
|
+
* the way a Lightning payment does.
|
|
422
|
+
*
|
|
423
|
+
* A BOLT11 payment proves settlement with a preimage whose sha256 the payer's
|
|
424
|
+
* invoice pins. A bank transfer has no such thing, so this mints one: the
|
|
425
|
+
* preimage is an HMAC of what is being asked for, and its hash is what the
|
|
426
|
+
* gateway is given. The money still moves straight to your account, and the
|
|
427
|
+
* gateway still learns only a hash and a URL to poll.
|
|
428
|
+
*
|
|
429
|
+
* What the preimage proves is therefore what LUD-21 proves and no more: that
|
|
430
|
+
* the server holding the secret saw the money arrive. It is the recipient's
|
|
431
|
+
* own word, made unforgeable by anyone else.
|
|
432
|
+
*
|
|
433
|
+
* The gateway has to be one of your own. Unlike a blind Lightning watch, which
|
|
434
|
+
* hands over a hash and an opaque wallet URL, this hands over a URL naming the
|
|
435
|
+
* amount and the reference, so whoever runs the gateway can read your order book
|
|
436
|
+
* from the watches alone.
|
|
437
|
+
*/
|
|
438
|
+
declare function bankTransfer(params: BankTransferParams): Promise<BankTransfer>;
|
|
439
|
+
/**
|
|
440
|
+
* The verify endpoint the gateway polls, as a Fetch handler, so it runs wherever
|
|
441
|
+
* `lnurlPayEndpoint` does.
|
|
442
|
+
*
|
|
443
|
+
* It answers the LUD-21 shape: `settled` false until a matching credit is on the
|
|
444
|
+
* statement, then `settled` true with the preimage. Nothing is stored, because
|
|
445
|
+
* the preimage is derived again from the secret every time it is asked for.
|
|
446
|
+
*
|
|
447
|
+
* The query has to carry the signature `bankTransfer` put there. Without that
|
|
448
|
+
* check this would answer "did anyone send you 480.55 with this note" to whoever
|
|
449
|
+
* asked, which is your bank statement handed out one question at a time.
|
|
450
|
+
*/
|
|
451
|
+
declare function bankVerifyEndpoint(config: BankVerifyConfig): (request: Request) => Promise<Response>;
|
|
452
|
+
|
|
453
|
+
interface FioConfig {
|
|
454
|
+
/**
|
|
455
|
+
* A token with "Sledování účtu" rights, which is read only and cannot move
|
|
456
|
+
* money. One token is one account, which is why this takes no account number.
|
|
457
|
+
*
|
|
458
|
+
* Give it several and they are used in turn. Fio's window is per token rather
|
|
459
|
+
* than per account, so five tokens on one account is a read every six seconds,
|
|
460
|
+
* and generating another token for the same account is what Fio's own
|
|
461
|
+
* documentation suggests when one is not enough
|
|
462
|
+
*/
|
|
463
|
+
token: string | string[];
|
|
464
|
+
/**
|
|
465
|
+
* Fio's window for one token, 30 seconds. No token is ever asked twice inside
|
|
466
|
+
* it, and the gap between reads is this divided by however many tokens were
|
|
467
|
+
* given, so the answers stay evenly spaced rather than arriving in bursts.
|
|
468
|
+
* Inside that gap the last answer is handed back. Only helps a process that
|
|
469
|
+
* stays up
|
|
470
|
+
*/
|
|
471
|
+
minIntervalSecs?: number;
|
|
472
|
+
/** Override to point at a mock */
|
|
473
|
+
baseUrl?: string;
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Read one Fio account as a `Statement`, so a bank transfer proves itself the
|
|
477
|
+
* way a Lightning payment does.
|
|
478
|
+
*
|
|
479
|
+
* The token is the read only kind, generated in internetbanking under Nastavení
|
|
480
|
+
* and API, and it is the whole configuration: a token belongs to one account, so
|
|
481
|
+
* there is no account number to get wrong. It cannot pay anyone, and the worst a
|
|
482
|
+
* leaked one costs you is that someone else can read the statement.
|
|
483
|
+
*
|
|
484
|
+
* Every field on a Fio transaction is optional and arrives as `null` when it is
|
|
485
|
+
* absent, the amount carries its direction in its sign rather than in a flag,
|
|
486
|
+
* and the date is a day and a UTC offset, `2026-07-15+0200`. This reads all
|
|
487
|
+
* three the way the bank answers them and treats a missing field as absent
|
|
488
|
+
* rather than guessing.
|
|
489
|
+
*/
|
|
490
|
+
declare function fioStatement(config: FioConfig): Statement;
|
|
491
|
+
|
|
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
|
+
/**
|
|
600
|
+
* How many minor units of `currency` one bitcoin costs at one venue, so 134883815
|
|
601
|
+
* is 1,348,838.15 CZK. Throws when that venue does not quote that currency, which
|
|
602
|
+
* is a normal answer rather than a fault: Kraken and Bitstamp have no CZK pair
|
|
603
|
+
*
|
|
604
|
+
* This is the plugin seam for prices. Another venue is another function of this
|
|
605
|
+
* shape
|
|
606
|
+
*/
|
|
607
|
+
type Ticker = (currency: string) => Promise<number>;
|
|
608
|
+
interface MedianOptions {
|
|
609
|
+
/**
|
|
610
|
+
* How many venues have to answer before a price is usable. Two is the floor
|
|
611
|
+
* worth having, because one venue is a number nobody checked
|
|
612
|
+
*/
|
|
613
|
+
minVenues?: number;
|
|
614
|
+
/**
|
|
615
|
+
* Refuse the lot when the cheapest and dearest answers are further apart than
|
|
616
|
+
* this many basis points. Venues normally sit inside 50, so a wider spread means
|
|
617
|
+
* one of them is broken or stale rather than that the market moved
|
|
618
|
+
*/
|
|
619
|
+
maxSpreadBps?: number;
|
|
620
|
+
/** Hold the last answer this long per currency, so an order page is not four requests */
|
|
621
|
+
holdForSecs?: number;
|
|
622
|
+
}
|
|
623
|
+
/** Coinbase, CASP authorised in Luxembourg. Quotes CZK, EUR and most fiat */
|
|
624
|
+
declare function coinbase(baseUrl?: string): Ticker;
|
|
625
|
+
/** Kraken, CASP authorised by the Central Bank of Ireland. Quotes EUR and USD, no CZK */
|
|
626
|
+
declare function kraken(baseUrl?: string): Ticker;
|
|
627
|
+
/**
|
|
628
|
+
* Bitstamp, CASP authorised by the CSSF in Luxembourg. Quotes EUR and USD, no CZK.
|
|
629
|
+
*
|
|
630
|
+
* An unknown pair is answered with a `200` and the whole ticker list, whose first
|
|
631
|
+
* entry is BTC/USD, so asking it for CZK and reading the number would quote a
|
|
632
|
+
* bitcoin at 64,000 crowns. Anything but a single object is therefore refused
|
|
633
|
+
*/
|
|
634
|
+
declare function bitstamp(baseUrl?: string): Ticker;
|
|
635
|
+
/** Coinmate, on the ESMA CASP register, Czech and the one with a real BTC/CZK book */
|
|
636
|
+
declare function coinmate(baseUrl?: string): Ticker;
|
|
637
|
+
/**
|
|
638
|
+
* Ask several venues and take the middle answer, refusing the lot when they
|
|
639
|
+
* disagree too much.
|
|
640
|
+
*
|
|
641
|
+
* The default is the four MiCA authorised venues below, and every one of them is
|
|
642
|
+
* replaceable: pass your own list, or one venue, or a function that reads a price
|
|
643
|
+
* you already have. A venue that does not quote the currency is skipped rather
|
|
644
|
+
* than fatal, which for CZK leaves Coinbase and Coinmate.
|
|
645
|
+
*
|
|
646
|
+
* The middle is taken rather than the mean so one stuck venue moves the answer by
|
|
647
|
+
* nothing instead of by half its error, and the spread check is what catches the
|
|
648
|
+
* stuck venue that stays inside the pack.
|
|
649
|
+
*/
|
|
650
|
+
declare function medianOf(tickers?: Ticker[], options?: MedianOptions): Ticker;
|
|
651
|
+
/**
|
|
652
|
+
* What to ask for over Lightning for a price named in fiat, in millisatoshi.
|
|
653
|
+
*
|
|
654
|
+
* `priceMinorPerBtc` is what a `Ticker` returns. The arithmetic is exact, in
|
|
655
|
+
* BigInt, because a million crown order times a hundred billion millisatoshi
|
|
656
|
+
* leaves what a double can count, and it rounds up, because the extra
|
|
657
|
+
* millisatoshi is worth nothing and belongs to the recipient rather than to a
|
|
658
|
+
* rounding rule.
|
|
659
|
+
*
|
|
660
|
+
* `spreadBps` is yours to set, in basis points, and defaults to none. A Lightning
|
|
661
|
+
* invoice lives an hour and a bank transfer takes days, so a shop pricing in fiat is
|
|
662
|
+
* carrying that volatility whether or not it charges for it
|
|
663
|
+
*/
|
|
664
|
+
declare function msatFor(amountMinor: number, priceMinorPerBtc: number, options?: {
|
|
665
|
+
spreadBps?: number;
|
|
666
|
+
}): number;
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* How many digits ISO 4217 gives the currency's minor unit, so 2 for a crown and a
|
|
670
|
+
* euro, 0 for a yen and 3 for a dinar.
|
|
671
|
+
*
|
|
672
|
+
* There is no sane default here, which is why an unlisted code throws rather than
|
|
673
|
+
* being treated as two. Assuming two turns 1000 yen into 10 and a dinar into a
|
|
674
|
+
* tenth of itself, and a payment library that guesses at this is a payment library
|
|
675
|
+
* that moves the wrong amount.
|
|
676
|
+
*/
|
|
677
|
+
declare function minorUnitsOf(currency: string): number;
|
|
678
|
+
/** The scale that minor unit implies, so 100 for a crown, 1 for a yen, 1000 for a dinar */
|
|
679
|
+
declare function minorScaleOf(currency: string): number;
|
|
680
|
+
|
|
285
681
|
/**
|
|
286
682
|
* Prove the invoice really is the one the recipient issued for what you asked,
|
|
287
683
|
* before the payer ever sees it, both fetches go straight to the recipient's own
|
|
@@ -338,6 +734,22 @@ declare function invoiceToDataUrl(destination: string, options?: QrOptions): str
|
|
|
338
734
|
declare function lnurlToSvg(endpoint: string, options?: QrOptions): string;
|
|
339
735
|
/** SVG data URL of the endpoint's QR, for an `<img>` `src` */
|
|
340
736
|
declare function lnurlToDataUrl(endpoint: string, options?: QrOptions): string;
|
|
737
|
+
/**
|
|
738
|
+
* Render the `spd` from `bankTransfer` as the QR a Czech banking app scans. The
|
|
739
|
+
* payload is a Short Payment Descriptor, so it carries the account, the amount
|
|
740
|
+
* and the reference the payer must leave on the transfer
|
|
741
|
+
*/
|
|
742
|
+
declare function spdToSvg(spd: string, options?: QrOptions): string;
|
|
743
|
+
/** SVG data URL of the bank transfer's QR, for an `<img>` `src` */
|
|
744
|
+
declare function spdToDataUrl(spd: string, options?: QrOptions): string;
|
|
745
|
+
/**
|
|
746
|
+
* Render any rail's `Leg.qr` as an SVG QR code. Each rail states its own payload,
|
|
747
|
+
* a BOLT11 invoice under the `LIGHTNING` scheme or a Short Payment Descriptor as
|
|
748
|
+
* it stands, so this draws a leg without being told which rail made it
|
|
749
|
+
*/
|
|
750
|
+
declare function qrToSvg(payload: string, options?: QrOptions): string;
|
|
751
|
+
/** SVG data URL of a leg's QR, for an `<img>` `src` */
|
|
752
|
+
declare function qrToDataUrl(payload: string, options?: QrOptions): string;
|
|
341
753
|
|
|
342
754
|
/**
|
|
343
755
|
* Bech32-encode a pay endpoint as the `LNURL1` string LUD-01 defines, uppercase
|
|
@@ -398,10 +810,14 @@ declare class ProblemError extends Error {
|
|
|
398
810
|
detail?: string;
|
|
399
811
|
});
|
|
400
812
|
}
|
|
401
|
-
|
|
402
|
-
declare
|
|
403
|
-
|
|
404
|
-
|
|
813
|
+
/** Whether a problem document carries this type */
|
|
814
|
+
declare function isProblemType(problem: {
|
|
815
|
+
type?: string;
|
|
816
|
+
}, type: string): boolean;
|
|
817
|
+
declare const NO_WALLET_AVAILABLE = "urn:problem-type:thunder-bridge:no-wallet-available";
|
|
818
|
+
declare const REQUEST_IN_FLIGHT = "urn:problem-type:thunder-bridge:request-in-flight";
|
|
819
|
+
declare const IDEMPOTENCY_KEY_REUSED = "urn:problem-type:thunder-bridge:idempotency-key-reused";
|
|
820
|
+
declare const PAYMENT_ALREADY_WATCHED = "urn:problem-type:thunder-bridge:payment-already-watched";
|
|
405
821
|
/**
|
|
406
822
|
* Why an `Idempotency-Key` was refused, `request-in-flight` is the benign one and
|
|
407
823
|
* `key-reused` means the same key was sent for a different request
|
|
@@ -432,4 +848,4 @@ declare class NoWalletAvailableError extends ProblemError {
|
|
|
432
848
|
}, wallets: WalletFailure[]);
|
|
433
849
|
}
|
|
434
850
|
|
|
435
|
-
export { type CreateOptions, type CreatePaymentParams, type CreateQuoteParams, type FollowOptions, type GatewayCheatCode, GatewayCheatError, IDEMPOTENCY_KEY_REUSED, type IdempotencyConflict, IdempotencyConflictError, type Invoice, type Minted, NO_WALLET_AVAILABLE, NoWalletAvailableError, PAYMENT_ALREADY_WATCHED, type Payment, type PaymentStatus, ProblemError, type QrOptions, type Quote, REQUEST_IN_FLIGHT, ThunderBridge, type ThunderBridgeOptions, type TriggerConfig, type TriggerEvent, UnverifiedRecipientError, type WaitOptions, type WalletFailure, type WalletReason, type WatchPaymentParams, type WebhookOptions, decodeInvoice, invoiceToDataUrl, invoiceToSvg, isProvablyPaid, lnurlPayEndpoint, lnurlToDataUrl, lnurlToSvg, parseWebhook, parseWebhookRequest, preimageMatchesHash, proveOrigin, proveSettlement, seal, toLnurl, unseal, verifyWebhookSignature };
|
|
851
|
+
export { type BankRailConfig, type BankTransfer, type BankTransferParams, type BankVerifyConfig, type BlindLightningRailConfig, type CreateOptions, type CreatePaymentParams, type CreateQuoteParams, type Credit, type FioConfig, type FollowOptions, type GatewayCheatCode, GatewayCheatError, IDEMPOTENCY_KEY_REUSED, type IdempotencyConflict, IdempotencyConflictError, type Invoice, type Leg, type LightningRailConfig, type MedianOptions, type Minted, NO_WALLET_AVAILABLE, NoWalletAvailableError, type Order, PAYMENT_ALREADY_WATCHED, type Payment, type PaymentStatus, ProblemError, type QrOptions, type Quote, REQUEST_IN_FLIGHT, type Rail, type Statement, ThunderBridge, type ThunderBridgeOptions, type Ticker, type TriggerConfig, type TriggerEvent, UnverifiedRecipientError, type WaitOptions, type WalletFailure, type WalletReason, type WatchPaymentParams, type WebhookOptions, bankRail, bankTransfer, bankVerifyEndpoint, bitstamp, blindLightningRail, coinbase, coinmate, decodeInvoice, fioStatement, invoiceToDataUrl, invoiceToSvg, isProblemType, isProvablyPaid, kraken, lightningRail, lnurlPayEndpoint, lnurlToDataUrl, lnurlToSvg, medianOf, minorScaleOf, minorUnitsOf, msatFor, parseWebhook, parseWebhookRequest, preimageMatchesHash, proveOrigin, proveSettlement, qrToDataUrl, qrToSvg, seal, spdToDataUrl, spdToSvg, toLnurl, unseal, verifyWebhookSignature };
|