aboutsummaryrefslogtreecommitdiff
path: root/src/qt/addresstablemodel.cpp
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2013-07-22 16:50:39 +1000
committerGavin Andresen <gavinandresen@gmail.com>2013-08-22 16:18:25 +1000
commita41d5fe01947f2f878c055670986a165af800f9a (patch)
tree40eeada1ebc180f8e3669a7d164104686dc0c618 /src/qt/addresstablemodel.cpp
parent47d0534368fbf0e3fb2cad7d05d60501d29f62aa (diff)
Payment Protocol: X509-validated payment requests
Add support for a Payment Protocol to Bitcoin-Qt. Payment messages are protocol-buffer encoded and communicated over http(s), so this adds a dependency on the Google protocol buffer library, and requires Qt with OpenSSL support.
Diffstat (limited to 'src/qt/addresstablemodel.cpp')
-rw-r--r--src/qt/addresstablemodel.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp
index 823730c4ca..dcc70222cc 100644
--- a/src/qt/addresstablemodel.cpp
+++ b/src/qt/addresstablemodel.cpp
@@ -62,9 +62,19 @@ public:
BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& item, wallet->mapAddressBook)
{
const CBitcoinAddress& address = item.first;
+
+ AddressTableEntry::Type addressType;
+ const std::string& strPurpose = item.second.purpose;
+ if (strPurpose == "send") addressType = AddressTableEntry::Sending;
+ else if (strPurpose == "receive") addressType = AddressTableEntry::Receiving;
+ else if (strPurpose == "unknown") {
+ bool fMine = IsMine(*wallet, address.Get());
+ addressType = (fMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending);
+ }
+ else continue; // "refund" addresses aren't shown, and change addresses aren't in mapAddressBook at all.
+
const std::string& strName = item.second.name;
- bool fMine = IsMine(*wallet, address.Get());
- cachedAddressTable.append(AddressTableEntry(fMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending,
+ cachedAddressTable.append(AddressTableEntry(addressType,
QString::fromStdString(strName),
QString::fromStdString(address.ToString())));
}
@@ -215,7 +225,7 @@ bool AddressTableModel::setData(const QModelIndex &index, const QVariant &value,
if(!index.isValid())
return false;
AddressTableEntry *rec = static_cast<AddressTableEntry*>(index.internalPointer());
-
+ std::string strPurpose = (rec->type == AddressTableEntry::Sending ? "send" : "receive");
editStatus = OK;
if(role == Qt::EditRole)
@@ -229,7 +239,7 @@ bool AddressTableModel::setData(const QModelIndex &index, const QVariant &value,
editStatus = NO_CHANGES;
return false;
}
- wallet->SetAddressBookName(CBitcoinAddress(rec->address.toStdString()).Get(), value.toString().toStdString());
+ wallet->SetAddressBook(CBitcoinAddress(rec->address.toStdString()).Get(), value.toString().toStdString(), strPurpose);
break;
case Address:
// Do nothing, if old address == new address
@@ -257,9 +267,9 @@ bool AddressTableModel::setData(const QModelIndex &index, const QVariant &value,
{
LOCK(wallet->cs_wallet);
// Remove old entry
- wallet->DelAddressBookName(CBitcoinAddress(rec->address.toStdString()).Get());
+ wallet->DelAddressBook(CBitcoinAddress(rec->address.toStdString()).Get());
// Add new entry with new address
- wallet->SetAddressBookName(CBitcoinAddress(value.toString().toStdString()).Get(), rec->label.toStdString());
+ wallet->SetAddressBook(CBitcoinAddress(value.toString().toStdString()).Get(), rec->label.toStdString(), strPurpose);
}
}
break;
@@ -368,7 +378,8 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con
// Add entry
{
LOCK(wallet->cs_wallet);
- wallet->SetAddressBookName(CBitcoinAddress(strAddress).Get(), strLabel);
+ wallet->SetAddressBook(CBitcoinAddress(strAddress).Get(), strLabel,
+ (type == Send ? "send" : "receive"));
}
return QString::fromStdString(strAddress);
}
@@ -385,7 +396,7 @@ bool AddressTableModel::removeRows(int row, int count, const QModelIndex &parent
}
{
LOCK(wallet->cs_wallet);
- wallet->DelAddressBookName(CBitcoinAddress(rec->address.toStdString()).Get());
+ wallet->DelAddressBook(CBitcoinAddress(rec->address.toStdString()).Get());
}
return true;
}