mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
[Qt] coin control change address handling update
- re-work change address handling so that default is CNoDestination(), until a verified and known change address was entered (easier code flow) - add a missing NULL pointer check for adresstablemodel - add a missing text when opening coin control address selection for priority and ensure the label is black - add a missing . at the end of a sentence
This commit is contained in:
@@ -546,44 +546,45 @@ void SendCoinsDialog::coinControlChangeChecked(int state)
|
||||
// Coin Control: custom change address changed
|
||||
void SendCoinsDialog::coinControlChangeEdited(const QString& text)
|
||||
{
|
||||
if (model)
|
||||
if (model && model->getAddressTableModel())
|
||||
{
|
||||
CoinControlDialog::coinControl->destChange = CBitcoinAddress(text.toStdString()).Get();
|
||||
// Default to no change address until verified
|
||||
CoinControlDialog::coinControl->destChange = CNoDestination();
|
||||
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}");
|
||||
|
||||
// label for the change address
|
||||
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}");
|
||||
if (text.isEmpty())
|
||||
ui->labelCoinControlChangeLabel->setText("");
|
||||
else if (!CBitcoinAddress(text.toStdString()).IsValid())
|
||||
CBitcoinAddress addr = CBitcoinAddress(text.toStdString());
|
||||
|
||||
if (text.isEmpty()) // Nothing entered
|
||||
{
|
||||
ui->labelCoinControlChangeLabel->setText("");
|
||||
}
|
||||
else if (!addr.IsValid()) // Invalid address
|
||||
{
|
||||
// invalid change address
|
||||
CoinControlDialog::coinControl->destChange = CNoDestination();
|
||||
|
||||
ui->lineEditCoinControlChange->setValid(false);
|
||||
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}");
|
||||
ui->labelCoinControlChangeLabel->setText(tr("Warning: Invalid Bitcoin address"));
|
||||
}
|
||||
else
|
||||
else // Valid address
|
||||
{
|
||||
QString associatedLabel = model->getAddressTableModel()->labelForAddress(text);
|
||||
if (!associatedLabel.isEmpty())
|
||||
ui->labelCoinControlChangeLabel->setText(associatedLabel);
|
||||
else
|
||||
CPubKey pubkey;
|
||||
CKeyID keyid;
|
||||
addr.GetKeyID(keyid);
|
||||
if (!model->getPubKey(keyid, pubkey)) // Unknown change address
|
||||
{
|
||||
CPubKey pubkey;
|
||||
CKeyID keyid;
|
||||
CBitcoinAddress(text.toStdString()).GetKeyID(keyid);
|
||||
if (model->getPubKey(keyid, pubkey))
|
||||
ui->labelCoinControlChangeLabel->setText(tr("(no label)"));
|
||||
else
|
||||
{
|
||||
// unknown change address
|
||||
CoinControlDialog::coinControl->destChange = CNoDestination();
|
||||
ui->lineEditCoinControlChange->setValid(false);
|
||||
ui->labelCoinControlChangeLabel->setText(tr("Warning: Unknown change address"));
|
||||
}
|
||||
else // Known change address
|
||||
{
|
||||
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}");
|
||||
|
||||
ui->lineEditCoinControlChange->setValid(false);
|
||||
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}");
|
||||
ui->labelCoinControlChangeLabel->setText(tr("Warning: Unknown change address"));
|
||||
}
|
||||
// Query label
|
||||
QString associatedLabel = model->getAddressTableModel()->labelForAddress(text);
|
||||
if (!associatedLabel.isEmpty())
|
||||
ui->labelCoinControlChangeLabel->setText(associatedLabel);
|
||||
else
|
||||
ui->labelCoinControlChangeLabel->setText(tr("(no label)"));
|
||||
|
||||
CoinControlDialog::coinControl->destChange = addr.Get();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user