diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2014-04-10 14:14:18 -0400 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2014-06-06 10:34:18 -0400 |
commit | c6cb21d17ab8097b6a425d37e48c955fbb0e9f0c (patch) | |
tree | 297b740beca0274be8a85d8c355acecafecbbc3e /src/qt/optionsmodel.cpp | |
parent | 345cb52e8ba878ca3e2590d5792b733ec11a1f0d (diff) |
Type-safe CFeeRate class
Use CFeeRate instead of an int64_t for quantities that are
fee-per-size.
Helps prevent unit-conversion mismatches between the wallet,
relaying, and mining code.
Diffstat (limited to 'src/qt/optionsmodel.cpp')
-rw-r--r-- | src/qt/optionsmodel.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 051098315d..f3a5f37bb3 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -94,7 +94,7 @@ void OptionsModel::Init() #ifdef ENABLE_WALLET if (!settings.contains("nTransactionFee")) settings.setValue("nTransactionFee", (qint64)DEFAULT_TRANSACTION_FEE); - nTransactionFee = settings.value("nTransactionFee").toLongLong(); // if -paytxfee is set, this will be overridden later in init.cpp + payTxFee = CFeeRate(settings.value("nTransactionFee").toLongLong()); // if -paytxfee is set, this will be overridden later in init.cpp if (mapArgs.count("-paytxfee")) addOverriddenOption("-paytxfee"); @@ -187,15 +187,16 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const return settings.value("nSocksVersion", 5); #ifdef ENABLE_WALLET - case Fee: - // Attention: Init() is called before nTransactionFee is set in AppInit2()! + case Fee: { + // Attention: Init() is called before payTxFee is set in AppInit2()! // To ensure we can change the fee on-the-fly update our QSetting when // opening OptionsDialog, which queries Fee via the mapper. - if (nTransactionFee != settings.value("nTransactionFee").toLongLong()) - settings.setValue("nTransactionFee", (qint64)nTransactionFee); - // Todo: Consider to revert back to use just nTransactionFee here, if we don't want + if (!(payTxFee == CFeeRate(settings.value("nTransactionFee").toLongLong(), 1000))) + settings.setValue("nTransactionFee", (qint64)payTxFee.GetFeePerK()); + // Todo: Consider to revert back to use just payTxFee here, if we don't want // -paytxfee to update our QSettings! return settings.value("nTransactionFee"); + } case SpendZeroConfChange: return settings.value("bSpendZeroConfChange"); #endif @@ -284,12 +285,14 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in } break; #ifdef ENABLE_WALLET - case Fee: // core option - can be changed on-the-fly + case Fee: { // core option - can be changed on-the-fly // Todo: Add is valid check and warn via message, if not - nTransactionFee = value.toLongLong(); - settings.setValue("nTransactionFee", (qint64)nTransactionFee); + qint64 nTransactionFee = value.toLongLong(); + payTxFee = CFeeRate(nTransactionFee, 1000); + settings.setValue("nTransactionFee", nTransactionFee); emit transactionFeeChanged(nTransactionFee); break; + } case SpendZeroConfChange: if (settings.value("bSpendZeroConfChange") != value) { settings.setValue("bSpendZeroConfChange", value); |