| 232 | } |
| 233 | |
| 234 | bool SendCoinsDialog::PrepareSendText(QString& question_string, QString& informative_text, QString& detailed_text) |
| 235 | { |
| 236 | QList<SendCoinsRecipient> recipients; |
| 237 | bool valid = true; |
| 238 | |
| 239 | for(int i = 0; i < ui->entries->count(); ++i) |
| 240 | { |
| 241 | SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget()); |
| 242 | if(entry) |
| 243 | { |
| 244 | if(entry->validate(model->node())) |
| 245 | { |
| 246 | recipients.append(entry->getValue()); |
| 247 | } |
| 248 | else if (valid) |
| 249 | { |
| 250 | ui->scrollArea->ensureWidgetVisible(entry); |
| 251 | valid = false; |
| 252 | } |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | if(!valid || recipients.isEmpty()) |
| 257 | { |
| 258 | return false; |
| 259 | } |
| 260 | |
| 261 | fNewRecipientAllowed = false; |
| 262 | WalletModel::UnlockContext ctx(model->requestUnlock()); |
| 263 | if(!ctx.isValid()) |
| 264 | { |
| 265 | // Unlock wallet was cancelled |
| 266 | fNewRecipientAllowed = true; |
| 267 | return false; |
| 268 | } |
| 269 | |
| 270 | // prepare transaction for getting txFee earlier |
| 271 | m_current_transaction = std::make_unique<WalletModelTransaction>(recipients); |
| 272 | WalletModel::SendCoinsReturn prepareStatus; |
| 273 | |
| 274 | updateCoinControlState(); |
| 275 | |
| 276 | CCoinControl coin_control = *m_coin_control; |
| 277 | coin_control.m_allow_other_inputs = !coin_control.HasSelected(); // future, could introduce a checkbox to customize this value. |
| 278 | prepareStatus = model->prepareTransaction(*m_current_transaction, coin_control); |
| 279 | |
| 280 | // process prepareStatus and on error generate message shown to user |
| 281 | processSendCoinsReturn(prepareStatus, |
| 282 | BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), m_current_transaction->getTransactionFee())); |
| 283 | |
| 284 | if(prepareStatus.status != WalletModel::OK) { |
| 285 | fNewRecipientAllowed = true; |
| 286 | return false; |
| 287 | } |
| 288 | |
| 289 | CAmount txFee = m_current_transaction->getTransactionFee(); |
| 290 | QStringList formatted; |
| 291 | for (const SendCoinsRecipient &rcp : m_current_transaction->getRecipients()) |
nothing calls this directly
no test coverage detected