|
48 | 48 | //! |
49 | 49 | //! let node_id = PublicKey::from_str("NODE_ID").unwrap(); |
50 | 50 | //! let node_addr = NetAddress::from_str("IP_ADDR:PORT").unwrap(); |
51 | | -//! node.connect_open_channel(node_id, node_addr, 10000, None, false).unwrap(); |
| 51 | +//! node.connect_open_channel(node_id, node_addr, 10000, None, None, false).unwrap(); |
52 | 52 | //! |
53 | 53 | //! let event = node.wait_next_event(); |
54 | 54 | //! println!("EVENT: {:?}", event); |
@@ -137,7 +137,7 @@ use lightning::ln::peer_handler::{IgnoringMessageHandler, MessageHandler}; |
137 | 137 | use lightning::ln::{PaymentHash, PaymentPreimage}; |
138 | 138 | use lightning::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringParameters}; |
139 | 139 |
|
140 | | -use lightning::util::config::{ChannelHandshakeConfig, ChannelHandshakeLimits, UserConfig}; |
| 140 | +use lightning::util::config::{ChannelConfig, ChannelHandshakeConfig, UserConfig}; |
141 | 141 | pub use lightning::util::logger::Level as LogLevel; |
142 | 142 | use lightning::util::ser::ReadableArgs; |
143 | 143 |
|
@@ -1371,7 +1371,8 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> { |
1371 | 1371 | /// Returns a temporary channel id. |
1372 | 1372 | pub fn connect_open_channel( |
1373 | 1373 | &self, node_id: PublicKey, address: NetAddress, channel_amount_sats: u64, |
1374 | | - push_to_counterparty_msat: Option<u64>, announce_channel: bool, |
| 1374 | + push_to_counterparty_msat: Option<u64>, channel_config: Option<ChannelConfig>, |
| 1375 | + announce_channel: bool, |
1375 | 1376 | ) -> Result<(), Error> { |
1376 | 1377 | let rt_lock = self.runtime.read().unwrap(); |
1377 | 1378 | if rt_lock.is_none() { |
@@ -1401,15 +1402,12 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> { |
1401 | 1402 | })?; |
1402 | 1403 |
|
1403 | 1404 | let user_config = UserConfig { |
1404 | | - channel_handshake_limits: ChannelHandshakeLimits { |
1405 | | - // lnd's max to_self_delay is 2016, so we want to be compatible. |
1406 | | - their_to_self_delay: 2016, |
1407 | | - ..Default::default() |
1408 | | - }, |
| 1405 | + channel_handshake_limits: Default::default(), |
1409 | 1406 | channel_handshake_config: ChannelHandshakeConfig { |
1410 | 1407 | announced_channel: announce_channel, |
1411 | 1408 | ..Default::default() |
1412 | 1409 | }, |
| 1410 | + channel_config: channel_config.unwrap_or_default(), |
1413 | 1411 | ..Default::default() |
1414 | 1412 | }; |
1415 | 1413 |
|
@@ -1510,6 +1508,16 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> { |
1510 | 1508 | } |
1511 | 1509 | } |
1512 | 1510 |
|
| 1511 | + /// Update the config for a previously opened channel. |
| 1512 | + pub fn update_channel_config( |
| 1513 | + &self, channel_id: &ChannelId, counterparty_node_id: PublicKey, |
| 1514 | + channel_config: &ChannelConfig, |
| 1515 | + ) -> Result<(), Error> { |
| 1516 | + self.channel_manager |
| 1517 | + .update_channel_config(&counterparty_node_id, &[channel_id.0], channel_config) |
| 1518 | + .map_err(|_| Error::ChannelConfigUpdateFailed) |
| 1519 | + } |
| 1520 | + |
1513 | 1521 | /// Send a payement given an invoice. |
1514 | 1522 | pub fn send_payment(&self, invoice: &Invoice) -> Result<PaymentHash, Error> { |
1515 | 1523 | let rt_lock = self.runtime.read().unwrap(); |
|
0 commit comments