Pagar faturas e enviar zaps
Pagar faturas e enviar zaps
@nostr-wot/wallet oferece zaps WebLN, conexões NWC e validação de recibos. O exemplo envia 21 sats após permissão WebLN, descoberta LNURL e assinatura da solicitação de tipo 9734.
terminal
$npm install @nostr-wot/wallet@2.0.0 nostr-wot-sdk@3.0.0 nostr-tools
Exemplo
typescript
import { isWebLNAvailable, zapViaWebLN } from "@nostr-wot/wallet";
import { Nip07Signer } from "nostr-wot-sdk/signers";
// Run once after the user confirms recipient and amount.
export async function sendZap(recipientPubkey: string, lightningAddress: string) {
if (!isWebLNAvailable()) throw new Error("Connect a WebLN wallet first");
await zapViaWebLN({
signer: new Nip07Signer(), recipientPubkey,
recipientLud16: lightningAddress, amountSats: 21,
relays: ["wss://nos.lol"],
});
}Notas de integração
Use a chave pública real e o endereço Lightning do destinatário. Desative o envio enquanto aguarda. Um timeout não comprova falha: consulte o histórico antes de repetir. URIs NWC contêm credenciais; não as coloque em logs, URLs públicas ou análise. Permissões da carteira e de assinatura são separadas.