Finish SetFlag/ClearFlag

This commit is contained in:
JoelKatz
2013-06-18 09:56:34 -07:00
parent 8e2c65d4e0
commit 421388d4a7
5 changed files with 35 additions and 17 deletions

View File

@@ -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." },

View File

@@ -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.

View File

@@ -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;

View File

@@ -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.";

View File

@@ -46,7 +46,7 @@ TER RegularKeySetTransactor::doApply ()
else
{
if (mTxnAccount->isFlag (lsfDisableMaster))
return tefMASTER_DISABLED;
return tecMASTER_DISABLED;
mTxnAccount->makeFieldAbsent (sfRegularKey);
}