@@ -2648,7 +2648,11 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const CoinEligibil
2648
2648
if (effective_value > 0 ) {
2649
2649
group.fee += coin.m_input_bytes < 0 ? 0 : coin_selection_params.effective_fee .GetFee (coin.m_input_bytes );
2650
2650
group.long_term_fee += coin.m_input_bytes < 0 ? 0 : long_term_feerate.GetFee (coin.m_input_bytes );
2651
- group.effective_value += effective_value;
2651
+ if (coin_selection_params.m_subtract_fee_outputs ) {
2652
+ group.effective_value += coin.txout .nValue ;
2653
+ } else {
2654
+ group.effective_value += effective_value;
2655
+ }
2652
2656
++it;
2653
2657
} else {
2654
2658
it = group.Discard (coin);
@@ -3022,7 +3026,8 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
3022
3026
3023
3027
// BnB selector is the only selector used when this is true.
3024
3028
// That should only happen on the first pass through the loop.
3025
- coin_selection_params.use_bnb = nSubtractFeeFromAmount == 0 ; // If we are doing subtract fee from recipient, then don't use BnB
3029
+ coin_selection_params.use_bnb = true ;
3030
+ coin_selection_params.m_subtract_fee_outputs = nSubtractFeeFromAmount != 0 ; // If we are doing subtract fee from recipient, don't use effective values
3026
3031
// Start with no fee and loop until there is enough fee
3027
3032
while (true )
3028
3033
{
@@ -3036,7 +3041,9 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
3036
3041
nValueToSelect += nFeeRet;
3037
3042
3038
3043
// vouts to the payees
3039
- coin_selection_params.tx_noinputs_size = 11 ; // Static vsize overhead + outputs vsize. 4 nVersion, 4 nLocktime, 1 input count, 1 output count, 1 witness overhead (dummy, flag, stack size)
3044
+ if (!coin_selection_params.m_subtract_fee_outputs ) {
3045
+ coin_selection_params.tx_noinputs_size = 11 ; // Static vsize overhead + outputs vsize. 4 nVersion, 4 nLocktime, 1 input count, 1 output count, 1 witness overhead (dummy, flag, stack size)
3046
+ }
3040
3047
for (const auto & recipient : vecSend)
3041
3048
{
3042
3049
CTxOut txout (recipient.nAmount , recipient.scriptPubKey );
@@ -3053,7 +3060,9 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
3053
3060
}
3054
3061
}
3055
3062
// Include the fee cost for outputs. Note this is only used for BnB right now
3056
- coin_selection_params.tx_noinputs_size += ::GetSerializeSize (txout, PROTOCOL_VERSION);
3063
+ if (!coin_selection_params.m_subtract_fee_outputs ) {
3064
+ coin_selection_params.tx_noinputs_size += ::GetSerializeSize (txout, PROTOCOL_VERSION);
3065
+ }
3057
3066
3058
3067
if (IsDust (txout, chain ().relayDustFee ()))
3059
3068
{
0 commit comments