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

@@ -347,19 +347,21 @@ STObject::startMultiSigningData () const
return s;
}
// VFALCO This should not be a member,
// and the function shouldn't even exist
void
STObject::finishMultiSigningData (
RippleAddress const& signingForID,
RippleAddress const& signingID,
AccountID const& signingForID,
AccountID const& signingID,
Serializer& s) const
{
s.add160 (signingForID.getAccountID ());
s.add160 (signingID.getAccountID ());
s.add160 (signingForID);
s.add160 (signingID);
}
Serializer
STObject::getMultiSigningData (
RippleAddress const& signingForID, RippleAddress const& signingID) const
AccountID const& signingForID, AccountID const& signingID) const
{
Serializer s (startMultiSigningData ());
finishMultiSigningData (signingForID, signingID, s);
@@ -586,26 +588,7 @@ uint256 STObject::getFieldH256 (SField const& field) const
return getFieldByValue <STHash256> (field);
}
RippleAddress STObject::getFieldAccount (SField const& field) const
{
const STBase* rf = peekAtPField (field);
if (!rf)
throw std::runtime_error ("Field not found");
SerializedTypeID id = rf->getSType ();
if (id == STI_NOTPRESENT) return RippleAddress ();
const STAccount* cf = dynamic_cast<const STAccount*> (rf);
if (!cf)
throw std::runtime_error ("Wrong field type");
return cf->getValueNCA ();
}
AccountID STObject::getFieldAccount160 (SField const& field) const
AccountID STObject::getAccountID (SField const& field) const
{
auto rf = peekAtPField (field);
if (!rf)
@@ -715,7 +698,7 @@ void STObject::setFieldV256 (SField const& field, STVector256 const& v)
setFieldUsingSetValue <STVector256> (field, v);
}
void STObject::setFieldAccount (SField const& field, AccountID const& v)
void STObject::setAccountID (SField const& field, AccountID const& v)
{
STBase* rf = getPField (field, true);