damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit eae844e08187f5a6522fdbaa6df3314929944c9d
parent 140b0e4fc47a12c5b7705f364ff1cb9722b62186
Author: William Casarin <jb55@jb55.com>
Date:   Mon,  6 Feb 2023 11:10:23 -0800

Fix event encoding issue

Diffstat:
Mdamus/Nostr/NostrEvent.swift | 1+
Mdamus/Nostr/RelayConnection.swift | 7+++----
Mdamus/Util/Zap.swift | 1+
3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/damus/Nostr/NostrEvent.swift b/damus/Nostr/NostrEvent.swift @@ -370,6 +370,7 @@ func decode_nostr_event(txt: String) -> NostrResponse? { func encode_json<T: Encodable>(_ val: T) -> String? { let encoder = JSONEncoder() + encoder.outputFormatting = .withoutEscapingSlashes return (try? encoder.encode(val)).map { String(decoding: $0, as: UTF8.self) } } diff --git a/damus/Nostr/RelayConnection.swift b/damus/Nostr/RelayConnection.swift @@ -118,10 +118,9 @@ func make_nostr_req(_ req: NostrRequest) -> String? { } func make_nostr_push_event(ev: NostrEvent) -> String? { - let encoder = JSONEncoder() - encoder.outputFormatting = .withoutEscapingSlashes - let event_data = try! encoder.encode(ev) - let event = String(decoding: event_data, as: UTF8.self) + guard let event = encode_json(ev) else { + return nil + } let encoded = "[\"EVENT\",\(event)]" print(encoded) return encoded diff --git a/damus/Util/Zap.swift b/damus/Util/Zap.swift @@ -296,6 +296,7 @@ func fetch_zap_invoice(_ payreq: LNUrlPayRequest, zapreq: NostrEvent, amount: In if zappable { if let json = encode_json(zapreq) { + print("zapreq json: \(json)") query.append(URLQueryItem(name: "nostr", value: json)) } }