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