aboutsummaryrefslogtreecommitdiff
path: root/src/qt
diff options
context:
space:
mode:
Diffstat (limited to 'src/qt')
-rw-r--r--src/qt/addresstablemodel.cpp4
-rw-r--r--src/qt/askpassphrasedialog.cpp2
-rw-r--r--src/qt/bitcoin.cpp2
-rw-r--r--src/qt/bitcoingui.cpp20
-rw-r--r--src/qt/bitcoingui.h6
-rw-r--r--src/qt/clientmodel.cpp29
-rw-r--r--src/qt/clientmodel.h8
-rw-r--r--src/qt/coincontroldialog.cpp25
-rw-r--r--src/qt/coincontroldialog.h1
-rw-r--r--src/qt/forms/sendcoinsdialog.ui20
-rw-r--r--src/qt/forms/sendcoinsentry.ui16
-rw-r--r--src/qt/guiutil.cpp53
-rw-r--r--src/qt/macdockiconhandler.h9
-rw-r--r--src/qt/macdockiconhandler.mm61
-rw-r--r--src/qt/optionsdialog.cpp4
-rw-r--r--src/qt/optionsmodel.cpp4
-rw-r--r--src/qt/paymentrequestplus.cpp1
-rw-r--r--src/qt/paymentrequestplus.h2
-rw-r--r--src/qt/paymentserver.cpp4
-rw-r--r--src/qt/rpcconsole.cpp10
-rw-r--r--src/qt/rpcconsole.h4
-rw-r--r--src/qt/sendcoinsdialog.cpp73
-rw-r--r--src/qt/sendcoinsentry.cpp6
-rw-r--r--src/qt/sendcoinsentry.h1
-rw-r--r--src/qt/signverifymessagedialog.cpp3
-rw-r--r--src/qt/splashscreen.cpp2
-rw-r--r--src/qt/transactiondesc.cpp4
-rw-r--r--src/qt/transactionrecord.cpp5
-rw-r--r--src/qt/transactiontablemodel.cpp2
-rw-r--r--src/qt/utilitydialog.cpp80
-rw-r--r--src/qt/walletmodel.cpp28
-rw-r--r--src/qt/walletmodel.h8
-rw-r--r--src/qt/walletmodeltransaction.cpp34
-rw-r--r--src/qt/walletmodeltransaction.h4
34 files changed, 305 insertions, 230 deletions
diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp
index 162ecdba4e..8e20836c65 100644
--- a/src/qt/addresstablemodel.cpp
+++ b/src/qt/addresstablemodel.cpp
@@ -8,7 +8,9 @@
#include "walletmodel.h"
#include "base58.h"
-#include "wallet.h"
+#include "wallet/wallet.h"
+
+#include <boost/foreach.hpp>
#include <QFont>
#include <QDebug>
diff --git a/src/qt/askpassphrasedialog.cpp b/src/qt/askpassphrasedialog.cpp
index 9b7b59c0db..229139e65c 100644
--- a/src/qt/askpassphrasedialog.cpp
+++ b/src/qt/askpassphrasedialog.cpp
@@ -8,7 +8,7 @@
#include "guiconstants.h"
#include "walletmodel.h"
-#include "allocators.h"
+#include "support/allocators/secure.h"
#include <QKeyEvent>
#include <QMessageBox>
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index 73c684e489..3ae780abfd 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -30,7 +30,7 @@
#include "util.h"
#ifdef ENABLE_WALLET
-#include "wallet.h"
+#include "wallet/wallet.h"
#endif
#include <stdint.h>
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index f64437f852..198dd1fdf9 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -151,7 +151,7 @@ BitcoinGUI::BitcoinGUI(const NetworkStyle *networkStyle, QWidget *parent) :
// Create actions for the toolbar, menu bar and tray/dock icon
// Needs walletFrame to be initialized
- createActions(networkStyle);
+ createActions();
// Create application menu bar
createMenuBar();
@@ -237,13 +237,13 @@ BitcoinGUI::~BitcoinGUI()
trayIcon->hide();
#ifdef Q_OS_MAC
delete appMenuBar;
- MacDockIconHandler::instance()->setMainWindow(NULL);
+ MacDockIconHandler::cleanup();
#endif
delete rpcConsole;
}
-void BitcoinGUI::createActions(const NetworkStyle *networkStyle)
+void BitcoinGUI::createActions()
{
QActionGroup *tabGroup = new QActionGroup(this);
@@ -340,6 +340,7 @@ void BitcoinGUI::createActions(const NetworkStyle *networkStyle)
openAction->setStatusTip(tr("Open a bitcoin: URI or payment request"));
showHelpMessageAction = new QAction(TextColorIcon(":/icons/info"), tr("&Command-line options"), this);
+ showHelpMessageAction->setMenuRole(QAction::NoRole);
showHelpMessageAction->setStatusTip(tr("Show the Bitcoin Core help message to get a list with possible Bitcoin command-line options"));
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
@@ -435,8 +436,8 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel)
setNumConnections(clientModel->getNumConnections());
connect(clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
- setNumBlocks(clientModel->getNumBlocks());
- connect(clientModel, SIGNAL(numBlocksChanged(int)), this, SLOT(setNumBlocks(int)));
+ setNumBlocks(clientModel->getNumBlocks(), clientModel->getLastBlockDate());
+ connect(clientModel, SIGNAL(numBlocksChanged(int,QDateTime)), this, SLOT(setNumBlocks(int,QDateTime)));
// Receive and report messages from client model
connect(clientModel, SIGNAL(message(QString,QString,unsigned int)), this, SLOT(message(QString,QString,unsigned int)));
@@ -652,7 +653,7 @@ void BitcoinGUI::setNumConnections(int count)
labelConnectionsIcon->setToolTip(tr("%n active connection(s) to Bitcoin network", "", count));
}
-void BitcoinGUI::setNumBlocks(int count)
+void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate)
{
if(!clientModel)
return;
@@ -680,9 +681,8 @@ void BitcoinGUI::setNumBlocks(int count)
QString tooltip;
- QDateTime lastBlockDate = clientModel->getLastBlockDate();
QDateTime currentDate = QDateTime::currentDateTime();
- int secs = lastBlockDate.secsTo(currentDate);
+ qint64 secs = blockDate.secsTo(currentDate);
tooltip = tr("Processed %n blocks of transaction history.", "", count);
@@ -722,8 +722,8 @@ void BitcoinGUI::setNumBlocks(int count)
}
else
{
- int years = secs / YEAR_IN_SECONDS;
- int remainder = secs % YEAR_IN_SECONDS;
+ qint64 years = secs / YEAR_IN_SECONDS;
+ qint64 remainder = secs % YEAR_IN_SECONDS;
timeBehindText = tr("%1 and %2").arg(tr("%n year(s)", "", years)).arg(tr("%n week(s)","", remainder/WEEK_IN_SECONDS));
}
diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h
index c47d7a4247..494541f002 100644
--- a/src/qt/bitcoingui.h
+++ b/src/qt/bitcoingui.h
@@ -118,7 +118,7 @@ private:
int spinnerFrame;
/** Create the main UI actions. */
- void createActions(const NetworkStyle *networkStyle);
+ void createActions();
/** Create the menu bar and sub-menus. */
void createMenuBar();
/** Create the toolbars */
@@ -143,8 +143,8 @@ signals:
public slots:
/** Set number of connections shown in the UI */
void setNumConnections(int count);
- /** Set number of blocks shown in the UI */
- void setNumBlocks(int count);
+ /** Set number of blocks and last block date shown in the UI */
+ void setNumBlocks(int count, const QDateTime& blockDate);
/** Notify the user of an event from the core network or transaction handling code.
@param[in] title the message box / notification title
diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp
index 03d94f2e13..dc32f81571 100644
--- a/src/qt/clientmodel.cpp
+++ b/src/qt/clientmodel.cpp
@@ -18,7 +18,6 @@
#include <stdint.h>
-#include <QDateTime>
#include <QDebug>
#include <QTimer>
@@ -29,8 +28,10 @@ ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) :
optionsModel(optionsModel),
peerTableModel(0),
cachedNumBlocks(0),
- cachedReindexing(0), cachedImporting(0),
- numBlocksAtStartup(-1), pollTimer(0)
+ cachedBlockDate(QDateTime()),
+ cachedReindexing(0),
+ cachedImporting(0),
+ pollTimer(0)
{
peerTableModel = new PeerTableModel(this);
pollTimer = new QTimer(this);
@@ -65,12 +66,6 @@ int ClientModel::getNumBlocks() const
return chainActive.Height();
}
-int ClientModel::getNumBlocksAtStartup()
-{
- if (numBlocksAtStartup == -1) numBlocksAtStartup = getNumBlocks();
- return numBlocksAtStartup;
-}
-
quint64 ClientModel::getTotalBytesRecv() const
{
return CNode::GetTotalBytesRecv();
@@ -84,10 +79,11 @@ quint64 ClientModel::getTotalBytesSent() const
QDateTime ClientModel::getLastBlockDate() const
{
LOCK(cs_main);
+
if (chainActive.Tip())
return QDateTime::fromTime_t(chainActive.Tip()->GetBlockTime());
- else
- return QDateTime::fromTime_t(Params().GenesisBlock().GetBlockTime()); // Genesis block's time of current network
+
+ return QDateTime::fromTime_t(Params().GenesisBlock().GetBlockTime()); // Genesis block's time of current network
}
double ClientModel::getVerificationProgress() const
@@ -102,21 +98,26 @@ void ClientModel::updateTimer()
// periodical polls if the core is holding the locks for a longer time -
// for example, during a wallet rescan.
TRY_LOCK(cs_main, lockMain);
- if(!lockMain)
+ if (!lockMain)
return;
+
// Some quantities (such as number of blocks) change so fast that we don't want to be notified for each change.
// Periodically check and update with a timer.
int newNumBlocks = getNumBlocks();
+ QDateTime newBlockDate = getLastBlockDate();
// check for changed number of blocks we have, number of blocks peers claim to have, reindexing state and importing state
if (cachedNumBlocks != newNumBlocks ||
- cachedReindexing != fReindex || cachedImporting != fImporting)
+ cachedBlockDate != newBlockDate ||
+ cachedReindexing != fReindex ||
+ cachedImporting != fImporting)
{
cachedNumBlocks = newNumBlocks;
+ cachedBlockDate = newBlockDate;
cachedReindexing = fReindex;
cachedImporting = fImporting;
- emit numBlocksChanged(newNumBlocks);
+ emit numBlocksChanged(newNumBlocks, newBlockDate);
}
emit bytesChanged(getTotalBytesRecv(), getTotalBytesSent());
diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h
index 4856a72d7d..214701810c 100644
--- a/src/qt/clientmodel.h
+++ b/src/qt/clientmodel.h
@@ -6,6 +6,7 @@
#define BITCOIN_QT_CLIENTMODEL_H
#include <QObject>
+#include <QDateTime>
class AddressTableModel;
class OptionsModel;
@@ -15,7 +16,6 @@ class TransactionTableModel;
class CWallet;
QT_BEGIN_NAMESPACE
-class QDateTime;
class QTimer;
QT_END_NAMESPACE
@@ -48,7 +48,6 @@ public:
//! Return number of connections, default is in- and outbound (total)
int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const;
int getNumBlocks() const;
- int getNumBlocksAtStartup();
quint64 getTotalBytesRecv() const;
quint64 getTotalBytesSent() const;
@@ -74,11 +73,10 @@ private:
PeerTableModel *peerTableModel;
int cachedNumBlocks;
+ QDateTime cachedBlockDate;
bool cachedReindexing;
bool cachedImporting;
- int numBlocksAtStartup;
-
QTimer *pollTimer;
void subscribeToCoreSignals();
@@ -86,7 +84,7 @@ private:
signals:
void numConnectionsChanged(int count);
- void numBlocksChanged(int count);
+ void numBlocksChanged(int count, const QDateTime& blockDate);
void alertsChanged(const QString &warnings);
void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut);
diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp
index 3f4f082b8c..e4e9015c85 100644
--- a/src/qt/coincontroldialog.cpp
+++ b/src/qt/coincontroldialog.cpp
@@ -15,7 +15,7 @@
#include "coincontrol.h"
#include "main.h"
-#include "wallet.h"
+#include "wallet/wallet.h"
#include <boost/assign/list_of.hpp> // for 'map_list_of()'
@@ -33,6 +33,7 @@
using namespace std;
QList<CAmount> CoinControlDialog::payAmounts;
CCoinControl* CoinControlDialog::coinControl = new CCoinControl();
+bool CoinControlDialog::fSubtractFeeFromAmount = false;
CoinControlDialog::CoinControlDialog(QWidget *parent) :
QDialog(parent),
@@ -541,6 +542,11 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
dPriority = dPriorityInputs / (nBytes - nBytesInputs + (nQuantityUncompressed * 29)); // 29 = 180 - 151 (uncompressed public keys are over the limit. max 151 bytes of the input are ignored for priority)
sPriorityLabel = CoinControlDialog::getPriorityLabel(dPriority, mempoolEstimatePriority);
+ // in the subtract fee from amount case, we can tell if zero change already and subtract the bytes, so that fee calculation afterwards is accurate
+ if (CoinControlDialog::fSubtractFeeFromAmount)
+ if (nAmount - nPayAmount == 0)
+ nBytes -= 34;
+
// Fee
nPayFee = CWallet::GetMinimumFee(nBytes, nTxConfirmTarget, mempool);
@@ -556,7 +562,9 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
if (nPayAmount > 0)
{
- nChange = nAmount - nPayFee - nPayAmount;
+ nChange = nAmount - nPayAmount;
+ if (!CoinControlDialog::fSubtractFeeFromAmount)
+ nChange -= nPayFee;
// Never create dust outputs; if we would, just add the dust to the fee.
if (nChange > 0 && nChange < CENT)
@@ -564,12 +572,17 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
CTxOut txout(nChange, (CScript)vector<unsigned char>(24, 0));
if (txout.IsDust(::minRelayTxFee))
{
- nPayFee += nChange;
- nChange = 0;
+ if (CoinControlDialog::fSubtractFeeFromAmount) // dust-change will be raised until no dust
+ nChange = txout.GetDustThreshold(::minRelayTxFee);
+ else
+ {
+ nPayFee += nChange;
+ nChange = 0;
+ }
}
}
- if (nChange == 0)
+ if (nChange == 0 && !CoinControlDialog::fSubtractFeeFromAmount)
nBytes -= 34;
}
@@ -612,7 +625,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
{
l3->setText(ASYMP_UTF8 + l3->text());
l4->setText(ASYMP_UTF8 + l4->text());
- if (nChange > 0)
+ if (nChange > 0 && !CoinControlDialog::fSubtractFeeFromAmount)
l8->setText(ASYMP_UTF8 + l8->text());
}
diff --git a/src/qt/coincontroldialog.h b/src/qt/coincontroldialog.h
index 5a91876f1f..5ec382838f 100644
--- a/src/qt/coincontroldialog.h
+++ b/src/qt/coincontroldialog.h
@@ -43,6 +43,7 @@ public:
static QList<CAmount> payAmounts;
static CCoinControl *coinControl;
+ static bool fSubtractFeeFromAmount;
private:
Ui::CoinControlDialog *ui;
diff --git a/src/qt/forms/sendcoinsdialog.ui b/src/qt/forms/sendcoinsdialog.ui
index eebb459327..b1ed7a27b5 100644
--- a/src/qt/forms/sendcoinsdialog.ui
+++ b/src/qt/forms/sendcoinsdialog.ui
@@ -771,16 +771,6 @@
</property>
</widget>
</item>
- <item>
- <widget class="QPushButton" name="buttonMinimizeFee">
- <property name="toolTip">
- <string>collapse fee-settings</string>
- </property>
- <property name="text">
- <string>Minimize</string>
- </property>
- </widget>
- </item>
</layout>
</item>
<item>
@@ -811,6 +801,16 @@
</property>
</spacer>
</item>
+ <item>
+ <widget class="QPushButton" name="buttonMinimizeFee">
+ <property name="toolTip">
+ <string>collapse fee-settings</string>
+ </property>
+ <property name="text">
+ <string>Minimize</string>
+ </property>
+ </widget>
+ </item>
</layout>
</item>
<item>
diff --git a/src/qt/forms/sendcoinsentry.ui b/src/qt/forms/sendcoinsentry.ui
index 9f8c0a4844..b362928438 100644
--- a/src/qt/forms/sendcoinsentry.ui
+++ b/src/qt/forms/sendcoinsentry.ui
@@ -157,7 +157,21 @@
</widget>
</item>
<item row="2" column="1">
- <widget class="BitcoinAmountField" name="payAmount"/>
+ <layout class="QHBoxLayout" name="horizontalLayoutAmount" stretch="0,1">
+ <item>
+ <widget class="BitcoinAmountField" name="payAmount"/>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkboxSubtractFeeFromAmount">
+ <property name="toolTip">
+ <string>The fee will be deducted from the amount being sent. The recipient will receive less bitcoins than you enter in the amount field. If multiple recipients are selected, the fee is split equally.</string>
+ </property>
+ <property name="text">
+ <string>S&amp;ubtract fee from amount</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="messageLabel">
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp
index 2a13f43ea4..a5ee81db6c 100644
--- a/src/qt/guiutil.cpp
+++ b/src/qt/guiutil.cpp
@@ -40,6 +40,7 @@
#if BOOST_FILESYSTEM_VERSION >= 3
#include <boost/filesystem/detail/utf8_codecvt_facet.hpp>
#endif
+#include <boost/scoped_array.hpp>
#include <QAbstractItemView>
#include <QApplication>
@@ -567,12 +568,17 @@ TableViewLastColumnResizingFixer::TableViewLastColumnResizingFixer(QTableView* t
#ifdef WIN32
boost::filesystem::path static StartupShortcutPath()
{
+ if (GetBoolArg("-testnet", false))
+ return GetSpecialFolderPath(CSIDL_STARTUP) / "Bitcoin (testnet).lnk";
+ else if (GetBoolArg("-regtest", false))
+ return GetSpecialFolderPath(CSIDL_STARTUP) / "Bitcoin (regtest).lnk";
+
return GetSpecialFolderPath(CSIDL_STARTUP) / "Bitcoin.lnk";
}
bool GetStartOnSystemStartup()
{
- // check for Bitcoin.lnk
+ // check for Bitcoin*.lnk
return boost::filesystem::exists(StartupShortcutPath());
}
@@ -588,8 +594,8 @@ bool SetStartOnSystemStartup(bool fAutoStart)
// Get a pointer to the IShellLink interface.
IShellLink* psl = NULL;
HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL,
- CLSCTX_INPROC_SERVER, IID_IShellLink,
- reinterpret_cast<void**>(&psl));
+ CLSCTX_INPROC_SERVER, IID_IShellLink,
+ reinterpret_cast<void**>(&psl));
if (SUCCEEDED(hres))
{
@@ -597,20 +603,34 @@ bool SetStartOnSystemStartup(bool fAutoStart)
TCHAR pszExePath[MAX_PATH];
GetModuleFileName(NULL, pszExePath, sizeof(pszExePath));
- TCHAR pszArgs[5] = TEXT("-min");
+ // Start client minimized
+ QString strArgs = "-min";
+ // Set -testnet /-regtest options
+ strArgs += QString::fromStdString(strprintf(" -testnet=%d -regtest=%d", GetBoolArg("-testnet", false), GetBoolArg("-regtest", false)));
+
+#ifdef UNICODE
+ boost::scoped_array<TCHAR> args(new TCHAR[strArgs.length() + 1]);
+ // Convert the QString to TCHAR*
+ strArgs.toWCharArray(args.get());
+ // Add missing '\0'-termination to string
+ args[strArgs.length()] = '\0';
+#endif
// Set the path to the shortcut target
psl->SetPath(pszExePath);
PathRemoveFileSpec(pszExePath);
psl->SetWorkingDirectory(pszExePath);
psl->SetShowCmd(SW_SHOWMINNOACTIVE);
- psl->SetArguments(pszArgs);
+#ifndef UNICODE
+ psl->SetArguments(strArgs.toStdString().c_str());
+#else
+ psl->SetArguments(args.get());
+#endif
// Query IShellLink for the IPersistFile interface for
// saving the shortcut in persistent storage.
IPersistFile* ppf = NULL;
- hres = psl->QueryInterface(IID_IPersistFile,
- reinterpret_cast<void**>(&ppf));
+ hres = psl->QueryInterface(IID_IPersistFile, reinterpret_cast<void**>(&ppf));
if (SUCCEEDED(hres))
{
WCHAR pwsz[MAX_PATH];
@@ -630,11 +650,10 @@ bool SetStartOnSystemStartup(bool fAutoStart)
}
return true;
}
-
#elif defined(Q_OS_LINUX)
// Follow the Desktop Application Autostart Spec:
-// http://standards.freedesktop.org/autostart-spec/autostart-spec-latest.html
+// http://standards.freedesktop.org/autostart-spec/autostart-spec-latest.html
boost::filesystem::path static GetAutostartDir()
{
@@ -690,8 +709,13 @@ bool SetStartOnSystemStartup(bool fAutoStart)
// Write a bitcoin.desktop file to the autostart directory:
optionFile << "[Desktop Entry]\n";
optionFile << "Type=Application\n";
- optionFile << "Name=Bitcoin\n";
- optionFile << "Exec=" << pszExePath << " -min\n";
+ if (GetBoolArg("-testnet", false))
+ optionFile << "Name=Bitcoin (testnet)\n";
+ else if (GetBoolArg("-regtest", false))
+ optionFile << "Name=Bitcoin (regtest)\n";
+ else
+ optionFile << "Name=Bitcoin\n";
+ optionFile << "Exec=" << pszExePath << strprintf(" -min -testnet=%d -regtest=%d\n", GetBoolArg("-testnet", false), GetBoolArg("-regtest", false));
optionFile << "Terminal=false\n";
optionFile << "Hidden=false\n";
optionFile.close();
@@ -854,10 +878,13 @@ QString formatServicesStr(quint64 mask)
switch (check)
{
case NODE_NETWORK:
- strList.append(QObject::tr("NETWORK"));
+ strList.append("NETWORK");
+ break;
+ case NODE_GETUTXO:
+ strList.append("GETUTXO");
break;
default:
- strList.append(QString("%1[%2]").arg(QObject::tr("UNKNOWN")).arg(check));
+ strList.append(QString("%1[%2]").arg("UNKNOWN").arg(check));
}
}
}
diff --git a/src/qt/macdockiconhandler.h b/src/qt/macdockiconhandler.h
index 1217bd8e88..15a6583ca4 100644
--- a/src/qt/macdockiconhandler.h
+++ b/src/qt/macdockiconhandler.h
@@ -14,12 +14,6 @@ class QMenu;
class QWidget;
QT_END_NAMESPACE
-#ifdef __OBJC__
-@class DockIconClickEventHandler;
-#else
-class DockIconClickEventHandler;
-#endif
-
/** Macintosh-specific dock icon handler.
*/
class MacDockIconHandler : public QObject
@@ -33,7 +27,7 @@ public:
void setIcon(const QIcon &icon);
void setMainWindow(QMainWindow *window);
static MacDockIconHandler *instance();
-
+ static void cleanup();
void handleDockIconClickEvent();
signals:
@@ -42,7 +36,6 @@ signals:
private:
MacDockIconHandler();
- DockIconClickEventHandler *m_dockIconClickEventHandler;
QWidget *m_dummyWidget;
QMenu *m_dockMenu;
QMainWindow *mainWindow;
diff --git a/src/qt/macdockiconhandler.mm b/src/qt/macdockiconhandler.mm
index e7b58b9cc0..58a0365d3d 100644
--- a/src/qt/macdockiconhandler.mm
+++ b/src/qt/macdockiconhandler.mm
@@ -11,52 +11,46 @@
#undef slots
#include <Cocoa/Cocoa.h>
+#include <objc/objc.h>
+#include <objc/message.h>
#if QT_VERSION < 0x050000
extern void qt_mac_set_dock_menu(QMenu *);
#endif
-@interface DockIconClickEventHandler : NSObject
-{
- MacDockIconHandler* dockIconHandler;
-}
-
-@end
+static MacDockIconHandler *s_instance = NULL;
-@implementation DockIconClickEventHandler
-
-- (id)initWithDockIconHandler:(MacDockIconHandler *)aDockIconHandler
-{
- self = [super init];
- if (self) {
- dockIconHandler = aDockIconHandler;
-
- [[NSAppleEventManager sharedAppleEventManager]
- setEventHandler:self
- andSelector:@selector(handleDockClickEvent:withReplyEvent:)
- forEventClass:kCoreEventClass
- andEventID:kAEReopenApplication];
- }
- return self;
+bool dockClickHandler(id self,SEL _cmd,...) {
+ Q_UNUSED(self)
+ Q_UNUSED(_cmd)
+
+ s_instance->handleDockIconClickEvent();
+
+ // Return NO (false) to suppress the default OS X actions
+ return false;
}
-- (void)handleDockClickEvent:(NSAppleEventDescriptor*)event withReplyEvent:(NSAppleEventDescriptor*)replyEvent
-{
- Q_UNUSED(event)
- Q_UNUSED(replyEvent)
-
- if (dockIconHandler) {
- dockIconHandler->handleDockIconClickEvent();
+void setupDockClickHandler() {
+ Class cls = objc_getClass("NSApplication");
+ id appInst = objc_msgSend((id)cls, sel_registerName("sharedApplication"));
+
+ if (appInst != NULL) {
+ id delegate = objc_msgSend(appInst, sel_registerName("delegate"));
+ Class delClass = (Class)objc_msgSend(delegate, sel_registerName("class"));
+ SEL shouldHandle = sel_registerName("applicationShouldHandleReopen:hasVisibleWindows:");
+ if (class_getInstanceMethod(delClass, shouldHandle))
+ class_replaceMethod(delClass, shouldHandle, (IMP)dockClickHandler, "B@:");
+ else
+ class_addMethod(delClass, shouldHandle, (IMP)dockClickHandler,"B@:");
}
}
-@end
MacDockIconHandler::MacDockIconHandler() : QObject()
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- this->m_dockIconClickEventHandler = [[DockIconClickEventHandler alloc] initWithDockIconHandler:this];
+ setupDockClickHandler();
this->m_dummyWidget = new QWidget();
this->m_dockMenu = new QMenu(this->m_dummyWidget);
this->setMainWindow(NULL);
@@ -74,7 +68,6 @@ void MacDockIconHandler::setMainWindow(QMainWindow *window) {
MacDockIconHandler::~MacDockIconHandler()
{
- [this->m_dockIconClickEventHandler release];
delete this->m_dummyWidget;
this->setMainWindow(NULL);
}
@@ -119,12 +112,16 @@ void MacDockIconHandler::setIcon(const QIcon &icon)
MacDockIconHandler *MacDockIconHandler::instance()
{
- static MacDockIconHandler *s_instance = NULL;
if (!s_instance)
s_instance = new MacDockIconHandler();
return s_instance;
}
+void MacDockIconHandler::cleanup()
+{
+ delete s_instance;
+}
+
void MacDockIconHandler::handleDockIconClickEvent()
{
if (this->mainWindow)
diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp
index a0f3993e69..a9e4b339e4 100644
--- a/src/qt/optionsdialog.cpp
+++ b/src/qt/optionsdialog.cpp
@@ -18,7 +18,7 @@
#include "txdb.h" // for -dbcache defaults
#ifdef ENABLE_WALLET
-#include "wallet.h" // for CWallet::minTxFee
+#include "wallet/wallet.h" // for CWallet::minTxFee
#endif
#include <boost/thread.hpp>
@@ -38,7 +38,6 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
fProxyIpValid(true)
{
ui->setupUi(this);
- GUIUtil::restoreWindowGeometry("nOptionsDialogWindow", this->size(), this);
/* Main elements init */
ui->databaseCache->setMinimum(nMinDbCache);
@@ -117,7 +116,6 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
OptionsDialog::~OptionsDialog()
{
- GUIUtil::saveWindowGeometry("nOptionsDialogWindow", this);
delete ui;
}
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index 7d2dbd96de..a169ed6b55 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -18,8 +18,8 @@
#include "txdb.h" // for -dbcache defaults
#ifdef ENABLE_WALLET
-#include "wallet.h"
-#include "walletdb.h"
+#include "wallet/wallet.h"
+#include "wallet/walletdb.h"
#endif
#include <QNetworkProxy>
diff --git a/src/qt/paymentrequestplus.cpp b/src/qt/paymentrequestplus.cpp
index 4c1e898020..b69461ad9e 100644
--- a/src/qt/paymentrequestplus.cpp
+++ b/src/qt/paymentrequestplus.cpp
@@ -13,7 +13,6 @@
#include <stdexcept>
-#include <openssl/x509.h>
#include <openssl/x509_vfy.h>
#include <QDateTime>
diff --git a/src/qt/paymentrequestplus.h b/src/qt/paymentrequestplus.h
index fbc3a09265..61f8a3415d 100644
--- a/src/qt/paymentrequestplus.h
+++ b/src/qt/paymentrequestplus.h
@@ -9,6 +9,8 @@
#include "base58.h"
+#include <openssl/x509.h>
+
#include <QByteArray>
#include <QList>
#include <QString>
diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp
index 9aab944f6b..ad489de343 100644
--- a/src/qt/paymentserver.cpp
+++ b/src/qt/paymentserver.cpp
@@ -10,13 +10,13 @@
#include "base58.h"
#include "chainparams.h"
+#include "main.h"
#include "ui_interface.h"
#include "util.h"
-#include "wallet.h"
+#include "wallet/wallet.h"
#include <cstdlib>
-#include <openssl/x509.h>
#include <openssl/x509_vfy.h>
#include <QApplication>
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index 9f3991c4c5..29c971ec79 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -293,8 +293,8 @@ void RPCConsole::setClientModel(ClientModel *model)
setNumConnections(model->getNumConnections());
connect(model, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
- setNumBlocks(model->getNumBlocks());
- connect(model, SIGNAL(numBlocksChanged(int)), this, SLOT(setNumBlocks(int)));
+ setNumBlocks(model->getNumBlocks(), model->getLastBlockDate());
+ connect(model, SIGNAL(numBlocksChanged(int,QDateTime)), this, SLOT(setNumBlocks(int,QDateTime)));
updateTrafficStats(model->getTotalBytesRecv(), model->getTotalBytesSent());
connect(model, SIGNAL(bytesChanged(quint64,quint64)), this, SLOT(updateTrafficStats(quint64, quint64)));
@@ -357,7 +357,6 @@ void RPCConsole::clear()
ui->messagesWidget->document()->setDefaultStyleSheet(
"table { }"
"td.time { color: #808080; padding-top: 3px; } "
- "td.message { font-family: monospace; font-size: 12px; } " // Todo: Remove fixed font-size
"td.cmd-request { color: #006060; } "
"td.cmd-error { color: red; } "
"b { color: #006060; } "
@@ -404,11 +403,10 @@ void RPCConsole::setNumConnections(int count)
ui->numberOfConnections->setText(connections);
}
-void RPCConsole::setNumBlocks(int count)
+void RPCConsole::setNumBlocks(int count, const QDateTime& blockDate)
{
ui->numberOfBlocks->setText(QString::number(count));
- if(clientModel)
- ui->lastBlockTime->setText(clientModel->getLastBlockDate().toString());
+ ui->lastBlockTime->setText(blockDate.toString());
}
void RPCConsole::on_lineEdit_returnPressed()
diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h
index fff5cfbf59..8737be35d1 100644
--- a/src/qt/rpcconsole.h
+++ b/src/qt/rpcconsole.h
@@ -63,8 +63,8 @@ public slots:
void message(int category, const QString &message, bool html = false);
/** Set number of connections shown in the UI */
void setNumConnections(int count);
- /** Set number of blocks shown in the UI */
- void setNumBlocks(int count);
+ /** Set number of blocks and last block date shown in the UI */
+ void setNumBlocks(int count, const QDateTime& blockDate);
/** Go forward or back in history */
void browseHistory(int offset);
/** Scroll console view to end */
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp
index 5aef2d7539..774667d4ac 100644
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -17,8 +17,9 @@
#include "base58.h"
#include "coincontrol.h"
+#include "main.h"
#include "ui_interface.h"
-#include "wallet.h"
+#include "wallet/wallet.h"
#include <QMessageBox>
#include <QScrollBar>
@@ -121,7 +122,7 @@ void SendCoinsDialog::setClientModel(ClientModel *clientModel)
this->clientModel = clientModel;
if (clientModel) {
- connect(clientModel, SIGNAL(numBlocksChanged(int)), this, SLOT(updateSmartFeeLabel()));
+ connect(clientModel, SIGNAL(numBlocksChanged(int,QDateTime)), this, SLOT(updateSmartFeeLabel()));
}
}
@@ -220,9 +221,37 @@ void SendCoinsDialog::on_sendButton_clicked()
return;
}
+ fNewRecipientAllowed = false;
+ WalletModel::UnlockContext ctx(model->requestUnlock());
+ if(!ctx.isValid())
+ {
+ // Unlock wallet was cancelled
+ fNewRecipientAllowed = true;
+ return;
+ }
+
+ // prepare transaction for getting txFee earlier
+ WalletModelTransaction currentTransaction(recipients);
+ WalletModel::SendCoinsReturn prepareStatus;
+ if (model->getOptionsModel()->getCoinControlFeatures()) // coin control enabled
+ prepareStatus = model->prepareTransaction(currentTransaction, CoinControlDialog::coinControl);
+ else
+ prepareStatus = model->prepareTransaction(currentTransaction);
+
+ // process prepareStatus and on error generate message shown to user
+ processSendCoinsReturn(prepareStatus,
+ BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), currentTransaction.getTransactionFee()));
+
+ if(prepareStatus.status != WalletModel::OK) {
+ fNewRecipientAllowed = true;
+ return;
+ }
+
+ CAmount txFee = currentTransaction.getTransactionFee();
+
// Format confirmation message
QStringList formatted;
- foreach(const SendCoinsRecipient &rcp, recipients)
+ foreach(const SendCoinsRecipient &rcp, currentTransaction.getRecipients())
{
// generate bold amount string
QString amount = "<b>" + BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), rcp.amount);
@@ -257,35 +286,6 @@ void SendCoinsDialog::on_sendButton_clicked()
formatted.append(recipientElement);
}
- fNewRecipientAllowed = false;
-
-
- WalletModel::UnlockContext ctx(model->requestUnlock());
- if(!ctx.isValid())
- {
- // Unlock wallet was cancelled
- fNewRecipientAllowed = true;
- return;
- }
-
- // prepare transaction for getting txFee earlier
- WalletModelTransaction currentTransaction(recipients);
- WalletModel::SendCoinsReturn prepareStatus;
- if (model->getOptionsModel()->getCoinControlFeatures()) // coin control enabled
- prepareStatus = model->prepareTransaction(currentTransaction, CoinControlDialog::coinControl);
- else
- prepareStatus = model->prepareTransaction(currentTransaction);
-
- // process prepareStatus and on error generate message shown to user
- processSendCoinsReturn(prepareStatus,
- BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), currentTransaction.getTransactionFee()));
-
- if(prepareStatus.status != WalletModel::OK) {
- fNewRecipientAllowed = true;
- return;
- }
-
- CAmount txFee = currentTransaction.getTransactionFee();
QString questionString = tr("Are you sure you want to send?");
questionString.append("<br /><br />%1");
@@ -368,6 +368,7 @@ SendCoinsEntry *SendCoinsDialog::addEntry()
ui->entries->addWidget(entry);
connect(entry, SIGNAL(removeEntry(SendCoinsEntry*)), this, SLOT(removeEntry(SendCoinsEntry*)));
connect(entry, SIGNAL(payAmountChanged()), this, SLOT(coinControlUpdateLabels()));
+ connect(entry, SIGNAL(subtractFeeFromAmountChanged()), this, SLOT(coinControlUpdateLabels()));
updateTabsAndLabels();
@@ -783,11 +784,17 @@ void SendCoinsDialog::coinControlUpdateLabels()
// set pay amounts
CoinControlDialog::payAmounts.clear();
+ CoinControlDialog::fSubtractFeeFromAmount = false;
for(int i = 0; i < ui->entries->count(); ++i)
{
SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget());
if(entry)
- CoinControlDialog::payAmounts.append(entry->getValue().amount);
+ {
+ SendCoinsRecipient rcp = entry->getValue();
+ CoinControlDialog::payAmounts.append(rcp.amount);
+ if (rcp.fSubtractFeeFromAmount)
+ CoinControlDialog::fSubtractFeeFromAmount = true;
+ }
}
if (CoinControlDialog::coinControl->HasSelected())
diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp
index 6db6eee75b..6ac650e74f 100644
--- a/src/qt/sendcoinsentry.cpp
+++ b/src/qt/sendcoinsentry.cpp
@@ -44,6 +44,7 @@ SendCoinsEntry::SendCoinsEntry(QWidget *parent) :
// Connect signals
connect(ui->payAmount, SIGNAL(valueChanged()), this, SIGNAL(payAmountChanged()));
+ connect(ui->checkboxSubtractFeeFromAmount, SIGNAL(toggled(bool)), this, SIGNAL(subtractFeeFromAmountChanged()));
connect(ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteClicked()));
connect(ui->deleteButton_is, SIGNAL(clicked()), this, SLOT(deleteClicked()));
connect(ui->deleteButton_s, SIGNAL(clicked()), this, SLOT(deleteClicked()));
@@ -94,6 +95,7 @@ void SendCoinsEntry::clear()
ui->payTo->clear();
ui->addAsLabel->clear();
ui->payAmount->clear();
+ ui->checkboxSubtractFeeFromAmount->setCheckState(Qt::Unchecked);
ui->messageTextLabel->clear();
ui->messageTextLabel->hide();
ui->messageLabel->hide();
@@ -165,6 +167,7 @@ SendCoinsRecipient SendCoinsEntry::getValue()
recipient.label = ui->addAsLabel->text();
recipient.amount = ui->payAmount->value();
recipient.message = ui->messageTextLabel->text();
+ recipient.fSubtractFeeFromAmount = (ui->checkboxSubtractFeeFromAmount->checkState() == Qt::Checked);
return recipient;
}
@@ -174,7 +177,8 @@ QWidget *SendCoinsEntry::setupTabChain(QWidget *prev)
QWidget::setTabOrder(prev, ui->payTo);
QWidget::setTabOrder(ui->payTo, ui->addAsLabel);
QWidget *w = ui->payAmount->setupTabChain(ui->addAsLabel);
- QWidget::setTabOrder(w, ui->addressBookButton);
+ QWidget::setTabOrder(w, ui->checkboxSubtractFeeFromAmount);
+ QWidget::setTabOrder(ui->checkboxSubtractFeeFromAmount, ui->addressBookButton);
QWidget::setTabOrder(ui->addressBookButton, ui->pasteButton);
QWidget::setTabOrder(ui->pasteButton, ui->deleteButton);
return ui->deleteButton;
diff --git a/src/qt/sendcoinsentry.h b/src/qt/sendcoinsentry.h
index 4cb00cd36a..c2d1185bdd 100644
--- a/src/qt/sendcoinsentry.h
+++ b/src/qt/sendcoinsentry.h
@@ -51,6 +51,7 @@ public slots:
signals:
void removeEntry(SendCoinsEntry *entry);
void payAmountChanged();
+ void subtractFeeFromAmountChanged();
private slots:
void deleteClicked();
diff --git a/src/qt/signverifymessagedialog.cpp b/src/qt/signverifymessagedialog.cpp
index 970f6a520d..ce166f3672 100644
--- a/src/qt/signverifymessagedialog.cpp
+++ b/src/qt/signverifymessagedialog.cpp
@@ -12,7 +12,8 @@
#include "base58.h"
#include "init.h"
-#include "wallet.h"
+#include "main.h" // For strMessageMagic
+#include "wallet/wallet.h"
#include <string>
#include <vector>
diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp
index e6a7fcaec5..414fe02ff9 100644
--- a/src/qt/splashscreen.cpp
+++ b/src/qt/splashscreen.cpp
@@ -12,7 +12,7 @@
#include "version.h"
#ifdef ENABLE_WALLET
-#include "wallet.h"
+#include "wallet/wallet.h"
#endif
#include <QApplication>
diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp
index 68c275d494..9b235f9130 100644
--- a/src/qt/transactiondesc.cpp
+++ b/src/qt/transactiondesc.cpp
@@ -10,13 +10,13 @@
#include "transactionrecord.h"
#include "base58.h"
-#include "db.h"
+#include "wallet/db.h"
#include "main.h"
#include "script/script.h"
#include "timedata.h"
#include "ui_interface.h"
#include "util.h"
-#include "wallet.h"
+#include "wallet/wallet.h"
#include <stdint.h>
#include <string>
diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp
index fea436806a..9db5ad0fd4 100644
--- a/src/qt/transactionrecord.cpp
+++ b/src/qt/transactionrecord.cpp
@@ -5,11 +5,14 @@
#include "transactionrecord.h"
#include "base58.h"
+#include "main.h"
#include "timedata.h"
-#include "wallet.h"
+#include "wallet/wallet.h"
#include <stdint.h>
+#include <boost/foreach.hpp>
+
/* Return positive answer if transaction should be shown in list.
*/
bool TransactionRecord::showTransaction(const CWalletTx &wtx)
diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp
index 585d8724c3..34464b4075 100644
--- a/src/qt/transactiontablemodel.cpp
+++ b/src/qt/transactiontablemodel.cpp
@@ -17,7 +17,7 @@
#include "sync.h"
#include "uint256.h"
#include "util.h"
-#include "wallet.h"
+#include "wallet/wallet.h"
#include <QColor>
#include <QDateTime>
diff --git a/src/qt/utilitydialog.cpp b/src/qt/utilitydialog.cpp
index 63dd6efb52..386cf31d73 100644
--- a/src/qt/utilitydialog.cpp
+++ b/src/qt/utilitydialog.cpp
@@ -29,7 +29,6 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
ui(new Ui::HelpMessageDialog)
{
ui->setupUi(this);
- GUIUtil::restoreWindowGeometry("nHelpMessageDialogWindow", this->size(), this);
QString version = tr("Bitcoin Core") + " " + tr("version") + " " + QString::fromStdString(FormatFullVersion());
/* On x86 add a bit specifier to the version so that users can distinguish between
@@ -63,13 +62,17 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
ui->helpMessage->setVisible(false);
} else {
setWindowTitle(tr("Command-line options"));
+ QString header = tr("Usage:") + "\n" +
+ " bitcoin-qt [" + tr("command-line options") + "] " + "\n";
QTextCursor cursor(ui->helpMessage->document());
cursor.insertText(version);
cursor.insertBlock();
- cursor.insertText(tr("Usage:") + '\n' +
- " bitcoin-qt [" + tr("command-line options") + "]\n");
-
+ cursor.insertText(header);
cursor.insertBlock();
+
+ QString coreOptions = QString::fromStdString(HelpMessage(HMM_BITCOIN_QT));
+ text = version + "\n" + header + "\n" + coreOptions;
+
QTextTableFormat tf;
tf.setBorderStyle(QTextFrameFormat::BorderStyle_None);
tf.setCellPadding(2);
@@ -77,63 +80,29 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
widths << QTextLength(QTextLength::PercentageLength, 35);
widths << QTextLength(QTextLength::PercentageLength, 65);
tf.setColumnWidthConstraints(widths);
- QTextTable *table = cursor.insertTable(2, 2, tf);
- QString coreOptions = QString::fromStdString(HelpMessage(HMM_BITCOIN_QT));
- bool first = true;
QTextCharFormat bold;
bold.setFontWeight(QFont::Bold);
- // note that coreOptions is not translated.
- foreach (const QString &line, coreOptions.split('\n')) {
- if (!first) {
- table->appendRows(1);
+
+ foreach (const QString &line, coreOptions.split("\n")) {
+ if (line.startsWith(" -"))
+ {
+ cursor.currentTable()->appendRows(1);
+ cursor.movePosition(QTextCursor::PreviousCell);
cursor.movePosition(QTextCursor::NextRow);
+ cursor.insertText(line.trimmed());
+ cursor.movePosition(QTextCursor::NextCell);
+ } else if (line.startsWith(" ")) {
+ cursor.insertText(line.trimmed()+' ');
+ } else if (line.size() > 0) {
+ //Title of a group
+ if (cursor.currentTable())
+ cursor.currentTable()->appendRows(1);
+ cursor.movePosition(QTextCursor::Down);
+ cursor.insertText(line.trimmed(), bold);
+ cursor.insertTable(1, 2, tf);
}
- first = false;
-
- if (line.startsWith(" ")) {
- int index = line.indexOf(' ', 3);
- if (index > 0) {
- cursor.insertText(line.left(index).trimmed());
- cursor.movePosition(QTextCursor::NextCell);
- cursor.insertText(line.mid(index).trimmed());
- continue;
- }
- }
- cursor.movePosition(QTextCursor::NextCell, QTextCursor::KeepAnchor);
- table->mergeCells(cursor);
- cursor.insertText(line.trimmed(), bold);
- }
-
- table->appendRows(6);
- cursor.movePosition(QTextCursor::NextRow);
- cursor.insertText(tr("UI options") + ":", bold);
- cursor.movePosition(QTextCursor::NextRow);
- if (GetBoolArg("-help-debug", false)) {
- cursor.insertText("-allowselfsignedrootcertificates");
- cursor.movePosition(QTextCursor::NextCell);
- cursor.insertText(tr("Allow self signed root certificates (default: 0)"));
- cursor.movePosition(QTextCursor::NextCell);
}
- cursor.insertText("-choosedatadir");
- cursor.movePosition(QTextCursor::NextCell);
- cursor.insertText(tr("Choose data directory on startup (default: 0)"));
- cursor.movePosition(QTextCursor::NextCell);
- cursor.insertText("-lang=<lang>");
- cursor.movePosition(QTextCursor::NextCell);
- cursor.insertText(tr("Set language, for example \"de_DE\" (default: system locale)"));
- cursor.movePosition(QTextCursor::NextCell);
- cursor.insertText("-min");
- cursor.movePosition(QTextCursor::NextCell);
- cursor.insertText(tr("Start minimized"));
- cursor.movePosition(QTextCursor::NextCell);
- cursor.insertText("-rootcertificates=<file>");
- cursor.movePosition(QTextCursor::NextCell);
- cursor.insertText(tr("Set SSL root certificates for payment request (default: -system-)"));
- cursor.movePosition(QTextCursor::NextCell);
- cursor.insertText("-splash");
- cursor.movePosition(QTextCursor::NextCell);
- cursor.insertText(tr("Show splash screen on startup (default: 1)"));
ui->helpMessage->moveCursor(QTextCursor::Start);
ui->scrollArea->setVisible(false);
@@ -143,7 +112,6 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
HelpMessageDialog::~HelpMessageDialog()
{
- GUIUtil::saveWindowGeometry("nHelpMessageDialogWindow", this);
delete ui;
}
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
index 79f5191fc0..09ed8ce9fd 100644
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -6,18 +6,19 @@
#include "addresstablemodel.h"
#include "guiconstants.h"
+#include "guiutil.h"
#include "paymentserver.h"
#include "recentrequeststablemodel.h"
#include "transactiontablemodel.h"
#include "base58.h"
-#include "db.h"
+#include "wallet/db.h"
#include "keystore.h"
#include "main.h"
#include "sync.h"
#include "ui_interface.h"
-#include "wallet.h"
-#include "walletdb.h" // for BackupWallet
+#include "wallet/wallet.h"
+#include "wallet/walletdb.h" // for BackupWallet
#include <stdint.h>
@@ -192,8 +193,9 @@ bool WalletModel::validateAddress(const QString &address)
WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransaction &transaction, const CCoinControl *coinControl)
{
CAmount total = 0;
+ bool fSubtractFeeFromAmount = false;
QList<SendCoinsRecipient> recipients = transaction.getRecipients();
- std::vector<std::pair<CScript, CAmount> > vecSend;
+ std::vector<CRecipient> vecSend;
if(recipients.empty())
{
@@ -206,6 +208,9 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
// Pre-check input data for validity
foreach(const SendCoinsRecipient &rcp, recipients)
{
+ if (rcp.fSubtractFeeFromAmount)
+ fSubtractFeeFromAmount = true;
+
if (rcp.paymentRequest.IsInitialized())
{ // PaymentRequest...
CAmount subtotal = 0;
@@ -217,7 +222,9 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
subtotal += out.amount();
const unsigned char* scriptStr = (const unsigned char*)out.script().data();
CScript scriptPubKey(scriptStr, scriptStr+out.script().size());
- vecSend.push_back(std::pair<CScript, CAmount>(scriptPubKey, out.amount()));
+ CAmount nAmount = out.amount();
+ CRecipient recipient = {scriptPubKey, nAmount, rcp.fSubtractFeeFromAmount};
+ vecSend.push_back(recipient);
}
if (subtotal <= 0)
{
@@ -239,7 +246,8 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
++nAddresses;
CScript scriptPubKey = GetScriptForDestination(CBitcoinAddress(rcp.address.toStdString()).Get());
- vecSend.push_back(std::pair<CScript, CAmount>(scriptPubKey, rcp.amount));
+ CRecipient recipient = {scriptPubKey, rcp.amount, rcp.fSubtractFeeFromAmount};
+ vecSend.push_back(recipient);
total += rcp.amount;
}
@@ -260,17 +268,21 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
LOCK2(cs_main, wallet->cs_wallet);
transaction.newPossibleKeyChange(wallet);
+
CAmount nFeeRequired = 0;
+ int nChangePosRet = -1;
std::string strFailReason;
CWalletTx *newTx = transaction.getTransaction();
CReserveKey *keyChange = transaction.getPossibleKeyChange();
- bool fCreated = wallet->CreateTransaction(vecSend, *newTx, *keyChange, nFeeRequired, strFailReason, coinControl);
+ bool fCreated = wallet->CreateTransaction(vecSend, *newTx, *keyChange, nFeeRequired, nChangePosRet, strFailReason, coinControl);
transaction.setTransactionFee(nFeeRequired);
+ if (fSubtractFeeFromAmount && fCreated)
+ transaction.reassignAmounts(nChangePosRet);
if(!fCreated)
{
- if((total + nFeeRequired) > nBalance)
+ if(!fSubtractFeeFromAmount && (total + nFeeRequired) > nBalance)
{
return SendCoinsReturn(AmountWithFeeExceedsBalance);
}
diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h
index 4a9a12beaa..e263438880 100644
--- a/src/qt/walletmodel.h
+++ b/src/qt/walletmodel.h
@@ -8,7 +8,7 @@
#include "paymentrequestplus.h"
#include "walletmodeltransaction.h"
-#include "allocators.h" /* for SecureString */
+#include "support/allocators/secure.h"
#include <map>
#include <vector>
@@ -36,9 +36,9 @@ QT_END_NAMESPACE
class SendCoinsRecipient
{
public:
- explicit SendCoinsRecipient() : amount(0), nVersion(SendCoinsRecipient::CURRENT_VERSION) { }
+ explicit SendCoinsRecipient() : amount(0), fSubtractFeeFromAmount(false), nVersion(SendCoinsRecipient::CURRENT_VERSION) { }
explicit SendCoinsRecipient(const QString &addr, const QString &label, const CAmount& amount, const QString &message):
- address(addr), label(label), amount(amount), message(message), nVersion(SendCoinsRecipient::CURRENT_VERSION) {}
+ address(addr), label(label), amount(amount), message(message), fSubtractFeeFromAmount(false), nVersion(SendCoinsRecipient::CURRENT_VERSION) {}
// If from an unauthenticated payment request, this is used for storing
// the addresses, e.g. address-A<br />address-B<br />address-C.
@@ -56,6 +56,8 @@ public:
// Empty if no authentication or invalid signature/cert/etc.
QString authenticatedMerchant;
+ bool fSubtractFeeFromAmount; // memory only
+
static const int CURRENT_VERSION = 1;
int nVersion;
diff --git a/src/qt/walletmodeltransaction.cpp b/src/qt/walletmodeltransaction.cpp
index 8f32e46148..206bb7c774 100644
--- a/src/qt/walletmodeltransaction.cpp
+++ b/src/qt/walletmodeltransaction.cpp
@@ -4,7 +4,7 @@
#include "walletmodeltransaction.h"
-#include "wallet.h"
+#include "wallet/wallet.h"
WalletModelTransaction::WalletModelTransaction(const QList<SendCoinsRecipient> &recipients) :
recipients(recipients),
@@ -46,6 +46,38 @@ void WalletModelTransaction::setTransactionFee(const CAmount& newFee)
fee = newFee;
}
+void WalletModelTransaction::reassignAmounts(int nChangePosRet)
+{
+ int i = 0;
+ for (QList<SendCoinsRecipient>::iterator it = recipients.begin(); it != recipients.end(); ++it)
+ {
+ SendCoinsRecipient& rcp = (*it);
+
+ if (rcp.paymentRequest.IsInitialized())
+ {
+ CAmount subtotal = 0;
+ const payments::PaymentDetails& details = rcp.paymentRequest.getDetails();
+ for (int j = 0; j < details.outputs_size(); j++)
+ {
+ const payments::Output& out = details.outputs(j);
+ if (out.amount() <= 0) continue;
+ if (i == nChangePosRet)
+ i++;
+ subtotal += walletTransaction->vout[i].nValue;
+ i++;
+ }
+ rcp.amount = subtotal;
+ }
+ else // normal recipient (no payment request)
+ {
+ if (i == nChangePosRet)
+ i++;
+ rcp.amount = walletTransaction->vout[i].nValue;
+ i++;
+ }
+ }
+}
+
CAmount WalletModelTransaction::getTotalTransactionAmount()
{
CAmount totalTransactionAmount = 0;
diff --git a/src/qt/walletmodeltransaction.h b/src/qt/walletmodeltransaction.h
index b6bb6d67f6..7765fea4af 100644
--- a/src/qt/walletmodeltransaction.h
+++ b/src/qt/walletmodeltransaction.h
@@ -35,8 +35,10 @@ public:
void newPossibleKeyChange(CWallet *wallet);
CReserveKey *getPossibleKeyChange();
+ void reassignAmounts(int nChangePosRet); // needed for the subtract-fee-from-amount feature
+
private:
- const QList<SendCoinsRecipient> recipients;
+ QList<SendCoinsRecipient> recipients;
CWalletTx *walletTransaction;
CReserveKey *keyChange;
CAmount fee;