@@ -772,12 +772,14 @@ fn do_test_revoked_counterparty_commitment_balances(confirm_htlc_spend_first: bo
772
772
let funding_outpoint = OutPoint { txid : funding_tx. txid ( ) , index : 0 } ;
773
773
assert_eq ! ( funding_outpoint. to_channel_id( ) , chan_id) ;
774
774
775
- // We create four HTLCs for B to claim against A's revoked commitment transaction:
775
+ // We create five HTLCs for B to claim against A's revoked commitment transaction:
776
776
//
777
777
// (1) one for which A is the originator and B knows the preimage
778
778
// (2) one for which B is the originator where the HTLC has since timed-out
779
779
// (3) one for which B is the originator but where the HTLC has not yet timed-out
780
780
// (4) one dust HTLC which is lost in the channel closure
781
+ // (5) one that actually isn't in the revoked commitment transaction at all, but was added in
782
+ // later commitment transaction updates
781
783
//
782
784
// Though they could all be claimed in a single claim transaction, due to CLTV timeouts they
783
785
// are all currently claimed in separate transactions, which helps us test as we can claim
@@ -801,16 +803,8 @@ fn do_test_revoked_counterparty_commitment_balances(confirm_htlc_spend_first: bo
801
803
802
804
let chan_feerate = get_feerate ! ( nodes[ 0 ] , chan_id) as u64 ;
803
805
804
- {
805
- let mut feerate = chanmon_cfgs[ 0 ] . fee_estimator . sat_per_kw . lock ( ) . unwrap ( ) ;
806
- * feerate += 1 ;
807
- }
808
- nodes[ 0 ] . node . timer_tick_occurred ( ) ;
809
- check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
810
-
811
- let fee_update = get_htlc_update_msgs ! ( nodes[ 0 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
812
- nodes[ 1 ] . node . handle_update_fee ( & nodes[ 0 ] . node . get_our_node_id ( ) , & fee_update. update_fee . unwrap ( ) ) ;
813
- commitment_signed_dance ! ( nodes[ 1 ] , nodes[ 0 ] , fee_update. commitment_signed, false ) ;
806
+ let missing_htlc_cltv_timeout = nodes[ 0 ] . best_block_info ( ) . 1 + TEST_FINAL_CLTV + 1 ; // Note ChannelManager adds one to CLTV timeouts for safety
807
+ let missing_htlc_payment_hash = route_payment ( & nodes[ 1 ] , & [ & nodes[ 0 ] ] , 2_000_000 ) . 1 ;
814
808
815
809
nodes[ 1 ] . node . claim_funds ( claimed_payment_preimage) ;
816
810
expect_payment_claimed ! ( nodes[ 1 ] , claimed_payment_hash, 3_000_000 ) ;
@@ -836,7 +830,10 @@ fn do_test_revoked_counterparty_commitment_balances(confirm_htlc_spend_first: bo
836
830
// Prior to channel closure, B considers the preimage HTLC as its own, and otherwise only
837
831
// lists the two on-chain timeout-able HTLCs as claimable balances.
838
832
assert_eq ! ( sorted_vec( vec![ Balance :: ClaimableOnChannelClose {
839
- claimable_amount_satoshis: 100_000 - 5_000 - 4_000 - 3 + 3_000 ,
833
+ claimable_amount_satoshis: 100_000 - 5_000 - 4_000 - 3 - 2_000 + 3_000 ,
834
+ } , Balance :: MaybeClaimableHTLCAwaitingTimeout {
835
+ claimable_amount_satoshis: 2_000 ,
836
+ claimable_height: missing_htlc_cltv_timeout,
840
837
} , Balance :: MaybeClaimableHTLCAwaitingTimeout {
841
838
claimable_amount_satoshis: 4_000 ,
842
839
claimable_height: htlc_cltv_timeout,
@@ -955,7 +952,14 @@ fn do_test_revoked_counterparty_commitment_balances(confirm_htlc_spend_first: bo
955
952
956
953
connect_blocks ( & nodes[ 1 ] , 1 ) ;
957
954
test_spendable_output ( & nodes[ 1 ] , & as_revoked_txn[ 0 ] ) ;
958
- expect_payment_failed ! ( nodes[ 1 ] , dust_payment_hash, true ) ;
955
+
956
+ let mut payment_failed_events = nodes[ 1 ] . node . get_and_clear_pending_events ( ) ;
957
+ expect_payment_failed_conditions_event ( & nodes[ 1 ] , payment_failed_events. pop ( ) . unwrap ( ) ,
958
+ dust_payment_hash, true , PaymentFailedConditions :: new ( ) ) ;
959
+ expect_payment_failed_conditions_event ( & nodes[ 1 ] , payment_failed_events. pop ( ) . unwrap ( ) ,
960
+ missing_htlc_payment_hash, true , PaymentFailedConditions :: new ( ) ) ;
961
+ assert ! ( payment_failed_events. is_empty( ) ) ;
962
+
959
963
connect_blocks ( & nodes[ 1 ] , 1 ) ;
960
964
test_spendable_output ( & nodes[ 1 ] , & claim_txn[ if confirm_htlc_spend_first { 2 } else { 3 } ] ) ;
961
965
connect_blocks ( & nodes[ 1 ] , 1 ) ;
0 commit comments