Skip to content

Commit 86d1a1f

Browse files
committed
Have update_channel_config take a UserChannelId
... which is nice for consistency reasons.
1 parent 4d3b600 commit 86d1a1f

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

bindings/ldk_node.udl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ interface LDKNode {
6767
[Throws=NodeError]
6868
void close_channel([ByRef]UserChannelId user_channel_id, PublicKey counterparty_node_id);
6969
[Throws=NodeError]
70-
void update_channel_config([ByRef]ChannelId channel_id, PublicKey counterparty_node_id, ChannelConfig channel_config);
70+
void update_channel_config([ByRef]UserChannelId user_channel_id, PublicKey counterparty_node_id, ChannelConfig channel_config);
7171
[Throws=NodeError]
7272
void sync_wallets();
7373
[Throws=NodeError]

src/lib.rs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,10 @@ use logger::{log_error, log_info, log_trace, FilesystemLogger, Logger};
130130
use lightning::chain::Confirm;
131131
use lightning::ln::channelmanager::{self, PaymentId, RecipientOnionFields, Retry};
132132
use lightning::ln::msgs::SocketAddress;
133-
use lightning::ln::{ChannelId, PaymentHash, PaymentPreimage};
133+
use lightning::ln::{PaymentHash, PaymentPreimage};
134+
135+
#[cfg(feature = "uniffi")]
136+
use lightning::ln::ChannelId;
134137
use lightning::sign::EntropySource;
135138

136139
use lightning::util::persist::KVStore;
@@ -1131,16 +1134,24 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> {
11311134

11321135
/// Update the config for a previously opened channel.
11331136
pub fn update_channel_config(
1134-
&self, channel_id: &ChannelId, counterparty_node_id: PublicKey,
1137+
&self, user_channel_id: &UserChannelId, counterparty_node_id: PublicKey,
11351138
channel_config: Arc<ChannelConfig>,
11361139
) -> Result<(), Error> {
1137-
self.channel_manager
1138-
.update_channel_config(
1139-
&counterparty_node_id,
1140-
&[*channel_id],
1141-
&(*channel_config).clone().into(),
1142-
)
1143-
.map_err(|_| Error::ChannelConfigUpdateFailed)
1140+
let open_channels =
1141+
self.channel_manager.list_channels_with_counterparty(&counterparty_node_id);
1142+
if let Some(channel_details) =
1143+
open_channels.iter().find(|c| c.user_channel_id == user_channel_id.0)
1144+
{
1145+
self.channel_manager
1146+
.update_channel_config(
1147+
&counterparty_node_id,
1148+
&[channel_details.channel_id],
1149+
&(*channel_config).clone().into(),
1150+
)
1151+
.map_err(|_| Error::ChannelConfigUpdateFailed)
1152+
} else {
1153+
Err(Error::ChannelConfigUpdateFailed)
1154+
}
11441155
}
11451156

11461157
/// Send a payment given an invoice.

0 commit comments

Comments
 (0)