Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/Nostr.Client/Client/NostrClientStreams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,18 @@ public class NostrClientStreams
internal readonly Subject<NostrRawResponse> UnknownRawSubject = new();

/// <summary>
/// Requested Nostr events
/// Requested Nostr events (includes all events, signature not validated)
/// </summary>
public IObservable<NostrEventResponse> EventStream => EventSubject.AsObservable();

/// <summary>
/// Requested Nostr events with valid signatures only.
/// Events with invalid or missing signatures are filtered out.
/// </summary>
public IObservable<NostrEventResponse> ValidEventStream => EventSubject
.AsObservable()
.Where(x => x.IsSignatureValid);

/// <summary>
/// Human-readable messages
/// </summary>
Expand Down
7 changes: 7 additions & 0 deletions src/Nostr.Client/Responses/NostrEventResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,12 @@ public class NostrEventResponse : NostrResponse
[ArrayProperty(2)]
[JsonConverter(typeof(NostrEventConverter))]
public NostrEvent? Event { get; init; }

/// <summary>
/// Check if the event signature is valid.
/// Returns false if event is null or signature verification fails.
/// </summary>
[JsonIgnore]
public bool IsSignatureValid => Event?.IsSignatureValid() ?? false;
}
}
Loading