mirror of
https://github.com/eosswedenorg/antelope-keygen
synced 2026-06-18 04:00:03 +02:00
common/include/eoskeygen/key_search.hpp: make prefix into a variable (we need it for k1 keys).
This commit is contained in:
parent
b39a2a09ae
commit
d579879d71
2 changed files with 15 additions and 3 deletions
|
|
@ -47,6 +47,8 @@ public :
|
|||
public :
|
||||
KeySearch();
|
||||
|
||||
void setPrefix(const std::string& prefix);
|
||||
|
||||
// Add a word to search for.
|
||||
void addWord(const std::string& str);
|
||||
|
||||
|
|
@ -97,6 +99,10 @@ protected :
|
|||
void _search_linear();
|
||||
|
||||
protected :
|
||||
|
||||
// Public key prefix.
|
||||
std::string m_prefix;
|
||||
|
||||
// List of words to search for.
|
||||
strlist_t m_words;
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
namespace eoskeygen {
|
||||
|
||||
KeySearch::KeySearch() :
|
||||
m_prefix ("EOS"),
|
||||
m_max (0),
|
||||
m_count (0),
|
||||
#ifdef EOSIOKEYGEN_HAVE_THREADS
|
||||
|
|
@ -40,6 +41,11 @@ KeySearch::KeySearch() :
|
|||
{
|
||||
}
|
||||
|
||||
void KeySearch::setPrefix(const std::string& prefix)
|
||||
{
|
||||
m_prefix = prefix;
|
||||
}
|
||||
|
||||
void KeySearch::addWord(const std::string& str)
|
||||
{
|
||||
std::string tmp = str;
|
||||
|
|
@ -107,14 +113,14 @@ void KeySearch::find(size_t num_results)
|
|||
|
||||
bool KeySearch::_contains_word(const struct libeosio::ec_keypair* key, struct result& result) {
|
||||
|
||||
// skip first 3 chars, as those are always "EOS"
|
||||
std::string pubstr = libeosio::wif_pub_encode(key->pub).substr(3);
|
||||
size_t prefix_len = m_prefix.length();
|
||||
std::string pubstr = libeosio::wif_pub_encode(key->pub, m_prefix).substr(prefix_len);
|
||||
strtolower(pubstr);
|
||||
|
||||
for(auto const& w: m_words) {
|
||||
size_t p = pubstr.find(w);
|
||||
if (p != std::string::npos) {
|
||||
result.pos = p + 3;
|
||||
result.pos = p + prefix_len;
|
||||
result.len = w.length();
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue