]> Nutra Git (v1) - gamesguru/feather.git/commitdiff
seed: check legacy checksum
authortobtoht <tob@featherwallet.org>
Mon, 24 Mar 2025 04:50:32 +0000 (05:50 +0100)
committertobtoht <tob@featherwallet.org>
Mon, 24 Mar 2025 04:50:32 +0000 (05:50 +0100)
src/utils/Seed.cpp

index 9522f5adfff7c585114400fa072886d5d67b2e30..9396cb35c0bc16341a9d7ccda72a91200b16b5cb 100644 (file)
@@ -7,6 +7,8 @@
 #include "monero_seed/monero_seed.hpp"
 #include "polyseed/polyseed.h"
 #include "utils/AppData.h"
+#include "crypto/crypto.h"
+#include "mnemonics/electrum-words.h"
 
 #include <sstream>
 #include <utility>
@@ -132,6 +134,20 @@ Seed::Seed(Type type, QStringList mnemonic, NetworkType::Type networkType)
             return;
         }
     }
+
+    if (this->type == Type::MONERO) {
+        crypto::secret_key recovery_key;
+        std::string old_language;
+        if (!crypto::ElectrumWords::words_to_bytes(mnemonic.join(" ").toStdString(), recovery_key, old_language)) {
+            if (this->mnemonic.length() == 25) {
+                this->errorString = "Invalid checksum word";
+            }
+            else {
+                this->errorString = "Invalid seed";
+            }
+            return;
+        }
+    }
 }
 
 void Seed::setRestoreHeight(int height) {