thunder-bridge 0.8.1 → 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 +36 -12
- package/dist/index.cjs +312 -90
- package/dist/index.d.cts +142 -14
- package/dist/index.d.ts +142 -14
- package/dist/index.js +307 -90
- package/package.json +3 -3
package/dist/index.d.cts
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,6 +154,7 @@ 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);
|
|
155
159
|
/**
|
|
156
160
|
* Whether a token was given, which is what makes an instance yours: a gateway
|
|
@@ -158,6 +162,16 @@ declare class ThunderBridge {
|
|
|
158
162
|
* stays between you and it
|
|
159
163
|
*/
|
|
160
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>;
|
|
161
175
|
/**
|
|
162
176
|
* Ask the gateway for an invoice payable to the first address on your list
|
|
163
177
|
* that can issue a provable one, throws `NoWalletAvailableError` when none can
|
|
@@ -330,6 +344,11 @@ interface Credit {
|
|
|
330
344
|
currency: string;
|
|
331
345
|
/** Whatever the payer wrote, wherever this bank puts it. Matching is a substring, so noise around it is fine */
|
|
332
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
|
+
*/
|
|
333
352
|
bookedAt: number;
|
|
334
353
|
}
|
|
335
354
|
/**
|
|
@@ -464,11 +483,119 @@ interface FioConfig {
|
|
|
464
483
|
*
|
|
465
484
|
* Every field on a Fio transaction is optional and arrives as `null` when it is
|
|
466
485
|
* absent, the amount carries its direction in its sign rather than in a flag,
|
|
467
|
-
* and the date is
|
|
468
|
-
*
|
|
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.
|
|
469
489
|
*/
|
|
470
490
|
declare function fioStatement(config: FioConfig): Statement;
|
|
471
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
|
+
|
|
472
599
|
/**
|
|
473
600
|
* How many minor units of `currency` one bitcoin costs at one venue, so 134883815
|
|
474
601
|
* is 1,348,838.15 CZK. Throws when that venue does not quote that currency, which
|
|
@@ -615,6 +742,14 @@ declare function lnurlToDataUrl(endpoint: string, options?: QrOptions): string;
|
|
|
615
742
|
declare function spdToSvg(spd: string, options?: QrOptions): string;
|
|
616
743
|
/** SVG data URL of the bank transfer's QR, for an `<img>` `src` */
|
|
617
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;
|
|
618
753
|
|
|
619
754
|
/**
|
|
620
755
|
* Bech32-encode a pay endpoint as the `LNURL1` string LUD-01 defines, uppercase
|
|
@@ -675,14 +810,7 @@ declare class ProblemError extends Error {
|
|
|
675
810
|
detail?: string;
|
|
676
811
|
});
|
|
677
812
|
}
|
|
678
|
-
/**
|
|
679
|
-
* Whether a problem document carries this type, accepting the namespace this
|
|
680
|
-
* project used before `direct` left its name.
|
|
681
|
-
*
|
|
682
|
-
* A problem type is an identifier clients branch on, so renaming one is a breaking
|
|
683
|
-
* change. The gateway emits only the new spelling, and this reads both, so a client
|
|
684
|
-
* that has been updated still types the errors of an instance that has not
|
|
685
|
-
*/
|
|
813
|
+
/** Whether a problem document carries this type */
|
|
686
814
|
declare function isProblemType(problem: {
|
|
687
815
|
type?: string;
|
|
688
816
|
}, type: string): boolean;
|
|
@@ -720,4 +848,4 @@ declare class NoWalletAvailableError extends ProblemError {
|
|
|
720
848
|
}, wallets: WalletFailure[]);
|
|
721
849
|
}
|
|
722
850
|
|
|
723
|
-
export { type BankTransfer, type BankTransferParams, type BankVerifyConfig, type CreateOptions, type CreatePaymentParams, type CreateQuoteParams, type Credit, type FioConfig, type FollowOptions, type GatewayCheatCode, GatewayCheatError, IDEMPOTENCY_KEY_REUSED, type IdempotencyConflict, IdempotencyConflictError, type Invoice, type MedianOptions, type Minted, NO_WALLET_AVAILABLE, NoWalletAvailableError, PAYMENT_ALREADY_WATCHED, type Payment, type PaymentStatus, ProblemError, type QrOptions, type Quote, REQUEST_IN_FLIGHT, type Statement, ThunderBridge, type ThunderBridgeOptions, type Ticker, type TriggerConfig, type TriggerEvent, UnverifiedRecipientError, type WaitOptions, type WalletFailure, type WalletReason, type WatchPaymentParams, type WebhookOptions, bankTransfer, bankVerifyEndpoint, bitstamp, coinbase, coinmate, decodeInvoice, fioStatement, invoiceToDataUrl, invoiceToSvg, isProblemType, isProvablyPaid, kraken, lnurlPayEndpoint, lnurlToDataUrl, lnurlToSvg, medianOf, minorScaleOf, minorUnitsOf, msatFor, parseWebhook, parseWebhookRequest, preimageMatchesHash, proveOrigin, proveSettlement, seal, spdToDataUrl, spdToSvg, 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 };
|
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,6 +154,7 @@ 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);
|
|
155
159
|
/**
|
|
156
160
|
* Whether a token was given, which is what makes an instance yours: a gateway
|
|
@@ -158,6 +162,16 @@ declare class ThunderBridge {
|
|
|
158
162
|
* stays between you and it
|
|
159
163
|
*/
|
|
160
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>;
|
|
161
175
|
/**
|
|
162
176
|
* Ask the gateway for an invoice payable to the first address on your list
|
|
163
177
|
* that can issue a provable one, throws `NoWalletAvailableError` when none can
|
|
@@ -330,6 +344,11 @@ interface Credit {
|
|
|
330
344
|
currency: string;
|
|
331
345
|
/** Whatever the payer wrote, wherever this bank puts it. Matching is a substring, so noise around it is fine */
|
|
332
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
|
+
*/
|
|
333
352
|
bookedAt: number;
|
|
334
353
|
}
|
|
335
354
|
/**
|
|
@@ -464,11 +483,119 @@ interface FioConfig {
|
|
|
464
483
|
*
|
|
465
484
|
* Every field on a Fio transaction is optional and arrives as `null` when it is
|
|
466
485
|
* absent, the amount carries its direction in its sign rather than in a flag,
|
|
467
|
-
* and the date is
|
|
468
|
-
*
|
|
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.
|
|
469
489
|
*/
|
|
470
490
|
declare function fioStatement(config: FioConfig): Statement;
|
|
471
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
|
+
|
|
472
599
|
/**
|
|
473
600
|
* How many minor units of `currency` one bitcoin costs at one venue, so 134883815
|
|
474
601
|
* is 1,348,838.15 CZK. Throws when that venue does not quote that currency, which
|
|
@@ -615,6 +742,14 @@ declare function lnurlToDataUrl(endpoint: string, options?: QrOptions): string;
|
|
|
615
742
|
declare function spdToSvg(spd: string, options?: QrOptions): string;
|
|
616
743
|
/** SVG data URL of the bank transfer's QR, for an `<img>` `src` */
|
|
617
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;
|
|
618
753
|
|
|
619
754
|
/**
|
|
620
755
|
* Bech32-encode a pay endpoint as the `LNURL1` string LUD-01 defines, uppercase
|
|
@@ -675,14 +810,7 @@ declare class ProblemError extends Error {
|
|
|
675
810
|
detail?: string;
|
|
676
811
|
});
|
|
677
812
|
}
|
|
678
|
-
/**
|
|
679
|
-
* Whether a problem document carries this type, accepting the namespace this
|
|
680
|
-
* project used before `direct` left its name.
|
|
681
|
-
*
|
|
682
|
-
* A problem type is an identifier clients branch on, so renaming one is a breaking
|
|
683
|
-
* change. The gateway emits only the new spelling, and this reads both, so a client
|
|
684
|
-
* that has been updated still types the errors of an instance that has not
|
|
685
|
-
*/
|
|
813
|
+
/** Whether a problem document carries this type */
|
|
686
814
|
declare function isProblemType(problem: {
|
|
687
815
|
type?: string;
|
|
688
816
|
}, type: string): boolean;
|
|
@@ -720,4 +848,4 @@ declare class NoWalletAvailableError extends ProblemError {
|
|
|
720
848
|
}, wallets: WalletFailure[]);
|
|
721
849
|
}
|
|
722
850
|
|
|
723
|
-
export { type BankTransfer, type BankTransferParams, type BankVerifyConfig, type CreateOptions, type CreatePaymentParams, type CreateQuoteParams, type Credit, type FioConfig, type FollowOptions, type GatewayCheatCode, GatewayCheatError, IDEMPOTENCY_KEY_REUSED, type IdempotencyConflict, IdempotencyConflictError, type Invoice, type MedianOptions, type Minted, NO_WALLET_AVAILABLE, NoWalletAvailableError, PAYMENT_ALREADY_WATCHED, type Payment, type PaymentStatus, ProblemError, type QrOptions, type Quote, REQUEST_IN_FLIGHT, type Statement, ThunderBridge, type ThunderBridgeOptions, type Ticker, type TriggerConfig, type TriggerEvent, UnverifiedRecipientError, type WaitOptions, type WalletFailure, type WalletReason, type WatchPaymentParams, type WebhookOptions, bankTransfer, bankVerifyEndpoint, bitstamp, coinbase, coinmate, decodeInvoice, fioStatement, invoiceToDataUrl, invoiceToSvg, isProblemType, isProvablyPaid, kraken, lnurlPayEndpoint, lnurlToDataUrl, lnurlToSvg, medianOf, minorScaleOf, minorUnitsOf, msatFor, parseWebhook, parseWebhookRequest, preimageMatchesHash, proveOrigin, proveSettlement, seal, spdToDataUrl, spdToSvg, 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 };
|