Skip to content
Permalink
Browse files

Add more mnemonic logs for debugging

  • Loading branch information...
miltonf committed Mar 21, 2019
1 parent dbc8a0b commit 0a78f5013c3f7277220e37ba380a4b7884d2ce4f
Showing with 15 additions and 2 deletions.
  1. +15 −2 src/mnemonics/electrum-words.cpp
@@ -274,6 +274,7 @@ namespace crypto
if (seed.size() != expected/2 && seed.size() != expected &&
seed.size() != expected + 1)
{
MERROR("Invalid seed: unexpected number of words");
return false;
}

@@ -285,6 +286,7 @@ namespace crypto
Language::Base *language;
if (!find_seed_language(seed, has_checksum, matched_indices, &language))
{
MERROR("Invalid seed: language not found");
return false;
}
language_name = language->get_language_name();
@@ -294,7 +296,8 @@ namespace crypto
{
if (!checksum_test(seed, language->get_unique_prefix_length()))
{
// Checksum fail
// Checksum failure
MERROR("Invalid seed: invalid checksum");
return false;
}
seed.pop_back();
@@ -311,7 +314,11 @@ namespace crypto
val = w1 + word_list_length * (((word_list_length - w1) + w2) % word_list_length) +
word_list_length * word_list_length * (((word_list_length - w2) + w3) % word_list_length);

if (!(val % word_list_length == w1)) return false;
if (!(val % word_list_length == w1))
{
MERROR("Invalid seed: mumble mumble");
return false;
}

dst.append((const char*)&val, 4); // copy 4 bytes to position
}
@@ -343,9 +350,15 @@ namespace crypto
{
std::string s;
if (!words_to_bytes(words, s, sizeof(dst), true, language_name))
{
MERROR("Invalid seed: failed to convert words to bytes");
return false;
}
if (s.size() != sizeof(dst))
{
MERROR("Invalid seed: wrong output size");
return false;
}
dst = *(const crypto::secret_key*)s.data();
return true;
}

0 comments on commit 0a78f50

Please sign in to comment.
You can’t perform that action at this time.