Skip to content

Commit dd4eea9

Browse files
committed
Expose update_channel_config method
1 parent 50a0113 commit dd4eea9

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

bindings/ldk_node.udl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ interface LDKNode {
5858
[Throws=NodeError]
5959
void close_channel([ByRef]ChannelId channel_id, PublicKey counterparty_node_id);
6060
[Throws=NodeError]
61+
void update_channel_config([ByRef]ChannelId channel_id, PublicKey counterparty_node_id, [ByRef]ChannelConfig channel_config);
62+
[Throws=NodeError]
6163
void sync_wallets();
6264
[Throws=NodeError]
6365
PaymentHash send_payment([ByRef]Invoice invoice);
@@ -90,6 +92,7 @@ enum NodeError {
9092
"PaymentSendingFailed",
9193
"ChannelCreationFailed",
9294
"ChannelClosingFailed",
95+
"ChannelConfigUpdateFailed",
9396
"PersistenceFailed",
9497
"WalletOperationFailed",
9598
"OnchainTxSigningFailed",
@@ -181,6 +184,14 @@ dictionary PeerDetails {
181184
boolean is_connected;
182185
};
183186

187+
dictionary ChannelConfig {
188+
u32 forwarding_fee_proportional_millionths;
189+
u32 forwarding_fee_base_msat;
190+
u16 cltv_expiry_delta;
191+
u64 max_dust_htlc_exposure_msat;
192+
u64 force_close_avoidance_max_fee_satoshis;
193+
};
194+
184195
enum LogLevel {
185196
"Gossip",
186197
"Trace",

src/error.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ pub enum Error {
1919
ChannelCreationFailed,
2020
/// A channel could not be closed.
2121
ChannelClosingFailed,
22+
/// A channel config could not be updated.
23+
ChannelConfigUpdateFailed,
2224
/// Persistence failed.
2325
PersistenceFailed,
2426
/// A wallet operation failed.
@@ -72,6 +74,7 @@ impl fmt::Display for Error {
7274
Self::PaymentSendingFailed => write!(f, "Failed to send the given payment."),
7375
Self::ChannelCreationFailed => write!(f, "Failed to create channel."),
7476
Self::ChannelClosingFailed => write!(f, "Failed to close channel."),
77+
Self::ChannelConfigUpdateFailed => write!(f, "Failed to update channel config."),
7578
Self::PersistenceFailed => write!(f, "Failed to persist data."),
7679
Self::WalletOperationFailed => write!(f, "Failed to conduct wallet operation."),
7780
Self::OnchainTxSigningFailed => write!(f, "Failed to sign given transaction."),

src/lib.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ use lightning::ln::peer_handler::{IgnoringMessageHandler, MessageHandler};
135135
use lightning::ln::{PaymentHash, PaymentPreimage};
136136
use lightning::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringParameters};
137137

138-
use lightning::util::config::{ChannelHandshakeConfig, UserConfig};
138+
use lightning::util::config::{ChannelConfig, ChannelHandshakeConfig, UserConfig};
139139
pub use lightning::util::logger::Level as LogLevel;
140140
use lightning::util::ser::ReadableArgs;
141141

@@ -1504,6 +1504,16 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> {
15041504
}
15051505
}
15061506

1507+
/// Update the config for a previously opened channel.
1508+
pub fn update_channel_config(
1509+
&self, channel_id: &ChannelId, counterparty_node_id: PublicKey,
1510+
channel_config: &ChannelConfig,
1511+
) -> Result<(), Error> {
1512+
self.channel_manager
1513+
.update_channel_config(&counterparty_node_id, &[channel_id.0], channel_config)
1514+
.map_err(|_| Error::ChannelConfigUpdateFailed)
1515+
}
1516+
15071517
/// Send a payement given an invoice.
15081518
pub fn send_payment(&self, invoice: &Invoice) -> Result<PaymentHash, Error> {
15091519
let rt_lock = self.runtime.read().unwrap();

0 commit comments

Comments
 (0)