aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/qt/clientmodel.cpp7
-rw-r--r--src/qt/clientmodel.h2
-rw-r--r--src/qt/forms/sendcoinsdialog.ui30
-rw-r--r--src/qt/sendcoinsdialog.cpp14
-rw-r--r--src/qt/sendcoinsdialog.h1
5 files changed, 47 insertions, 7 deletions
diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp
index 4e6a34c79f..e39bb7ecb1 100644
--- a/src/qt/clientmodel.cpp
+++ b/src/qt/clientmodel.cpp
@@ -60,7 +60,7 @@ void ClientModel::update()
addressTableModel->update();
}
-ClientModel::StatusCode ClientModel::sendCoins(const QString &payTo, qint64 payAmount)
+ClientModel::StatusCode ClientModel::sendCoins(const QString &payTo, qint64 payAmount, const QString &addToAddressBookAs)
{
uint160 hash160 = 0;
bool valid = false;
@@ -95,7 +95,7 @@ ClientModel::StatusCode ClientModel::sendCoins(const QString &payTo, qint64 payA
std::string strError = SendMoney(scriptPubKey, payAmount, wtx, true);
if (strError == "")
{
- return OK;
+ // OK
}
else if (strError == "ABORTED")
{
@@ -107,11 +107,12 @@ ClientModel::StatusCode ClientModel::sendCoins(const QString &payTo, qint64 payA
return MiscError;
}
}
+
// Add addresses that we've sent to to the address book
std::string strAddress = payTo.toStdString();
CRITICAL_BLOCK(cs_mapAddressBook)
if (!mapAddressBook.count(strAddress))
- SetAddressBookName(strAddress, "");
+ SetAddressBookName(strAddress, addToAddressBookAs.toStdString());
return OK;
}
diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h
index 169ed8c4c9..da3e52e20e 100644
--- a/src/qt/clientmodel.h
+++ b/src/qt/clientmodel.h
@@ -39,7 +39,7 @@ public:
int getTotalBlocksEstimate() const;
/* Send coins */
- StatusCode sendCoins(const QString &payTo, qint64 payAmount);
+ StatusCode sendCoins(const QString &payTo, qint64 payAmount, const QString &addToAddressBookAs=QString());
private:
OptionsModel *optionsModel;
AddressTableModel *addressTableModel;
diff --git a/src/qt/forms/sendcoinsdialog.ui b/src/qt/forms/sendcoinsdialog.ui
index b88839a7ca..46c71456af 100644
--- a/src/qt/forms/sendcoinsdialog.ui
+++ b/src/qt/forms/sendcoinsdialog.ui
@@ -16,7 +16,7 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
- <item row="4" column="0">
+ <item row="5" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Amount:</string>
@@ -90,9 +90,33 @@
</property>
</widget>
</item>
- <item row="4" column="1">
+ <item row="5" column="1">
<widget class="BitcoinAmountField" name="payAmount" native="true"/>
</item>
+ <item row="4" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QCheckBox" name="addToAddressBook">
+ <property name="toolTip">
+ <string>Add specified destination address to address book</string>
+ </property>
+ <property name="text">
+ <string>Add to address book as</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="addAsLabel">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string>Label to add address as</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
</layout>
</item>
<item>
@@ -170,6 +194,8 @@
</customwidgets>
<tabstops>
<tabstop>payTo</tabstop>
+ <tabstop>addToAddressBook</tabstop>
+ <tabstop>addAsLabel</tabstop>
<tabstop>payAmount</tabstop>
<tabstop>pasteButton</tabstop>
<tabstop>addressBookButton</tabstop>
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp
index 5f9ee18a37..67c270e6f8 100644
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -46,6 +46,7 @@ void SendCoinsDialog::on_sendButton_clicked()
{
bool valid;
QString payAmount = ui->payAmount->text();
+ QString label;
qint64 payAmountParsed;
valid = ParseMoney(payAmount.toStdString(), payAmountParsed);
@@ -58,7 +59,13 @@ void SendCoinsDialog::on_sendButton_clicked()
return;
}
- switch(model->sendCoins(ui->payTo->text(), payAmountParsed))
+ if(ui->addToAddressBook->isChecked())
+ {
+ // Add address to address book under label, if specified
+ label = ui->addAsLabel->text();
+ }
+
+ switch(model->sendCoins(ui->payTo->text(), payAmountParsed, label))
{
case ClientModel::InvalidAddress:
QMessageBox::warning(this, tr("Send Coins"),
@@ -110,3 +117,8 @@ void SendCoinsDialog::on_buttonBox_rejected()
{
reject();
}
+
+void SendCoinsDialog::on_addToAddressBook_toggled(bool checked)
+{
+ ui->addAsLabel->setEnabled(checked);
+}
diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h
index f73c38d63a..206a854ee1 100644
--- a/src/qt/sendcoinsdialog.h
+++ b/src/qt/sendcoinsdialog.h
@@ -23,6 +23,7 @@ private:
ClientModel *model;
private slots:
+ void on_addToAddressBook_toggled(bool checked);
void on_buttonBox_rejected();
void on_addressBookButton_clicked();
void on_pasteButton_clicked();