File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -3781,6 +3781,7 @@ pub(crate) mod test {
37813781 . del_utxo ( & txin. previous_output )
37823782 . unwrap ( ) ;
37833783 }
3784+ let original_tx_weight = tx. weight ( ) ;
37843785 original_details. transaction = Some ( tx) ;
37853786 wallet
37863787 . database
@@ -3789,7 +3790,20 @@ pub(crate) mod test {
37893790 . unwrap ( ) ;
37903791
37913792 let mut builder = wallet. build_fee_bump ( txid) . unwrap ( ) ;
3792- builder. fee_rate ( FeeRate :: from_sat_per_vb ( 141.0 ) ) ;
3793+ // We set a fee high enough that during rbf we are forced to add
3794+ // a new input and also that we have to remove the change
3795+ // that we had previously
3796+
3797+ // We calculate the new weight as:
3798+ // original weight
3799+ // + extra input weight: 160 WU = (32 (prevout) + 4 (vout) + 4 (nsequence)) * 4
3800+ // + input satisfaction weight: 112 WU = 106 (witness) + 2 (witness len) + (1 (script len)) * 4
3801+ // - change output weight: 124 WU = (8 (value) + 1 (script len) + 22 (script)) * 4
3802+ let new_tx_weight = original_tx_weight + 160 + 112 - 124 ;
3803+ // two inputs (50k, 25k) and one output (45k) - epsilon
3804+ // We use epsilon here to avoid asking for a slightly too high feerate
3805+ let fee_abs = 50_000 + 25_000 - 45_000 - 10 ;
3806+ builder. fee_rate ( FeeRate :: from_wu ( fee_abs, new_tx_weight) ) ;
37933807 let ( psbt, details) = builder. finish ( ) . unwrap ( ) ;
37943808
37953809 assert_eq ! (
You can’t perform that action at this time.
0 commit comments