From d718d876fc3d1f7cb3027b52be09e96ecdc33a66 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Sat, 27 Apr 2024 23:26:32 +0400 Subject: [PATCH] added address field to get_seed_phrase_info --- src/wallet/wallet_helpers.h | 29 ++++++++++++++++++++----- src/wallet/wallet_public_structs_defs.h | 2 ++ 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/wallet/wallet_helpers.h b/src/wallet/wallet_helpers.h index 6c24ef88..50da63a0 100644 --- a/src/wallet/wallet_helpers.h +++ b/src/wallet/wallet_helpers.h @@ -38,21 +38,40 @@ namespace tools result.hash_sum_matched = false; result.syntax_correct = acc.restore_from_tracking_seed(seed_phrase); if (result.syntax_correct) + { result.tracking = true; + result.address = acc.get_public_address_str(); + } } else { result.syntax_correct = currency::account_base::is_seed_password_protected(seed_phrase, result.require_password); - if (result.syntax_correct && result.require_password) + if (result.syntax_correct ) { - if (seed_password.size()) + if (result.require_password) { - currency::account_base acc; - result.hash_sum_matched = acc.restore_from_seed_phrase(seed_phrase, seed_password); + if (seed_password.size()) + { + currency::account_base acc; + result.hash_sum_matched = acc.restore_from_seed_phrase(seed_phrase, seed_password); + if (result.hash_sum_matched) + { + result.address = acc.get_public_address_str(); + } + } + else + { + result.hash_sum_matched = false; + } } else { - result.hash_sum_matched = false; + currency::account_base acc; + result.syntax_correct = acc.restore_from_seed_phrase(seed_phrase, ""); + if (result.syntax_correct) + { + result.address = acc.get_public_address_str(); + } } } } diff --git a/src/wallet/wallet_public_structs_defs.h b/src/wallet/wallet_public_structs_defs.h index 2d8a3685..663fb080 100644 --- a/src/wallet/wallet_public_structs_defs.h +++ b/src/wallet/wallet_public_structs_defs.h @@ -381,12 +381,14 @@ namespace wallet_public bool require_password; bool hash_sum_matched; bool tracking; + std::string address; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(syntax_correct) DOC_DSCR("Indicates whether the syntax is correct.") DOC_EXMP(true) DOC_END KV_SERIALIZE(require_password) DOC_DSCR("Indicates whether a password is required.") DOC_EXMP(true) DOC_END KV_SERIALIZE(hash_sum_matched) DOC_DSCR("Indicates whether the hash sum matches.") DOC_EXMP(true) DOC_END KV_SERIALIZE(tracking) DOC_DSCR("Indicates whether tracking is enabled.") DOC_EXMP(false) DOC_END + KV_SERIALIZE(address) DOC_DSCR("Return address of the seed phrase.") DOC_EXMP("ZxDNaMeZjwCjnHuU5gUNyrP1pM3U5vckbakzzV6dEHyDYeCpW8XGLBFTshcaY8LkG9RQn7FsQx8w2JeJzJwPwuDm2NfixPAXf") DOC_END END_KV_SERIALIZE_MAP() };