Workbench memory
Signing keyempty
Macaroonempty
Challengeempty
Credentialempty
GenerateMint a macaroon from a root key; add an invoice for a challenge, a preimage for a credential
idle
Use from Workbench
typescriptrecipe code - fill generated values
import { decodeBolt11Invoice, mintMacaroon } from "@boltwall/l402";
function hexToBytes(hex: string): Uint8Array {
const bytes = new Uint8Array(hex.length / 2);
for (let i = 0; i < bytes.length; i++) {
bytes[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
}
return bytes;
}
const rootKey = hexToBytes("<64-char hex key>");
const invoice = "";
const paymentHash = invoice
? decodeBolt11Invoice(invoice).paymentHash
: crypto.getRandomValues(new Uint8Array(32));
const identifier = {
version: 0 as const,
paymentHash,
tokenId: crypto.getRandomValues(new Uint8Array(32)),
};
const macaroon = mintMacaroon({ rootKey, identifier });
L402 Playground