Skip to content
Draft
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
1,584 changes: 935 additions & 649 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ lto = true

[profile.dev]
panic = "abort"

[patch.crates-io]
esplora-client = { git = 'https://github.com/acidbunny21/rust-esplora-client.git', branch = 'submit-tx-pkg-clients' }
6 changes: 6 additions & 0 deletions ldk-server-protos/src/proto/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ message Bolt11Jit {
// See [`LdkChannelConfig::accept_underpaying_htlcs`](https://docs.rs/lightning/latest/lightning/util/config/struct.ChannelConfig.html#structfield.accept_underpaying_htlcs)
// for more information.
LSPFeeLimits lsp_fee_limits = 4;

// The value, in thousands of a satoshi, that was deducted from this payment as an extra
// fee taken by our channel counterparty.
//
// Will only be `Some` once we received the payment.
optional uint64 counterparty_skimmed_fee_msat = 5;
}

// Represents a BOLT 12 ‘offer’ payment, i.e., a payment for an Offer.
Expand Down
6 changes: 6 additions & 0 deletions ldk-server-protos/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ pub struct Bolt11Jit {
/// for more information.
#[prost(message, optional, tag = "4")]
pub lsp_fee_limits: ::core::option::Option<LspFeeLimits>,
/// The value, in thousands of a satoshi, that was deducted from this payment as an extra
/// fee taken by our channel counterparty.
///
/// Will only be `Some` once we received the payment.
#[prost(uint64, optional, tag = "5")]
pub counterparty_skimmed_fee_msat: ::core::option::Option<u64>,
}
/// Represents a BOLT 12 ‘offer’ payment, i.e., a payment for an Offer.
#[allow(clippy::derive_partial_eq_without_eq)]
Expand Down
2 changes: 1 addition & 1 deletion ldk-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
ldk-node = { git = "https://github.com/lightningdevkit/ldk-node.git", rev = "f0338d19256615088fabab2b6927d478ae3ec1a1" }
ldk-node = { git = "https://github.com/tankyleo/ldk-node.git", branch = "25-10-0fc-channel-config" }
serde = { version = "1.0.203", default-features = false, features = ["derive"] }
hyper = { version = "1", default-features = false, features = ["server", "http1"] }
http-body-util = { version = "0.1", default-features = false }
Expand Down
9 changes: 9 additions & 0 deletions ldk-server/ldk-server-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@ rest_service_address = "127.0.0.1:3002" # LDK Server REST address
[storage.disk]
dir_path = "/tmp/ldk-server/" # Path for LDK and BDK data persistence


# Must set either bitcoind or esplora settings, but not both

# Bitcoin Core settings
[bitcoind]
rpc_address = "127.0.0.1:18444" # RPC endpoint
rpc_user = "polaruser" # RPC username
rpc_password = "polarpass" # RPC password

# Esplora settings
[esplora]
server_url = "https://mempool.space/api" # Esplora endpoint

# RabbitMQ settings (only required if using events-rabbitmq feature)
[rabbitmq]
connection_string = "" # RabbitMQ connection string
Expand Down Expand Up @@ -50,3 +57,5 @@ max_payment_size_msat = 25000000000 # 0.25 BTC
## A token we may require to be sent by the clients.
## If set, only requests matching this token will be accepted. (uncomment and set if required)
# require_token = ""

