@@ -473,6 +473,19 @@ pub(crate) enum ChannelMonitorUpdateStep {
473
473
} ,
474
474
}
475
475
476
+ impl ChannelMonitorUpdateStep {
477
+ fn variant_name ( & self ) -> & ' static str {
478
+ match self {
479
+ ChannelMonitorUpdateStep :: LatestHolderCommitmentTXInfo { .. } => "LatestHolderCommitmentTXInfo" ,
480
+ ChannelMonitorUpdateStep :: LatestCounterpartyCommitmentTXInfo { .. } => "LatestCounterpartyCommitmentTXInfo" ,
481
+ ChannelMonitorUpdateStep :: PaymentPreimage { .. } => "PaymentPreimage" ,
482
+ ChannelMonitorUpdateStep :: CommitmentSecret { .. } => "CommitmentSecret" ,
483
+ ChannelMonitorUpdateStep :: ChannelForceClosed { .. } => "ChannelForceClosed" ,
484
+ ChannelMonitorUpdateStep :: ShutdownScript { .. } => "ShutdownScript" ,
485
+ }
486
+ }
487
+ }
488
+
476
489
impl_writeable_tlv_based_enum_upgradable ! ( ChannelMonitorUpdateStep ,
477
490
( 0 , LatestHolderCommitmentTXInfo ) => {
478
491
( 0 , commitment_tx, required) ,
@@ -1871,16 +1884,21 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1871
1884
F :: Target : FeeEstimator ,
1872
1885
L :: Target : Logger ,
1873
1886
{
1887
+ log_info ! ( logger, "Applying update to monitor {}, bringing update_id from {} to {} with {} changes." ,
1888
+ log_funding_info!( self ) , self . latest_update_id, updates. update_id, updates. updates. len( ) ) ;
1874
1889
// ChannelMonitor updates may be applied after force close if we receive a
1875
1890
// preimage for a broadcasted commitment transaction HTLC output that we'd
1876
1891
// like to claim on-chain. If this is the case, we no longer have guaranteed
1877
1892
// access to the monitor's update ID, so we use a sentinel value instead.
1878
1893
if updates. update_id == CLOSED_CHANNEL_UPDATE_ID {
1894
+ assert_eq ! ( updates. updates. len( ) , 1 ) ;
1879
1895
match updates. updates [ 0 ] {
1880
1896
ChannelMonitorUpdateStep :: PaymentPreimage { .. } => { } ,
1881
- _ => panic ! ( "Attempted to apply post-force-close ChannelMonitorUpdate that wasn't providing a payment preimage" ) ,
1897
+ _ => {
1898
+ log_error ! ( logger, "Attempted to apply post-force-close ChannelMonitorUpdate of type {}" , updates. updates[ 0 ] . variant_name( ) ) ;
1899
+ panic ! ( "Attempted to apply post-force-close ChannelMonitorUpdate that wasn't providing a payment preimage" ) ;
1900
+ } ,
1882
1901
}
1883
- assert_eq ! ( updates. updates. len( ) , 1 ) ;
1884
1902
} else if self . latest_update_id + 1 != updates. update_id {
1885
1903
panic ! ( "Attempted to apply ChannelMonitorUpdates out of order, check the update_id before passing an update to update_monitor!" ) ;
1886
1904
}
0 commit comments