From ac0ec894acb9b555ff969983005e6d18d3bf9e1e Mon Sep 17 00:00:00 2001 From: benthecarman Date: Tue, 26 Mar 2024 14:53:27 -0500 Subject: [PATCH] Fix max amount --- src/lnurlp.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lnurlp.rs b/src/lnurlp.rs index 3feaf14..8745992 100644 --- a/src/lnurlp.rs +++ b/src/lnurlp.rs @@ -31,7 +31,7 @@ pub async fn well_known_lnurlp( let res = LnurlWellKnownResponse { callback: format!("{}/lnurlp/{}/callback", state.domain, name).parse()?, - max_sendable: Amount { msats: 100000 }, + max_sendable: Amount { msats: MAX_AMOUNT }, min_sendable: Amount { msats: MIN_AMOUNT }, metadata: calc_metadata(&name, &state.domain_no_http()), comment_allowed: None, @@ -44,7 +44,8 @@ pub async fn well_known_lnurlp( Ok(res) } -const MIN_AMOUNT: u64 = 1000; +const MAX_AMOUNT: u64 = 100_000_000 * 1_000; // 1 BTC +const MIN_AMOUNT: u64 = 1_000; // 1 sat pub async fn lnurl_callback( state: &State, @@ -64,6 +65,13 @@ pub async fn lnurl_callback( )); } + if params.amount > MAX_AMOUNT { + return Err(anyhow::anyhow!( + "Amount ({}) < MAX_AMOUNT ({MAX_AMOUNT})", + params.amount + )); + } + // verify nostr param is a zap request if params .nostr