Changeset View
Changeset View
Standalone View
Standalone View
src/qt/coincontroldialog.cpp
// Copyright (c) 2011-2016 The Bitcoin Core developers | // Copyright (c) 2011-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include "coincontroldialog.h" | #include "coincontroldialog.h" | ||||
#include "ui_coincontroldialog.h" | #include "ui_coincontroldialog.h" | ||||
#include "addresstablemodel.h" | #include "addresstablemodel.h" | ||||
#include "bitcoinunits.h" | #include "bitcoinunits.h" | ||||
#include "config.h" | |||||
#include "guiutil.h" | #include "guiutil.h" | ||||
#include "optionsmodel.h" | #include "optionsmodel.h" | ||||
#include "platformstyle.h" | #include "platformstyle.h" | ||||
#include "txmempool.h" | #include "txmempool.h" | ||||
#include "walletmodel.h" | #include "walletmodel.h" | ||||
#include "dstencode.h" | #include "dstencode.h" | ||||
#include "init.h" | #include "init.h" | ||||
▲ Show 20 Lines • Show All 490 Lines • ▼ Show 20 Lines | for (const COutput &out : vOutputs) { | ||||
CKeyID *keyid = boost::get<CKeyID>(&address); | CKeyID *keyid = boost::get<CKeyID>(&address); | ||||
if (keyid && model->getPubKey(*keyid, pubkey)) { | if (keyid && model->getPubKey(*keyid, pubkey)) { | ||||
nBytesInputs += (pubkey.IsCompressed() ? 148 : 180); | nBytesInputs += (pubkey.IsCompressed() ? 148 : 180); | ||||
if (!pubkey.IsCompressed()) nQuantityUncompressed++; | if (!pubkey.IsCompressed()) nQuantityUncompressed++; | ||||
} else { | } else { | ||||
// in all error cases, simply assume 148 here | // in all error cases, simply assume 148 here | ||||
nBytesInputs += 148; | nBytesInputs += 148; | ||||
} | } | ||||
} else | } else { | ||||
nBytesInputs += 148; | nBytesInputs += 148; | ||||
} | } | ||||
} | |||||
// calculation | // calculation | ||||
if (nQuantity > 0) { | if (nQuantity > 0) { | ||||
// Bytes | |||||
// always assume +1 output for change here | // always assume +1 output for change here | ||||
nBytes = nBytesInputs + ((CoinControlDialog::payAmounts.size() > 0 | uint64_t txOuts = (CoinControlDialog::payAmounts.size() > 0 | ||||
? CoinControlDialog::payAmounts.size() + 1 | ? CoinControlDialog::payAmounts.size() + 1 | ||||
: 2) * | : 2); | ||||
34) + | // Bytes | ||||
10; | nBytes = nBytesInputs + txOuts * 34 + 10; | ||||
// in the subtract fee from amount case, we can tell if zero change | // in the subtract fee from amount case, we can tell if zero change | ||||
// already and subtract the bytes, so that fee calculation afterwards is | // already and subtract the bytes, so that fee calculation afterwards is | ||||
// accurate | // accurate | ||||
if (CoinControlDialog::fSubtractFeeFromAmount) { | if (CoinControlDialog::fSubtractFeeFromAmount) { | ||||
if (nAmount - nPayAmount == Amount(0)) { | if (nAmount - nPayAmount == Amount(0)) { | ||||
nBytes -= 34; | nBytes -= 34; | ||||
} | } | ||||
} | } | ||||
// Fee | // Fee | ||||
nPayFee = CWallet::GetMinimumFee(nBytes, nTxConfirmTarget, mempool); | const Config &config = GetConfig(); | ||||
nPayFee = CWallet::GetMinimumFee(config, nBytes, nQuantity - txOuts, | |||||
nTxConfirmTarget, mempool); | |||||
if (nPayFee > Amount(0) && coinControl->nMinimumTotalFee > nPayFee) { | if (nPayFee > Amount(0) && coinControl->nMinimumTotalFee > nPayFee) { | ||||
nPayFee = coinControl->nMinimumTotalFee; | nPayFee = coinControl->nMinimumTotalFee; | ||||
} | } | ||||
// Allow free? (require at least hard-coded threshold and default to | // Allow free? (require at least hard-coded threshold and default to | ||||
// that if no estimate) | // that if no estimate) | ||||
double mempoolEstimatePriority = | double mempoolEstimatePriority = | ||||
mempool.estimateSmartPriority(nTxConfirmTarget); | mempool.estimateSmartPriority(nTxConfirmTarget); | ||||
▲ Show 20 Lines • Show All 302 Lines • Show Last 20 Lines |