Skip to content
Integra Protocol
API

@integraledger/lcp/lightning

The exports of @integraledger/lcp/lightning.

Interfaces

Bolt11

Properties

PropertyTypeDescription
amountMsatbigint | null-
currency"bc" | "tb" | "tbs" | "bcrt"-
descriptionstring | null-
descriptionHashUint8Array<ArrayBufferLike> | null-
expirynumber-
metadataUint8Array<ArrayBufferLike> | null-
paymentHashUint8Array-
tagsreadonly number[]Every tagged field's type, in invoice order.
timestampnumber-

LnMppChoice

Properties

PropertyTypeDescription
challengeMppChallenge & object-
returnInvoice?stringsession only: the payer's return invoice, a BOLT11 invoice with no amount, which the open action registers.

LnMppUnsigned

Properties

PropertyType
requestobject
request.invoicestring
request.kind"bolt11-pay"

Methods

complete()

complete(preimage): Refusal | MppCredential

Parameters
ParameterType
preimagestring
Returns

Refusal | MppCredential


LnRef

The read keys recorded at claim: the invoice's payment hash as lowercase hex, and when the payment can land.

Properties

PropertyType
networkstring
paymentHashstring
settleBynumber

LnUnsigned

Properties

PropertyTypeDescription
requestobjectThe payer's node pays exactly this invoice.
request.invoicestring-
request.kind"bolt11-pay"-

Methods

complete()

complete(preimage): Refusal | LnPaymentPayload

Parameters
ParameterType
preimagestring
Returns

Refusal | LnPaymentPayload

Type Aliases

LnMppPairing

LnMppPairing = typeof LN_CHARGE | typeof LN_SESSION


LnNetwork

LnNetwork = "lnbtc:000000000019d6689c085ae165831e93" | "lnbtc:000000000933ea01ad0ee984209779ba"

CAIP-2 for Lightning: lnbtc: and the first 32 hex digits of the Bitcoin network's genesis block hash.


LnPaymentPayload

LnPaymentPayload = object

Properties

PropertyType
acceptedPaymentRequirements
extensions?PaymentRequired["extensions"]
payloadobject
payload.preimagestring
resource?PaymentRequired["resource"]
x402Version2

Variables

chargeLightning

const chargeLightning: Readonly<{ advertise: (doc, h, link, offer, agreementUrl?) => Refusal | MppChallenge[]; advertiseBeforeCarrier: (doc, h, link, offer, agreementUrl?) => Refusal | MppChallenge[]; bound: (presented) => Promise<`0x${string}` | Refusal>; build: (choice, h) => Promise<Refusal | LnMppUnsigned>; carrier: string; claims: boolean; id: "mpp/charge/lightning"; pattern: LcpPattern; read: (doc) => Refusal | { agreement?: string; h: `0x${string}`; link: string; offer: { challenges: MppChallenge[]; }; }; reference: (presented) => Promise<Refusal | LnRef>; tie: (options) => ["mpp", { challenges: MppChallenge[]; }]; unplaced: (c) => MppChallenge; }>


exactLnbtc

const exactLnbtc: Readonly<{ advertise: (doc, h, link, offer, agreementUrl?) => Refusal | PaymentRequired; advertiseBeforeCarrier: (doc, h, link, offer, agreementUrl?) => Refusal | PaymentRequired; bound: (presented) => Promise<`0x${string}` | Refusal>; build: (c, h) => Promise<Refusal | LnUnsigned>; carrier: "extra.invoice#m"; claims: boolean; id: "x402/exact/lnbtc"; pattern: LcpPattern; read: (doc) => Refusal | X402Read; reference: (presented) => Promise<Refusal | LnRef>; tie: (accepts, request) => ["x402", { accepts: readonly PaymentRequirements[]; request: RequestCommitment; }]; unplaced: (option) => PaymentRequirements; }>


exactLnbtcNamed

const exactLnbtcNamed: Readonly<{ advertise: (doc, h, link, offer, agreementUrl?) => Refusal | PaymentRequired; bound: (presented) => Promise<`0x${string}` | Refusal>; build: (c, h) => Promise<Refusal | LnUnsigned>; carrier: null; claims: boolean; id: "x402/exact/lnbtc/invoice-named"; pattern: LcpPattern; read: (doc) => Refusal | X402Read; reference: (presented) => Promise<Refusal | LnRef>; tie: (accepts, request) => ["x402", { accepts: readonly PaymentRequirements[]; request: RequestCommitment; }]; unplaced: (option) => PaymentRequirements; }>


sessionLightning

const sessionLightning: Readonly<{ advertise: (doc, h, link, offer, agreementUrl?) => Refusal | MppChallenge[]; advertiseBeforeCarrier: (doc, h, link, offer, agreementUrl?) => Refusal | MppChallenge[]; bound: (presented) => Promise<`0x${string}` | Refusal>; build: (choice, h) => Promise<Refusal | LnMppUnsigned>; carrier: string; channel: Readonly<{ boundWithin: (_presented) => Promise<`0x${string}` | Refusal>; kind: (presented) => "open" | "close" | Refusal | "within"; ref: (presented) => Promise<Refusal | { channel: string; network: string; }>; until: (_presented) => number | undefined; }>; claims: boolean; id: "mpp/session/lightning"; pattern: LcpPattern; read: (doc) => Refusal | { agreement?: string; h: `0x${string}`; link: string; offer: { challenges: MppChallenge[]; }; }; reference: (presented) => Promise<Refusal | LnRef>; tie: (options) => ["mpp", { challenges: MppChallenge[]; }]; unplaced: (c) => MppChallenge; }>

Functions

atrNamesInvoice()

atrNamesInvoice(atr, invoice): boolean

True when the ATR's bytes are one JSON object whose x402 slot's accepts holds an option whose extra.invoice is exactly invoice. Only that slot is read.

Parameters

ParameterType
atrUint8Array
invoicestring

Returns

boolean


decodeBolt11()

decodeBolt11(invoice): Promise<Refusal | Bolt11>

Decodes a BOLT11 invoice without its length limit, up to 8 KiB. The signature is not verified.

Parameters

ParameterType
invoicestring

Returns

Promise<Refusal | Bolt11>


invoiceH()

invoiceH(b, field): `0x${string}` | Refusal

The one 32-byte h or m field of an invoice, as the hash it carries.

Parameters

ParameterType
bBolt11
field"h" | "m"

Returns

`0x${string}` | Refusal


lnbtcPairingOf()

lnbtcPairingOf(option): "x402/exact/lnbtc" | "x402/exact/lnbtc/invoice-named" | undefined

Which of the two x402 Lightning pairings an option belongs to: by whether its invoice has an m field. An option whose extra has no invoice is the offer the seller sends before its node writes the invoice, so it is x402/exact/lnbtc; an invoice-named option carries its invoice at issue.

Parameters

ParameterType
optionunknown

Returns

"x402/exact/lnbtc" | "x402/exact/lnbtc/invoice-named" | undefined

Last updated on

On this page