mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
Return error when no ScriptPubKeyMan is available for specified type
When a CWallet doesn't have a ScriptPubKeyMan for the requested type in GetNewDestination, give a meaningful error. Also handle this in Qt which did not do anything with errors.
This commit is contained in:
parent
388ba94231
commit
3c19fdd2a2
2 changed files with 35 additions and 10 deletions
|
@ -157,17 +157,40 @@ void ReceiveCoinsDialog::on_receiveButton_clicked()
|
|||
}
|
||||
}
|
||||
address = model->getAddressTableModel()->addRow(AddressTableModel::Receive, label, "", address_type);
|
||||
SendCoinsRecipient info(address, label,
|
||||
ui->reqAmount->value(), ui->reqMessage->text());
|
||||
ReceiveRequestDialog *dialog = new ReceiveRequestDialog(this);
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
dialog->setModel(model);
|
||||
dialog->setInfo(info);
|
||||
dialog->show();
|
||||
clear();
|
||||
|
||||
/* Store request for later reference */
|
||||
model->getRecentRequestsTableModel()->addNewRequest(info);
|
||||
switch(model->getAddressTableModel()->getEditStatus())
|
||||
{
|
||||
case AddressTableModel::EditStatus::OK: {
|
||||
// Success
|
||||
SendCoinsRecipient info(address, label,
|
||||
ui->reqAmount->value(), ui->reqMessage->text());
|
||||
ReceiveRequestDialog *dialog = new ReceiveRequestDialog(this);
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
dialog->setModel(model);
|
||||
dialog->setInfo(info);
|
||||
dialog->show();
|
||||
|
||||
/* Store request for later reference */
|
||||
model->getRecentRequestsTableModel()->addNewRequest(info);
|
||||
break;
|
||||
}
|
||||
case AddressTableModel::EditStatus::WALLET_UNLOCK_FAILURE:
|
||||
QMessageBox::critical(this, windowTitle(),
|
||||
tr("Could not unlock wallet."),
|
||||
QMessageBox::Ok, QMessageBox::Ok);
|
||||
break;
|
||||
case AddressTableModel::EditStatus::KEY_GENERATION_FAILURE:
|
||||
QMessageBox::critical(this, windowTitle(),
|
||||
tr("Could not generate new %1 address").arg(QString::fromStdString(FormatOutputType(address_type))),
|
||||
QMessageBox::Ok, QMessageBox::Ok);
|
||||
break;
|
||||
// These aren't valid return values for our action
|
||||
case AddressTableModel::EditStatus::INVALID_ADDRESS:
|
||||
case AddressTableModel::EditStatus::DUPLICATE_ADDRESS:
|
||||
case AddressTableModel::EditStatus::NO_CHANGES:
|
||||
assert(false);
|
||||
}
|
||||
clear();
|
||||
}
|
||||
|
||||
void ReceiveCoinsDialog::on_recentRequestsView_doubleClicked(const QModelIndex &index)
|
||||
|
|
|
@ -3227,6 +3227,8 @@ bool CWallet::GetNewDestination(const OutputType type, const std::string label,
|
|||
if (spk_man) {
|
||||
spk_man->TopUp();
|
||||
result = spk_man->GetNewDestination(type, dest, error);
|
||||
} else {
|
||||
error = strprintf("Error: No %s addresses available.", FormatOutputType(type));
|
||||
}
|
||||
if (result) {
|
||||
SetAddressBook(dest, label, "receive");
|
||||
|
|
Loading…
Add table
Reference in a new issue