mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-16 18:39:59 +01:00
interfaces: Stop exposing wallet destdata to gui
Stop giving GUI access to destdata rows in database. Replace with narrow API just for saving and reading receive request information. This simplifies code and should prevent the GUI from interfering with other destdata like address-used status. Note: No user-visible behavior is changing in this commit. New CWallet::SetAddressReceiveRequest() implementation avoids a bug in CWallet::AddDestData() where a modification would leave the previous value in memory while writing the new value to disk. But it doesn't matter because the GUI doesn't currently expose the ability to modify receive requests, only to add and erase them.
This commit is contained in:
@@ -10,7 +10,10 @@
|
||||
#include <qt/walletmodel.h>
|
||||
|
||||
#include <clientversion.h>
|
||||
#include <interfaces/wallet.h>
|
||||
#include <key_io.h>
|
||||
#include <streams.h>
|
||||
#include <util/string.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
@@ -18,10 +21,9 @@ RecentRequestsTableModel::RecentRequestsTableModel(WalletModel *parent) :
|
||||
QAbstractTableModel(parent), walletModel(parent)
|
||||
{
|
||||
// Load entries from wallet
|
||||
std::vector<std::string> vReceiveRequests;
|
||||
parent->loadReceiveRequests(vReceiveRequests);
|
||||
for (const std::string& request : vReceiveRequests)
|
||||
for (const std::string& request : parent->wallet().getAddressReceiveRequests()) {
|
||||
addNewRequest(request);
|
||||
}
|
||||
|
||||
/* These columns must match the indices in the ColumnIndex enumeration */
|
||||
columns << tr("Date") << tr("Label") << tr("Message") << getAmountTitle();
|
||||
@@ -143,7 +145,7 @@ bool RecentRequestsTableModel::removeRows(int row, int count, const QModelIndex
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
const RecentRequestEntry* rec = &list[row+i];
|
||||
if (!walletModel->saveReceiveRequest(rec->recipient.address.toStdString(), rec->id, ""))
|
||||
if (!walletModel->wallet().setAddressReceiveRequest(DecodeDestination(rec->recipient.address.toStdString()), ToString(rec->id), ""))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -172,7 +174,7 @@ void RecentRequestsTableModel::addNewRequest(const SendCoinsRecipient &recipient
|
||||
CDataStream ss(SER_DISK, CLIENT_VERSION);
|
||||
ss << newEntry;
|
||||
|
||||
if (!walletModel->saveReceiveRequest(recipient.address.toStdString(), newEntry.id, ss.str()))
|
||||
if (!walletModel->wallet().setAddressReceiveRequest(DecodeDestination(recipient.address.toStdString()), ToString(newEntry.id), ss.str()))
|
||||
return;
|
||||
|
||||
addNewRequest(newEntry);
|
||||
|
||||
Reference in New Issue
Block a user