@@ -2648,7 +2648,11 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const CoinEligibil
26482648 if (effective_value > 0 ) {
26492649 group.fee += coin.m_input_bytes < 0 ? 0 : coin_selection_params.effective_fee .GetFee (coin.m_input_bytes );
26502650 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+ }
26522656 ++it;
26532657 } else {
26542658 it = group.Discard (coin);
@@ -3022,7 +3026,8 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
30223026
30233027 // BnB selector is the only selector used when this is true.
30243028 // 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
30263031 // Start with no fee and loop until there is enough fee
30273032 while (true )
30283033 {
@@ -3036,7 +3041,9 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
30363041 nValueToSelect += nFeeRet;
30373042
30383043 // 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+ }
30403047 for (const auto & recipient : vecSend)
30413048 {
30423049 CTxOut txout (recipient.nAmount , recipient.scriptPubKey );
@@ -3053,7 +3060,9 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
30533060 }
30543061 }
30553062 // 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+ }
30573066
30583067 if (IsDust (txout, chain ().relayDustFee ()))
30593068 {
0 commit comments