createZapRequest method
creates a zap request
Implementation
Future<ZapRequest> createZapRequest({
required int amountSats,
required EventSigner signer,
required String pubKey,
String? eventId,
String? comment,
required Iterable<String> relays,
String? pollOption,
}) async {
if (amountSats < 0) {
throw ArgumentError("amount cannot be < 0");
}
final amount = amountSats * 1000;
var tags = [
["relays", ...relays],
["amount", amount.toString()],
["p", pubKey],
];
if (eventId != null) {
tags.add(["e", eventId]);
}
if (pollOption != null) {
tags.add(["poll_option", pollOption]);
}
var event = ZapRequest(
pubKey: signer.getPublicKey(), tags: tags, content: comment ?? '');
await signer.sign(event);
return event;
}