Changeset View
Changeset View
Standalone View
Standalone View
src/qt/signverifymessagedialog.cpp
Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | |||||
void SignVerifyMessageDialog::on_signMessageButton_SM_clicked() { | void SignVerifyMessageDialog::on_signMessageButton_SM_clicked() { | ||||
if (!model) return; | if (!model) return; | ||||
/* Clear old signature to ensure users don't get confused on error with an | /* Clear old signature to ensure users don't get confused on error with an | ||||
* old signature displayed */ | * old signature displayed */ | ||||
ui->signatureOut_SM->clear(); | ui->signatureOut_SM->clear(); | ||||
CBitcoinAddress addr(ui->addressIn_SM->text().toStdString()); | CTxDestination destination = | ||||
if (!addr.IsValid()) { | DecodeDestination(ui->addressIn_SM->text().toStdString()); | ||||
if (!IsValidDestination(destination)) { | |||||
ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); | ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); | ||||
ui->statusLabel_SM->setText( | ui->statusLabel_SM->setText( | ||||
tr("The entered address is invalid.") + QString(" ") + | tr("The entered address is invalid.") + QString(" ") + | ||||
tr("Please check the address and try again.")); | tr("Please check the address and try again.")); | ||||
return; | return; | ||||
} | } | ||||
CKeyID keyID; | const CKeyID *keyID = boost::get<CKeyID>(&destination); | ||||
if (!addr.GetKeyID(keyID)) { | if (!keyID) { | ||||
ui->addressIn_SM->setValid(false); | ui->addressIn_SM->setValid(false); | ||||
ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); | ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); | ||||
ui->statusLabel_SM->setText( | ui->statusLabel_SM->setText( | ||||
tr("The entered address does not refer to a key.") + QString(" ") + | tr("The entered address does not refer to a key.") + QString(" ") + | ||||
tr("Please check the address and try again.")); | tr("Please check the address and try again.")); | ||||
return; | return; | ||||
} | } | ||||
WalletModel::UnlockContext ctx(model->requestUnlock()); | WalletModel::UnlockContext ctx(model->requestUnlock()); | ||||
if (!ctx.isValid()) { | if (!ctx.isValid()) { | ||||
ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); | ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); | ||||
ui->statusLabel_SM->setText(tr("Wallet unlock was cancelled.")); | ui->statusLabel_SM->setText(tr("Wallet unlock was cancelled.")); | ||||
return; | return; | ||||
} | } | ||||
CKey key; | CKey key; | ||||
if (!model->getPrivKey(keyID, key)) { | if (!model->getPrivKey(*keyID, key)) { | ||||
ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); | ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); | ||||
ui->statusLabel_SM->setText( | ui->statusLabel_SM->setText( | ||||
tr("Private key for the entered address is not available.")); | tr("Private key for the entered address is not available.")); | ||||
return; | return; | ||||
} | } | ||||
CHashWriter ss(SER_GETHASH, 0); | CHashWriter ss(SER_GETHASH, 0); | ||||
ss << strMessageMagic; | ss << strMessageMagic; | ||||
Show All 36 Lines | if (model && model->getAddressTableModel()) { | ||||
dlg.setModel(model->getAddressTableModel()); | dlg.setModel(model->getAddressTableModel()); | ||||
if (dlg.exec()) { | if (dlg.exec()) { | ||||
setAddress_VM(dlg.getReturnValue()); | setAddress_VM(dlg.getReturnValue()); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
void SignVerifyMessageDialog::on_verifyMessageButton_VM_clicked() { | void SignVerifyMessageDialog::on_verifyMessageButton_VM_clicked() { | ||||
CBitcoinAddress addr(ui->addressIn_VM->text().toStdString()); | CTxDestination destination = | ||||
if (!addr.IsValid()) { | DecodeDestination(ui->addressIn_VM->text().toStdString()); | ||||
if (!IsValidDestination(destination)) { | |||||
ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); | ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); | ||||
ui->statusLabel_VM->setText( | ui->statusLabel_VM->setText( | ||||
tr("The entered address is invalid.") + QString(" ") + | tr("The entered address is invalid.") + QString(" ") + | ||||
tr("Please check the address and try again.")); | tr("Please check the address and try again.")); | ||||
return; | return; | ||||
} | } | ||||
CKeyID keyID; | if (!boost::get<CKeyID>(&destination)) { | ||||
if (!addr.GetKeyID(keyID)) { | |||||
ui->addressIn_VM->setValid(false); | ui->addressIn_VM->setValid(false); | ||||
ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); | ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); | ||||
ui->statusLabel_VM->setText( | ui->statusLabel_VM->setText( | ||||
tr("The entered address does not refer to a key.") + QString(" ") + | tr("The entered address does not refer to a key.") + QString(" ") + | ||||
tr("Please check the address and try again.")); | tr("Please check the address and try again.")); | ||||
return; | return; | ||||
} | } | ||||
Show All 19 Lines | if (!pubkey.RecoverCompact(ss.GetHash(), vchSig)) { | ||||
ui->signatureIn_VM->setValid(false); | ui->signatureIn_VM->setValid(false); | ||||
ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); | ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); | ||||
ui->statusLabel_VM->setText( | ui->statusLabel_VM->setText( | ||||
tr("The signature did not match the message digest.") + | tr("The signature did not match the message digest.") + | ||||
QString(" ") + tr("Please check the signature and try again.")); | QString(" ") + tr("Please check the signature and try again.")); | ||||
return; | return; | ||||
} | } | ||||
if (!(CBitcoinAddress(pubkey.GetID()) == addr)) { | if (!(CTxDestination(pubkey.GetID()) == destination)) { | ||||
ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); | ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); | ||||
ui->statusLabel_VM->setText(QString("<nobr>") + | ui->statusLabel_VM->setText(QString("<nobr>") + | ||||
tr("Message verification failed.") + | tr("Message verification failed.") + | ||||
QString("</nobr>")); | QString("</nobr>")); | ||||
return; | return; | ||||
} | } | ||||
ui->statusLabel_VM->setStyleSheet("QLabel { color: green; }"); | ui->statusLabel_VM->setStyleSheet("QLabel { color: green; }"); | ||||
Show All 32 Lines |