mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-13 12:33:42 +02:00
GUI: Clone SendCoinsRecipient to SendAssetsRecipient
This commit is contained in:
parent
70458f6f9d
commit
f4d5552f6c
9 changed files with 52 additions and 25 deletions
|
|
@ -605,7 +605,7 @@ void PaymentServer::fetchRequest(const QUrl& url)
|
|||
netManager->get(netRequest);
|
||||
}
|
||||
|
||||
void PaymentServer::fetchPaymentACK(WalletModel* walletModel, const SendCoinsRecipient& recipient, QByteArray transaction)
|
||||
void PaymentServer::fetchPaymentACK(WalletModel* walletModel, const SendAssetsRecipient& recipient, QByteArray transaction)
|
||||
{
|
||||
const payments::PaymentDetails& details = recipient.paymentRequest.getDetails();
|
||||
if (!details.has_payment_url())
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ public Q_SLOTS:
|
|||
void uiReady();
|
||||
|
||||
// Submit Payment message to a merchant, get back PaymentACK:
|
||||
void fetchPaymentACK(WalletModel* walletModel, const SendCoinsRecipient& recipient, QByteArray transaction);
|
||||
void fetchPaymentACK(WalletModel* walletModel, const SendAssetsRecipient& recipient, QByteArray transaction);
|
||||
|
||||
// Handle an incoming URI, URI with local file scheme or file
|
||||
void handleURIOrFile(const QString& s);
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ void SendCoinsDialog::on_sendButton_clicked()
|
|||
if(!model || !model->getOptionsModel())
|
||||
return;
|
||||
|
||||
QList<SendCoinsRecipient> recipients;
|
||||
QList<SendAssetsRecipient> recipients;
|
||||
bool valid = true;
|
||||
|
||||
for(int i = 0; i < ui->entries->count(); ++i)
|
||||
|
|
@ -276,7 +276,7 @@ void SendCoinsDialog::on_sendButton_clicked()
|
|||
|
||||
// Format confirmation message
|
||||
QStringList formatted;
|
||||
for (const SendCoinsRecipient &rcp : currentTransaction.getRecipients())
|
||||
for (const SendAssetsRecipient &rcp : currentTransaction.getRecipients())
|
||||
{
|
||||
// generate bold amount string with wallet name in case of multiwallet
|
||||
QString amount = "<b>" + BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), rcp.amount);
|
||||
|
|
@ -511,7 +511,7 @@ void SendCoinsDialog::pasteEntry(const SendCoinsRecipient &rv)
|
|||
entry = addEntry();
|
||||
}
|
||||
|
||||
entry->setValue(rv);
|
||||
entry->setValue(SendAssetsRecipient(rv));
|
||||
updateTabsAndLabels();
|
||||
}
|
||||
|
||||
|
|
@ -871,7 +871,7 @@ void SendCoinsDialog::coinControlUpdateLabels()
|
|||
SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget());
|
||||
if(entry && !entry->isHidden())
|
||||
{
|
||||
SendCoinsRecipient rcp = entry->getValue();
|
||||
auto rcp = entry->getValue();
|
||||
CoinControlDialog::payAmounts.append(rcp.amount);
|
||||
if (rcp.fSubtractFeeFromAmount)
|
||||
CoinControlDialog::fSubtractFeeFromAmount = true;
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ bool SendCoinsEntry::validate(interfaces::Node& node)
|
|||
return retval;
|
||||
}
|
||||
|
||||
SendCoinsRecipient SendCoinsEntry::getValue()
|
||||
SendAssetsRecipient SendCoinsEntry::getValue()
|
||||
{
|
||||
// Payment request
|
||||
if (recipient.paymentRequest.IsInitialized())
|
||||
|
|
@ -195,7 +195,7 @@ QWidget *SendCoinsEntry::setupTabChain(QWidget *prev)
|
|||
return ui->deleteButton;
|
||||
}
|
||||
|
||||
void SendCoinsEntry::setValue(const SendCoinsRecipient &value)
|
||||
void SendCoinsEntry::setValue(const SendAssetsRecipient &value)
|
||||
{
|
||||
recipient = value;
|
||||
|
||||
|
|
|
|||
|
|
@ -31,12 +31,12 @@ public:
|
|||
|
||||
void setModel(WalletModel *model);
|
||||
bool validate(interfaces::Node& node);
|
||||
SendCoinsRecipient getValue();
|
||||
SendAssetsRecipient getValue();
|
||||
|
||||
/** Return whether the entry is still empty and unedited */
|
||||
bool isClear();
|
||||
|
||||
void setValue(const SendCoinsRecipient &value);
|
||||
void setValue(const SendAssetsRecipient &value);
|
||||
void setAddress(const QString &address);
|
||||
void setAmount(const CAmount &amount);
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ private Q_SLOTS:
|
|||
void updateAssetTypes();
|
||||
|
||||
private:
|
||||
SendCoinsRecipient recipient;
|
||||
SendAssetsRecipient recipient;
|
||||
Ui::SendCoinsEntry *ui;
|
||||
WalletModel *model;
|
||||
const PlatformStyle *platformStyle;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,16 @@
|
|||
#include <QSet>
|
||||
#include <QTimer>
|
||||
|
||||
SendAssetsRecipient::SendAssetsRecipient(SendCoinsRecipient r) :
|
||||
address(r.address),
|
||||
label(r.label),
|
||||
amount(r.amount),
|
||||
message(r.message),
|
||||
paymentRequest(r.paymentRequest),
|
||||
authenticatedMerchant(r.authenticatedMerchant),
|
||||
fSubtractFeeFromAmount(r.fSubtractFeeFromAmount)
|
||||
{
|
||||
}
|
||||
|
||||
WalletModel::WalletModel(std::unique_ptr<interfaces::Wallet> wallet, interfaces::Node& node, const PlatformStyle *platformStyle, OptionsModel *_optionsModel, QObject *parent) :
|
||||
QObject(parent), m_wallet(std::move(wallet)), m_node(node), optionsModel(_optionsModel), addressTableModel(0),
|
||||
|
|
@ -141,7 +151,7 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
|
|||
{
|
||||
CAmount total = 0;
|
||||
bool fSubtractFeeFromAmount = false;
|
||||
QList<SendCoinsRecipient> recipients = transaction.getRecipients();
|
||||
auto recipients = transaction.getRecipients();
|
||||
std::vector<CRecipient> vecSend;
|
||||
|
||||
if(recipients.empty())
|
||||
|
|
@ -153,7 +163,7 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
|
|||
int nAddresses = 0;
|
||||
|
||||
// Pre-check input data for validity
|
||||
for (const SendCoinsRecipient &rcp : recipients)
|
||||
for (const SendAssetsRecipient &rcp : recipients)
|
||||
{
|
||||
if (rcp.fSubtractFeeFromAmount)
|
||||
fSubtractFeeFromAmount = true;
|
||||
|
|
@ -249,7 +259,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &tran
|
|||
|
||||
{
|
||||
std::vector<std::pair<std::string, std::string>> vOrderForm;
|
||||
for (const SendCoinsRecipient &rcp : transaction.getRecipients())
|
||||
for (const SendAssetsRecipient &rcp : transaction.getRecipients())
|
||||
{
|
||||
if (rcp.paymentRequest.IsInitialized())
|
||||
{
|
||||
|
|
@ -279,7 +289,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &tran
|
|||
|
||||
// Add addresses / update labels that we've sent to the address book,
|
||||
// and emit coinsSent signal for each recipient
|
||||
for (const SendCoinsRecipient &rcp : transaction.getRecipients())
|
||||
for (const SendAssetsRecipient &rcp : transaction.getRecipients())
|
||||
{
|
||||
// Don't touch the address book when we have a payment request
|
||||
if (!rcp.paymentRequest.IsInitialized())
|
||||
|
|
|
|||
|
|
@ -105,6 +105,23 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class SendAssetsRecipient
|
||||
{
|
||||
public:
|
||||
explicit SendAssetsRecipient() : fSubtractFeeFromAmount(false) { }
|
||||
explicit SendAssetsRecipient(SendCoinsRecipient r);
|
||||
public:
|
||||
QString address;
|
||||
QString label;
|
||||
CAmount amount;
|
||||
QString message;
|
||||
|
||||
PaymentRequestPlus paymentRequest;
|
||||
QString authenticatedMerchant;
|
||||
|
||||
bool fSubtractFeeFromAmount; // memory only
|
||||
};
|
||||
|
||||
/** Interface to Bitcoin wallet from Qt view code. */
|
||||
class WalletModel : public QObject
|
||||
{
|
||||
|
|
@ -260,7 +277,7 @@ Q_SIGNALS:
|
|||
void message(const QString &title, const QString &message, unsigned int style);
|
||||
|
||||
// Coins sent: from wallet, to recipient, in (serialized) transaction:
|
||||
void coinsSent(WalletModel* wallet, SendCoinsRecipient recipient, QByteArray transaction);
|
||||
void coinsSent(WalletModel* wallet, SendAssetsRecipient recipient, QByteArray transaction);
|
||||
|
||||
// Show progress dialog e.g. for rescan
|
||||
void showProgress(const QString &title, int nProgress);
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@
|
|||
#include <interfaces/node.h>
|
||||
#include <policy/policy.h>
|
||||
|
||||
WalletModelTransaction::WalletModelTransaction(const QList<SendCoinsRecipient> &_recipients) :
|
||||
WalletModelTransaction::WalletModelTransaction(const QList<SendAssetsRecipient> &_recipients) :
|
||||
recipients(_recipients),
|
||||
fee(0)
|
||||
{
|
||||
}
|
||||
|
||||
QList<SendCoinsRecipient> WalletModelTransaction::getRecipients() const
|
||||
QList<SendAssetsRecipient> WalletModelTransaction::getRecipients() const
|
||||
{
|
||||
return recipients;
|
||||
}
|
||||
|
|
@ -42,9 +42,9 @@ void WalletModelTransaction::reassignAmounts(int nChangePosRet)
|
|||
{
|
||||
const CTransaction* walletTransaction = &wtx->get();
|
||||
int i = 0;
|
||||
for (QList<SendCoinsRecipient>::iterator it = recipients.begin(); it != recipients.end(); ++it)
|
||||
for (auto it = recipients.begin(); it != recipients.end(); ++it)
|
||||
{
|
||||
SendCoinsRecipient& rcp = (*it);
|
||||
auto& rcp = (*it);
|
||||
|
||||
if (rcp.paymentRequest.IsInitialized())
|
||||
{
|
||||
|
|
@ -74,7 +74,7 @@ void WalletModelTransaction::reassignAmounts(int nChangePosRet)
|
|||
CAmount WalletModelTransaction::getTotalTransactionAmount() const
|
||||
{
|
||||
CAmount totalTransactionAmount = 0;
|
||||
for (const SendCoinsRecipient &rcp : recipients)
|
||||
for (const SendAssetsRecipient &rcp : recipients)
|
||||
{
|
||||
totalTransactionAmount += rcp.amount;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include <QObject>
|
||||
|
||||
class SendCoinsRecipient;
|
||||
class SendAssetsRecipient;
|
||||
|
||||
namespace interfaces {
|
||||
class Node;
|
||||
|
|
@ -22,9 +22,9 @@ class PendingWalletTx;
|
|||
class WalletModelTransaction
|
||||
{
|
||||
public:
|
||||
explicit WalletModelTransaction(const QList<SendCoinsRecipient> &recipients);
|
||||
explicit WalletModelTransaction(const QList<SendAssetsRecipient> &recipients);
|
||||
|
||||
QList<SendCoinsRecipient> getRecipients() const;
|
||||
QList<SendAssetsRecipient> getRecipients() const;
|
||||
|
||||
std::unique_ptr<interfaces::PendingWalletTx>& getWtx();
|
||||
unsigned int getTransactionSize();
|
||||
|
|
@ -37,7 +37,7 @@ public:
|
|||
void reassignAmounts(int nChangePosRet); // needed for the subtract-fee-from-amount feature
|
||||
|
||||
private:
|
||||
QList<SendCoinsRecipient> recipients;
|
||||
QList<SendAssetsRecipient> recipients;
|
||||
std::unique_ptr<interfaces::PendingWalletTx> wtx;
|
||||
CAmount fee;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue