mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-23 04:25:51 +00:00
Implement clearing the regular key, setting and clearing the no master
flag and enforcing the no master flag.
This commit is contained in:
@@ -531,6 +531,11 @@ bool STObject::clearFlag (uint32 f)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool STObject::isFlag (uint32 f)
|
||||||
|
{
|
||||||
|
return (getFlags () & f) == f;
|
||||||
|
}
|
||||||
|
|
||||||
uint32 STObject::getFlags (void) const
|
uint32 STObject::getFlags (void) const
|
||||||
{
|
{
|
||||||
const STUInt32* t = dynamic_cast<const STUInt32*> (peekAtPField (sfFlags));
|
const STUInt32* t = dynamic_cast<const STUInt32*> (peekAtPField (sfFlags));
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ public:
|
|||||||
|
|
||||||
bool setFlag (uint32);
|
bool setFlag (uint32);
|
||||||
bool clearFlag (uint32);
|
bool clearFlag (uint32);
|
||||||
|
bool isFlag(uint32);
|
||||||
uint32 getFlags () const;
|
uint32 getFlags () const;
|
||||||
|
|
||||||
uint256 getHash (uint32 prefix) const;
|
uint256 getHash (uint32 prefix) const;
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ bool transResultInfo (TER terCode, std::string& strToken, std::string& strHuman)
|
|||||||
{ tefNO_AUTH_REQUIRED, "tefNO_AUTH_REQUIRED", "Auth is not required." },
|
{ tefNO_AUTH_REQUIRED, "tefNO_AUTH_REQUIRED", "Auth is not required." },
|
||||||
{ tefPAST_SEQ, "tefPAST_SEQ", "This sequence number has already past." },
|
{ tefPAST_SEQ, "tefPAST_SEQ", "This sequence number has already past." },
|
||||||
{ tefWRONG_PRIOR, "tefWRONG_PRIOR", "This previous transaction does not match." },
|
{ tefWRONG_PRIOR, "tefWRONG_PRIOR", "This previous transaction does not match." },
|
||||||
|
{ tefMASTER_DISABLED, "tefMASTER_DISABLED", "Master key is disabled." },
|
||||||
|
{ tefNO_REGULAR_KEY, "tefNO_REGULAR_KEY", "Regular key is not set." },
|
||||||
|
|
||||||
{ telLOCAL_ERROR, "telLOCAL_ERROR", "Local failure." },
|
{ telLOCAL_ERROR, "telLOCAL_ERROR", "Local failure." },
|
||||||
{ telBAD_DOMAIN, "telBAD_DOMAIN", "Domain too long." },
|
{ telBAD_DOMAIN, "telBAD_DOMAIN", "Domain too long." },
|
||||||
|
|||||||
@@ -94,6 +94,8 @@ enum TER // aka TransactionEngineResult
|
|||||||
tefNO_AUTH_REQUIRED, // Can't set auth if auth is not required.
|
tefNO_AUTH_REQUIRED, // Can't set auth if auth is not required.
|
||||||
tefPAST_SEQ,
|
tefPAST_SEQ,
|
||||||
tefWRONG_PRIOR,
|
tefWRONG_PRIOR,
|
||||||
|
tefMASTER_DISABLED,
|
||||||
|
tefNO_REGULAR_KEY,
|
||||||
|
|
||||||
// -99 .. -1: R Retry (sequence too high, no funds for txn fee, originating account non-existent)
|
// -99 .. -1: R Retry (sequence too high, no funds for txn fee, originating account non-existent)
|
||||||
// Causes:
|
// Causes:
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ void TFInit ()
|
|||||||
;
|
;
|
||||||
|
|
||||||
DECLARE_TF (SetRegularKey, ttREGULAR_KEY_SET)
|
DECLARE_TF (SetRegularKey, ttREGULAR_KEY_SET)
|
||||||
<< SOElement (sfRegularKey, SOE_REQUIRED)
|
<< SOElement (sfRegularKey, SOE_OPTIONAL)
|
||||||
;
|
;
|
||||||
|
|
||||||
DECLARE_TF (Payment, ttPAYMENT)
|
DECLARE_TF (Payment, ttPAYMENT)
|
||||||
|
|||||||
@@ -105,6 +105,34 @@ TER AccountSetTransactor::doApply ()
|
|||||||
uFlagsOut &= ~lsfDisallowXRP;
|
uFlagsOut &= ~lsfDisallowXRP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// DisableMaster
|
||||||
|
//
|
||||||
|
|
||||||
|
if ((tfDisableMaster | tfEnableMaster) == (uTxFlags & (tfDisableMaster | tfEnableMaster)))
|
||||||
|
{
|
||||||
|
WriteLog (lsINFO, AccountSetTransactor) << "AccountSet: Malformed transaction: Contradictory flags set.";
|
||||||
|
|
||||||
|
return temINVALID_FLAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((uTxFlags & tfDisableMaster) && !isSetBit (uFlagsIn, lsfDisableMaster))
|
||||||
|
{
|
||||||
|
if (!mTxnAccount->isFieldPresent (sfRegularKey))
|
||||||
|
return tefNO_REGULAR_KEY;
|
||||||
|
|
||||||
|
WriteLog (lsINFO, AccountSetTransactor) << "AccountSet: Set lsfDisableMaster.";
|
||||||
|
|
||||||
|
uFlagsOut |= lsfDisableMaster;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((uTxFlags & tfEnableMaster) && isSetBit (uFlagsIn, lsfDisableMaster))
|
||||||
|
{
|
||||||
|
WriteLog (lsINFO, AccountSetTransactor) << "AccountSet: Clear lsfDisableMaster.";
|
||||||
|
|
||||||
|
uFlagsOut &= ~lsfDisableMaster;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// EmailHash
|
// EmailHash
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -38,8 +38,17 @@ TER RegularKeySetTransactor::doApply ()
|
|||||||
mTxnAccount->setFlag (lsfPasswordSpent);
|
mTxnAccount->setFlag (lsfPasswordSpent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mTxn.isFieldPresent (sfRegularKey))
|
||||||
|
{
|
||||||
uint160 uAuthKeyID = mTxn.getFieldAccount160 (sfRegularKey);
|
uint160 uAuthKeyID = mTxn.getFieldAccount160 (sfRegularKey);
|
||||||
mTxnAccount->setFieldAccount (sfRegularKey, uAuthKeyID);
|
mTxnAccount->setFieldAccount (sfRegularKey, uAuthKeyID);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (mTxnAccount->isFlag (lsfDisableMaster))
|
||||||
|
return tefMASTER_DISABLED;
|
||||||
|
mTxnAccount->makeFieldAbsent (sfRegularKey);
|
||||||
|
}
|
||||||
|
|
||||||
std::cerr << "RegularKeySet<" << std::endl;
|
std::cerr << "RegularKeySet<" << std::endl;
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ UPTR_T<Transactor> Transactor::makeTransactor (const SerializedTransaction& txn,
|
|||||||
Transactor::Transactor (const SerializedTransaction& txn, TransactionEngineParams params, TransactionEngine* engine) : mTxn (txn), mEngine (engine), mParams (params)
|
Transactor::Transactor (const SerializedTransaction& txn, TransactionEngineParams params, TransactionEngine* engine) : mTxn (txn), mEngine (engine), mParams (params)
|
||||||
{
|
{
|
||||||
mHasAuthKey = false;
|
mHasAuthKey = false;
|
||||||
|
mSigMaster = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transactor::calculateFee ()
|
void Transactor::calculateFee ()
|
||||||
@@ -101,12 +102,14 @@ TER Transactor::checkSig ()
|
|||||||
{
|
{
|
||||||
// Consistency: Check signature
|
// Consistency: Check signature
|
||||||
// Verify the transaction's signing public key is the key authorized for signing.
|
// Verify the transaction's signing public key is the key authorized for signing.
|
||||||
if (mHasAuthKey && mSigningPubKey.getAccountID () == mTxnAccount->getFieldAccount160 (sfRegularKey))
|
if (mSigningPubKey.getAccountID () == mTxnAccountID)
|
||||||
{
|
{
|
||||||
// Authorized to continue.
|
// Authorized to continue.
|
||||||
nothing ();
|
mSigMaster = true;
|
||||||
|
if (mTxnAccount->isFlag(lsfDisableMaster))
|
||||||
|
return tefMASTER_DISABLED;
|
||||||
}
|
}
|
||||||
else if (mSigningPubKey.getAccountID () == mTxnAccountID)
|
else if (mHasAuthKey && mSigningPubKey.getAccountID () == mTxnAccount->getFieldAccount160 (sfRegularKey))
|
||||||
{
|
{
|
||||||
// Authorized to continue.
|
// Authorized to continue.
|
||||||
nothing ();
|
nothing ();
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ protected:
|
|||||||
STAmount mSourceBalance; // Balance after fees.
|
STAmount mSourceBalance; // Balance after fees.
|
||||||
SLE::pointer mTxnAccount;
|
SLE::pointer mTxnAccount;
|
||||||
bool mHasAuthKey;
|
bool mHasAuthKey;
|
||||||
|
bool mSigMaster;
|
||||||
RippleAddress mSigningPubKey;
|
RippleAddress mSigningPubKey;
|
||||||
|
|
||||||
virtual TER preCheck ();
|
virtual TER preCheck ();
|
||||||
|
|||||||
Reference in New Issue
Block a user