@getalby/lightning-tools
Version:
Collection of helpful building blocks and tools to develop Bitcoin Lightning web apps
33 lines (29 loc) • 949 B
TypeScript
interface Wallet {
payInvoice(args: {
invoice: string;
}): Promise<{
preimage: string;
}>;
}
interface X402Requirements {
scheme: string;
network: string;
extra: {
invoice: string;
paymentMethod?: string;
[key: string]: unknown;
};
[key: string]: unknown;
}
/**
* Probe a PAYMENT-REQUIRED header for a lightning-payable offer without
* throwing. Returns the matching requirements, or null if the header has no
* lightning entry (e.g. USDC-only endpoints) or is malformed. Used by the
* top-level fetch402 dispatcher to decide whether to attempt payment or hand
* the 402 back to the caller.
*/
declare const findX402LightningRequirements: (x402Header: string) => X402Requirements | null;
declare const fetchWithX402: (url: string, fetchArgs: RequestInit, options: {
wallet: Wallet;
}) => Promise<Response>;
export { fetchWithX402, findX402LightningRequirements };