AddressChecker: add torsion check

This commit is contained in:
tobtoht 2025-03-18 08:31:08 +01:00
parent 1c6bd9815b
commit c34ad819a6
No known key found for this signature in database
GPG key ID: E45B10DD027D2472
3 changed files with 16 additions and 0 deletions

View file

@ -1388,6 +1388,11 @@ void MainWindow::showAddressChecker() {
return;
}
if (!m_wallet->isAddressTorsionFree(address)) {
Utils::showWarning(this, "Address is not torsion-free", "This address is not compatible with reference wallets.\n\nSending to this address MAY RESULT IN A LOSS OF FUNDS.");
return;
}
SubaddressIndex index = m_wallet->subaddressIndex(address);
if (!index.isValid()) {
// TODO: probably mention lookahead here

View file

@ -331,6 +331,15 @@ QString Wallet::getSubaddressLookahead() const {
return QString("%1:%2").arg(QString::number(lookahead.first), QString::number(lookahead.second));
}
bool Wallet::isAddressTorsionFree(const QString& address) {
cryptonote::address_parse_info info;
bool r = cryptonote::get_account_address_from_str(info, m_wallet2->nettype(), address.toStdString());
if (!r) {
return false;
}
return rct::isInMainSubgroup(rct::pk2rct(info.address.m_spend_public_key)) && rct::isInMainSubgroup(rct::pk2rct(info.address.m_view_public_key));
}
// #################### Seed ####################
QString Wallet::getSeed(const QString &seedOffset) const {

View file

@ -176,6 +176,8 @@ public:
void deviceShowAddressAsync(quint32 accountIndex, quint32 addressIndex, const QString &paymentId);
QString getSubaddressLookahead() const;
bool isAddressTorsionFree(const QString& address);
// ##### Seed #####
//! returns mnemonic seed