client_trusts_lsp = false
5 changes: 4 additions & 1 deletion ldk-server/src/api/bolt12_send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ pub(crate) fn handle_bolt12_send_request(
Offer::from_str(&request.offer.as_str()).map_err(|_| ldk_node::NodeError::InvalidOffer)?;

let payment_id = match request.amount_msat {
None => context.node.bolt12_payment().send(&offer, request.quantity, request.payer_note),
None => {
context.node.bolt12_payment().send(&offer, request.quantity, request.payer_note, None)
},
Some(amount_msat) => context.node.bolt12_payment().send_using_amount(
&offer,
amount_msat,
request.quantity,
request.payer_note,
None,
),
}?;

Expand Down
5 changes: 4 additions & 1 deletion ldk-server/src/api/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ impl From<NodeError> for LdkServerError {
| NodeError::InvalidNodeAlias
| NodeError::InvalidDateTime
| NodeError::InvalidFeeRate
| NodeError::UriParameterParsingFailed => {
| NodeError::UriParameterParsingFailed
| NodeError::InvalidBlindedPaths
| NodeError::AsyncPaymentServicesDisabled => {
(error.to_string(), LdkServerErrorCode::InvalidRequestError)
},

Expand All @@ -96,6 +98,7 @@ impl From<NodeError> for LdkServerError {
| NodeError::DuplicatePayment
| NodeError::InsufficientFunds
| NodeError::UnsupportedCurrency
| NodeError::ChannelSplicingFailed
| NodeError::LiquidityFeeTooHigh => (error.to_string(), LdkServerErrorCode::LightningError),

NodeError::AlreadyRunning
Expand Down
34 changes: 21 additions & 13 deletions ldk-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ use crate::io::persist::{
FORWARDED_PAYMENTS_PERSISTENCE_SECONDARY_NAMESPACE, PAYMENTS_PERSISTENCE_PRIMARY_NAMESPACE,
PAYMENTS_PERSISTENCE_SECONDARY_NAMESPACE,
};
use crate::util::config::load_config;
use crate::util::config::{load_config, ChainSource};
use crate::util::proto_adapter::{forwarded_payment_to_proto, payment_to_proto};
use hex::DisplayHex;
use ldk_node::config::Config;
use ldk_node::lightning::ln::channelmanager::PaymentId;
#[cfg(feature = "experimental-lsps2-support")]
use ldk_node::liquidity::LSPS2ServiceConfig;
use ldk_node::logger::LogLevel;
use ldk_server_protos::events;
use ldk_server_protos::events::{event_envelope, EventEnvelope};
use ldk_server_protos::types::Payment;
Expand Down Expand Up @@ -63,7 +64,6 @@ fn main() {
std::process::exit(-1);
}

let mut ldk_node_config = Config::default();
let config_file = match load_config(Path::new(arg)) {
Ok(config) => config,
Err(e) => {
Expand All @@ -72,21 +72,27 @@ fn main() {
},
};

let mut ldk_node_config = Config::default();
ldk_node_config.storage_dir_path = config_file.storage_dir_path.clone();
ldk_node_config.listening_addresses = Some(vec![config_file.listening_addr]);
ldk_node_config.network = config_file.network;

let mut builder = Builder::from_config(ldk_node_config);
builder.set_log_facade_logger();

let bitcoind_rpc_addr = config_file.bitcoind_rpc_addr;

builder.set_chain_source_bitcoind_rpc(
bitcoind_rpc_addr.ip().to_string(),
bitcoind_rpc_addr.port(),
config_file.bitcoind_rpc_user,
config_file.bitcoind_rpc_password,
);
builder.set_filesystem_logger(None, Some(LogLevel::Trace));

match config_file.chain_source {
ChainSource::Rpc { rpc_address, rpc_user, rpc_password } => {
builder.set_chain_source_bitcoind_rpc(
rpc_address.ip().to_string(),
rpc_address.port(),
rpc_user,
rpc_password,
);
},
ChainSource::Esplora { server_url } => {
builder.set_chain_source_esplora(server_url, None);
},
}

// LSPS2 support is highly experimental and for testing purposes only.
#[cfg(feature = "experimental-lsps2-support")]
Expand All @@ -102,6 +108,8 @@ fn main() {
},
};

builder.set_runtime(runtime.handle().clone());

let node = match builder.build() {
Ok(node) => Arc::new(node),
Err(e) => {
Expand Down Expand Up @@ -131,7 +139,7 @@ fn main() {
};

println!("Starting up...");
match node.start_with_runtime(Arc::clone(&runtime)) {
match node.start() {
Ok(()) => {},
Err(e) => {
eprintln!("Failed to start up LDK Node: {}", e);
Expand Down
Loading
Loading