@@ -2293,6 +2293,9 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2293
2293
action : msgs:: ErrorAction :: IgnoreError
2294
2294
} ) ;
2295
2295
}
2296
+ if chan. get_short_channel_id ( ) . is_none ( ) {
2297
+ return Err ( LightningError { err : "Channel not yet established" . to_owned ( ) , action : msgs:: ErrorAction :: IgnoreError } ) ;
2298
+ }
2296
2299
log_trace ! ( self . logger, "Attempting to generate broadcast channel update for channel {}" , log_bytes!( chan. channel_id( ) ) ) ;
2297
2300
self . get_channel_update_for_unicast ( chan)
2298
2301
}
@@ -2304,7 +2307,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2304
2307
/// May be called with channel_state already locked!
2305
2308
fn get_channel_update_for_unicast ( & self , chan : & Channel < Signer > ) -> Result < msgs:: ChannelUpdate , LightningError > {
2306
2309
log_trace ! ( self . logger, "Attempting to generate channel update for channel {}" , log_bytes!( chan. channel_id( ) ) ) ;
2307
- let short_channel_id = match chan. get_short_channel_id ( ) {
2310
+ let short_channel_id = match chan. get_short_channel_id ( ) . or ( chan . latest_inbound_scid_alias ( ) ) {
2308
2311
None => return Err ( LightningError { err : "Channel not yet established" . to_owned ( ) , action : msgs:: ErrorAction :: IgnoreError } ) ,
2309
2312
Some ( id) => id,
2310
2313
} ;
@@ -4262,7 +4265,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
4262
4265
}
4263
4266
4264
4267
fn internal_funding_created ( & self , counterparty_node_id : & PublicKey , msg : & msgs:: FundingCreated ) -> Result < ( ) , MsgHandleErrInternal > {
4265
- let ( ( funding_msg, monitor) , mut chan) = {
4268
+ let ( ( funding_msg, monitor, mut funding_locked ) , mut chan) = {
4266
4269
let best_block = * self . best_block . read ( ) . unwrap ( ) ;
4267
4270
let mut channel_lock = self . channel_state . lock ( ) . unwrap ( ) ;
4268
4271
let channel_state = & mut * channel_lock;
@@ -4297,7 +4300,8 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
4297
4300
// hasn't persisted to disk yet - we can't lose money on a transaction that we haven't
4298
4301
// accepted payment from yet. We do, however, need to wait to send our funding_locked
4299
4302
// until we have persisted our monitor.
4300
- chan. monitor_update_failed ( false , false , false , Vec :: new ( ) , Vec :: new ( ) , Vec :: new ( ) ) ;
4303
+ chan. monitor_update_failed ( false , false , funding_locked. is_some ( ) , Vec :: new ( ) , Vec :: new ( ) , Vec :: new ( ) ) ;
4304
+ funding_locked = None ; // Don't send the funding_locked now
4301
4305
} ,
4302
4306
}
4303
4307
}
@@ -4312,6 +4316,9 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
4312
4316
node_id : counterparty_node_id. clone ( ) ,
4313
4317
msg : funding_msg,
4314
4318
} ) ;
4319
+ if let Some ( msg) = funding_locked {
4320
+ send_funding_locked ! ( channel_state. short_to_id, channel_state. pending_msg_events, chan, msg) ;
4321
+ }
4315
4322
e. insert ( chan) ;
4316
4323
}
4317
4324
}
0 commit comments