mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user