@@ -3355,6 +3355,7 @@ mod tests {
3355
3355
use ln:: channel:: { COMMITMENT_TX_BASE_WEIGHT , COMMITMENT_TX_WEIGHT_PER_HTLC } ;
3356
3356
use ln:: channelmanager:: { ChannelManager , ChannelManagerReadArgs , OnionKeys , PaymentFailReason , RAACommitmentOrder } ;
3357
3357
use ln:: channelmonitor:: { ChannelMonitor , ChannelMonitorUpdateErr , CLTV_CLAIM_BUFFER , HTLC_FAIL_TIMEOUT_BLOCKS , ManyChannelMonitor } ;
3358
+ use ln:: channel:: { ACCEPTED_HTLC_SCRIPT_WEIGHT , OFFERED_HTLC_SCRIPT_WEIGHT } ;
3358
3359
use ln:: router:: { Route , RouteHop , Router } ;
3359
3360
use ln:: msgs;
3360
3361
use ln:: msgs:: { ChannelMessageHandler , RoutingMessageHandler } ;
@@ -5887,7 +5888,7 @@ mod tests {
5887
5888
assert_eq ! ( revoked_local_txn[ 0 ] . output. len( ) , 2 ) ; // Only HTLC and output back to 0 are present
5888
5889
assert_eq ! ( revoked_local_txn[ 1 ] . input. len( ) , 1 ) ;
5889
5890
assert_eq ! ( revoked_local_txn[ 1 ] . input[ 0 ] . previous_output. txid, revoked_local_txn[ 0 ] . txid( ) ) ;
5890
- assert_eq ! ( revoked_local_txn[ 1 ] . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , 133 ) ; // HTLC-Timeout
5891
+ assert_eq ! ( revoked_local_txn[ 1 ] . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ; // HTLC-Timeout
5891
5892
// Revoke the old state
5892
5893
claim_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] ) [ ..] , payment_preimage_3) ;
5893
5894
@@ -6006,7 +6007,7 @@ mod tests {
6006
6007
assert_eq ! ( revoked_local_txn[ 0 ] . input[ 0 ] . previous_output. txid, chan_1. 3 . txid( ) ) ;
6007
6008
assert_eq ! ( revoked_local_txn[ 1 ] . input. len( ) , 1 ) ;
6008
6009
assert_eq ! ( revoked_local_txn[ 1 ] . input[ 0 ] . previous_output. txid, revoked_local_txn[ 0 ] . txid( ) ) ;
6009
- assert_eq ! ( revoked_local_txn[ 1 ] . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , 133 ) ; // HTLC-Timeout
6010
+ assert_eq ! ( revoked_local_txn[ 1 ] . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ; // HTLC-Timeout
6010
6011
check_spends ! ( revoked_local_txn[ 1 ] , revoked_local_txn[ 0 ] . clone( ) ) ;
6011
6012
6012
6013
//Revoke the old state
@@ -6040,16 +6041,16 @@ mod tests {
6040
6041
witness_lens. insert ( node_txn[ 0 ] . input [ 2 ] . witness . last ( ) . unwrap ( ) . len ( ) ) ;
6041
6042
assert_eq ! ( witness_lens. len( ) , 3 ) ;
6042
6043
assert_eq ! ( * witness_lens. iter( ) . skip( 0 ) . next( ) . unwrap( ) , 77 ) ; // revoked to_local
6043
- assert_eq ! ( * witness_lens. iter( ) . skip( 1 ) . next( ) . unwrap( ) , 133 ) ; // revoked offered HTLC
6044
- assert_eq ! ( * witness_lens. iter( ) . skip( 2 ) . next( ) . unwrap( ) , 138 ) ; // revoked received HTLC
6044
+ assert_eq ! ( * witness_lens. iter( ) . skip( 1 ) . next( ) . unwrap( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ; // revoked offered HTLC
6045
+ assert_eq ! ( * witness_lens. iter( ) . skip( 2 ) . next( ) . unwrap( ) , ACCEPTED_HTLC_SCRIPT_WEIGHT ) ; // revoked received HTLC
6045
6046
6046
6047
// Next nodes[1] broadcasts its current local tx state:
6047
6048
assert_eq ! ( node_txn[ 1 ] . input. len( ) , 1 ) ;
6048
6049
assert_eq ! ( node_txn[ 1 ] . input[ 0 ] . previous_output. txid, chan_1. 3 . txid( ) ) ; //Spending funding tx unique txouput, tx broadcasted by ChannelManager
6049
6050
6050
6051
assert_eq ! ( node_txn[ 2 ] . input. len( ) , 1 ) ;
6051
6052
let witness_script = node_txn[ 2 ] . clone ( ) . input [ 0 ] . witness . pop ( ) . unwrap ( ) ;
6052
- assert_eq ! ( witness_script. len( ) , 133 ) ; //Spending an offered htlc output
6053
+ assert_eq ! ( witness_script. len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ; //Spending an offered htlc output
6053
6054
assert_eq ! ( node_txn[ 2 ] . input[ 0 ] . previous_output. txid, node_txn[ 1 ] . txid( ) ) ;
6054
6055
assert_ne ! ( node_txn[ 2 ] . input[ 0 ] . previous_output. txid, node_txn[ 0 ] . input[ 0 ] . previous_output. txid) ;
6055
6056
assert_ne ! ( node_txn[ 2 ] . input[ 0 ] . previous_output. txid, node_txn[ 0 ] . input[ 1 ] . previous_output. txid) ;
@@ -6120,15 +6121,15 @@ mod tests {
6120
6121
witness_lens. insert ( node_txn[ 2 ] . input [ 0 ] . witness . last ( ) . unwrap ( ) . len ( ) ) ;
6121
6122
assert_eq ! ( witness_lens. len( ) , 3 ) ;
6122
6123
assert_eq ! ( * witness_lens. iter( ) . skip( 0 ) . next( ) . unwrap( ) , 77 ) ; // revoked to_local
6123
- assert_eq ! ( * witness_lens. iter( ) . skip( 1 ) . next( ) . unwrap( ) , 133 ) ; // revoked offered HTLC
6124
- assert_eq ! ( * witness_lens. iter( ) . skip( 2 ) . next( ) . unwrap( ) , 138 ) ; // revoked received HTLC
6124
+ assert_eq ! ( * witness_lens. iter( ) . skip( 1 ) . next( ) . unwrap( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ; // revoked offered HTLC
6125
+ assert_eq ! ( * witness_lens. iter( ) . skip( 2 ) . next( ) . unwrap( ) , ACCEPTED_HTLC_SCRIPT_WEIGHT ) ; // revoked received HTLC
6125
6126
6126
6127
assert_eq ! ( node_txn[ 3 ] . input. len( ) , 1 ) ;
6127
6128
check_spends ! ( node_txn[ 3 ] , chan_1. 3 . clone( ) ) ;
6128
6129
6129
6130
assert_eq ! ( node_txn[ 4 ] . input. len( ) , 1 ) ;
6130
6131
let witness_script = node_txn[ 4 ] . input [ 0 ] . witness . last ( ) . unwrap ( ) ;
6131
- assert_eq ! ( witness_script. len( ) , 133 ) ; //Spending an offered htlc output
6132
+ assert_eq ! ( witness_script. len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ; //Spending an offered htlc output
6132
6133
assert_eq ! ( node_txn[ 4 ] . input[ 0 ] . previous_output. txid, node_txn[ 3 ] . txid( ) ) ;
6133
6134
assert_ne ! ( node_txn[ 4 ] . input[ 0 ] . previous_output. txid, node_txn[ 0 ] . input[ 0 ] . previous_output. txid) ;
6134
6135
assert_ne ! ( node_txn[ 4 ] . input[ 0 ] . previous_output. txid, node_txn[ 1 ] . input[ 0 ] . previous_output. txid) ;
@@ -8408,7 +8409,7 @@ mod tests {
8408
8409
let node_txn = nodes[ 1 ] . tx_broadcaster . txn_broadcasted . lock ( ) . unwrap ( ) ; // ChannelManager : 1 (local commitment tx), ChannelMonitor: 2 (1 preimage tx) * 2 (block-rescan)
8409
8410
check_spends ! ( node_txn[ 0 ] , commitment_tx[ 0 ] . clone( ) ) ;
8410
8411
assert_eq ! ( node_txn[ 0 ] , node_txn[ 2 ] ) ;
8411
- assert_eq ! ( node_txn[ 0 ] . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , 133 ) ;
8412
+ assert_eq ! ( node_txn[ 0 ] . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ;
8412
8413
check_spends ! ( node_txn[ 1 ] , chan_1. 3 . clone( ) ) ;
8413
8414
8414
8415
let spend_txn = check_spendable_outputs ! ( nodes[ 1 ] , 1 ) ; // , 0, 0, 1, 1);
@@ -8476,7 +8477,7 @@ mod tests {
8476
8477
assert_eq ! ( revoked_htlc_txn. len( ) , 3 ) ;
8477
8478
assert_eq ! ( revoked_htlc_txn[ 0 ] , revoked_htlc_txn[ 2 ] ) ;
8478
8479
assert_eq ! ( revoked_htlc_txn[ 0 ] . input. len( ) , 1 ) ;
8479
- assert_eq ! ( revoked_htlc_txn[ 0 ] . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , 133 ) ;
8480
+ assert_eq ! ( revoked_htlc_txn[ 0 ] . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ;
8480
8481
check_spends ! ( revoked_htlc_txn[ 0 ] , revoked_local_txn[ 0 ] . clone( ) ) ;
8481
8482
check_spends ! ( revoked_htlc_txn[ 1 ] , chan_1. 3 . clone( ) ) ;
8482
8483
@@ -8528,7 +8529,7 @@ mod tests {
8528
8529
assert_eq ! ( revoked_htlc_txn. len( ) , 3 ) ;
8529
8530
assert_eq ! ( revoked_htlc_txn[ 0 ] , revoked_htlc_txn[ 2 ] ) ;
8530
8531
assert_eq ! ( revoked_htlc_txn[ 0 ] . input. len( ) , 1 ) ;
8531
- assert_eq ! ( revoked_htlc_txn[ 0 ] . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , 138 ) ;
8532
+ assert_eq ! ( revoked_htlc_txn[ 0 ] . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , ACCEPTED_HTLC_SCRIPT_WEIGHT ) ;
8532
8533
check_spends ! ( revoked_htlc_txn[ 0 ] , revoked_local_txn[ 0 ] . clone( ) ) ;
8533
8534
8534
8535
// A will generate justice tx from B's revoked commitment/HTLC tx
@@ -8582,7 +8583,7 @@ mod tests {
8582
8583
}
8583
8584
let node_txn = nodes[ 1 ] . tx_broadcaster . txn_broadcasted . lock ( ) . unwrap ( ) ;
8584
8585
assert_eq ! ( node_txn[ 0 ] . input. len( ) , 1 ) ;
8585
- assert_eq ! ( node_txn[ 0 ] . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , 138 ) ;
8586
+ assert_eq ! ( node_txn[ 0 ] . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , ACCEPTED_HTLC_SCRIPT_WEIGHT ) ;
8586
8587
check_spends ! ( node_txn[ 0 ] , local_txn[ 0 ] . clone( ) ) ;
8587
8588
8588
8589
// Verify that B is able to spend its own HTLC-Success tx thanks to spendable output event given back by its ChannelMonitor
@@ -8614,7 +8615,7 @@ mod tests {
8614
8615
}
8615
8616
let node_txn = nodes[ 0 ] . tx_broadcaster . txn_broadcasted . lock ( ) . unwrap ( ) ;
8616
8617
assert_eq ! ( node_txn[ 0 ] . input. len( ) , 1 ) ;
8617
- assert_eq ! ( node_txn[ 0 ] . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , 133 ) ;
8618
+ assert_eq ! ( node_txn[ 0 ] . input[ 0 ] . witness. last( ) . unwrap( ) . len( ) , OFFERED_HTLC_SCRIPT_WEIGHT ) ;
8618
8619
check_spends ! ( node_txn[ 0 ] , local_txn[ 0 ] . clone( ) ) ;
8619
8620
8620
8621
// Verify that A is able to spend its own HTLC-Timeout tx thanks to spendable output event given back by its ChannelMonitor
0 commit comments