Skip to content

Commit d7ec6ef

Browse files
committed
qml: Prepare transaction with recipients list
1 parent bbc6355 commit d7ec6ef

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/qml/models/sendrecipientslistmodel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class SendRecipientsListModel : public QAbstractListModel
4141
void setCurrentIndex(int row);
4242
SendRecipient* currentRecipient() const;
4343
int count() const { return m_recipients.size(); }
44+
QList<SendRecipient*> recipients() const { return m_recipients; }
4445

4546
Q_SIGNALS:
4647
void currentIndexChanged();

src/qml/models/walletqmlmodel.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,21 @@ bool WalletQmlModel::prepareTransaction()
106106
return false;
107107
}
108108

109-
CScript scriptPubKey = GetScriptForDestination(DecodeDestination(m_current_recipient->address().toStdString()));
110-
wallet::CRecipient recipient = {scriptPubKey, m_current_recipient->cAmount(), m_current_recipient->subtractFeeFromAmount()};
111-
m_coin_control.m_feerate = CFeeRate(1000);
109+
std::vector<wallet::CRecipient> vecSend;
110+
CAmount total = 0;
111+
for (auto * recipient : m_send_recipients->recipients()) {
112+
CScript scriptPubKey = GetScriptForDestination(DecodeDestination(recipient->address().toStdString()));
113+
wallet::CRecipient c_recipient = {scriptPubKey, recipient->cAmount(), recipient->subtractFeeFromAmount()};
114+
m_coin_control.m_feerate = CFeeRate(1000);
115+
vecSend.push_back(c_recipient);
116+
total += recipient->cAmount();
117+
}
112118

113119
CAmount balance = m_wallet->getBalance();
114-
if (balance < recipient.nAmount) {
120+
if (balance < total) {
115121
return false;
116122
}
117123

118-
std::vector<wallet::CRecipient> vecSend{recipient};
119124
int nChangePosRet = -1;
120125
CAmount nFeeRequired = 0;
121126
const auto& res = m_wallet->createTransaction(vecSend, m_coin_control, true, nChangePosRet, nFeeRequired);

0 commit comments

Comments
 (0)