isValid method

bool isValid({
  1. required String nostrPubKey,
  2. required String recipientLnurl,
})

is valid

Implementation

bool isValid({required String nostrPubKey, required String recipientLnurl}) {
  //  - The zap receipt event's pubkey MUST be the same as the recipient's lnurl provider's nostrPubkey (retrieved in step 1 of the protocol flow).
  if (pubKey != nostrPubKey) {
    return false;
  }
  //  - The invoiceAmount contained in the bolt11 tag of the zap receipt MUST equal the amount tag of the zap request (if present).
  if (bolt11 != null && bolt11!.isNotEmpty) {
    if (amountSats != Lnurl.getAmountFromBolt11(bolt11!)) {
      return false;
    }
  }
  //  - The lnurl tag of the zap request (if present) SHOULD equal the recipient's lnurl.
  if (lnurl != null && lnurl!.isNotEmpty) {
    if (lnurl != recipientLnurl) {
      return false;
    }
  }
  return true;
}