createZapRequest method

Future<ZapRequest> createZapRequest({
  1. required int amountSats,
  2. required EventSigner signer,
  3. required String pubKey,
  4. String? eventId,
  5. String? comment,
  6. required Iterable<String> relays,
  7. String? pollOption,
})

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;
}