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