@getalby/lightning-tools
Version:
Collection of helpful building blocks and tools to develop Bitcoin Lightning web apps
27 lines (24 loc) • 845 B
TypeScript
interface Wallet {
payInvoice(args: {
invoice: string;
}): Promise<{
preimage: string;
}>;
}
/**
* Fetch a resource protected by the draft-lightning-charge-00 payment
* authentication protocol.
*
* On a `402 Payment Required` response that carries a
* `WWW-Authenticate: Payment method="lightning" intent="charge" …` header
* the function pays the embedded BOLT11 invoice and retries with the
* resulting preimage as the credential.
*
* Note: lightning-charge uses consume-once challenge semantics – each
* challenge embeds a fresh invoice, so paid credentials cannot be reused.
* The `store` option is accepted for API consistency but is not used.
*/
declare const fetchWithMpp: (url: string, fetchArgs: RequestInit, options: {
wallet: Wallet;
}) => Promise<Response>;
export { fetchWithMpp };