Skip to content

Commit 90a43c1

Browse files
cozzlaanwj
authored andcommitted
[Qt] Code-movement-only: Format confirmation message in sendcoinsdialog
1 parent 3dfcdf4 commit 90a43c1

File tree

1 file changed

+30
-29
lines changed

1 file changed

+30
-29
lines changed

src/qt/sendcoinsdialog.cpp

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,36 @@ void SendCoinsDialog::on_sendButton_clicked()
220220
return;
221221
}
222222

223+
fNewRecipientAllowed = false;
224+
225+
226+
WalletModel::UnlockContext ctx(model->requestUnlock());
227+
if(!ctx.isValid())
228+
{
229+
// Unlock wallet was cancelled
230+
fNewRecipientAllowed = true;
231+
return;
232+
}
233+
234+
// prepare transaction for getting txFee earlier
235+
WalletModelTransaction currentTransaction(recipients);
236+
WalletModel::SendCoinsReturn prepareStatus;
237+
if (model->getOptionsModel()->getCoinControlFeatures()) // coin control enabled
238+
prepareStatus = model->prepareTransaction(currentTransaction, CoinControlDialog::coinControl);
239+
else
240+
prepareStatus = model->prepareTransaction(currentTransaction);
241+
242+
// process prepareStatus and on error generate message shown to user
243+
processSendCoinsReturn(prepareStatus,
244+
BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), currentTransaction.getTransactionFee()));
245+
246+
if(prepareStatus.status != WalletModel::OK) {
247+
fNewRecipientAllowed = true;
248+
return;
249+
}
250+
251+
CAmount txFee = currentTransaction.getTransactionFee();
252+
223253
// Format confirmation message
224254
QStringList formatted;
225255
foreach(const SendCoinsRecipient &rcp, recipients)
@@ -257,35 +287,6 @@ void SendCoinsDialog::on_sendButton_clicked()
257287
formatted.append(recipientElement);
258288
}
259289

260-
fNewRecipientAllowed = false;
261-
262-
263-
WalletModel::UnlockContext ctx(model->requestUnlock());
264-
if(!ctx.isValid())
265-
{
266-
// Unlock wallet was cancelled
267-
fNewRecipientAllowed = true;
268-
return;
269-
}
270-
271-
// prepare transaction for getting txFee earlier
272-
WalletModelTransaction currentTransaction(recipients);
273-
WalletModel::SendCoinsReturn prepareStatus;
274-
if (model->getOptionsModel()->getCoinControlFeatures()) // coin control enabled
275-
prepareStatus = model->prepareTransaction(currentTransaction, CoinControlDialog::coinControl);
276-
else
277-
prepareStatus = model->prepareTransaction(currentTransaction);
278-
279-
// process prepareStatus and on error generate message shown to user
280-
processSendCoinsReturn(prepareStatus,
281-
BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), currentTransaction.getTransactionFee()));
282-
283-
if(prepareStatus.status != WalletModel::OK) {
284-
fNewRecipientAllowed = true;
285-
return;
286-
}
287-
288-
CAmount txFee = currentTransaction.getTransactionFee();
289290
QString questionString = tr("Are you sure you want to send?");
290291
questionString.append("<br /><br />%1");
291292

0 commit comments

Comments
 (0)