Add tx comment to send dialog

This commit is contained in:
Jeremiah Buddenhagen 2018-01-23 11:05:28 -08:00
parent 5b708f9ae1
commit 51616fd135
5 changed files with 35 additions and 11 deletions

View File

@ -13,7 +13,7 @@
<property name="windowTitle">
<string>Send Coins</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,1,0,0">
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,1,0,0,0">
<property name="bottomMargin">
<number>8</number>
</property>
@ -588,7 +588,7 @@
<x>0</x>
<y>0</y>
<width>830</width>
<height>104</height>
<height>68</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,1">
@ -628,6 +628,20 @@
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="txCommentLabel">
<property name="text">
<string>TX Comment: </string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="txComment"/>
</item>
</layout>
</item>
<item>
<widget class="QFrame" name="frameFee">
<property name="sizePolicy">
@ -765,10 +779,10 @@
<string>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.</string>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Warning: Fee estimation is currently not possible.</string>

View File

@ -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

View File

@ -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);

View File

@ -7,11 +7,12 @@
#include "policy/policy.h"
#include "wallet/wallet.h"
WalletModelTransaction::WalletModelTransaction(const QList<SendCoinsRecipient> &_recipients) :
WalletModelTransaction::WalletModelTransaction(const QList<SendCoinsRecipient> &_recipients, std::string txComment) :
recipients(_recipients),
walletTransaction(0),
keyChange(0),
fee(0)
fee(0),
strTxComment(txComment)
{
walletTransaction = new CWalletTx();
}
@ -27,6 +28,11 @@ QList<SendCoinsRecipient> WalletModelTransaction::getRecipients()
return recipients;
}
std::string WalletModelTransaction::getTxComment()
{
return strTxComment;
}
CWalletTx *WalletModelTransaction::getTransaction()
{
return walletTransaction;

View File

@ -19,7 +19,7 @@ class CWalletTx;
class WalletModelTransaction
{
public:
explicit WalletModelTransaction(const QList<SendCoinsRecipient> &recipients);
explicit WalletModelTransaction(const QList<SendCoinsRecipient> &recipients, std::string txComment);
~WalletModelTransaction();
QList<SendCoinsRecipient> 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