Skip to content

Commit 19b9b2f

Browse files
committed
qml: Prepare transaction with recipients list
1 parent 132e03f commit 19b9b2f

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/qml/models/walletqmlmodel.cpp

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

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

114120
CAmount balance = m_wallet->getBalance();
115-
if (balance < recipient.nAmount) {
121+
if (balance < total) {
116122
return false;
117123
}
118124

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

0 commit comments

Comments
 (0)