Skip to content
Permalink
Browse files

qt: Use IsMine to validate custom change address

(cherry picked from commit c41224d)

Github-Pull: #11247
Rebased-From: a1ea1cf
  • Loading branch information...
dooglus authored and MarcoFalke committed Aug 30, 2017
1 parent 7310f1f commit 47c02a8ae8b406a1a7d7004b2a0337a1f32420e9
Showing with 7 additions and 9 deletions.
  1. +4 −6 src/qt/sendcoinsdialog.cpp
  2. +2 −2 src/qt/walletmodel.cpp
  3. +1 −1 src/qt/walletmodel.h
@@ -789,18 +789,16 @@ void SendCoinsDialog::coinControlChangeEdited(const QString& text)
}
else // Valid address
{
CKeyID keyid;
addr.GetKeyID(keyid);
if (!model->havePrivKey(keyid)) // Unknown change address
{
const CTxDestination dest = addr.Get();
if (!model->IsSpendable(dest)) {
ui->labelCoinControlChangeLabel->setText(tr("Warning: Unknown change address"));

// confirmation dialog
QMessageBox::StandardButton btnRetVal = QMessageBox::question(this, tr("Confirm custom change address"), tr("The address you selected for change is not part of this wallet. Any or all funds in your wallet may be sent to this address. Are you sure?"),
QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);

if(btnRetVal == QMessageBox::Yes)
CoinControlDialog::coinControl->destChange = addr.Get();
CoinControlDialog::coinControl->destChange = dest;
else
{
ui->lineEditCoinControlChange->setText("");
@@ -819,7 +817,7 @@ void SendCoinsDialog::coinControlChangeEdited(const QString& text)
else
ui->labelCoinControlChangeLabel->setText(tr("(no label)"));

CoinControlDialog::coinControl->destChange = addr.Get();
CoinControlDialog::coinControl->destChange = dest;
}
}
}
@@ -561,9 +561,9 @@ bool WalletModel::getPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const
return wallet->GetPubKey(address, vchPubKeyOut);
}

bool WalletModel::havePrivKey(const CKeyID &address) const
bool WalletModel::IsSpendable(const CTxDestination& dest) const
{
return wallet->HaveKey(address);
return IsMine(*wallet, dest) & ISMINE_SPENDABLE;
}

bool WalletModel::getPrivKey(const CKeyID &address, CKey& vchPrivKeyOut) const
@@ -190,7 +190,7 @@ class WalletModel : public QObject
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<COutPoint>& vOutpoints, std::vector<COutput>& vOutputs);
bool isSpent(const COutPoint& outpoint) const;

0 comments on commit 47c02a8

Please sign in to comment.
You can’t perform that action at this time.