Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
450 changes: 396 additions & 54 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ demo = []
# Branch: https://github.com/moneydevkit/ldk-node/tree/lsp-0.7.0_socks-support
ldk-node = { git = "https://github.com/moneydevkit/ldk-node", rev = "c3aba2a47a6314968979de8fe772d9d1bcb3ee6e" }

# Pinned to the same git rev as ldk-node's transitive pull to avoid duplicate
# crate compilation. Verify with `cargo tree -d | grep bitcoin-payment-instructions`.
bitcoin-payment-instructions = { git = "https://github.com/moneydevkit/bitcoin-payment-instructions", rev = "6796e87525d6c564e1332354a808730e2ba2ebf8", default-features = false, features = ["http"] }

axum = { version = "0.8", features = ["json", "ws"] }
utoipa = { version = "5.4", features = ["axum_extras"] }
utoipa-axum = "0.2"
Expand Down Expand Up @@ -45,3 +49,5 @@ ldk-node-lsp = { package = "ldk-node", git = "https://github.com/moneydevkit/ldk
tempfile = "3"
tokio-tungstenite = "0.26"
tower = "0.5.3"
wiremock = "0.6"
bech32 = "0.11"
21 changes: 20 additions & 1 deletion src/daemon/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub mod info;
pub mod invoices;
pub mod onchain;
pub mod pay;
pub mod pay_any;
pub mod websocket;

use std::sync::Arc;
Expand All @@ -32,7 +33,7 @@ use crate::daemon::types::{
DecodeInvoiceRequest, DecodeInvoiceResponse, DecodeOfferRequest, DecodeOfferResponse,
GetBalanceResponse, GetInfoResponse, IncomingPaymentResponse, ListOutgoingPaymentsRequest,
ListPaymentsRequest, OutgoingPaymentResponse, PayInvoiceRequest, PayInvoiceResponse,
SendToAddressRequest,
PayRequest, PayResponse, SendToAddressRequest,
};

#[derive(Clone)]
Expand Down Expand Up @@ -89,6 +90,7 @@ pub fn router(state: AppState) -> Router {
.routes(routes!(close_channel))
.routes(routes!(send_to_address))
.routes(routes!(pay_invoice))
.routes(routes!(pay))
.layer(middleware::from_fn(auth::require_full_access));

let (router, api) = OpenApiRouter::with_openapi(ApiDoc::openapi())
Expand Down Expand Up @@ -320,3 +322,20 @@ async fn pay_invoice(
) -> Result<Json<PayInvoiceResponse>, AppError> {
Ok(Json(pay::handle_pay_invoice(state.node, &req).await?))
}

#[utoipa::path(
post, path = "/pay", tag = "send",
request_body(content = PayRequest, content_type = "application/x-www-form-urlencoded"),
responses(
(status = 200, body = PayResponse),
(status = 400, body = ApiError),
(status = 500, body = ApiError),
),
security(("basic_auth" = []))
)]
async fn pay(
State(state): State<AppState>,
Form(req): Form<PayRequest>,
) -> Result<Json<PayResponse>, AppError> {
Ok(Json(pay_any::handle_pay(state, &req).await?))
}
Loading
Loading