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