Skip to content

Commit

Permalink
Expose update_channel_config method
Browse files Browse the repository at this point in the history
  • Loading branch information
tnull committed Jun 15, 2023
1 parent 50a0113 commit dd4eea9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
11 changes: 11 additions & 0 deletions bindings/ldk_node.udl
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ interface LDKNode {
[Throws=NodeError]
void close_channel([ByRef]ChannelId channel_id, PublicKey counterparty_node_id);
[Throws=NodeError]
void update_channel_config([ByRef]ChannelId channel_id, PublicKey counterparty_node_id, [ByRef]ChannelConfig channel_config);
[Throws=NodeError]
void sync_wallets();
[Throws=NodeError]
PaymentHash send_payment([ByRef]Invoice invoice);
Expand Down Expand Up @@ -90,6 +92,7 @@ enum NodeError {
"PaymentSendingFailed",
"ChannelCreationFailed",
"ChannelClosingFailed",
"ChannelConfigUpdateFailed",
"PersistenceFailed",
"WalletOperationFailed",
"OnchainTxSigningFailed",
Expand Down Expand Up @@ -181,6 +184,14 @@ dictionary PeerDetails {
boolean is_connected;
};

dictionary ChannelConfig {
u32 forwarding_fee_proportional_millionths;
u32 forwarding_fee_base_msat;
u16 cltv_expiry_delta;
u64 max_dust_htlc_exposure_msat;
u64 force_close_avoidance_max_fee_satoshis;
};

enum LogLevel {
"Gossip",
"Trace",
Expand Down
3 changes: 3 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ pub enum Error {
ChannelCreationFailed,
/// A channel could not be closed.
ChannelClosingFailed,
/// A channel config could not be updated.
ChannelConfigUpdateFailed,
/// Persistence failed.
PersistenceFailed,
/// A wallet operation failed.
Expand Down Expand Up @@ -72,6 +74,7 @@ impl fmt::Display for Error {
Self::PaymentSendingFailed => write!(f, "Failed to send the given payment."),
Self::ChannelCreationFailed => write!(f, "Failed to create channel."),
Self::ChannelClosingFailed => write!(f, "Failed to close channel."),
Self::ChannelConfigUpdateFailed => write!(f, "Failed to update channel config."),
Self::PersistenceFailed => write!(f, "Failed to persist data."),
Self::WalletOperationFailed => write!(f, "Failed to conduct wallet operation."),
Self::OnchainTxSigningFailed => write!(f, "Failed to sign given transaction."),
Expand Down
12 changes: 11 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ use lightning::ln::peer_handler::{IgnoringMessageHandler, MessageHandler};
use lightning::ln::{PaymentHash, PaymentPreimage};
use lightning::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringParameters};

use lightning::util::config::{ChannelHandshakeConfig, UserConfig};
use lightning::util::config::{ChannelConfig, ChannelHandshakeConfig, UserConfig};
pub use lightning::util::logger::Level as LogLevel;
use lightning::util::ser::ReadableArgs;

Expand Down Expand Up @@ -1504,6 +1504,16 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> {
}
}

/// Update the config for a previously opened channel.
pub fn update_channel_config(
&self, channel_id: &ChannelId, counterparty_node_id: PublicKey,
channel_config: &ChannelConfig,
) -> Result<(), Error> {
self.channel_manager
.update_channel_config(&counterparty_node_id, &[channel_id.0], channel_config)
.map_err(|_| Error::ChannelConfigUpdateFailed)
}

/// Send a payement given an invoice.
pub fn send_payment(&self, invoice: &Invoice) -> Result<PaymentHash, Error> {
let rt_lock = self.runtime.read().unwrap();
Expand Down

0 comments on commit dd4eea9

Please sign in to comment.