Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix max amount #8

Merged
merged 3 commits into from
Mar 26, 2024
Merged
Changes from 2 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
14 changes: 11 additions & 3 deletions src/lnurlp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
TonyGiorgio marked this conversation as resolved.
Show resolved Hide resolved

pub async fn lnurl_callback(
state: &State,
Expand All @@ -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
Expand Down Expand Up @@ -106,7 +114,7 @@ pub async fn lnurl_callback(
Amount::from_msats(params.amount),
Bolt11InvoiceDescription::Hash(&desc_hash),
Some(86_400), // 1 day expiry
user.pubkey().public_key(Parity::Even), // todo is this parity correct / easy to work with?
user.pubkey().public_key(Parity::Even),
invoice_index as u64,
(),
Some(gateway),
Expand Down