@@ -2529,6 +2529,9 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2529
2529
action : msgs:: ErrorAction :: IgnoreError
2530
2530
} ) ;
2531
2531
}
2532
+ if chan. get_short_channel_id ( ) . is_none ( ) {
2533
+ return Err ( LightningError { err : "Channel not yet established" . to_owned ( ) , action : msgs:: ErrorAction :: IgnoreError } ) ;
2534
+ }
2532
2535
log_trace ! ( self . logger, "Attempting to generate broadcast channel update for channel {}" , log_bytes!( chan. channel_id( ) ) ) ;
2533
2536
self . get_channel_update_for_unicast ( chan)
2534
2537
}
@@ -2540,7 +2543,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2540
2543
/// May be called with channel_state already locked!
2541
2544
fn get_channel_update_for_unicast ( & self , chan : & Channel < Signer > ) -> Result < msgs:: ChannelUpdate , LightningError > {
2542
2545
log_trace ! ( self . logger, "Attempting to generate channel update for channel {}" , log_bytes!( chan. channel_id( ) ) ) ;
2543
- let short_channel_id = match chan. get_short_channel_id ( ) {
2546
+ let short_channel_id = match chan. get_short_channel_id ( ) . or ( chan . latest_inbound_scid_alias ( ) ) {
2544
2547
None => return Err ( LightningError { err : "Channel not yet established" . to_owned ( ) , action : msgs:: ErrorAction :: IgnoreError } ) ,
2545
2548
Some ( id) => id,
2546
2549
} ;
@@ -4489,7 +4492,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
4489
4492
}
4490
4493
4491
4494
fn internal_funding_created ( & self , counterparty_node_id : & PublicKey , msg : & msgs:: FundingCreated ) -> Result < ( ) , MsgHandleErrInternal > {
4492
- let ( ( funding_msg, monitor) , mut chan) = {
4495
+ let ( ( funding_msg, monitor, mut funding_locked ) , mut chan) = {
4493
4496
let best_block = * self . best_block . read ( ) . unwrap ( ) ;
4494
4497
let mut channel_lock = self . channel_state . lock ( ) . unwrap ( ) ;
4495
4498
let channel_state = & mut * channel_lock;
@@ -4524,7 +4527,8 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
4524
4527
// hasn't persisted to disk yet - we can't lose money on a transaction that we haven't
4525
4528
// accepted payment from yet. We do, however, need to wait to send our funding_locked
4526
4529
// until we have persisted our monitor.
4527
- chan. monitor_update_failed ( false , false , false , Vec :: new ( ) , Vec :: new ( ) , Vec :: new ( ) ) ;
4530
+ chan. monitor_update_failed ( false , false , funding_locked. is_some ( ) , Vec :: new ( ) , Vec :: new ( ) , Vec :: new ( ) ) ;
4531
+ funding_locked = None ; // Don't send the funding_locked now
4528
4532
} ,
4529
4533
}
4530
4534
}
@@ -4539,6 +4543,9 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
4539
4543
node_id : counterparty_node_id. clone ( ) ,
4540
4544
msg : funding_msg,
4541
4545
} ) ;
4546
+ if let Some ( msg) = funding_locked {
4547
+ send_funding_locked ! ( channel_state. short_to_id, channel_state. pending_msg_events, chan, msg) ;
4548
+ }
4542
4549
e. insert ( chan) ;
4543
4550
}
4544
4551
}
0 commit comments