]> Nutra Git (v2) - gamesguru/feather.git/commitdiff
AddressChecker: add torsion check
authortobtoht <tob@featherwallet.org>
Tue, 18 Mar 2025 07:31:08 +0000 (08:31 +0100)
committertobtoht <tob@featherwallet.org>
Tue, 18 Mar 2025 07:35:02 +0000 (08:35 +0100)
src/MainWindow.cpp
src/libwalletqt/Wallet.cpp
src/libwalletqt/Wallet.h

index 28cb8f8dc0e8e00e96ff8f01fcf4b0f4fb4428e2..698f17b0e7c65df5f97898639811ad97a0752299 100644 (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
index f9fa06afeed10a70afa8736cc846b2dc97a80c78..4fed2adfe74076088a32400f261bfc02fb90a792 100644 (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 {
index 74838c67891471d5e69b58a2ac4b0ae694086406..79b1f15677753193c2488c9f7761f6a323a4e60e 100644 (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