@@ -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
@@ -2776,7 +2778,8 @@ fn test_bump_fee_add_input_change_dust() {
2776
2778
2777
2779
let mut tx = psbt. extract_tx ( ) . expect ( "failed to extract tx" ) ;
2778
2780
for txin in & mut tx. input {
2779
- txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_WITNESS_SIZE ] ) ; // to get realistic weight
2781
+ txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_SIG_SIZE ] ) ; // sig (72)
2782
+ txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_PK_SIZE ] ) ; // pk (33)
2780
2783
}
2781
2784
let original_tx_weight = tx. weight ( ) ;
2782
2785
assert_eq ! ( tx. input. len( ) , 1 ) ;
@@ -2847,7 +2850,8 @@ fn test_bump_fee_force_add_input() {
2847
2850
let original_sent_received = wallet. sent_and_received ( & tx) ;
2848
2851
let txid = tx. compute_txid ( ) ;
2849
2852
for txin in & mut tx. input {
2850
- txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_WITNESS_SIZE ] ) ; // fake signature
2853
+ txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_SIG_SIZE ] ) ; // sig (72)
2854
+ txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_PK_SIZE ] ) ; // pk (33)
2851
2855
}
2852
2856
insert_tx ( & mut wallet, tx. clone ( ) ) ;
2853
2857
// the new fee_rate is low enough that just reducing the change would be fine, but we force
@@ -2910,7 +2914,8 @@ fn test_bump_fee_absolute_force_add_input() {
2910
2914
let txid = tx. compute_txid ( ) ;
2911
2915
// skip saving the new utxos, we know they can't be used anyways
2912
2916
for txin in & mut tx. input {
2913
- txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_WITNESS_SIZE ] ) ; // fake signature
2917
+ txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_SIG_SIZE ] ) ; // sig (72)
2918
+ txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_PK_SIZE ] ) ; // pk (33)
2914
2919
}
2915
2920
insert_tx ( & mut wallet, tx. clone ( ) ) ;
2916
2921
@@ -2980,7 +2985,8 @@ fn test_bump_fee_unconfirmed_inputs_only() {
2980
2985
let mut tx = psbt. extract_tx ( ) . expect ( "failed to extract tx" ) ;
2981
2986
let txid = tx. compute_txid ( ) ;
2982
2987
for txin in & mut tx. input {
2983
- txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_WITNESS_SIZE ] ) ; // fake signature
2988
+ txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_SIG_SIZE ] ) ; // sig (72)
2989
+ txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_PK_SIZE ] ) ; // pk (33)
2984
2990
}
2985
2991
insert_tx ( & mut wallet, tx) ;
2986
2992
let mut builder = wallet. build_fee_bump ( txid) . unwrap ( ) ;
@@ -3008,7 +3014,8 @@ fn test_bump_fee_unconfirmed_input() {
3008
3014
let mut tx = psbt. extract_tx ( ) . expect ( "failed to extract tx" ) ;
3009
3015
let txid = tx. compute_txid ( ) ;
3010
3016
for txin in & mut tx. input {
3011
- txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_WITNESS_SIZE ] ) ; // fake signature
3017
+ txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_SIG_SIZE ] ) ; // sig (72)
3018
+ txin. witness . push ( [ 0x00 ; P2WPKH_FAKE_PK_SIZE ] ) ; // pk (33)
3012
3019
}
3013
3020
insert_tx ( & mut wallet, tx) ;
3014
3021
0 commit comments