From 0dbd07445c987ba47b36e1e4f18e1987ac92225b Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Sat, 12 May 2012 21:52:43 -0700 Subject: [PATCH] Add setFamilySeedGeneric to take any text. --- src/NewcoinAddress.cpp | 18 ++++++++++++++++++ src/NewcoinAddress.h | 1 + 2 files changed, 19 insertions(+) diff --git a/src/NewcoinAddress.cpp b/src/NewcoinAddress.cpp index 553bb3e9f..70346c196 100644 --- a/src/NewcoinAddress.cpp +++ b/src/NewcoinAddress.cpp @@ -562,6 +562,24 @@ bool NewcoinAddress::setFamilySeed(const std::string& strSeed) return SetString(strSeed.c_str(), VER_FAMILY_SEED); } +void NewcoinAddress::setFamilySeedGeneric(const std::string& strText) +{ + if (setFamilySeed(strText)) + { + std::cerr << "Recognized seed." << std::endl; + } + else if (1 == setFamilySeed1751(strText)) + { + std::cerr << "Recognized 1751 seed." << std::endl; + } + else + { + std::cerr << "Creating seed from pass phrase." << std::endl; + + setFamilySeed(CKey::PassPhraseToKey(strText)); + } +} + void NewcoinAddress::setFamilySeed(uint128 hash128) { SetData(VER_FAMILY_SEED, hash128.begin(), 16); } diff --git a/src/NewcoinAddress.h b/src/NewcoinAddress.h index fcca3c1bc..2842b5462 100644 --- a/src/NewcoinAddress.h +++ b/src/NewcoinAddress.h @@ -117,6 +117,7 @@ public: bool setFamilySeed(const std::string& strSeed); int setFamilySeed1751(const std::string& strHuman1751); + void setFamilySeedGeneric(const std::string& strText); void setFamilySeed(uint128 hash128); void setFamilySeedRandom(); };