diff --git a/src/lightning.rs b/src/lightning.rs index 0c8bc49..3cd9e58 100644 --- a/src/lightning.rs +++ b/src/lightning.rs @@ -1,10 +1,9 @@ use serde::{Deserialize, Serialize}; +use lightning_invoice::Bolt11Invoice; use std::str::FromStr; use std::sync::{Arc, Mutex}; use tonic_openssl_lnd::lnrpc; -use lightning_invoice::Bolt11Invoice; - use crate::{AppState, MAX_SEND_AMOUNT}; @@ -25,7 +24,7 @@ pub async fn pay_lightning( if let Ok(invoice) = Bolt11Invoice::from_str(&payload.bolt11) { if let Some(msat_amount) = invoice.amount_milli_satoshis() { if msat_amount / 1000 > MAX_SEND_AMOUNT { - anyhow::bail!("max amount is 1,000,000"); + anyhow::bail!("max amount is 10,000,000"); } } else { anyhow::bail!("bolt11 invoice should have an amount"); diff --git a/src/main.rs b/src/main.rs index 703e0ec..39770d1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ use axum::{ extract::State, - http::{StatusCode, Method, self}, + http::{self, Method, StatusCode}, response::{IntoResponse, Response}, routing::post, Json, Router, @@ -15,14 +15,14 @@ use std::{ use tonic_openssl_lnd::LndLightningClient; use tower_http::cors::{Any, CorsLayer}; +mod bolt11; mod lightning; mod onchain; mod setup; -mod bolt11; +use bolt11::{request_bolt11, Bolt11Request, Bolt11Response}; use lightning::{pay_lightning, LightningRequest, LightningResponse}; use onchain::{pay_onchain, OnchainRequest, OnchainResponse}; -use bolt11::{request_bolt11, Bolt11Request, Bolt11Response}; use setup::setup; pub struct AppState { @@ -47,7 +47,7 @@ impl AppState { type SharedState = Arc>; -const MAX_SEND_AMOUNT: u64 = 1_000_000; +const MAX_SEND_AMOUNT: u64 = 10_000_000; #[tokio::main] async fn main() -> anyhow::Result<()> { @@ -102,10 +102,9 @@ async fn bolt11_handler( ) -> Result, AppError> { let bolt11 = request_bolt11(state.clone(), payload.clone()).await?; - Ok(Json(Bolt11Response{ bolt11 })) + Ok(Json(Bolt11Response { bolt11 })) } - // Make our own error that wraps `anyhow::Error`. struct AppError(anyhow::Error);