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