@@ -1128,7 +1128,7 @@ impl Node {
11281128 fn open_channel_inner (
11291129 & self , node_id : PublicKey , address : SocketAddress , channel_amount_sats : FundingAmount ,
11301130 push_to_counterparty_msat : Option < u64 > , channel_config : Option < ChannelConfig > ,
1131- announce_for_forwarding : bool ,
1131+ announce_for_forwarding : bool , set_0reserve : bool ,
11321132 ) -> Result < UserChannelId , Error > {
11331133 if !* self . is_running . read ( ) . unwrap ( ) {
11341134 return Err ( Error :: NotRunning ) ;
@@ -1196,25 +1196,46 @@ impl Node {
11961196 self . keys_manager . get_secure_random_bytes ( ) [ ..16 ] . try_into ( ) . unwrap ( ) ,
11971197 ) ;
11981198
1199- match self . channel_manager . create_channel (
1200- peer_info. node_id ,
1201- channel_amount_sats,
1202- push_msat,
1203- user_channel_id,
1204- None ,
1205- Some ( user_config) ,
1206- ) {
1199+ let result = if set_0reserve {
1200+ self . channel_manager . create_channel_to_trusted_peer_0reserve (
1201+ peer_info. node_id ,
1202+ channel_amount_sats,
1203+ push_msat,
1204+ user_channel_id,
1205+ None ,
1206+ Some ( user_config) ,
1207+ )
1208+ } else {
1209+ self . channel_manager . create_channel (
1210+ peer_info. node_id ,
1211+ channel_amount_sats,
1212+ push_msat,
1213+ user_channel_id,
1214+ None ,
1215+ Some ( user_config) ,
1216+ )
1217+ } ;
1218+
1219+ let zero_reserve_string = if set_0reserve { "0reserve " } else { "" } ;
1220+
1221+ match result {
12071222 Ok ( _) => {
12081223 log_info ! (
12091224 self . logger,
1210- "Initiated channel creation with peer {}. " ,
1225+ "Initiated {}channel creation with peer {}. " ,
1226+ zero_reserve_string,
12111227 peer_info. node_id
12121228 ) ;
12131229 self . peer_store . add_peer ( peer_info) ?;
12141230 Ok ( UserChannelId ( user_channel_id) )
12151231 } ,
12161232 Err ( e) => {
1217- log_error ! ( self . logger, "Failed to initiate channel creation: {:?}" , e) ;
1233+ log_error ! (
1234+ self . logger,
1235+ "Failed to initiate {}channel creation: {:?}" ,
1236+ zero_reserve_string,
1237+ e
1238+ ) ;
12181239 Err ( Error :: ChannelCreationFailed )
12191240 } ,
12201241 }
@@ -1290,6 +1311,7 @@ impl Node {
12901311 push_to_counterparty_msat,
12911312 channel_config,
12921313 false ,
1314+ false ,
12931315 )
12941316 }
12951317
@@ -1330,6 +1352,7 @@ impl Node {
13301352 push_to_counterparty_msat,
13311353 channel_config,
13321354 true ,
1355+ false ,
13331356 )
13341357 }
13351358
@@ -1358,6 +1381,7 @@ impl Node {
13581381 push_to_counterparty_msat,
13591382 channel_config,
13601383 false ,
1384+ false ,
13611385 )
13621386 }
13631387
@@ -1395,6 +1419,7 @@ impl Node {
13951419 push_to_counterparty_msat,
13961420 channel_config,
13971421 true ,
1422+ false ,
13981423 )
13991424 }
14001425
0 commit comments