Skip to content

Commit d26b6a8

Browse files
authored
Fix a couple of issues with PS fee calculations (#3077)
* Fix PS fee calculations in GUI Fixes the GUI fee estimation in Coin Control dialog when creating PS txes with the fSubtractFeeFromAmount option. * Add missing nChangePosInOut reset for PS txes
1 parent 40399fd commit d26b6a8

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/qt/coincontroldialog.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,15 +554,18 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
554554
if (nPayAmount > 0)
555555
{
556556
nChange = nAmount - nPayAmount;
557-
if (!CoinControlDialog::fSubtractFeeFromAmount)
558-
nChange -= nPayFee;
559557

560558
// PrivateSend Fee = overpay
561559
if(coinControl->fUsePrivateSend && nChange > 0)
562560
{
563-
nPayFee += nChange;
561+
nPayFee = std::max(nChange, nPayFee);
564562
nChange = 0;
563+
if (CoinControlDialog::fSubtractFeeFromAmount)
564+
nBytes -= 34; // we didn't detect lack of change above
565+
} else if (!CoinControlDialog::fSubtractFeeFromAmount) {
566+
nChange -= nPayFee;
565567
}
568+
566569
// Never create dust outputs; if we would, just add the dust to the fee.
567570
if (nChange > 0 && nChange < MIN_CHANGE)
568571
{

src/wallet/wallet.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3782,6 +3782,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
37823782
{
37833783
//over pay for denominated transactions
37843784
if (nCoinType == ONLY_DENOMINATED) {
3785+
nChangePosInOut = -1;
37853786
nFeeRet += nChange;
37863787
wtxNew.mapValue["DS"] = "1";
37873788
} else {

0 commit comments

Comments
 (0)