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);
|
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 */
|
switch(model->getAddressTableModel()->getEditStatus())
|
||||||
model->getRecentRequestsTableModel()->addNewRequest(info);
|
{
|
||||||
|
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)
|
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) {
|
if (spk_man) {
|
||||||
spk_man->TopUp();
|
spk_man->TopUp();
|
||||||
result = spk_man->GetNewDestination(type, dest, error);
|
result = spk_man->GetNewDestination(type, dest, error);
|
||||||
|
} else {
|
||||||
|
error = strprintf("Error: No %s addresses available.", FormatOutputType(type));
|
||||||
}
|
}
|
||||||
if (result) {
|
if (result) {
|
||||||
SetAddressBook(dest, label, "receive");
|
SetAddressBook(dest, label, "receive");
|
||||||
|
|
Loading…
Reference in a new issue