diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -833,16 +833,14 @@ if (text.isEmpty()) { // Nothing entered ui->labelCoinControlChangeLabel->setText(""); - } else if (!addr.IsValid()) { - // Invalid address + } else if (!addr.IsValid()) // Invalid address + { ui->labelCoinControlChangeLabel->setText( tr("Warning: Invalid Bitcoin address")); - } else { - // Valid address - CKeyID keyid; - addr.GetKeyID(keyid); - // Unknown change address - if (!model->havePrivKey(keyid)) { + } else // Valid address + { + const CTxDestination dest = addr.Get(); + if (!model->IsSpendable(dest)) { ui->labelCoinControlChangeLabel->setText( tr("Warning: Unknown change address")); @@ -856,7 +854,7 @@ QMessageBox::Cancel); if (btnRetVal == QMessageBox::Yes) - CoinControlDialog::coinControl->destChange = addr.Get(); + CoinControlDialog::coinControl->destChange = dest; else { ui->lineEditCoinControlChange->setText(""); ui->labelCoinControlChangeLabel->setStyleSheet( @@ -876,7 +874,7 @@ else ui->labelCoinControlChangeLabel->setText(tr("(no label)")); - CoinControlDialog::coinControl->destChange = addr.Get(); + CoinControlDialog::coinControl->destChange = dest; } } } diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -205,7 +205,7 @@ UnlockContext requestUnlock(); bool getPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const; - bool havePrivKey(const CKeyID &address) const; + bool IsSpendable(const CTxDestination &dest) const; bool getPrivKey(const CKeyID &address, CKey &vchPrivKeyOut) const; void getOutputs(const std::vector &vOutpoints, std::vector &vOutputs); diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -532,8 +532,8 @@ return wallet->GetPubKey(address, vchPubKeyOut); } -bool WalletModel::havePrivKey(const CKeyID &address) const { - return wallet->HaveKey(address); +bool WalletModel::IsSpendable(const CTxDestination &dest) const { + return IsMine(*wallet, dest) & ISMINE_SPENDABLE; } bool WalletModel::getPrivKey(const CKeyID &address, CKey &vchPrivKeyOut) const {