Skip to content
Open
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
12 changes: 7 additions & 5 deletions ldk-server-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use bitcoin_hashes::{sha256, Hash, HashEngine};
use hyper::body::HttpBody as _;
use hyper::{Body as HyperBody, Client as HyperClient, Request as HyperRequest, Version};
use hyper_rustls::{HttpsConnector, HttpsConnectorBuilder};
use ldk_server_grpc::api::SubscribeEventsRequest;
use ldk_server_grpc::api::{
Bolt11ClaimForHashRequest, Bolt11ClaimForHashResponse, Bolt11FailForHashRequest,
Bolt11FailForHashResponse, Bolt11ReceiveForHashRequest, Bolt11ReceiveForHashResponse,
Expand All @@ -36,8 +35,9 @@ use ldk_server_grpc::api::{
OnchainReceiveRequest, OnchainReceiveResponse, OnchainSendRequest, OnchainSendResponse,
OpenChannelRequest, OpenChannelResponse, SignMessageRequest, SignMessageResponse,
SpliceInRequest, SpliceInResponse, SpliceOutRequest, SpliceOutResponse, SpontaneousSendRequest,
SpontaneousSendResponse, UnifiedSendRequest, UnifiedSendResponse, UpdateChannelConfigRequest,
UpdateChannelConfigResponse, VerifySignatureRequest, VerifySignatureResponse,
SpontaneousSendResponse, SubscribeEventsRequest, UnifiedSendRequest, UnifiedSendResponse,
UpdateChannelConfigRequest, UpdateChannelConfigResponse, VerifySignatureRequest,
VerifySignatureResponse,
};
use ldk_server_grpc::endpoints::{
BOLT11_CLAIM_FOR_HASH_PATH, BOLT11_FAIL_FOR_HASH_PATH, BOLT11_RECEIVE_FOR_HASH_PATH,
Expand All @@ -59,7 +59,8 @@ use ldk_server_grpc::grpc::{
GRPC_STATUS_UNAUTHENTICATED, GRPC_STATUS_UNAVAILABLE,
};
use prost::Message;
use reqwest::{header::HeaderMap, Certificate, Client};
use reqwest::header::HeaderMap;
use reqwest::{Certificate, Client};
use rustls::{ClientConfig, RootCertStore};
use rustls_pemfile::certs;

Expand Down Expand Up @@ -660,10 +661,11 @@ fn build_streaming_client(server_cert_pem: &[u8]) -> Result<StreamingClient, Str

#[cfg(test)]
mod tests {
use super::*;
use hyper::Body;
use reqwest::header::HeaderValue;

use super::*;

#[test]
fn test_grpc_error_from_headers_ignores_ok_status() {
let mut headers = HeaderMap::new();
Expand Down
3 changes: 2 additions & 1 deletion ldk-server/src/api/bolt11_claim_for_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// You may not use this file except in accordance with one or both of these
// licenses.

use std::sync::Arc;

use hex::FromHex;
use ldk_node::bitcoin::hashes::{sha256, Hash};
use ldk_node::lightning_types::payment::{PaymentHash, PaymentPreimage};
Expand All @@ -15,7 +17,6 @@ use ldk_server_grpc::api::{Bolt11ClaimForHashRequest, Bolt11ClaimForHashResponse
use crate::api::error::LdkServerError;
use crate::api::error::LdkServerErrorCode::InvalidRequestError;
use crate::service::Context;
use std::sync::Arc;

pub(crate) async fn handle_bolt11_claim_for_hash_request(
context: Arc<Context>, request: Bolt11ClaimForHashRequest,
Expand Down
3 changes: 2 additions & 1 deletion ldk-server/src/api/bolt11_fail_for_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
// You may not use this file except in accordance with one or both of these
// licenses.

use std::sync::Arc;

use hex::FromHex;
use ldk_node::lightning_types::payment::PaymentHash;
use ldk_server_grpc::api::{Bolt11FailForHashRequest, Bolt11FailForHashResponse};

use crate::api::error::LdkServerError;
use crate::api::error::LdkServerErrorCode::InvalidRequestError;
use crate::service::Context;
use std::sync::Arc;

pub(crate) async fn handle_bolt11_fail_for_hash_request(
context: Arc<Context>, request: Bolt11FailForHashRequest,
Expand Down
3 changes: 2 additions & 1 deletion ldk-server/src/api/bolt11_receive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
// You may not use this file except in accordance with one or both of these
// licenses.

use std::sync::Arc;

use hex::DisplayHex;
use ldk_server_grpc::api::{Bolt11ReceiveRequest, Bolt11ReceiveResponse};

use crate::api::error::LdkServerError;
use crate::service::Context;
use crate::util::proto_adapter::proto_to_bolt11_description;
use std::sync::Arc;

pub(crate) async fn handle_bolt11_receive_request(
context: Arc<Context>, request: Bolt11ReceiveRequest,
Expand Down
3 changes: 2 additions & 1 deletion ldk-server/src/api/bolt11_receive_for_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// You may not use this file except in accordance with one or both of these
// licenses.

use std::sync::Arc;

use hex::FromHex;
use ldk_node::lightning_types::payment::PaymentHash;
use ldk_server_grpc::api::{Bolt11ReceiveForHashRequest, Bolt11ReceiveForHashResponse};
Expand All @@ -15,7 +17,6 @@ use crate::api::error::LdkServerError;
use crate::api::error::LdkServerErrorCode::InvalidRequestError;
use crate::service::Context;
use crate::util::proto_adapter::proto_to_bolt11_description;
use std::sync::Arc;

pub(crate) async fn handle_bolt11_receive_for_hash_request(
context: Arc<Context>, request: Bolt11ReceiveForHashRequest,
Expand Down
3 changes: 2 additions & 1 deletion ldk-server/src/api/bolt11_receive_via_jit_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// You may not use this file except in accordance with one or both of these
// licenses.

use std::sync::Arc;

use ldk_server_grpc::api::{
Bolt11ReceiveVariableAmountViaJitChannelRequest,
Bolt11ReceiveVariableAmountViaJitChannelResponse, Bolt11ReceiveViaJitChannelRequest,
Expand All @@ -16,7 +18,6 @@ use ldk_server_grpc::api::{
use crate::api::error::LdkServerError;
use crate::service::Context;
use crate::util::proto_adapter::proto_to_bolt11_description;
use std::sync::Arc;

pub(crate) async fn handle_bolt11_receive_via_jit_channel_request(
context: Arc<Context>, request: Bolt11ReceiveViaJitChannelRequest,
Expand Down
2 changes: 1 addition & 1 deletion ldk-server/src/api/bolt11_send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
// licenses.

use std::str::FromStr;
use std::sync::Arc;

use ldk_node::lightning_invoice::Bolt11Invoice;
use ldk_server_grpc::api::{Bolt11SendRequest, Bolt11SendResponse};

use crate::api::build_route_parameters_config_from_proto;
use crate::api::error::LdkServerError;
use crate::service::Context;
use std::sync::Arc;

pub(crate) async fn handle_bolt11_send_request(
context: Arc<Context>, request: Bolt11SendRequest,
Expand Down
3 changes: 2 additions & 1 deletion ldk-server/src/api/bolt12_receive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
// You may not use this file except in accordance with one or both of these
// licenses.

use std::sync::Arc;

use hex::DisplayHex;
use ldk_server_grpc::api::{Bolt12ReceiveRequest, Bolt12ReceiveResponse};

use crate::api::error::LdkServerError;
use crate::service::Context;
use std::sync::Arc;

pub(crate) async fn handle_bolt12_receive_request(
context: Arc<Context>, request: Bolt12ReceiveRequest,
Expand Down
2 changes: 1 addition & 1 deletion ldk-server/src/api/bolt12_send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
// licenses.

use std::str::FromStr;
use std::sync::Arc;

use ldk_node::lightning::offers::offer::Offer;
use ldk_server_grpc::api::{Bolt12SendRequest, Bolt12SendResponse};

use crate::api::build_route_parameters_config_from_proto;
use crate::api::error::LdkServerError;
use crate::service::Context;
use std::sync::Arc;

pub(crate) async fn handle_bolt12_send_request(
context: Arc<Context>, request: Bolt12SendRequest,
Expand Down
2 changes: 1 addition & 1 deletion ldk-server/src/api/close_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// licenses.

use std::str::FromStr;
use std::sync::Arc;

use ldk_node::bitcoin::secp256k1::PublicKey;
use ldk_node::UserChannelId;
Expand All @@ -18,7 +19,6 @@ use ldk_server_grpc::api::{
use crate::api::error::LdkServerError;
use crate::api::error::LdkServerErrorCode::InvalidRequestError;
use crate::service::Context;
use std::sync::Arc;

pub(crate) async fn handle_close_channel_request(
context: Arc<Context>, request: CloseChannelRequest,
Expand Down
2 changes: 1 addition & 1 deletion ldk-server/src/api/connect_peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
// licenses.

use std::str::FromStr;
use std::sync::Arc;

use ldk_node::bitcoin::secp256k1::PublicKey;
use ldk_node::lightning::ln::msgs::SocketAddress;
use ldk_server_grpc::api::{ConnectPeerRequest, ConnectPeerResponse};

use crate::api::error::LdkServerError;
use crate::service::Context;
use std::sync::Arc;

pub(crate) async fn handle_connect_peer(
context: Arc<Context>, request: ConnectPeerRequest,
Expand Down
2 changes: 1 addition & 1 deletion ldk-server/src/api/decode_invoice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// licenses.

use std::str::FromStr;
use std::sync::Arc;

use hex::prelude::*;
use ldk_node::lightning_invoice::Bolt11Invoice;
Expand All @@ -18,7 +19,6 @@ use ldk_server_grpc::types::{Bolt11HopHint, Bolt11RouteHint};
use crate::api::decode_features;
use crate::api::error::LdkServerError;
use crate::service::Context;
use std::sync::Arc;

pub(crate) async fn handle_decode_invoice_request(
_context: Arc<Context>, request: DecodeInvoiceRequest,
Expand Down
2 changes: 1 addition & 1 deletion ldk-server/src/api/decode_offer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// licenses.

use std::str::FromStr;
use std::sync::Arc;

use hex::prelude::*;
use ldk_node::lightning::bitcoin::blockdata::constants::ChainHash;
Expand All @@ -22,7 +23,6 @@ use ldk_server_grpc::types::{BlindedPath, CurrencyAmount, OfferAmount, OfferQuan
use crate::api::decode_features;
use crate::api::error::LdkServerError;
use crate::service::Context;
use std::sync::Arc;

pub(crate) async fn handle_decode_offer_request(
_context: Arc<Context>, request: DecodeOfferRequest,
Expand Down
2 changes: 1 addition & 1 deletion ldk-server/src/api/disconnect_peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
// licenses.

use std::str::FromStr;
use std::sync::Arc;

use ldk_node::bitcoin::secp256k1::PublicKey;
use ldk_server_grpc::api::{DisconnectPeerRequest, DisconnectPeerResponse};

use crate::api::error::LdkServerError;
use crate::service::Context;
use std::sync::Arc;

pub(crate) async fn handle_disconnect_peer(
context: Arc<Context>, request: DisconnectPeerRequest,
Expand Down
3 changes: 2 additions & 1 deletion ldk-server/src/api/export_pathfinding_scores.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
// You may not use this file except in accordance with one or both of these
// licenses.

use std::sync::Arc;

use ldk_server_grpc::api::{ExportPathfindingScoresRequest, ExportPathfindingScoresResponse};

use crate::api::error::LdkServerError;
use crate::service::Context;
use std::sync::Arc;

pub(crate) async fn handle_export_pathfinding_scores_request(
context: Arc<Context>, _request: ExportPathfindingScoresRequest,
Expand Down
3 changes: 2 additions & 1 deletion ldk-server/src/api/get_balances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
// You may not use this file except in accordance with one or both of these
// licenses.

use std::sync::Arc;

use ldk_server_grpc::api::{GetBalancesRequest, GetBalancesResponse};

use crate::api::error::LdkServerError;
use crate::service::Context;
use crate::util::proto_adapter::{lightning_balance_to_proto, pending_sweep_balance_to_proto};
use std::sync::Arc;

pub(crate) async fn handle_get_balances_request(
context: Arc<Context>, _request: GetBalancesRequest,
Expand Down
3 changes: 2 additions & 1 deletion ldk-server/src/api/get_node_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
// You may not use this file except in accordance with one or both of these
// licenses.

use std::sync::Arc;

use ldk_server_grpc::api::{GetNodeInfoRequest, GetNodeInfoResponse};
use ldk_server_grpc::types::BestBlock;

use crate::api::error::LdkServerError;
use crate::service::Context;
use std::sync::Arc;

pub(crate) async fn handle_get_node_info_request(
context: Arc<Context>, _request: GetNodeInfoRequest,
Expand Down
3 changes: 2 additions & 1 deletion ldk-server/src/api/get_payment_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// You may not use this file except in accordance with one or both of these
// licenses.

use std::sync::Arc;

use hex::FromHex;
use ldk_node::lightning::ln::channelmanager::PaymentId;
use ldk_server_grpc::api::{GetPaymentDetailsRequest, GetPaymentDetailsResponse};
Expand All @@ -15,7 +17,6 @@ use crate::api::error::LdkServerError;
use crate::api::error::LdkServerErrorCode::InvalidRequestError;
use crate::service::Context;
use crate::util::proto_adapter::payment_to_proto;
use std::sync::Arc;

pub(crate) async fn handle_get_payment_details_request(
context: Arc<Context>, request: GetPaymentDetailsRequest,
Expand Down
3 changes: 2 additions & 1 deletion ldk-server/src/api/graph_get_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
// You may not use this file except in accordance with one or both of these
// licenses.

use std::sync::Arc;

use ldk_server_grpc::api::{GraphGetChannelRequest, GraphGetChannelResponse};

use crate::api::error::LdkServerError;
use crate::api::error::LdkServerErrorCode::InvalidRequestError;
use crate::service::Context;
use crate::util::proto_adapter::graph_channel_to_proto;
use std::sync::Arc;

pub(crate) async fn handle_graph_get_channel_request(
context: Arc<Context>, request: GraphGetChannelRequest,
Expand Down
3 changes: 2 additions & 1 deletion ldk-server/src/api/graph_get_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
// You may not use this file except in accordance with one or both of these
// licenses.

use std::sync::Arc;

use ldk_node::lightning::routing::gossip::NodeId;
use ldk_server_grpc::api::{GraphGetNodeRequest, GraphGetNodeResponse};

use crate::api::error::LdkServerError;
use crate::api::error::LdkServerErrorCode::InvalidRequestError;
use crate::service::Context;
use crate::util::proto_adapter::graph_node_to_proto;
use std::sync::Arc;

pub(crate) async fn handle_graph_get_node_request(
context: Arc<Context>, request: GraphGetNodeRequest,
Expand Down
3 changes: 2 additions & 1 deletion ldk-server/src/api/graph_list_channels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
// You may not use this file except in accordance with one or both of these
// licenses.

use std::sync::Arc;

use ldk_server_grpc::api::{GraphListChannelsRequest, GraphListChannelsResponse};

use crate::api::error::LdkServerError;
use crate::service::Context;
use std::sync::Arc;

pub(crate) async fn handle_graph_list_channels_request(
context: Arc<Context>, _request: GraphListChannelsRequest,
Expand Down
3 changes: 2 additions & 1 deletion ldk-server/src/api/graph_list_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
// You may not use this file except in accordance with one or both of these
// licenses.

use std::sync::Arc;

use ldk_server_grpc::api::{GraphListNodesRequest, GraphListNodesResponse};

use crate::api::error::LdkServerError;
use crate::service::Context;
use std::sync::Arc;

pub(crate) async fn handle_graph_list_nodes_request(
context: Arc<Context>, _request: GraphListNodesRequest,
Expand Down
3 changes: 2 additions & 1 deletion ldk-server/src/api/list_channels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
// You may not use this file except in accordance with one or both of these
// licenses.

use std::sync::Arc;

use ldk_server_grpc::api::{ListChannelsRequest, ListChannelsResponse};

use crate::api::error::LdkServerError;
use crate::service::Context;
use crate::util::proto_adapter::channel_to_proto;
use std::sync::Arc;

pub(crate) async fn handle_list_channels_request(
context: Arc<Context>, _request: ListChannelsRequest,
Expand Down
Loading