Refactor AccountID (RIPD-953):

All AccountID functionality is removed from RippleAddress and
replaced with free functions. The AccountID to string conversion
cache is factored out as an explicit type with an instance in
the Application object. New base58 conversion functions are used,
with no dependence on OpenSSL.

All types and free functions related to AccountID are consolidated
into one header file. Routines to operate on "tokens" are also
introduced and consolidated into a single header file.

A token one of the cryptographic primitives used in Ripple:

    Secret Seed
    Server Public Key
    Server Secret Key
    Account ID
    Account Public Key
    Account Private Key

    and these deprecated primitives:

    Account Family Seed
    Account Family Generator
This commit is contained in:
Vinnie Falco
2015-06-18 11:05:18 -07:00
parent 63d438c979
commit 2f485672fa
109 changed files with 1901 additions and 1545 deletions

View File

@@ -23,35 +23,41 @@
namespace ripple {
namespace RPC {
// --> strIdent: public key, account ID, or regular seed.
// --> bStrict: Only allow account id or public key.
// <-- bIndex: true if iIndex > 0 and used the index.
//
// Returns a Json::objectValue, containing error information if there was one.
Json::Value accountFromString (
RippleAddress& naAccount,
AccountID& result,
bool& bIndex,
std::string const& strIdent,
int const iIndex,
bool const bStrict)
{
RippleAddress naSeed;
if (naAccount.setAccountPublic (strIdent) ||
naAccount.setAccountID (strIdent))
// VFALCO Use AnyPublicKey
// Try public key
RippleAddress naAccount;
if (naAccount.setAccountPublic(strIdent))
{
// Got the account.
result = calcAccountID(naAccount);
bIndex = false;
return Json::Value (Json::objectValue);
return Json::objectValue;
}
// Try AccountID
auto accountID =
parseBase58<AccountID>(strIdent);
if (accountID)
{
result = *accountID;
bIndex = false;
return Json::objectValue;
}
if (bStrict)
{
auto success = naAccount.setAccountID (
strIdent, Base58::getBitcoinAlphabet ());
return rpcError (success ? rpcACT_BITCOIN : rpcACT_MALFORMED);
accountID = deprecatedParseBitcoinAccountID(strIdent);
return rpcError (accountID ? rpcACT_BITCOIN : rpcACT_MALFORMED);
}
RippleAddress naSeed;
// Otherwise, it must be a seed.
if (!naSeed.setSeedGeneric (strIdent))
return rpcError (rpcBAD_SEED);
@@ -67,7 +73,8 @@ Json::Value accountFromString (
bIndex = !iIndex;
naAccount.setAccountPublic (naGenerator, iIndex);
return Json::Value (Json::objectValue);
result = calcAccountID(naAccount);
return Json::objectValue;
}
} // RPC