Changeset View
Changeset View
Standalone View
Standalone View
src/qt/receiverequestdialog.cpp
// Copyright (c) 2011-2016 The Bitcoin Core developers | // Copyright (c) 2011-2016 The Bitcoin Core developers | ||||
// Copyright (c) 2017 The Bitcoin developers | |||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include "receiverequestdialog.h" | #include "receiverequestdialog.h" | ||||
#include "ui_receiverequestdialog.h" | #include "ui_receiverequestdialog.h" | ||||
#include "bitcoinunits.h" | #include "bitcoinunits.h" | ||||
#include "config.h" | #include "config.h" | ||||
#include "dstencode.h" | |||||
#include "guiconstants.h" | #include "guiconstants.h" | ||||
#include "guiutil.h" | #include "guiutil.h" | ||||
#include "optionsmodel.h" | #include "optionsmodel.h" | ||||
#include "walletmodel.h" | #include "walletmodel.h" | ||||
#include <QClipboard> | #include <QClipboard> | ||||
#include <QDrag> | #include <QDrag> | ||||
#include <QMenu> | #include <QMenu> | ||||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | void ReceiveRequestDialog::setModel(OptionsModel *_model) { | ||||
if (_model) | if (_model) | ||||
connect(_model, SIGNAL(displayUnitChanged(int)), this, SLOT(update())); | connect(_model, SIGNAL(displayUnitChanged(int)), this, SLOT(update())); | ||||
// update the display unit if necessary | // update the display unit if necessary | ||||
update(); | update(); | ||||
} | } | ||||
// Addresses are stored in the database with the encoding that the client was | |||||
// configured with at the time of creation. | |||||
// | |||||
// This converts to clients current configuration. | |||||
QString ToCurrentEncoding(const QString &addr, const Config &cfg) { | |||||
if (!IsValidDestinationString(addr.toStdString(), cfg.GetChainParams())) { | |||||
// We have something sketchy as input. Do not try to convert. | |||||
return addr; | |||||
} | |||||
CTxDestination dst = | |||||
DecodeDestination(addr.toStdString(), cfg.GetChainParams()); | |||||
return QString::fromStdString( | |||||
EncodeDestination(dst, cfg.GetChainParams(), cfg)); | |||||
} | |||||
void ReceiveRequestDialog::setInfo(const SendCoinsRecipient &_info) { | void ReceiveRequestDialog::setInfo(const SendCoinsRecipient &_info) { | ||||
this->info = _info; | this->info = _info; | ||||
// Display addresses with currently configured encoding. | |||||
this->info.address = ToCurrentEncoding(this->info.address, *cfg); | |||||
update(); | update(); | ||||
} | } | ||||
void ReceiveRequestDialog::update() { | void ReceiveRequestDialog::update() { | ||||
if (!model) return; | if (!model) return; | ||||
QString target = info.label; | QString target = info.label; | ||||
if (target.isEmpty()) target = info.address; | if (target.isEmpty()) target = info.address; | ||||
setWindowTitle(tr("Request payment to %1").arg(target)); | setWindowTitle(tr("Request payment to %1").arg(target)); | ||||
▲ Show 20 Lines • Show All 80 Lines • Show Last 20 Lines |