Merge pull request #6 from mtjburton/Blackcoin-Lore
Porting memory/performance fixes from upstream
This commit is contained in:
@@ -10,57 +10,73 @@
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "compat/endian.h"
|
||||
|
||||
uint16_t static inline ReadLE16(const unsigned char* ptr)
|
||||
{
|
||||
return le16toh(*((uint16_t*)ptr));
|
||||
uint16_t x;
|
||||
memcpy((char*)&x, ptr, 2);
|
||||
return le16toh(x);
|
||||
}
|
||||
|
||||
uint32_t static inline ReadLE32(const unsigned char* ptr)
|
||||
{
|
||||
return le32toh(*((uint32_t*)ptr));
|
||||
uint32_t x;
|
||||
memcpy((char*)&x, ptr, 4);
|
||||
return le32toh(x);
|
||||
}
|
||||
|
||||
uint64_t static inline ReadLE64(const unsigned char* ptr)
|
||||
{
|
||||
return le64toh(*((uint64_t*)ptr));
|
||||
uint64_t x;
|
||||
memcpy((char*)&x, ptr, 8);
|
||||
return le64toh(x);
|
||||
}
|
||||
|
||||
void static inline WriteLE16(unsigned char* ptr, uint16_t x)
|
||||
{
|
||||
*((uint16_t*)ptr) = htole16(x);
|
||||
uint16_t v = htole16(x);
|
||||
memcpy(ptr, (char*)&v, 2);
|
||||
}
|
||||
|
||||
void static inline WriteLE32(unsigned char* ptr, uint32_t x)
|
||||
{
|
||||
*((uint32_t*)ptr) = htole32(x);
|
||||
uint32_t v = htole32(x);
|
||||
memcpy(ptr, (char*)&v, 4);
|
||||
}
|
||||
|
||||
void static inline WriteLE64(unsigned char* ptr, uint64_t x)
|
||||
{
|
||||
*((uint64_t*)ptr) = htole64(x);
|
||||
uint64_t v = htole64(x);
|
||||
memcpy(ptr, (char*)&v, 8);
|
||||
}
|
||||
|
||||
uint32_t static inline ReadBE32(const unsigned char* ptr)
|
||||
{
|
||||
return be32toh(*((uint32_t*)ptr));
|
||||
uint32_t x;
|
||||
memcpy((char*)&x, ptr, 4);
|
||||
return be32toh(x);
|
||||
}
|
||||
|
||||
uint64_t static inline ReadBE64(const unsigned char* ptr)
|
||||
{
|
||||
return be64toh(*((uint64_t*)ptr));
|
||||
uint64_t x;
|
||||
memcpy((char*)&x, ptr, 8);
|
||||
return be64toh(x);
|
||||
}
|
||||
|
||||
void static inline WriteBE32(unsigned char* ptr, uint32_t x)
|
||||
{
|
||||
*((uint32_t*)ptr) = htobe32(x);
|
||||
uint32_t v = htobe32(x);
|
||||
memcpy(ptr, (char*)&v, 4);
|
||||
}
|
||||
|
||||
void static inline WriteBE64(unsigned char* ptr, uint64_t x)
|
||||
{
|
||||
*((uint64_t*)ptr) = htobe64(x);
|
||||
uint64_t v = htobe64(x);
|
||||
memcpy(ptr, (char*)&v, 8);
|
||||
}
|
||||
|
||||
#endif // BITCOIN_CRYPTO_COMMON_H
|
||||
|
||||
@@ -109,8 +109,8 @@ static bool multiUserAuthorized(std::string strUserPass)
|
||||
std::string strHash = vFields[2];
|
||||
|
||||
unsigned int KEY_SIZE = 32;
|
||||
unsigned char *out = new unsigned char[KEY_SIZE];
|
||||
|
||||
unsigned char out[KEY_SIZE];
|
||||
|
||||
CHMAC_SHA256(reinterpret_cast<const unsigned char*>(strSalt.c_str()), strSalt.size()).Write(reinterpret_cast<const unsigned char*>(strPass.c_str()), strPass.size()).Finalize(out);
|
||||
std::vector<unsigned char> hexvec(out, out+KEY_SIZE);
|
||||
std::string strHashFromPass = HexStr(hexvec);
|
||||
|
||||
@@ -83,7 +83,7 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode mode,
|
||||
deleteAction = new QAction(ui->deleteAddress->text(), this);
|
||||
|
||||
// Build context menu
|
||||
contextMenu = new QMenu();
|
||||
contextMenu = new QMenu(this);
|
||||
contextMenu->addAction(copyAddressAction);
|
||||
contextMenu->addAction(copyLabelAction);
|
||||
contextMenu->addAction(editAction);
|
||||
|
||||
@@ -86,7 +86,7 @@ BanTableModel::BanTableModel(ClientModel *parent) :
|
||||
clientModel(parent)
|
||||
{
|
||||
columns << tr("IP/Netmask") << tr("Banned Until");
|
||||
priv = new BanTablePriv();
|
||||
priv.reset(new BanTablePriv());
|
||||
// default to unsorted
|
||||
priv->sortColumn = -1;
|
||||
|
||||
@@ -94,6 +94,11 @@ BanTableModel::BanTableModel(ClientModel *parent) :
|
||||
refresh();
|
||||
}
|
||||
|
||||
BanTableModel::~BanTableModel()
|
||||
{
|
||||
// Intentionally left empty
|
||||
}
|
||||
|
||||
int BanTableModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
|
||||
@@ -40,6 +40,7 @@ class BanTableModel : public QAbstractTableModel
|
||||
|
||||
public:
|
||||
explicit BanTableModel(ClientModel *parent = 0);
|
||||
~BanTableModel();
|
||||
void startAutoRefresh();
|
||||
void stopAutoRefresh();
|
||||
|
||||
@@ -66,7 +67,7 @@ public Q_SLOTS:
|
||||
private:
|
||||
ClientModel *clientModel;
|
||||
QStringList columns;
|
||||
BanTablePriv *priv;
|
||||
std::unique_ptr<BanTablePriv> priv;
|
||||
};
|
||||
|
||||
#endif // BITCOIN_QT_BANTABLEMODEL_H
|
||||
|
||||
@@ -365,9 +365,8 @@ void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
|
||||
void BitcoinApplication::createSplashScreen(const NetworkStyle *networkStyle)
|
||||
{
|
||||
SplashScreen *splash = new SplashScreen(0, networkStyle);
|
||||
// We don't hold a direct pointer to the splash screen after creation, so use
|
||||
// Qt::WA_DeleteOnClose to make sure that the window will be deleted eventually.
|
||||
splash->setAttribute(Qt::WA_DeleteOnClose);
|
||||
// We don't hold a direct pointer to the splash screen after creation, but the splash
|
||||
// screen will take care of deleting itself when slotFinish happens.
|
||||
splash->show();
|
||||
connect(this, SIGNAL(splashFinished(QWidget*)), splash, SLOT(slotFinish(QWidget*)));
|
||||
}
|
||||
|
||||
@@ -1178,7 +1178,7 @@ void UnitDisplayStatusBarControl::mousePressEvent(QMouseEvent *event)
|
||||
/** Creates context menu, its actions, and wires up all the relevant signals for mouse events. */
|
||||
void UnitDisplayStatusBarControl::createContextMenu()
|
||||
{
|
||||
menu = new QMenu();
|
||||
menu = new QMenu(this);
|
||||
Q_FOREACH(BitcoinUnits::Unit u, BitcoinUnits::availableUnits())
|
||||
{
|
||||
QAction *menuAction = new QAction(QString(BitcoinUnits::name(u)), this);
|
||||
|
||||
@@ -52,7 +52,7 @@ CoinControlDialog::CoinControlDialog(const PlatformStyle *platformStyle, QWidget
|
||||
unlockAction = new QAction(tr("Unlock unspent"), this); // we need to enable/disable this
|
||||
|
||||
// context menu
|
||||
contextMenu = new QMenu();
|
||||
contextMenu = new QMenu(this);
|
||||
contextMenu->addAction(copyAddressAction);
|
||||
contextMenu->addAction(copyLabelAction);
|
||||
contextMenu->addAction(copyAmountAction);
|
||||
|
||||
@@ -573,7 +573,8 @@ void TableViewLastColumnResizingFixer::on_geometriesChanged()
|
||||
* Initializes all internal variables and prepares the
|
||||
* the resize modes of the last 2 columns of the table and
|
||||
*/
|
||||
TableViewLastColumnResizingFixer::TableViewLastColumnResizingFixer(QTableView* table, int lastColMinimumWidth, int allColsMinimumWidth) :
|
||||
TableViewLastColumnResizingFixer::TableViewLastColumnResizingFixer(QTableView* table, int lastColMinimumWidth, int allColsMinimumWidth, QObject *parent) :
|
||||
QObject(parent),
|
||||
tableView(table),
|
||||
lastColumnMinimumWidth(lastColMinimumWidth),
|
||||
allColumnsMinimumWidth(allColsMinimumWidth)
|
||||
@@ -758,6 +759,11 @@ LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef
|
||||
{
|
||||
// loop through the list of startup items and try to find the bitcoin app
|
||||
CFArrayRef listSnapshot = LSSharedFileListCopySnapshot(list, NULL);
|
||||
if (listSnapshot == NULL) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// loop through the list of startup items and try to find the bitcoin app
|
||||
for(int i = 0; i < CFArrayGetCount(listSnapshot); i++) {
|
||||
LSSharedFileListItemRef item = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(listSnapshot, i);
|
||||
UInt32 resolutionFlags = kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes;
|
||||
@@ -774,31 +780,48 @@ LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef
|
||||
LSSharedFileListItemResolve(item, resolutionFlags, ¤tItemURL, NULL);
|
||||
#endif
|
||||
|
||||
if(currentItemURL && CFEqual(currentItemURL, findUrl)) {
|
||||
// found
|
||||
CFRelease(currentItemURL);
|
||||
return item;
|
||||
}
|
||||
if(currentItemURL) {
|
||||
if (CFEqual(currentItemURL, findUrl)) {
|
||||
// found
|
||||
CFRelease(listSnapshot);
|
||||
CFRelease(currentItemURL);
|
||||
return item;
|
||||
}
|
||||
CFRelease(currentItemURL);
|
||||
}
|
||||
}
|
||||
|
||||
CFRelease(listSnapshot);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool GetStartOnSystemStartup()
|
||||
{
|
||||
CFURLRef bitcoinAppUrl = CFBundleCopyBundleURL(CFBundleGetMainBundle());
|
||||
LSSharedFileListRef loginItems = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
|
||||
|
||||
if (bitcoinAppUrl == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
LSSharedFileListRef loginItems = LSSharedFileListCreate(nullptr, kLSSharedFileListSessionLoginItems, nullptr);
|
||||
LSSharedFileListItemRef foundItem = findStartupItemInList(loginItems, bitcoinAppUrl);
|
||||
LSSharedFileListRef loginItems = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
|
||||
|
||||
CFRelease(bitcoinAppUrl);
|
||||
return !!foundItem; // return boolified object
|
||||
}
|
||||
|
||||
bool SetStartOnSystemStartup(bool fAutoStart)
|
||||
{
|
||||
CFURLRef bitcoinAppUrl = CFBundleCopyBundleURL(CFBundleGetMainBundle());
|
||||
LSSharedFileListRef loginItems = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
|
||||
|
||||
if (bitcoinAppUrl == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
LSSharedFileListRef loginItems = LSSharedFileListCreate(nullptr, kLSSharedFileListSessionLoginItems, nullptr);
|
||||
LSSharedFileListItemRef foundItem = findStartupItemInList(loginItems, bitcoinAppUrl);
|
||||
LSSharedFileListRef loginItems = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
|
||||
|
||||
if(fAutoStart && !foundItem) {
|
||||
// add bitcoin app to startup item list
|
||||
@@ -808,6 +831,8 @@ bool SetStartOnSystemStartup(bool fAutoStart)
|
||||
// remove item
|
||||
LSSharedFileListItemRemove(loginItems, foundItem);
|
||||
}
|
||||
|
||||
CFRelease(bitcoinAppUrl);
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
@@ -830,14 +855,17 @@ void restoreWindowGeometry(const QString& strSetting, const QSize& defaultSize,
|
||||
QPoint pos = settings.value(strSetting + "Pos").toPoint();
|
||||
QSize size = settings.value(strSetting + "Size", defaultSize).toSize();
|
||||
|
||||
if (!pos.x() && !pos.y()) {
|
||||
QRect screen = QApplication::desktop()->screenGeometry();
|
||||
pos.setX((screen.width() - size.width()) / 2);
|
||||
pos.setY((screen.height() - size.height()) / 2);
|
||||
}
|
||||
|
||||
parent->resize(size);
|
||||
parent->move(pos);
|
||||
|
||||
if ((!pos.x() && !pos.y()) || (QApplication::desktop()->screenNumber(parent) == -1))
|
||||
{
|
||||
QRect screen = QApplication::desktop()->screenGeometry();
|
||||
QPoint defaultPos((screen.width() - defaultSize.width()) / 2,
|
||||
(screen.height() - defaultSize.height()) / 2);
|
||||
parent->resize(defaultSize);
|
||||
parent->move(defaultPos);
|
||||
}
|
||||
}
|
||||
|
||||
void setClipboard(const QString& str)
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace GUIUtil
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TableViewLastColumnResizingFixer(QTableView* table, int lastColMinimumWidth, int allColsMinimumWidth);
|
||||
TableViewLastColumnResizingFixer(QTableView* table, int lastColMinimumWidth, int allColsMinimumWidth, QObject *parent);
|
||||
void stretchColumnWidth(int column);
|
||||
|
||||
private:
|
||||
|
||||
@@ -25,9 +25,9 @@ class TxViewDelegate : public QAbstractItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TxViewDelegate(const PlatformStyle *platformStyle):
|
||||
QAbstractItemDelegate(), unit(BitcoinUnits::BTC),
|
||||
platformStyle(platformStyle)
|
||||
TxViewDelegate(const PlatformStyle *_platformStyle, QObject *parent=nullptr):
|
||||
QAbstractItemDelegate(parent), unit(BitcoinUnits::BTC),
|
||||
platformStyle(_platformStyle)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -119,8 +119,7 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent)
|
||||
currentWatchOnlyBalance(-1),
|
||||
currentWatchUnconfBalance(-1),
|
||||
currentWatchImmatureBalance(-1),
|
||||
txdelegate(new TxViewDelegate(platformStyle)),
|
||||
filter(0)
|
||||
txdelegate(new TxViewDelegate(platformStyle, this))
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -213,7 +212,7 @@ void OverviewPage::setWalletModel(WalletModel *model)
|
||||
if(model && model->getOptionsModel())
|
||||
{
|
||||
// Set up transaction list
|
||||
filter = new TransactionFilterProxy();
|
||||
filter.reset(new TransactionFilterProxy());
|
||||
filter->setSourceModel(model->getTransactionTableModel());
|
||||
filter->setLimit(NUM_ITEMS);
|
||||
filter->setDynamicSortFilter(true);
|
||||
@@ -221,7 +220,7 @@ void OverviewPage::setWalletModel(WalletModel *model)
|
||||
filter->setShowInactive(false);
|
||||
filter->sort(TransactionTableModel::Status, Qt::DescendingOrder);
|
||||
|
||||
ui->listTransactions->setModel(filter);
|
||||
ui->listTransactions->setModel(filter.get());
|
||||
ui->listTransactions->setModelColumn(TransactionTableModel::ToAddress);
|
||||
|
||||
// Keep up to date with wallet
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "amount.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <memory>
|
||||
|
||||
class ClientModel;
|
||||
class TransactionFilterProxy;
|
||||
@@ -55,7 +56,7 @@ private:
|
||||
CAmount currentWatchImmatureBalance;
|
||||
|
||||
TxViewDelegate *txdelegate;
|
||||
TransactionFilterProxy *filter;
|
||||
std::unique_ptr<TransactionFilterProxy> filter;
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateDisplayUnit();
|
||||
|
||||
@@ -58,14 +58,19 @@ const char* BIP71_MIMETYPE_PAYMENTREQUEST = "application/bitcoin-paymentrequest"
|
||||
// BIP70 max payment request size in bytes (DoS protection)
|
||||
const qint64 BIP70_MAX_PAYMENTREQUEST_SIZE = 50000;
|
||||
|
||||
X509_STORE* PaymentServer::certStore = NULL;
|
||||
void PaymentServer::freeCertStore()
|
||||
struct X509StoreDeleter {
|
||||
void operator()(X509_STORE* b) {
|
||||
X509_STORE_free(b);
|
||||
}
|
||||
};
|
||||
|
||||
struct X509Deleter {
|
||||
void operator()(X509* b) { X509_free(b); }
|
||||
};
|
||||
|
||||
namespace // Anon namespace
|
||||
{
|
||||
if (PaymentServer::certStore != NULL)
|
||||
{
|
||||
X509_STORE_free(PaymentServer::certStore);
|
||||
PaymentServer::certStore = NULL;
|
||||
}
|
||||
std::unique_ptr<X509_STORE, X509StoreDeleter> certStore;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -107,20 +112,15 @@ static void ReportInvalidCertificate(const QSslCertificate& cert)
|
||||
//
|
||||
void PaymentServer::LoadRootCAs(X509_STORE* _store)
|
||||
{
|
||||
if (PaymentServer::certStore == NULL)
|
||||
atexit(PaymentServer::freeCertStore);
|
||||
else
|
||||
freeCertStore();
|
||||
|
||||
// Unit tests mostly use this, to pass in fake root CAs:
|
||||
if (_store)
|
||||
{
|
||||
PaymentServer::certStore = _store;
|
||||
certStore.reset(_store);
|
||||
return;
|
||||
}
|
||||
|
||||
// Normal execution, use either -rootcertificates or system certs:
|
||||
PaymentServer::certStore = X509_STORE_new();
|
||||
certStore.reset(X509_STORE_new());
|
||||
|
||||
// Note: use "-system-" default here so that users can pass -rootcertificates=""
|
||||
// and get 'I don't like X.509 certificates, don't trust anybody' behavior:
|
||||
@@ -167,11 +167,11 @@ void PaymentServer::LoadRootCAs(X509_STORE* _store)
|
||||
QByteArray certData = cert.toDer();
|
||||
const unsigned char *data = (const unsigned char *)certData.data();
|
||||
|
||||
X509* x509 = d2i_X509(0, &data, certData.size());
|
||||
if (x509 && X509_STORE_add_cert(PaymentServer::certStore, x509))
|
||||
std::unique_ptr<X509, X509Deleter> x509(d2i_X509(0, &data, certData.size()));
|
||||
if (x509 && X509_STORE_add_cert(certStore.get(), x509.get()))
|
||||
{
|
||||
// Note: X509_STORE_free will free the X509* objects when
|
||||
// the PaymentServer is destroyed
|
||||
// Note: X509_STORE increases the reference count to the X509 object,
|
||||
// we still have to release our reference to it.
|
||||
++nRootCerts;
|
||||
}
|
||||
else
|
||||
@@ -550,7 +550,7 @@ bool PaymentServer::processPaymentRequest(const PaymentRequestPlus& request, Sen
|
||||
recipient.paymentRequest = request;
|
||||
recipient.message = GUIUtil::HtmlEscape(request.getDetails().memo());
|
||||
|
||||
request.getMerchant(PaymentServer::certStore, recipient.authenticatedMerchant);
|
||||
request.getMerchant(certStore.get(), recipient.authenticatedMerchant);
|
||||
|
||||
QList<std::pair<CScript, CAmount> > sendingTos = request.getPayTo();
|
||||
QStringList addresses;
|
||||
@@ -807,3 +807,8 @@ bool PaymentServer::verifyAmount(const CAmount& requestAmount)
|
||||
}
|
||||
return fVerified;
|
||||
}
|
||||
|
||||
X509_STORE* PaymentServer::getCertStore()
|
||||
{
|
||||
return certStore.get();
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
static void LoadRootCAs(X509_STORE* store = NULL);
|
||||
|
||||
// Return certificate store
|
||||
static X509_STORE* getCertStore() { return certStore; }
|
||||
static X509_STORE* getCertStore();
|
||||
|
||||
// OptionsModel is used for getting proxy settings and display unit
|
||||
void setOptionsModel(OptionsModel *optionsModel);
|
||||
@@ -140,9 +140,6 @@ private:
|
||||
bool saveURIs; // true during startup
|
||||
QLocalServer* uriServer;
|
||||
|
||||
static X509_STORE* certStore; // Trusted root certificates
|
||||
static void freeCertStore();
|
||||
|
||||
QNetworkAccessManager* netManager; // Used to fetch payment requests
|
||||
|
||||
OptionsModel *optionsModel;
|
||||
|
||||
@@ -115,12 +115,12 @@ PeerTableModel::PeerTableModel(ClientModel *parent) :
|
||||
timer(0)
|
||||
{
|
||||
columns << tr("Node/Service") << tr("User Agent") << tr("Ping Time");
|
||||
priv = new PeerTablePriv();
|
||||
priv.reset(new PeerTablePriv());
|
||||
// default to unsorted
|
||||
priv->sortColumn = -1;
|
||||
|
||||
// set up timer for auto refresh
|
||||
timer = new QTimer();
|
||||
timer = new QTimer(this);
|
||||
connect(timer, SIGNAL(timeout()), SLOT(refresh()));
|
||||
timer->setInterval(MODEL_UPDATE_DELAY);
|
||||
|
||||
@@ -128,6 +128,11 @@ PeerTableModel::PeerTableModel(ClientModel *parent) :
|
||||
refresh();
|
||||
}
|
||||
|
||||
PeerTableModel::~PeerTableModel()
|
||||
{
|
||||
// Intentionally left empty
|
||||
}
|
||||
|
||||
void PeerTableModel::startAutoRefresh()
|
||||
{
|
||||
timer->start();
|
||||
|
||||
@@ -46,6 +46,7 @@ class PeerTableModel : public QAbstractTableModel
|
||||
|
||||
public:
|
||||
explicit PeerTableModel(ClientModel *parent = 0);
|
||||
~PeerTableModel();
|
||||
const CNodeCombinedStats *getNodeStats(int idx);
|
||||
int getRowByNodeId(NodeId nodeid);
|
||||
void startAutoRefresh();
|
||||
@@ -74,7 +75,7 @@ public Q_SLOTS:
|
||||
private:
|
||||
ClientModel *clientModel;
|
||||
QStringList columns;
|
||||
PeerTablePriv *priv;
|
||||
std::unique_ptr<PeerTablePriv> priv;
|
||||
QTimer *timer;
|
||||
};
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
ReceiveCoinsDialog::ReceiveCoinsDialog(const PlatformStyle *platformStyle, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::ReceiveCoinsDialog),
|
||||
columnResizingFixer(0),
|
||||
model(0),
|
||||
platformStyle(platformStyle)
|
||||
{
|
||||
@@ -48,7 +49,7 @@ ReceiveCoinsDialog::ReceiveCoinsDialog(const PlatformStyle *platformStyle, QWidg
|
||||
QAction *copyAmountAction = new QAction(tr("Copy amount"), this);
|
||||
|
||||
// context menu
|
||||
contextMenu = new QMenu();
|
||||
contextMenu = new QMenu(this);
|
||||
contextMenu->addAction(copyLabelAction);
|
||||
contextMenu->addAction(copyMessageAction);
|
||||
contextMenu->addAction(copyAmountAction);
|
||||
@@ -87,7 +88,7 @@ void ReceiveCoinsDialog::setModel(WalletModel *model)
|
||||
SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this,
|
||||
SLOT(recentRequestsView_selectionChanged(QItemSelection, QItemSelection)));
|
||||
// Last 2 columns are set by the columnResizingFixer, when the table geometry is ready.
|
||||
columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(tableView, AMOUNT_MINIMUM_COLUMN_WIDTH, DATE_COLUMN_WIDTH);
|
||||
columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(tableView, AMOUNT_MINIMUM_COLUMN_WIDTH, DATE_COLUMN_WIDTH, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
QRImageWidget::QRImageWidget(QWidget *parent):
|
||||
QLabel(parent), contextMenu(0)
|
||||
{
|
||||
contextMenu = new QMenu();
|
||||
contextMenu = new QMenu(this);
|
||||
QAction *saveImageAction = new QAction(tr("&Save Image..."), this);
|
||||
connect(saveImageAction, SIGNAL(triggered()), this, SLOT(saveImage()));
|
||||
contextMenu->addAction(saveImageAction);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
RecentRequestsTableModel::RecentRequestsTableModel(CWallet *wallet, WalletModel *parent) :
|
||||
walletModel(parent)
|
||||
QAbstractTableModel(parent), walletModel(parent)
|
||||
{
|
||||
Q_UNUSED(wallet);
|
||||
nReceiveRequestsMaxId = 0;
|
||||
|
||||
@@ -364,7 +364,7 @@ void RPCConsole::setClientModel(ClientModel *model)
|
||||
QAction* banAction365d = new QAction(tr("Ban Node for") + " " + tr("1 &year"), this);
|
||||
|
||||
// create peer table context menu
|
||||
peersTableContextMenu = new QMenu();
|
||||
peersTableContextMenu = new QMenu(this);
|
||||
peersTableContextMenu->addAction(disconnectAction);
|
||||
peersTableContextMenu->addAction(banAction1h);
|
||||
peersTableContextMenu->addAction(banAction24h);
|
||||
@@ -410,7 +410,7 @@ void RPCConsole::setClientModel(ClientModel *model)
|
||||
QAction* unbanAction = new QAction(tr("&Unban Node"), this);
|
||||
|
||||
// create ban table context menu
|
||||
banTableContextMenu = new QMenu();
|
||||
banTableContextMenu = new QMenu(this);
|
||||
banTableContextMenu->addAction(unbanAction);
|
||||
|
||||
// ban table context menu signals
|
||||
|
||||
@@ -134,6 +134,7 @@ void SplashScreen::slotFinish(QWidget *mainWin)
|
||||
{
|
||||
Q_UNUSED(mainWin);
|
||||
hide();
|
||||
deleteLater(); // No more need for this
|
||||
}
|
||||
|
||||
static void InitMessage(SplashScreen *splash, const std::string &message)
|
||||
|
||||
@@ -145,7 +145,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
|
||||
QAction *editLabelAction = new QAction(tr("Edit label"), this);
|
||||
QAction *showDetailsAction = new QAction(tr("Show transaction details"), this);
|
||||
|
||||
contextMenu = new QMenu();
|
||||
contextMenu = new QMenu(this);
|
||||
contextMenu->addAction(copyAddressAction);
|
||||
contextMenu->addAction(copyLabelAction);
|
||||
contextMenu->addAction(copyAmountAction);
|
||||
@@ -205,7 +205,7 @@ void TransactionView::setModel(WalletModel *model)
|
||||
transactionView->setColumnWidth(TransactionTableModel::Type, TYPE_COLUMN_WIDTH);
|
||||
transactionView->setColumnWidth(TransactionTableModel::Amount, AMOUNT_MINIMUM_COLUMN_WIDTH);
|
||||
|
||||
columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(transactionView, AMOUNT_MINIMUM_COLUMN_WIDTH, MINIMUM_COLUMN_WIDTH);
|
||||
columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(transactionView, AMOUNT_MINIMUM_COLUMN_WIDTH, MINIMUM_COLUMN_WIDTH, this);
|
||||
|
||||
if (model->getOptionsModel())
|
||||
{
|
||||
|
||||
12
src/rest.cpp
12
src/rest.cpp
@@ -17,7 +17,6 @@
|
||||
#include "version.h"
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/dynamic_bitset.hpp>
|
||||
|
||||
#include <univalue.h>
|
||||
|
||||
@@ -498,7 +497,8 @@ static bool rest_getutxos(HTTPRequest* req, const std::string& strURIPart)
|
||||
vector<unsigned char> bitmap;
|
||||
vector<CCoin> outs;
|
||||
std::string bitmapStringRepresentation;
|
||||
boost::dynamic_bitset<unsigned char> hits(vOutPoints.size());
|
||||
std::vector<bool> hits;
|
||||
bitmap.resize((vOutPoints.size() + 7) / 8);
|
||||
{
|
||||
LOCK2(cs_main, mempool.cs);
|
||||
|
||||
@@ -514,10 +514,11 @@ static bool rest_getutxos(HTTPRequest* req, const std::string& strURIPart)
|
||||
for (size_t i = 0; i < vOutPoints.size(); i++) {
|
||||
CCoins coins;
|
||||
uint256 hash = vOutPoints[i].hash;
|
||||
bool hit = false;
|
||||
if (view.GetCoins(hash, coins)) {
|
||||
mempool.pruneSpent(hash, coins);
|
||||
if (coins.IsAvailable(vOutPoints[i].n)) {
|
||||
hits[i] = true;
|
||||
hit = true;
|
||||
// Safe to index into vout here because IsAvailable checked if it's off the end of the array, or if
|
||||
// n is valid but points to an already spent output (IsNull).
|
||||
CCoin coin;
|
||||
@@ -529,10 +530,11 @@ static bool rest_getutxos(HTTPRequest* req, const std::string& strURIPart)
|
||||
}
|
||||
}
|
||||
|
||||
bitmapStringRepresentation.append(hits[i] ? "1" : "0"); // form a binary string representation (human-readable for json output)
|
||||
hits.push_back(hit);
|
||||
bitmapStringRepresentation.append(hit ? "1" : "0"); // form a binary string representation (human-readable for json output)
|
||||
bitmap[i / 8] |= ((uint8_t)hit) << (i % 8);
|
||||
}
|
||||
}
|
||||
boost::to_block_range(hits, std::back_inserter(bitmap));
|
||||
|
||||
switch (rf) {
|
||||
case RF_BINARY: {
|
||||
|
||||
@@ -5,9 +5,35 @@
|
||||
|
||||
#include "cleanse.h"
|
||||
|
||||
#include <openssl/crypto.h>
|
||||
#include <cstring>
|
||||
|
||||
/* Compilers have a bad habit of removing "superfluous" memset calls that
|
||||
* are trying to zero memory. For example, when memset()ing a buffer and
|
||||
* then free()ing it, the compiler might decide that the memset is
|
||||
* unobservable and thus can be removed.
|
||||
*
|
||||
* Previously we used OpenSSL which tried to stop this by a) implementing
|
||||
* memset in assembly on x86 and b) putting the function in its own file
|
||||
* for other platforms.
|
||||
*
|
||||
* This change removes those tricks in favour of using asm directives to
|
||||
* scare the compiler away. As best as our compiler folks can tell, this is
|
||||
* sufficient and will continue to be so.
|
||||
*
|
||||
* Adam Langley <agl@google.com>
|
||||
* Commit: ad1907fe73334d6c696c8539646c21b11178f20f
|
||||
* BoringSSL (LICENSE: ISC)
|
||||
*/
|
||||
void memory_cleanse(void *ptr, size_t len)
|
||||
{
|
||||
OPENSSL_cleanse(ptr, len);
|
||||
std::memset(ptr, 0, len);
|
||||
|
||||
/* As best as we can tell, this is sufficient to break any optimisations that
|
||||
might try to eliminate "superfluous" memsets. If there's an easy way to
|
||||
detect memset_s, it would be better to use that. */
|
||||
#if defined(_MSC_VER)
|
||||
__asm;
|
||||
#else
|
||||
__asm__ __volatile__("" : : "r"(ptr) : "memory");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -12,8 +12,10 @@
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(scriptnum_tests, BasicTestingSetup)
|
||||
|
||||
static const int64_t values[] = \
|
||||
{ 0, 1, CHAR_MIN, CHAR_MAX, UCHAR_MAX, SHRT_MIN, USHRT_MAX, INT_MIN, INT_MAX, UINT_MAX, LONG_MIN, LONG_MAX };
|
||||
/** A selection of numbers that do not trigger int64_t overflow
|
||||
* when added/subtracted. */
|
||||
static const int64_t values[] = { 0, 1, -2, 127, 128, -255, 256, (1LL << 15) - 1, -(1LL << 16), (1LL << 24) - 1, (1LL << 31), 1 - (1LL << 32), 1LL << 40 };
|
||||
|
||||
static const int64_t offsets[] = { 1, 0x79, 0x80, 0x81, 0xFF, 0x7FFF, 0x8000, 0xFFFF, 0x10000};
|
||||
|
||||
static bool verify(const CScriptNum10& bignum, const CScriptNum& scriptnum)
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
std::vector<std::unique_ptr<CWalletTx>> wtxn;
|
||||
|
||||
typedef set<pair<const CWalletTx*,unsigned int> > CoinSet;
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(wallet_tests, TestingSetup)
|
||||
@@ -50,13 +52,13 @@ static void add_coin(const CAmount& nValue, int nAge = 6*24, bool fIsFromMe = fa
|
||||
}
|
||||
COutput output(wtx, nInput, nAge, true);
|
||||
vCoins.push_back(output);
|
||||
wtxn.emplace_back(std::move(wtx));
|
||||
}
|
||||
|
||||
static void empty_wallet(void)
|
||||
{
|
||||
BOOST_FOREACH(COutput output, vCoins)
|
||||
delete output.tx;
|
||||
vCoins.clear();
|
||||
wtxn.clear();
|
||||
}
|
||||
|
||||
static bool equal_sets(CoinSet a, CoinSet b)
|
||||
|
||||
Reference in New Issue
Block a user