@@ -36,12 +36,13 @@ fn parse_descriptor(s: &str) -> (Descriptor<DescriptorPublicKey>, KeyMap) {
36
36
. expect ( "failed to parse descriptor" )
37
37
}
38
38
39
- // The satisfaction size of a P2WPKH is 108 WU =
40
- // 1 (elements in witness) + 1 (OP_PUSH) + 33 (pubkey) + 1 (OP_PUSH) + 72 (signature + sighash).
41
- // TODO: tests won't pass with 108 but will with 106.
42
- const P2WPKH_FAKE_WITNESS_SIZE : usize = 106 ;
39
+ /// The satisfaction size of P2WPKH is 108 WU =
40
+ /// 1 (elements in witness) + 1 (size)
41
+ /// + 72 (signature + sighash) + 1 (size) + 33 (pubkey).
42
+ const P2WPKH_FAKE_PK_SIZE : usize = 72 ;
43
+ const P2WPKH_FAKE_SIG_SIZE : usize = 33 ;
43
44
44
- /// The satisfaction size of a P2PKH is 107 WU =
45
+ /// The satisfaction size of P2PKH is 107 =
45
46
/// 1 (OP_PUSH) + 72 (signature + sighash) + 1 (OP_PUSH) + 33 (pubkey).
46
47
const P2PKH_FAKE_SCRIPT_SIG_SIZE : usize = 107 ;
47
48
@@ -484,7 +485,8 @@ macro_rules! assert_fee_rate {
484
485
$(
485
486
$( $add_signature ) *
486
487
for txin in & mut tx. input {
487
- txin. witness. push( [ 0x00 ; P2WPKH_FAKE_WITNESS_SIZE ] ) ; // fake signature
488
+ txin. witness. push( [ 0x00 ; P2WPKH_FAKE_SIG_SIZE ] ) ; // sig (72)
489
+ txin. witness. push( [ 0x00 ; P2WPKH_FAKE_PK_SIZE ] ) ; // pk (33)
488
490
}
489
491
) *
490
492
@@ -2773,7 +2775,8 @@ fn test_bump_fee_add_input_change_dust() {
2773
2775
2774
2776
let mut tx = psbt. extract_tx ( ) . expect ( "failed to extract tx" ) ;
2775
2777
for txin in & mut tx. input {
2776
- txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_WITNESS_SIZE ] ) ; // to get realistic weight
2778
+ txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_SIG_SIZE ] ) ; // sig (72)
2779
+ txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_PK_SIZE ] ) ; // pk (33)
2777
2780
}
2778
2781
let original_tx_weight = tx. weight ( ) ;
2779
2782
assert_eq ! ( tx. input. len( ) , 1 ) ;
@@ -2844,7 +2847,8 @@ fn test_bump_fee_force_add_input() {
2844
2847
let original_sent_received = wallet. sent_and_received ( & tx) ;
2845
2848
let txid = tx. compute_txid ( ) ;
2846
2849
for txin in & mut tx. input {
2847
- txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_WITNESS_SIZE ] ) ; // fake signature
2850
+ txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_SIG_SIZE ] ) ; // sig (72)
2851
+ txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_PK_SIZE ] ) ; // pk (33)
2848
2852
}
2849
2853
insert_tx ( & mut wallet, tx. clone ( ) ) ;
2850
2854
// the new fee_rate is low enough that just reducing the change would be fine, but we force
@@ -2907,7 +2911,8 @@ fn test_bump_fee_absolute_force_add_input() {
2907
2911
let txid = tx. compute_txid ( ) ;
2908
2912
// skip saving the new utxos, we know they can't be used anyways
2909
2913
for txin in & mut tx. input {
2910
- txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_WITNESS_SIZE ] ) ; // fake signature
2914
+ txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_SIG_SIZE ] ) ; // sig (72)
2915
+ txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_PK_SIZE ] ) ; // pk (33)
2911
2916
}
2912
2917
insert_tx ( & mut wallet, tx. clone ( ) ) ;
2913
2918
@@ -2977,7 +2982,8 @@ fn test_bump_fee_unconfirmed_inputs_only() {
2977
2982
let mut tx = psbt. extract_tx ( ) . expect ( "failed to extract tx" ) ;
2978
2983
let txid = tx. compute_txid ( ) ;
2979
2984
for txin in & mut tx. input {
2980
- txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_WITNESS_SIZE ] ) ; // fake signature
2985
+ txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_SIG_SIZE ] ) ; // sig (72)
2986
+ txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_PK_SIZE ] ) ; // pk (33)
2981
2987
}
2982
2988
insert_tx ( & mut wallet, tx) ;
2983
2989
let mut builder = wallet. build_fee_bump ( txid) . unwrap ( ) ;
@@ -3005,7 +3011,8 @@ fn test_bump_fee_unconfirmed_input() {
3005
3011
let mut tx = psbt. extract_tx ( ) . expect ( "failed to extract tx" ) ;
3006
3012
let txid = tx. compute_txid ( ) ;
3007
3013
for txin in & mut tx. input {
3008
- txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_WITNESS_SIZE ] ) ; // fake signature
3014
+ txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_SIG_SIZE ] ) ; // sig (72)
3015
+ txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_PK_SIZE ] ) ; // pk (33)
3009
3016
}
3010
3017
insert_tx ( & mut wallet, tx) ;
3011
3018
0 commit comments