@@ -38,7 +38,7 @@ use crate::types::features::ChannelTypeFeatures;
38
38
use crate :: types:: payment:: { PaymentHash , PaymentPreimage } ;
39
39
use crate :: ln:: msgs:: DecodeError ;
40
40
use crate :: ln:: channel_keys:: { DelayedPaymentKey , DelayedPaymentBasepoint , HtlcBasepoint , HtlcKey , RevocationKey , RevocationBasepoint } ;
41
- use crate :: ln:: chan_utils:: { self , CommitmentTransaction , CounterpartyCommitmentSecrets , HTLCOutputInCommitment , HTLCClaim , ChannelTransactionParameters , HolderCommitmentTransaction } ;
41
+ use crate :: ln:: chan_utils:: { self , CommitmentTransaction , CounterpartyCommitmentSecrets , HTLCOutputInCommitment , HTLCClaim , ChannelTransactionParameters , HolderCommitmentTransaction , HTLCOutputData } ;
42
42
use crate :: ln:: channelmanager:: { HTLCSource , SentHTLCId , PaymentClaimDetails } ;
43
43
use crate :: chain;
44
44
use crate :: chain:: { BestBlock , WatchedOutput } ;
@@ -591,11 +591,16 @@ pub(crate) enum ChannelMonitorUpdateStep {
591
591
to_broadcaster_value_sat : Option < u64 > ,
592
592
to_countersignatory_value_sat : Option < u64 > ,
593
593
} ,
594
- LatestCounterpartyCommitmentTX {
594
+ LatestHolderCommitmentTXs {
595
+ htlc_data : Vec < ( HTLCOutputData , Option < HTLCSource > ) > ,
596
+ commitment_txs : Vec < HolderCommitmentTransaction > ,
597
+ claimed_htlcs : Vec < ( SentHTLCId , PaymentPreimage ) > ,
598
+ } ,
599
+ LatestCounterpartyCommitmentTXs {
595
600
// The dust and non-dust htlcs for that commitment
596
- htlc_outputs : Vec < ( HTLCOutputInCommitment , Option < Box < HTLCSource > > ) > ,
601
+ htlc_data : Vec < ( HTLCOutputData , Option < Box < HTLCSource > > ) > ,
597
602
// Contains only the non-dust htlcs
598
- commitment_tx : CommitmentTransaction ,
603
+ commitment_txs : Vec < CommitmentTransaction > ,
599
604
} ,
600
605
PaymentPreimage {
601
606
payment_preimage : PaymentPreimage ,
@@ -624,7 +629,8 @@ impl ChannelMonitorUpdateStep {
624
629
match self {
625
630
ChannelMonitorUpdateStep :: LatestHolderCommitmentTXInfo { .. } => "LatestHolderCommitmentTXInfo" ,
626
631
ChannelMonitorUpdateStep :: LatestCounterpartyCommitmentTXInfo { .. } => "LatestCounterpartyCommitmentTXInfo" ,
627
- ChannelMonitorUpdateStep :: LatestCounterpartyCommitmentTX { .. } => "LatestCounterpartyCommitmentTX" ,
632
+ ChannelMonitorUpdateStep :: LatestHolderCommitmentTXs { .. } => "LatestHolderCommitmentTXs" ,
633
+ ChannelMonitorUpdateStep :: LatestCounterpartyCommitmentTXs { .. } => "LatestCounterpartyCommitmentTXs" ,
628
634
ChannelMonitorUpdateStep :: PaymentPreimage { .. } => "PaymentPreimage" ,
629
635
ChannelMonitorUpdateStep :: CommitmentSecret { .. } => "CommitmentSecret" ,
630
636
ChannelMonitorUpdateStep :: ChannelForceClosed { .. } => "ChannelForceClosed" ,
@@ -663,9 +669,14 @@ impl_writeable_tlv_based_enum_upgradable!(ChannelMonitorUpdateStep,
663
669
( 5 , ShutdownScript ) => {
664
670
( 0 , scriptpubkey, required) ,
665
671
} ,
666
- ( 6 , LatestCounterpartyCommitmentTX ) => {
667
- ( 0 , htlc_outputs, required_vec) ,
668
- ( 2 , commitment_tx, required) ,
672
+ ( 6 , LatestHolderCommitmentTXs ) => {
673
+ ( 0 , htlc_data, required_vec) ,
674
+ ( 2 , commitment_txs, required_vec) ,
675
+ ( 4 , claimed_htlcs, required_vec) ,
676
+ } ,
677
+ ( 7 , LatestCounterpartyCommitmentTXs ) => {
678
+ ( 0 , htlc_data, required_vec) ,
679
+ ( 2 , commitment_txs, required_vec) ,
669
680
} ,
670
681
) ;
671
682
@@ -3084,6 +3095,19 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3084
3095
}
3085
3096
}
3086
3097
3098
+ // This is the sibling of `provide_latest_counterparty_commitment_tx`, but updated for a world
3099
+ // in which the HTLC-source table passed from channel does NOT store dust-vs-nondust and
3100
+ // index HTLC data.
3101
+ fn provide_latest_counterparty_commitment_data < L : Deref > (
3102
+ & mut self ,
3103
+ _htlc_data : Vec < ( HTLCOutputData , Option < Box < HTLCSource > > ) > ,
3104
+ _txs : & Vec < CommitmentTransaction > ,
3105
+ _logger : & WithChannelMonitor < L > ,
3106
+ ) where L :: Target : Logger {
3107
+ // TODO(splicing, 0.2): Populate this monitor's data structures
3108
+ todo ! ( ) ;
3109
+ }
3110
+
3087
3111
/// Informs this monitor of the latest holder (ie broadcastable) commitment transaction. The
3088
3112
/// monitor watches for timeouts and may broadcast it if we approach such a timeout. Thus, it
3089
3113
/// is important that any clones of this channel monitor (including remote clones) by kept
@@ -3175,6 +3199,19 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3175
3199
}
3176
3200
}
3177
3201
3202
+ // This is the sibling of `provide_latest_holder_commitment_tx`, but updated for a world
3203
+ // in which the HTLC-source table passed from channel does NOT store dust-vs-nondust and
3204
+ // index HTLC data.
3205
+ fn provide_latest_holder_commitment_data (
3206
+ & mut self ,
3207
+ _htlc_data : Vec < ( HTLCOutputData , Option < HTLCSource > ) > ,
3208
+ _holder_commitment_txs : Vec < HolderCommitmentTransaction > ,
3209
+ _claimed_htlcs : & [ ( SentHTLCId , PaymentPreimage ) ] ,
3210
+ ) {
3211
+ // TODO(splicing, 0.2): Populate this monitor's data structures
3212
+ todo ! ( ) ;
3213
+ }
3214
+
3178
3215
/// Provides a payment_hash->payment_preimage mapping. Will be automatically pruned when all
3179
3216
/// commitment_tx_infos which contain the payment hash have been revoked.
3180
3217
///
@@ -3399,9 +3436,14 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3399
3436
log_trace ! ( logger, "Updating ChannelMonitor with latest counterparty commitment transaction info" ) ;
3400
3437
self . provide_latest_counterparty_commitment_tx ( * commitment_txid, htlc_outputs. clone ( ) , * commitment_number, * their_per_commitment_point, logger)
3401
3438
} ,
3402
- ChannelMonitorUpdateStep :: LatestCounterpartyCommitmentTX { htlc_outputs, commitment_tx } => {
3403
- log_trace ! ( logger, "Updating ChannelMonitor with latest counterparty commitment transaction info" ) ;
3404
- self . provide_latest_counterparty_commitment_tx ( commitment_tx. trust ( ) . txid ( ) , htlc_outputs. clone ( ) , commitment_tx. commitment_number ( ) , commitment_tx. per_commitment_point ( ) , logger)
3439
+ ChannelMonitorUpdateStep :: LatestHolderCommitmentTXs { htlc_data, commitment_txs, claimed_htlcs } => {
3440
+ log_trace ! ( logger, "Updating ChannelMonitor with latest holder commitment transaction(s)" ) ;
3441
+ if self . lockdown_from_offchain { panic ! ( ) ; }
3442
+ self . provide_latest_holder_commitment_data ( htlc_data. clone ( ) , commitment_txs. clone ( ) , claimed_htlcs)
3443
+ }
3444
+ ChannelMonitorUpdateStep :: LatestCounterpartyCommitmentTXs { htlc_data, commitment_txs } => {
3445
+ log_trace ! ( logger, "Updating ChannelMonitor with latest counterparty commitment transaction(s)" ) ;
3446
+ self . provide_latest_counterparty_commitment_data ( htlc_data. clone ( ) , commitment_txs, logger)
3405
3447
} ,
3406
3448
ChannelMonitorUpdateStep :: PaymentPreimage { payment_preimage, payment_info } => {
3407
3449
log_trace ! ( logger, "Updating ChannelMonitor with payment preimage" ) ;
@@ -3465,7 +3507,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3465
3507
match update {
3466
3508
ChannelMonitorUpdateStep :: LatestHolderCommitmentTXInfo { .. }
3467
3509
|ChannelMonitorUpdateStep :: LatestCounterpartyCommitmentTXInfo { .. }
3468
- |ChannelMonitorUpdateStep :: LatestCounterpartyCommitmentTX { .. }
3510
+ |ChannelMonitorUpdateStep :: LatestHolderCommitmentTXs { .. }
3511
+ |ChannelMonitorUpdateStep :: LatestCounterpartyCommitmentTXs { .. }
3469
3512
|ChannelMonitorUpdateStep :: ShutdownScript { .. }
3470
3513
|ChannelMonitorUpdateStep :: CommitmentSecret { .. } =>
3471
3514
is_pre_close_update = true ,
@@ -3638,16 +3681,16 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3638
3681
3639
3682
debug_assert_eq ! ( commitment_tx. trust( ) . txid( ) , commitment_txid) ;
3640
3683
3641
- Some ( commitment_tx)
3684
+ Some ( vec ! [ commitment_tx] )
3642
3685
} ,
3643
- & ChannelMonitorUpdateStep :: LatestCounterpartyCommitmentTX {
3644
- htlc_outputs : _, ref commitment_tx ,
3686
+ & ChannelMonitorUpdateStep :: LatestCounterpartyCommitmentTXs {
3687
+ htlc_data : _, ref commitment_txs ,
3645
3688
} => {
3646
- Some ( commitment_tx . clone ( ) )
3689
+ Some ( commitment_txs . clone ( ) )
3647
3690
} ,
3648
3691
_ => None ,
3649
3692
}
3650
- } ) . collect ( )
3693
+ } ) . flatten ( ) . collect ( )
3651
3694
}
3652
3695
3653
3696
fn sign_to_local_justice_tx (
0 commit comments