66#include < qml/models/walletqmlmodel.h>
77
88#include < qml/models/activitylistmodel.h>
9+ #include < qml/models/paymentrequest.h>
910#include < qml/models/sendrecipient.h>
1011#include < qml/models/sendrecipientslistmodel.h>
1112#include < qml/models/walletqmlmodeltransaction.h>
1819#include < wallet/coincontrol.h>
1920#include < wallet/wallet.h>
2021
21- # include < QTimer >
22+ unsigned int WalletQmlModel::m_next_payment_request_id{ 1 };
2223
2324WalletQmlModel::WalletQmlModel (std::unique_ptr<interfaces::Wallet> wallet, QObject *parent)
2425 : QObject(parent)
@@ -27,6 +28,7 @@ WalletQmlModel::WalletQmlModel(std::unique_ptr<interfaces::Wallet> wallet, QObje
2728 m_activity_list_model = new ActivityListModel (this );
2829 m_coins_list_model = new CoinsListModel (this );
2930 m_send_recipients = new SendRecipientsListModel (this );
31+ m_current_payment_request = new PaymentRequest (this );
3032}
3133
3234WalletQmlModel::WalletQmlModel (QObject* parent)
@@ -35,13 +37,15 @@ WalletQmlModel::WalletQmlModel(QObject* parent)
3537 m_activity_list_model = new ActivityListModel (this );
3638 m_coins_list_model = new CoinsListModel (this );
3739 m_send_recipients = new SendRecipientsListModel (this );
40+ m_current_payment_request = new PaymentRequest (this );
3841}
3942
4043WalletQmlModel::~WalletQmlModel ()
4144{
4245 delete m_activity_list_model;
4346 delete m_coins_list_model;
4447 delete m_send_recipients;
48+ delete m_current_payment_request;
4549 if (m_current_transaction) {
4650 delete m_current_transaction;
4751 }
@@ -81,6 +85,31 @@ QString WalletQmlModel::newAddress(QString label)
8185 return QString::fromStdString (EncodeDestination (dest.value ()));
8286}
8387
88+ void WalletQmlModel::commitPaymentRequest ()
89+ {
90+ if (!m_wallet || !m_current_payment_request) {
91+ return ;
92+ }
93+
94+ if (m_current_payment_request->id ().isEmpty ()) {
95+ m_current_payment_request->setId (m_next_payment_request_id++);
96+ }
97+
98+ if (m_current_payment_request->address ().isEmpty ()) {
99+ const OutputType output_type = m_wallet->getDefaultAddressType ();
100+ const auto destination{m_wallet->getNewDestination (output_type, m_current_payment_request->label ().toStdString ())};
101+ if (!destination) {
102+ return ;
103+ }
104+ m_current_payment_request->setDestination (destination.value ());
105+ }
106+
107+ m_wallet->setAddressReceiveRequest (
108+ m_current_payment_request->destination (),
109+ m_current_payment_request->id ().toStdString (),
110+ m_current_payment_request->message ().toStdString ());
111+ }
112+
84113std::set<interfaces::WalletTx> WalletQmlModel::getWalletTxs () const
85114{
86115 if (!m_wallet) {
0 commit comments