@@ -7784,12 +7784,14 @@ fn test_bump_penalty_txn_on_revoked_htlcs() {
7784
7784
check_spends ! ( revoked_htlc_txn[ 0 ] , revoked_local_txn[ 0 ] ) ;
7785
7785
assert_eq ! ( revoked_htlc_txn[ 1 ] . input. len( ) , 1 ) ;
7786
7786
assert_eq ! ( revoked_htlc_txn[ 1 ] . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ;
7787
+ assert_eq ! ( revoked_htlc_txn[ 1 ] . output. len( ) , 1 ) ;
7787
7788
check_spends ! ( revoked_htlc_txn[ 1 ] , revoked_local_txn[ 0 ] ) ;
7788
7789
} else if revoked_htlc_txn[ 1 ] . input [ 0 ] . witness . last ( ) . unwrap ( ) . len ( ) == ACCEPTED_HTLC_SCRIPT_WEIGHT {
7789
7790
assert_eq ! ( revoked_htlc_txn[ 1 ] . input. len( ) , 1 ) ;
7790
7791
check_spends ! ( revoked_htlc_txn[ 1 ] , revoked_local_txn[ 0 ] ) ;
7791
7792
assert_eq ! ( revoked_htlc_txn[ 0 ] . input. len( ) , 1 ) ;
7792
7793
assert_eq ! ( revoked_htlc_txn[ 0 ] . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ;
7794
+ assert_eq ! ( revoked_htlc_txn[ 0 ] . output. len( ) , 1 ) ;
7793
7795
check_spends ! ( revoked_htlc_txn[ 0 ] , revoked_local_txn[ 0 ] ) ;
7794
7796
}
7795
7797
@@ -7806,18 +7808,43 @@ fn test_bump_penalty_txn_on_revoked_htlcs() {
7806
7808
let mut node_txn = nodes[ 0 ] . tx_broadcaster . txn_broadcasted . lock ( ) . unwrap ( ) ;
7807
7809
assert_eq ! ( node_txn. len( ) , 5 ) ; // 3 penalty txn on revoked commitment tx + A commitment tx + 1 penalty tnx on revoked HTLC txn
7808
7810
// Verify claim tx are spending revoked HTLC txn
7811
+
7812
+ // node_txn 1-3 each spend a separate revoked output from revoked_local_txn[0]
7813
+ // Note that node_txn[0] and node_txn[1] are bogus - they double spend the revoked_htlc_txn
7814
+ // which are included in the same block (they are broadcasted just because and in case of
7815
+ // reorgs).
7816
+ assert_eq ! ( node_txn[ 0 ] . input. len( ) , 1 ) ;
7817
+ check_spends ! ( node_txn[ 0 ] , revoked_local_txn[ 0 ] ) ;
7818
+ assert_eq ! ( node_txn[ 1 ] . input. len( ) , 1 ) ;
7819
+ check_spends ! ( node_txn[ 1 ] , revoked_local_txn[ 0 ] ) ;
7820
+ assert_eq ! ( node_txn[ 2 ] . input. len( ) , 1 ) ;
7821
+ check_spends ! ( node_txn[ 2 ] , revoked_local_txn[ 0 ] ) ;
7822
+
7823
+ assert_ne ! ( node_txn[ 0 ] . input[ 0 ] . previous_output, node_txn[ 1 ] . input[ 0 ] . previous_output) ;
7824
+ assert_ne ! ( node_txn[ 0 ] . input[ 0 ] . previous_output, node_txn[ 2 ] . input[ 0 ] . previous_output) ;
7825
+ assert_ne ! ( node_txn[ 1 ] . input[ 0 ] . previous_output, node_txn[ 2 ] . input[ 0 ] . previous_output) ;
7826
+
7827
+ assert_eq ! ( node_txn[ 0 ] . input[ 0 ] . previous_output, revoked_htlc_txn[ 0 ] . input[ 0 ] . previous_output) ;
7828
+ assert_eq ! ( node_txn[ 1 ] . input[ 0 ] . previous_output, revoked_htlc_txn[ 1 ] . input[ 0 ] . previous_output) ;
7829
+
7830
+ // node_txn[3] is the local commitment tx broadcast just because (and somewhat in case of
7831
+ // reorgs)
7832
+ check_spends ! ( node_txn[ 3 ] , chan. 3 ) ;
7833
+
7834
+ // node_txn[4] spends the revoked outputs from the revoked_htlc_txn (which only have one
7835
+ // output, checked above).
7809
7836
assert_eq ! ( node_txn[ 4 ] . input. len( ) , 2 ) ;
7810
7837
assert_eq ! ( node_txn[ 4 ] . output. len( ) , 1 ) ;
7811
7838
check_spends ! ( node_txn[ 4 ] , revoked_htlc_txn[ 0 ] , revoked_htlc_txn[ 1 ] ) ;
7812
7839
first = node_txn[ 4 ] . txid ( ) ;
7813
7840
// Store both feerates for later comparison
7814
7841
let fee_1 = revoked_htlc_txn[ 0 ] . output [ 0 ] . value + revoked_htlc_txn[ 1 ] . output [ 0 ] . value - node_txn[ 4 ] . output [ 0 ] . value ;
7815
7842
feerate_1 = fee_1 * 1000 / node_txn[ 4 ] . get_weight ( ) as u64 ;
7816
- penalty_txn = vec ! [ node_txn[ 0 ] . clone ( ) , node_txn [ 1 ] . clone ( ) , node_txn [ 2 ] . clone( ) ] ;
7843
+ penalty_txn = vec ! [ node_txn[ 2 ] . clone( ) ] ;
7817
7844
node_txn. clear ( ) ;
7818
7845
}
7819
7846
7820
- // Connect three more block to see if bumped penalty are issued for HTLC txn
7847
+ // Connect one more block to see if bumped penalty are issued for HTLC txn
7821
7848
let header_130 = BlockHeader { version : 0x20000000 , prev_blockhash : header_129. block_hash ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
7822
7849
nodes[ 0 ] . block_notifier . block_connected ( & Block { header : header_130, txdata : penalty_txn } , 130 ) ;
7823
7850
{
@@ -7826,6 +7853,11 @@ fn test_bump_penalty_txn_on_revoked_htlcs() {
7826
7853
7827
7854
check_spends ! ( node_txn[ 0 ] , revoked_local_txn[ 0 ] ) ;
7828
7855
check_spends ! ( node_txn[ 1 ] , revoked_local_txn[ 0 ] ) ;
7856
+ // Note that these are both bogus - they spend outputs already claimed in block 129:
7857
+ assert ! ( ( node_txn[ 0 ] . input[ 0 ] . previous_output == revoked_htlc_txn[ 0 ] . input[ 0 ] . previous_output &&
7858
+ node_txn[ 1 ] . input[ 0 ] . previous_output == revoked_htlc_txn[ 1 ] . input[ 0 ] . previous_output) ||
7859
+ ( node_txn[ 0 ] . input[ 0 ] . previous_output == revoked_htlc_txn[ 1 ] . input[ 0 ] . previous_output &&
7860
+ node_txn[ 1 ] . input[ 0 ] . previous_output == revoked_htlc_txn[ 0 ] . input[ 0 ] . previous_output) ) ;
7829
7861
7830
7862
node_txn. clear ( ) ;
7831
7863
} ;
0 commit comments