diff --git a/modules/ripple_data/protocol/ripple_TER.cpp b/modules/ripple_data/protocol/ripple_TER.cpp index a902d3379c..fa2418a9e1 100644 --- a/modules/ripple_data/protocol/ripple_TER.cpp +++ b/modules/ripple_data/protocol/ripple_TER.cpp @@ -24,6 +24,8 @@ bool transResultInfo (TER terCode, std::string& strToken, std::string& strHuman) { tecNO_LINE_REDUNDANT, "tecNO_LINE_REDUNDANT", "Can't set non-existant line to default." }, { tecPATH_DRY, "tecPATH_DRY", "Path could not send partial amount." }, { tecPATH_PARTIAL, "tecPATH_PARTIAL", "Path could not send full amount." }, + { tecMASTER_DISABLED, "tefMASTER_DISABLED", "Master key is disabled." }, + { tecNO_REGULAR_KEY, "tefNO_REGULAR_KEY", "Regular key is not set." }, { tecUNFUNDED, "tecUNFUNDED", "One of _ADD, _OFFER, or _SEND. Deprecated." }, { tecUNFUNDED_ADD, "tecUNFUNDED_ADD", "Insufficient XRP balance for WalletAdd." }, @@ -47,7 +49,6 @@ bool transResultInfo (TER terCode, std::string& strToken, std::string& strHuman) { tefPAST_SEQ, "tefPAST_SEQ", "This sequence number has already past." }, { 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." }, { telBAD_DOMAIN, "telBAD_DOMAIN", "Domain too long." }, diff --git a/modules/ripple_data/protocol/ripple_TER.h b/modules/ripple_data/protocol/ripple_TER.h index dc1bbda68f..b51a229454 100644 --- a/modules/ripple_data/protocol/ripple_TER.h +++ b/modules/ripple_data/protocol/ripple_TER.h @@ -95,7 +95,6 @@ enum TER // aka TransactionEngineResult tefPAST_SEQ, tefWRONG_PRIOR, tefMASTER_DISABLED, - tefNO_REGULAR_KEY, // -99 .. -1: R Retry (sequence too high, no funds for txn fee, originating account non-existent) // Causes: @@ -149,6 +148,8 @@ enum TER // aka TransactionEngineResult tecNO_LINE_REDUNDANT = 127, tecPATH_DRY = 128, tecUNFUNDED = 129, // Deprecated, old ambiguous unfunded. + tecMASTER_DISABLED = 130, + tecNO_REGULAR_KEY = 131, }; // VFALCO TODO change these to normal functions. diff --git a/modules/ripple_data/protocol/ripple_TxFlags.h b/modules/ripple_data/protocol/ripple_TxFlags.h index 5a8fee2207..a8f2a615be 100644 --- a/modules/ripple_data/protocol/ripple_TxFlags.h +++ b/modules/ripple_data/protocol/ripple_TxFlags.h @@ -37,6 +37,12 @@ const uint32 tfAccountSetMask = ~ (TxFlag::requireDestTag | tfOptionalDest | tfRequireAuth | tfOptionalAuth | tfDisallowXRP | tfAllowXRP); +// AccountSet SetFlag/ClearFlag values +const uint32 asfRequireDest = 1; +const uint32 asfRequireAuth = 2; +const uint32 asfDisallowXRP = 3; +const uint32 asfDisableMaster = 4; + // OfferCreate flags: const uint32 tfPassive = 0x00010000; const uint32 tfImmediateOrCancel = 0x00020000; diff --git a/src/cpp/ripple/AccountSetTransactor.cpp b/src/cpp/ripple/AccountSetTransactor.cpp index 34941727fe..871b0dcc13 100644 --- a/src/cpp/ripple/AccountSetTransactor.cpp +++ b/src/cpp/ripple/AccountSetTransactor.cpp @@ -15,6 +15,17 @@ TER AccountSetTransactor::doApply () const uint32 uFlagsIn = mTxnAccount->getFieldU32 (sfFlags); uint32 uFlagsOut = uFlagsIn; + const uint32 uSetFlag = mTxn.getFieldU32 (sfSetFlag); + const uint32 uClearFlag = mTxn.getFieldU32 (sfClearFlag); + + // legacy AccountSet flags + bool bSetRequireDest = (uFlagsIn & TxFlag::requireDestTag) || (uSetFlag == asfRequireDest); + bool bClearRequireDest = (uFlagsIn & tfOptionalDestTag) || (uClearFlag == asfRequireDest); + bool bSetRequireAuth = (uFlagsIn & tfRequireAuth) || (uSetFlag == asfRequireAuth); + bool bClearRequireAuth = (uFlagsIn & tfOptionalAuth) || (uClearFlag == asfRequireAuth); + bool bSetDisallowXRP = (uFlagsIn & tfDisallowXRP) || (uSetFlag == asfDisallowXRP); + bool bClearDisallowXRP = (uFlagsIn & tfAllowXRP) || (uClearFlag == asfDisallowXRP); + if (uTxFlags & tfAccountSetMask) { WriteLog (lsINFO, AccountSetTransactor) << "AccountSet: Malformed transaction: Invalid flags set."; @@ -26,14 +37,14 @@ TER AccountSetTransactor::doApply () // RequireAuth // - if ((tfRequireAuth | tfOptionalAuth) == (uTxFlags & (tfRequireAuth | tfOptionalAuth))) + if (bSetRequireAuth && bClearRequireAuth) { WriteLog (lsINFO, AccountSetTransactor) << "AccountSet: Malformed transaction: Contradictory flags set."; return temINVALID_FLAG; } - if ((uTxFlags & tfRequireAuth) && !isSetBit (uFlagsIn, lsfRequireAuth)) + if (bSetRequireAuth && !isSetBit (uFlagsIn, lsfRequireAuth)) { if (mTxnAccount->getFieldU32 (sfOwnerCount)) { @@ -47,7 +58,7 @@ TER AccountSetTransactor::doApply () uFlagsOut |= lsfRequireAuth; } - if ((uTxFlags & tfOptionalAuth) && isSetBit (uFlagsIn, lsfRequireAuth)) + if (bClearRequireAuth && isSetBit (uFlagsIn, lsfRequireAuth)) { WriteLog (lsINFO, AccountSetTransactor) << "AccountSet: Clear RequireAuth."; @@ -58,22 +69,21 @@ TER AccountSetTransactor::doApply () // RequireDestTag // - // VFALCO TODO Make a function bool areBothFlagsSet (uint value, uint flag1, uint flag2) - if ((TxFlag::requireDestTag | tfOptionalDestTag) == (uTxFlags & (TxFlag::requireDestTag | tfOptionalDestTag))) + if (bSetRequireDest && bClearRequireDest) { WriteLog (lsINFO, AccountSetTransactor) << "AccountSet: Malformed transaction: Contradictory flags set."; return temINVALID_FLAG; } - if ((uTxFlags & TxFlag::requireDestTag) && !isSetBit (uFlagsIn, lsfRequireDestTag)) + if (bSetRequireDest && !isSetBit (uFlagsIn, lsfRequireDestTag)) { WriteLog (lsINFO, AccountSetTransactor) << "AccountSet: Set lsfRequireDestTag."; uFlagsOut |= lsfRequireDestTag; } - if ((uTxFlags & tfOptionalDestTag) && isSetBit (uFlagsIn, lsfRequireDestTag)) + if (bClearRequireDest && isSetBit (uFlagsIn, lsfRequireDestTag)) { WriteLog (lsINFO, AccountSetTransactor) << "AccountSet: Clear lsfRequireDestTag."; @@ -84,21 +94,21 @@ TER AccountSetTransactor::doApply () // DisallowXRP // - if ((tfDisallowXRP | tfAllowXRP) == (uTxFlags & (tfDisallowXRP | tfAllowXRP))) + if (bSetDisallowXRP && bClearDisallowXRP) { WriteLog (lsINFO, AccountSetTransactor) << "AccountSet: Malformed transaction: Contradictory flags set."; return temINVALID_FLAG; } - if ((uTxFlags & tfDisallowXRP) && !isSetBit (uFlagsIn, lsfDisallowXRP)) + if (bSetDisallowXRP && !isSetBit (uFlagsIn, lsfDisallowXRP)) { WriteLog (lsINFO, AccountSetTransactor) << "AccountSet: Set lsfDisallowXRP."; uFlagsOut |= lsfDisallowXRP; } - if ((uTxFlags & tfAllowXRP) && isSetBit (uFlagsIn, lsfDisallowXRP)) + if (bClearDisallowXRP && isSetBit (uFlagsIn, lsfDisallowXRP)) { WriteLog (lsINFO, AccountSetTransactor) << "AccountSet: Clear lsfDisallowXRP."; @@ -109,24 +119,24 @@ TER AccountSetTransactor::doApply () // DisableMaster // - if ((tfDisableMaster | tfEnableMaster) == (uTxFlags & (tfDisableMaster | tfEnableMaster))) + if ((uSetFlag == asfDisableMaster) && (uClearFlag == asfDisableMaster)) { WriteLog (lsINFO, AccountSetTransactor) << "AccountSet: Malformed transaction: Contradictory flags set."; return temINVALID_FLAG; } - if ((uTxFlags & tfDisableMaster) && !isSetBit (uFlagsIn, lsfDisableMaster)) + if ((uSetFlag == asfDisableMaster) && !isSetBit (uFlagsIn, lsfDisableMaster)) { if (!mTxnAccount->isFieldPresent (sfRegularKey)) - return tefNO_REGULAR_KEY; + return tecNO_REGULAR_KEY; WriteLog (lsINFO, AccountSetTransactor) << "AccountSet: Set lsfDisableMaster."; uFlagsOut |= lsfDisableMaster; } - if ((uTxFlags & tfEnableMaster) && isSetBit (uFlagsIn, lsfDisableMaster)) + if ((uClearFlag == asfDisableMaster) && isSetBit (uFlagsIn, lsfDisableMaster)) { WriteLog (lsINFO, AccountSetTransactor) << "AccountSet: Clear lsfDisableMaster."; diff --git a/src/cpp/ripple/RegularKeySetTransactor.cpp b/src/cpp/ripple/RegularKeySetTransactor.cpp index 2d0b472afa..13dbcf4b41 100644 --- a/src/cpp/ripple/RegularKeySetTransactor.cpp +++ b/src/cpp/ripple/RegularKeySetTransactor.cpp @@ -46,7 +46,7 @@ TER RegularKeySetTransactor::doApply () else { if (mTxnAccount->isFlag (lsfDisableMaster)) - return tefMASTER_DISABLED; + return tecMASTER_DISABLED; mTxnAccount->makeFieldAbsent (sfRegularKey); }