Payer des factures et envoyer des zaps
Payer des factures et envoyer des zaps
@nostr-wot/wallet fournit les zaps WebLN, les connexions NWC et la validation des reçus. L’exemple envoie 21 sats après autorisation WebLN, découverte LNURL et signature d’une demande de type 9734.
terminal
$npm install @nostr-wot/wallet@2.0.0 nostr-wot-sdk@3.0.0 nostr-tools
Exemple
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"],
});
}Notes d’intégration
Utilisez la vraie clé publique et l’adresse Lightning du destinataire. Désactivez le bouton pendant le paiement. Un délai dépassé ne prouve pas un échec : vérifiez l’historique avant de réessayer. Les URI NWC contiennent des identifiants secrets. Les permissions WebLN et Nostr sont distinctes.