mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01: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:
@@ -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");
|
||||||
|
|||||||
Reference in New Issue
Block a user