Skip to content

Commit a31e9ad

Browse files
author
MarcoFalke
committed
Merge #11247: qt: Use IsMine to validate custom change address
a1ea1cf qt: Use IsMine to validate custom change address (Chris Moore) Pull request description: Fixes #11137 Closes #11184 (which was accidentally opened against 0.15 branch) Tree-SHA512: a20a59b4f36c1471a9c84bcc7c69048576d1f413104c299a7ed9ba221f28eddf93d727fca2926420ea5d0dd9aba582924f26a5acd44d995039b7202c73eb53bc
2 parents 777519b + a1ea1cf commit a31e9ad

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

src/qt/sendcoinsdialog.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -789,18 +789,16 @@ void SendCoinsDialog::coinControlChangeEdited(const QString& text)
789789
}
790790
else // Valid address
791791
{
792-
CKeyID keyid;
793-
addr.GetKeyID(keyid);
794-
if (!model->havePrivKey(keyid)) // Unknown change address
795-
{
792+
const CTxDestination dest = addr.Get();
793+
if (!model->IsSpendable(dest)) {
796794
ui->labelCoinControlChangeLabel->setText(tr("Warning: Unknown change address"));
797795

798796
// confirmation dialog
799797
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?"),
800798
QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
801799

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

822-
CoinControlDialog::coinControl->destChange = addr.Get();
820+
CoinControlDialog::coinControl->destChange = dest;
823821
}
824822
}
825823
}

src/qt/walletmodel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,9 +561,9 @@ bool WalletModel::getPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const
561561
return wallet->GetPubKey(address, vchPubKeyOut);
562562
}
563563

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

569569
bool WalletModel::getPrivKey(const CKeyID &address, CKey& vchPrivKeyOut) const

src/qt/walletmodel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ class WalletModel : public QObject
190190
UnlockContext requestUnlock();
191191

192192
bool getPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const;
193-
bool havePrivKey(const CKeyID &address) const;
193+
bool IsSpendable(const CTxDestination& dest) const;
194194
bool getPrivKey(const CKeyID &address, CKey& vchPrivKeyOut) const;
195195
void getOutputs(const std::vector<COutPoint>& vOutpoints, std::vector<COutput>& vOutputs);
196196
bool isSpent(const COutPoint& outpoint) const;

0 commit comments

Comments
 (0)