Skip to content

Commit

Permalink
Fix max amount to 10M
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyGiorgio committed Sep 11, 2023
1 parent 93b4cec commit 4288756
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/lightning.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand All @@ -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");
Expand Down
11 changes: 5 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use axum::{
extract::State,
http::{StatusCode, Method, self},
http::{self, Method, StatusCode},
response::{IntoResponse, Response},
routing::post,
Json, Router,
Expand All @@ -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 {
Expand All @@ -47,7 +47,7 @@ impl AppState {

type SharedState = Arc<Mutex<AppState>>;

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

#[tokio::main]
async fn main() -> anyhow::Result<()> {
Expand Down Expand Up @@ -102,10 +102,9 @@ async fn bolt11_handler(
) -> Result<Json<Bolt11Response>, 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);

Expand Down

0 comments on commit 4288756

Please sign in to comment.