Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Nov 21, 2024
1 parent a4b57a6 commit 16f0571
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ pub async fn open_channel(
x_forwarded_for: &str,
payload: ChannelRequest,
) -> anyhow::Result<String> {
if payload.capacity > MAX_SEND_AMOUNT.try_into().unwrap() {
anyhow::bail!("max capacity is 10,000,000");
if payload.capacity > MAX_SEND_AMOUNT.try_into()? {
anyhow::bail!("max capacity is 1,000,000");
}
if payload.push_amount < 0 {
anyhow::bail!("push_amount must be positive");
Expand All @@ -32,7 +32,7 @@ pub async fn open_channel(
anyhow::bail!("push_amount must be less than or equal to capacity");
}

let node_pubkey_result = hex::decode(payload.pubkey.clone());
let node_pubkey_result = hex::decode(&payload.pubkey);
let node_pubkey = match node_pubkey_result {
Ok(pubkey) => pubkey,
Err(e) => anyhow::bail!("invalid pubkey: {}", e),
Expand Down
6 changes: 3 additions & 3 deletions src/lightning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub async fn pay_lightning(
let invoice = if let Some(invoice) = params.invoice() {
if let Some(msat_amount) = invoice.amount_milli_satoshis() {
if msat_amount / 1000 > MAX_SEND_AMOUNT {
anyhow::bail!("max amount is 10,000,000");
anyhow::bail!("max amount is 1,000,000");
}
invoice
} else {
Expand All @@ -43,7 +43,7 @@ pub async fn pay_lightning(
match state.lnurl.make_request(&lnurl.url).await? {
LnUrlResponse::LnUrlPayResponse(pay) => {
if pay.min_sendable > MAX_SEND_AMOUNT {
anyhow::bail!("max amount is 10,000,000");
anyhow::bail!("max amount is 1,000,000");
}
let inv = state
.lnurl
Expand Down Expand Up @@ -78,7 +78,7 @@ pub async fn pay_lightning(
match state.lnurl.make_request(&lnurl.url).await? {
LnUrlResponse::LnUrlPayResponse(pay) => {
if pay.min_sendable > MAX_SEND_AMOUNT {
anyhow::bail!("max amount is 10,000,000");
anyhow::bail!("max amount is 1,000,000");
}

let relays = RELAYS.iter().map(|r| UncheckedUrl::new(*r));
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl AppState {
}
}

const MAX_SEND_AMOUNT: u64 = 10_000_000;
const MAX_SEND_AMOUNT: u64 = 1_000_000;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
Expand Down
9 changes: 2 additions & 7 deletions src/nostr_dms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ use nostr_sdk::{Client, RelayPoolNotification};
use std::str::FromStr;
use tonic_openssl_lnd::lnrpc;

pub const RELAYS: [&str; 4] = [
"wss://nostr.mutinywallet.com",
"wss://relay.mutinywallet.com",
"wss://relay.primal.net",
"wss://relay.damus.io",
];
pub const RELAYS: [&str; 2] = ["wss://relay.primal.net", "wss://relay.damus.io"];

pub async fn listen_to_nostr_dms(state: AppState) -> anyhow::Result<()> {
loop {
Expand Down Expand Up @@ -124,7 +119,7 @@ async fn get_invoice(
LnUrlResponse::LnUrlPayResponse(pay) => {
let amount_msats = pay.min_sendable * 2;
if amount_msats > MAX_SEND_AMOUNT {
anyhow::bail!("max amount is 10,000,000");
anyhow::bail!("max amount is 1,000,000");
}

let relays = RELAYS.iter().map(|r| UncheckedUrl::new(*r));
Expand Down
2 changes: 1 addition & 1 deletion src/onchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub async fn pay_onchain(
.ok_or(anyhow::anyhow!("invalid amount"))?;

if amount.to_sat() > MAX_SEND_AMOUNT {
anyhow::bail!("max amount is 10,000,000");
anyhow::bail!("max amount is 1,000,000");
}

let resp = {
Expand Down

0 comments on commit 16f0571

Please sign in to comment.