fetchZappedReceipts method

Stream<ZapReceipt> fetchZappedReceipts({
  1. required String pubKey,
  2. String? eventId,
  3. String? addressableId,
  4. Duration? timeout,
})

fetch all zap receipts matching given pubKey and optional event id, in sats

Implementation

Stream<ZapReceipt> fetchZappedReceipts({
  required String pubKey,
  String? eventId,
  String? addressableId,
  Duration? timeout,
}) {
  NdkResponse? response = _requests.query(
    timeout: timeout ?? Duration(seconds: 10),
    filters: [
      Filter(
        kinds: [ZapReceipt.kKind],
        eTags: eventId != null ? [eventId] : null,
        aTags: addressableId != null ? [addressableId] : null,
        pTags: [pubKey],
      ),
    ],
  );
  // TODO how to check validity of zap receipts without nostrPubKey and recipientLnurl????
  return response.stream.map((event) => ZapReceipt.fromEvent(event));
  // List<Nip01Event> events = await response.future;
  // return events.map((event) => ZapReceipt.fromEvent(event)).toList();
}