mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-26 11:13:23 -03:00
qt: Use IsMine to validate custom change address
(cherry picked from commit c41224dfd5
)
This commit is contained in:
parent
1227be30ec
commit
a1ea1cfbd8
3 changed files with 7 additions and 9 deletions
|
@ -789,10 +789,8 @@ void SendCoinsDialog::coinControlChangeEdited(const QString& text)
|
||||||
}
|
}
|
||||||
else // Valid address
|
else // Valid address
|
||||||
{
|
{
|
||||||
CKeyID keyid;
|
const CTxDestination dest = addr.Get();
|
||||||
addr.GetKeyID(keyid);
|
if (!model->IsSpendable(dest)) {
|
||||||
if (!model->havePrivKey(keyid)) // Unknown change address
|
|
||||||
{
|
|
||||||
ui->labelCoinControlChangeLabel->setText(tr("Warning: Unknown change address"));
|
ui->labelCoinControlChangeLabel->setText(tr("Warning: Unknown change address"));
|
||||||
|
|
||||||
// confirmation dialog
|
// confirmation dialog
|
||||||
|
@ -800,7 +798,7 @@ void SendCoinsDialog::coinControlChangeEdited(const QString& text)
|
||||||
QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
|
QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
|
||||||
|
|
||||||
if(btnRetVal == QMessageBox::Yes)
|
if(btnRetVal == QMessageBox::Yes)
|
||||||
CoinControlDialog::coinControl->destChange = addr.Get();
|
CoinControlDialog::coinControl->destChange = dest;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui->lineEditCoinControlChange->setText("");
|
ui->lineEditCoinControlChange->setText("");
|
||||||
|
@ -819,7 +817,7 @@ void SendCoinsDialog::coinControlChangeEdited(const QString& text)
|
||||||
else
|
else
|
||||||
ui->labelCoinControlChangeLabel->setText(tr("(no label)"));
|
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);
|
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
|
bool WalletModel::getPrivKey(const CKeyID &address, CKey& vchPrivKeyOut) const
|
||||||
|
|
|
@ -190,7 +190,7 @@ public:
|
||||||
UnlockContext requestUnlock();
|
UnlockContext requestUnlock();
|
||||||
|
|
||||||
bool getPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const;
|
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;
|
bool getPrivKey(const CKeyID &address, CKey& vchPrivKeyOut) const;
|
||||||
void getOutputs(const std::vector<COutPoint>& vOutpoints, std::vector<COutput>& vOutputs);
|
void getOutputs(const std::vector<COutPoint>& vOutpoints, std::vector<COutput>& vOutputs);
|
||||||
bool isSpent(const COutPoint& outpoint) const;
|
bool isSpent(const COutPoint& outpoint) const;
|
||||||
|
|
Loading…
Add table
Reference in a new issue