notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 8bc54cc519929d1e761fff5fc6fb2ac6626bfc2b
parent 528237343466cad46d536d90ccef60ee1a6c6d4e
Author: kernelkind <kernelkind@gmail.com>
Date:   Mon,  1 Sep 2025 15:52:55 -0400

zap: add requirements for zapping user

these requirements are specified by nip 57 but weren't implemented

Signed-off-by: kernelkind <kernelkind@gmail.com>

Diffstat:
Mcrates/notedeck/src/zaps/networking.rs | 36++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+), 0 deletions(-)

diff --git a/crates/notedeck/src/zaps/networking.rs b/crates/notedeck/src/zaps/networking.rs @@ -250,6 +250,42 @@ async fn fetch_invoice_lnurl_async( relays: Vec<String>, target: ZapTargetOwned, ) -> FetchedInvoiceResponse { + if !pay_entry.response.allow_nostr { + return FetchedInvoiceResponse { + invoice: Err(ZapError::endpoint_error( + "endpoint does not allow nostr".to_owned(), + )), + pay_entry: Some(pay_entry), + }; + } + + if let Err(e) = &pay_entry.response.nostr_pubkey { + return FetchedInvoiceResponse { + invoice: Err(ZapError::EndpointError(e.clone())), + pay_entry: Some(pay_entry), + }; + }; + + let min_sendable = pay_entry.response.min_sendable; + if msats < min_sendable { + return FetchedInvoiceResponse { + invoice: Err(ZapError::endpoint_error(format!( + "zap amount {msats} is less than minimum sendable: {min_sendable} (in msats)" + ))), + pay_entry: Some(pay_entry), + }; + } + + let max_sendable = pay_entry.response.max_sendable; + if msats > max_sendable { + return FetchedInvoiceResponse { + invoice: Err(ZapError::endpoint_error(format!( + "zap amount {msats} is greater than maximum sendable: {max_sendable} (in msats)" + ))), + pay_entry: Some(pay_entry), + }; + } + let base_url = match &pay_entry.response.callback_url { Ok(url) => url.clone(), Err(error) => {