From 51616fd1358c566296f337377ed96b1ba2f3882c Mon Sep 17 00:00:00 2001 From: Jeremiah Buddenhagen Date: Tue, 23 Jan 2018 11:05:28 -0800 Subject: [PATCH] Add tx comment to send dialog --- src/qt/forms/sendcoinsdialog.ui | 26 ++++++++++++++++++++------ src/qt/sendcoinsdialog.cpp | 3 ++- src/qt/walletmodel.cpp | 3 ++- src/qt/walletmodeltransaction.cpp | 10 ++++++++-- src/qt/walletmodeltransaction.h | 4 +++- 5 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/qt/forms/sendcoinsdialog.ui b/src/qt/forms/sendcoinsdialog.ui index 069d8603a..e51d4efe0 100644 --- a/src/qt/forms/sendcoinsdialog.ui +++ b/src/qt/forms/sendcoinsdialog.ui @@ -13,7 +13,7 @@ Send Coins - + 8 @@ -588,7 +588,7 @@ 0 0 830 - 104 + 68 @@ -628,6 +628,20 @@ + + + + + + TX Comment: + + + + + + + + @@ -765,10 +779,10 @@ Using the fallbackfee can result in sending a transaction that will take several hours or days (or never) to confirm. Consider choosing your fee manually or wait until you have validated the complete chain. - - 75 - true - + + 75 + true + Warning: Fee estimation is currently not possible. diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index d17537057..a5fe69bc2 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -261,7 +261,8 @@ void SendCoinsDialog::on_sendButton_clicked() } // prepare transaction for getting txFee earlier - WalletModelTransaction currentTransaction(recipients); + std::string txComment = ui->txComment->text().toStdString(); + WalletModelTransaction currentTransaction(recipients, txComment); WalletModel::SendCoinsReturn prepareStatus; // Always use a CCoinControl instance, use the CoinControlDialog instance if CoinControl has been enabled diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 3ca726d0f..323eae3be 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -277,7 +277,8 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact CWalletTx *newTx = transaction.getTransaction(); CReserveKey *keyChange = transaction.getPossibleKeyChange(); - bool fCreated = wallet->CreateTransaction(vecSend, *newTx, *keyChange, nFeeRequired, nChangePosRet, strFailReason, coinControl); + std::string strTxComment = transaction.getTxComment(); + bool fCreated = wallet->CreateTransaction(vecSend, *newTx, *keyChange, nFeeRequired, nChangePosRet, strFailReason, coinControl, strTxComment); transaction.setTransactionFee(nFeeRequired); if (fSubtractFeeFromAmount && fCreated) transaction.reassignAmounts(nChangePosRet); diff --git a/src/qt/walletmodeltransaction.cpp b/src/qt/walletmodeltransaction.cpp index 8bc9ef725..9ee7077db 100644 --- a/src/qt/walletmodeltransaction.cpp +++ b/src/qt/walletmodeltransaction.cpp @@ -7,11 +7,12 @@ #include "policy/policy.h" #include "wallet/wallet.h" -WalletModelTransaction::WalletModelTransaction(const QList &_recipients) : +WalletModelTransaction::WalletModelTransaction(const QList &_recipients, std::string txComment) : recipients(_recipients), walletTransaction(0), keyChange(0), - fee(0) + fee(0), + strTxComment(txComment) { walletTransaction = new CWalletTx(); } @@ -27,6 +28,11 @@ QList WalletModelTransaction::getRecipients() return recipients; } +std::string WalletModelTransaction::getTxComment() +{ + return strTxComment; +} + CWalletTx *WalletModelTransaction::getTransaction() { return walletTransaction; diff --git a/src/qt/walletmodeltransaction.h b/src/qt/walletmodeltransaction.h index 64922efad..cf87c506c 100644 --- a/src/qt/walletmodeltransaction.h +++ b/src/qt/walletmodeltransaction.h @@ -19,7 +19,7 @@ class CWalletTx; class WalletModelTransaction { public: - explicit WalletModelTransaction(const QList &recipients); + explicit WalletModelTransaction(const QList &recipients, std::string txComment); ~WalletModelTransaction(); QList getRecipients(); @@ -29,6 +29,7 @@ public: void setTransactionFee(const CAmount& newFee); CAmount getTransactionFee(); + std::string getTxComment(); CAmount getTotalTransactionAmount(); @@ -42,6 +43,7 @@ private: CWalletTx *walletTransaction; CReserveKey *keyChange; CAmount fee; + std::string strTxComment; }; #endif // BITCOIN_QT_WALLETMODELTRANSACTION_H