mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Refactor View, MetaView, and tx processing:
This tidies up the View interface and makes transaction application a free function, with the removal of the TransactionEngine class. A new class ApplyContext provides all the state information needed to apply a Transactor. The Transactor is refactored to perform all the processing activities previously part of TransactionEngine. The calculation of metadata from a MetaView is improved. A new apply function performs all the steps for calculating and inserting metadata into the tx map. Transaction processing code path is passed a Config instead of retrieving the global, and uses the Journal supplied in the call to apply() consistently. To support transaction processing and RPC operations, a new POD type ViewInfo is added which consolidates static information about open and closed ledgers, such as the ledger sequence number or the closing times. Ledger and MetaView are refactored to use this info. The ViewInfo now contains the "open ledger" setting. The tapOPEN_LEDGER ViewFlag is removed. The view property of being an open ledger is obtained from the base or by using the MetaView constructor which presents a closed ledger as an open one. View, MetaView: * Fix missing includes * Add apply free function * Use Journal in TransactionEngine * Use BasicView in TransactionEngine * inline NetworkOPs::batchApply * Add shallow_copy, open_ledger MetaView ctor tags * Add ViewInfo with open flag, seq, close times * Make parent_ a reference * Tidy up ctor arguments and base_ name * Remove tapOPEN_LEDGER * add assert to MetaView::apply * ViewInfo comment * Throw, pass Journal in txInsert * Add BasicView::txCount TransactionEngine: * Add apply * Make TransactionEngine private * Refactor MetaView::apply and apply() * Rename to TxMeta * Refactor treatment of metadata in MetaView, TransactionEngine * Rename to ApplyContext * Use ApplyContext& in Transactor * Pass Config in ApplyContext * Declare Transactor classes in headers * Use view flags in Transactor
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/app/tx/impl/Transactor.h>
|
||||
#include <ripple/app/tx/impl/SetAccount.h>
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <ripple/core/Config.h>
|
||||
#include <ripple/protocol/Indexes.h>
|
||||
@@ -27,370 +27,342 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
class SetAccount
|
||||
: public Transactor
|
||||
TER
|
||||
SetAccount::preCheck ()
|
||||
{
|
||||
static std::size_t const DOMAIN_BYTES_MAX = 256;
|
||||
static std::size_t const PUBLIC_BYTES_MAX = 33;
|
||||
std::uint32_t const uTxFlags = mTxn.getFlags ();
|
||||
|
||||
public:
|
||||
SetAccount (
|
||||
STTx const& txn,
|
||||
ViewFlags params,
|
||||
TransactionEngine* engine)
|
||||
: Transactor (
|
||||
txn,
|
||||
params,
|
||||
engine,
|
||||
deprecatedLogs().journal("SetAccount"))
|
||||
if (uTxFlags & tfAccountSetMask)
|
||||
{
|
||||
|
||||
j_.trace << "Malformed transaction: Invalid flags set.";
|
||||
return temINVALID_FLAG;
|
||||
}
|
||||
|
||||
TER preCheck () override
|
||||
std::uint32_t const uSetFlag = mTxn.getFieldU32 (sfSetFlag);
|
||||
std::uint32_t const uClearFlag = mTxn.getFieldU32 (sfClearFlag);
|
||||
|
||||
if ((uSetFlag != 0) && (uSetFlag == uClearFlag))
|
||||
{
|
||||
std::uint32_t const uTxFlags = mTxn.getFlags ();
|
||||
|
||||
if (uTxFlags & tfAccountSetMask)
|
||||
{
|
||||
m_journal.trace << "Malformed transaction: Invalid flags set.";
|
||||
return temINVALID_FLAG;
|
||||
}
|
||||
|
||||
std::uint32_t const uSetFlag = mTxn.getFieldU32 (sfSetFlag);
|
||||
std::uint32_t const uClearFlag = mTxn.getFieldU32 (sfClearFlag);
|
||||
|
||||
if ((uSetFlag != 0) && (uSetFlag == uClearFlag))
|
||||
{
|
||||
m_journal.trace << "Malformed transaction: Set and clear same flag.";
|
||||
return temINVALID_FLAG;
|
||||
}
|
||||
|
||||
//
|
||||
// RequireAuth
|
||||
//
|
||||
bool bSetRequireAuth = (uTxFlags & tfRequireAuth) || (uSetFlag == asfRequireAuth);
|
||||
bool bClearRequireAuth = (uTxFlags & tfOptionalAuth) || (uClearFlag == asfRequireAuth);
|
||||
|
||||
if (bSetRequireAuth && bClearRequireAuth)
|
||||
{
|
||||
m_journal.trace << "Malformed transaction: Contradictory flags set.";
|
||||
return temINVALID_FLAG;
|
||||
}
|
||||
|
||||
//
|
||||
// RequireDestTag
|
||||
//
|
||||
bool bSetRequireDest = (uTxFlags & TxFlag::requireDestTag) || (uSetFlag == asfRequireDest);
|
||||
bool bClearRequireDest = (uTxFlags & tfOptionalDestTag) || (uClearFlag == asfRequireDest);
|
||||
|
||||
if (bSetRequireDest && bClearRequireDest)
|
||||
{
|
||||
m_journal.trace << "Malformed transaction: Contradictory flags set.";
|
||||
return temINVALID_FLAG;
|
||||
}
|
||||
|
||||
//
|
||||
// DisallowXRP
|
||||
//
|
||||
bool bSetDisallowXRP = (uTxFlags & tfDisallowXRP) || (uSetFlag == asfDisallowXRP);
|
||||
bool bClearDisallowXRP = (uTxFlags & tfAllowXRP) || (uClearFlag == asfDisallowXRP);
|
||||
|
||||
if (bSetDisallowXRP && bClearDisallowXRP)
|
||||
{
|
||||
m_journal.trace << "Malformed transaction: Contradictory flags set.";
|
||||
return temINVALID_FLAG;
|
||||
}
|
||||
|
||||
// TransferRate
|
||||
if (mTxn.isFieldPresent (sfTransferRate))
|
||||
{
|
||||
std::uint32_t uRate = mTxn.getFieldU32 (sfTransferRate);
|
||||
|
||||
if (uRate && (uRate < QUALITY_ONE))
|
||||
{
|
||||
m_journal.trace << "Malformed transaction: Bad transfer rate.";
|
||||
return temBAD_TRANSFER_RATE;
|
||||
}
|
||||
}
|
||||
|
||||
return Transactor::preCheck ();
|
||||
j_.trace << "Malformed transaction: Set and clear same flag.";
|
||||
return temINVALID_FLAG;
|
||||
}
|
||||
|
||||
TER doApply () override
|
||||
//
|
||||
// RequireAuth
|
||||
//
|
||||
bool bSetRequireAuth = (uTxFlags & tfRequireAuth) || (uSetFlag == asfRequireAuth);
|
||||
bool bClearRequireAuth = (uTxFlags & tfOptionalAuth) || (uClearFlag == asfRequireAuth);
|
||||
|
||||
if (bSetRequireAuth && bClearRequireAuth)
|
||||
{
|
||||
std::uint32_t const uTxFlags = mTxn.getFlags ();
|
||||
|
||||
std::uint32_t const uFlagsIn = mTxnAccount->getFieldU32 (sfFlags);
|
||||
std::uint32_t uFlagsOut = uFlagsIn;
|
||||
|
||||
std::uint32_t const uSetFlag = mTxn.getFieldU32 (sfSetFlag);
|
||||
std::uint32_t const uClearFlag = mTxn.getFieldU32 (sfClearFlag);
|
||||
|
||||
// legacy AccountSet flags
|
||||
bool bSetRequireDest = (uTxFlags & TxFlag::requireDestTag) || (uSetFlag == asfRequireDest);
|
||||
bool bClearRequireDest = (uTxFlags & tfOptionalDestTag) || (uClearFlag == asfRequireDest);
|
||||
bool bSetRequireAuth = (uTxFlags & tfRequireAuth) || (uSetFlag == asfRequireAuth);
|
||||
bool bClearRequireAuth = (uTxFlags & tfOptionalAuth) || (uClearFlag == asfRequireAuth);
|
||||
bool bSetDisallowXRP = (uTxFlags & tfDisallowXRP) || (uSetFlag == asfDisallowXRP);
|
||||
bool bClearDisallowXRP = (uTxFlags & tfAllowXRP) || (uClearFlag == asfDisallowXRP);
|
||||
|
||||
//
|
||||
// RequireAuth
|
||||
//
|
||||
if (bSetRequireAuth && !(uFlagsIn & lsfRequireAuth))
|
||||
{
|
||||
if (! dirIsEmpty (mEngine->view(),
|
||||
keylet::ownerDir(mTxnAccountID)))
|
||||
{
|
||||
m_journal.trace << "Retry: Owner directory not empty.";
|
||||
return (mParams & tapRETRY) ? terOWNERS : tecOWNERS;
|
||||
}
|
||||
|
||||
m_journal.trace << "Set RequireAuth.";
|
||||
uFlagsOut |= lsfRequireAuth;
|
||||
}
|
||||
|
||||
if (bClearRequireAuth && (uFlagsIn & lsfRequireAuth))
|
||||
{
|
||||
m_journal.trace << "Clear RequireAuth.";
|
||||
uFlagsOut &= ~lsfRequireAuth;
|
||||
}
|
||||
|
||||
//
|
||||
// RequireDestTag
|
||||
//
|
||||
if (bSetRequireDest && !(uFlagsIn & lsfRequireDestTag))
|
||||
{
|
||||
m_journal.trace << "Set lsfRequireDestTag.";
|
||||
uFlagsOut |= lsfRequireDestTag;
|
||||
}
|
||||
|
||||
if (bClearRequireDest && (uFlagsIn & lsfRequireDestTag))
|
||||
{
|
||||
m_journal.trace << "Clear lsfRequireDestTag.";
|
||||
uFlagsOut &= ~lsfRequireDestTag;
|
||||
}
|
||||
|
||||
//
|
||||
// DisallowXRP
|
||||
//
|
||||
if (bSetDisallowXRP && !(uFlagsIn & lsfDisallowXRP))
|
||||
{
|
||||
m_journal.trace << "Set lsfDisallowXRP.";
|
||||
uFlagsOut |= lsfDisallowXRP;
|
||||
}
|
||||
|
||||
if (bClearDisallowXRP && (uFlagsIn & lsfDisallowXRP))
|
||||
{
|
||||
m_journal.trace << "Clear lsfDisallowXRP.";
|
||||
uFlagsOut &= ~lsfDisallowXRP;
|
||||
}
|
||||
|
||||
//
|
||||
// DisableMaster
|
||||
//
|
||||
if ((uSetFlag == asfDisableMaster) && !(uFlagsIn & lsfDisableMaster))
|
||||
{
|
||||
if (!mSigMaster)
|
||||
{
|
||||
m_journal.trace << "Must use master key to disable master key.";
|
||||
return tecNEED_MASTER_KEY;
|
||||
}
|
||||
|
||||
if (!mTxnAccount->isFieldPresent (sfRegularKey))
|
||||
return tecNO_REGULAR_KEY;
|
||||
|
||||
m_journal.trace << "Set lsfDisableMaster.";
|
||||
uFlagsOut |= lsfDisableMaster;
|
||||
}
|
||||
|
||||
if ((uClearFlag == asfDisableMaster) && (uFlagsIn & lsfDisableMaster))
|
||||
{
|
||||
m_journal.trace << "Clear lsfDisableMaster.";
|
||||
uFlagsOut &= ~lsfDisableMaster;
|
||||
}
|
||||
|
||||
//
|
||||
// DefaultRipple
|
||||
//
|
||||
if (uSetFlag == asfDefaultRipple)
|
||||
{
|
||||
uFlagsOut |= lsfDefaultRipple;
|
||||
}
|
||||
else if (uClearFlag == asfDefaultRipple)
|
||||
{
|
||||
uFlagsOut &= ~lsfDefaultRipple;
|
||||
}
|
||||
|
||||
//
|
||||
// NoFreeze
|
||||
//
|
||||
if (uSetFlag == asfNoFreeze)
|
||||
{
|
||||
if (!mSigMaster && !(uFlagsIn & lsfDisableMaster))
|
||||
{
|
||||
m_journal.trace << "Can't use regular key to set NoFreeze.";
|
||||
return tecNEED_MASTER_KEY;
|
||||
}
|
||||
|
||||
m_journal.trace << "Set NoFreeze flag";
|
||||
uFlagsOut |= lsfNoFreeze;
|
||||
}
|
||||
|
||||
// Anyone may set global freeze
|
||||
if (uSetFlag == asfGlobalFreeze)
|
||||
{
|
||||
m_journal.trace << "Set GlobalFreeze flag";
|
||||
uFlagsOut |= lsfGlobalFreeze;
|
||||
}
|
||||
|
||||
// If you have set NoFreeze, you may not clear GlobalFreeze
|
||||
// This prevents those who have set NoFreeze from using
|
||||
// GlobalFreeze strategically.
|
||||
if ((uSetFlag != asfGlobalFreeze) && (uClearFlag == asfGlobalFreeze) &&
|
||||
((uFlagsOut & lsfNoFreeze) == 0))
|
||||
{
|
||||
m_journal.trace << "Clear GlobalFreeze flag";
|
||||
uFlagsOut &= ~lsfGlobalFreeze;
|
||||
}
|
||||
|
||||
//
|
||||
// Track transaction IDs signed by this account in its root
|
||||
//
|
||||
if ((uSetFlag == asfAccountTxnID) && !mTxnAccount->isFieldPresent (sfAccountTxnID))
|
||||
{
|
||||
m_journal.trace << "Set AccountTxnID";
|
||||
mTxnAccount->makeFieldPresent (sfAccountTxnID);
|
||||
}
|
||||
|
||||
if ((uClearFlag == asfAccountTxnID) && mTxnAccount->isFieldPresent (sfAccountTxnID))
|
||||
{
|
||||
m_journal.trace << "Clear AccountTxnID";
|
||||
mTxnAccount->makeFieldAbsent (sfAccountTxnID);
|
||||
}
|
||||
|
||||
//
|
||||
// EmailHash
|
||||
//
|
||||
if (mTxn.isFieldPresent (sfEmailHash))
|
||||
{
|
||||
uint128 const uHash = mTxn.getFieldH128 (sfEmailHash);
|
||||
|
||||
if (!uHash)
|
||||
{
|
||||
m_journal.trace << "unset email hash";
|
||||
mTxnAccount->makeFieldAbsent (sfEmailHash);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_journal.trace << "set email hash";
|
||||
mTxnAccount->setFieldH128 (sfEmailHash, uHash);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// WalletLocator
|
||||
//
|
||||
if (mTxn.isFieldPresent (sfWalletLocator))
|
||||
{
|
||||
uint256 const uHash = mTxn.getFieldH256 (sfWalletLocator);
|
||||
|
||||
if (!uHash)
|
||||
{
|
||||
m_journal.trace << "unset wallet locator";
|
||||
mTxnAccount->makeFieldAbsent (sfWalletLocator);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_journal.trace << "set wallet locator";
|
||||
mTxnAccount->setFieldH256 (sfWalletLocator, uHash);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// MessageKey
|
||||
//
|
||||
if (mTxn.isFieldPresent (sfMessageKey))
|
||||
{
|
||||
Blob const messageKey = mTxn.getFieldVL (sfMessageKey);
|
||||
|
||||
if (messageKey.size () > PUBLIC_BYTES_MAX)
|
||||
{
|
||||
m_journal.trace << "message key too long";
|
||||
return telBAD_PUBLIC_KEY;
|
||||
}
|
||||
|
||||
if (messageKey.empty ())
|
||||
{
|
||||
m_journal.debug << "set message key";
|
||||
mTxnAccount->makeFieldAbsent (sfMessageKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_journal.debug << "set message key";
|
||||
mTxnAccount->setFieldVL (sfMessageKey, messageKey);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Domain
|
||||
//
|
||||
if (mTxn.isFieldPresent (sfDomain))
|
||||
{
|
||||
Blob const domain = mTxn.getFieldVL (sfDomain);
|
||||
|
||||
if (domain.size () > DOMAIN_BYTES_MAX)
|
||||
{
|
||||
m_journal.trace << "domain too long";
|
||||
return telBAD_DOMAIN;
|
||||
}
|
||||
|
||||
if (domain.empty ())
|
||||
{
|
||||
m_journal.trace << "unset domain";
|
||||
mTxnAccount->makeFieldAbsent (sfDomain);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_journal.trace << "set domain";
|
||||
mTxnAccount->setFieldVL (sfDomain, domain);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// TransferRate
|
||||
//
|
||||
if (mTxn.isFieldPresent (sfTransferRate))
|
||||
{
|
||||
std::uint32_t uRate = mTxn.getFieldU32 (sfTransferRate);
|
||||
|
||||
if (uRate == 0 || uRate == QUALITY_ONE)
|
||||
{
|
||||
m_journal.trace << "unset transfer rate";
|
||||
mTxnAccount->makeFieldAbsent (sfTransferRate);
|
||||
}
|
||||
else if (uRate > QUALITY_ONE)
|
||||
{
|
||||
m_journal.trace << "set transfer rate";
|
||||
mTxnAccount->setFieldU32 (sfTransferRate, uRate);
|
||||
}
|
||||
}
|
||||
|
||||
if (uFlagsIn != uFlagsOut)
|
||||
mTxnAccount->setFieldU32 (sfFlags, uFlagsOut);
|
||||
|
||||
return tesSUCCESS;
|
||||
j_.trace << "Malformed transaction: Contradictory flags set.";
|
||||
return temINVALID_FLAG;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// RequireDestTag
|
||||
//
|
||||
bool bSetRequireDest = (uTxFlags & TxFlag::requireDestTag) || (uSetFlag == asfRequireDest);
|
||||
bool bClearRequireDest = (uTxFlags & tfOptionalDestTag) || (uClearFlag == asfRequireDest);
|
||||
|
||||
if (bSetRequireDest && bClearRequireDest)
|
||||
{
|
||||
j_.trace << "Malformed transaction: Contradictory flags set.";
|
||||
return temINVALID_FLAG;
|
||||
}
|
||||
|
||||
//
|
||||
// DisallowXRP
|
||||
//
|
||||
bool bSetDisallowXRP = (uTxFlags & tfDisallowXRP) || (uSetFlag == asfDisallowXRP);
|
||||
bool bClearDisallowXRP = (uTxFlags & tfAllowXRP) || (uClearFlag == asfDisallowXRP);
|
||||
|
||||
if (bSetDisallowXRP && bClearDisallowXRP)
|
||||
{
|
||||
j_.trace << "Malformed transaction: Contradictory flags set.";
|
||||
return temINVALID_FLAG;
|
||||
}
|
||||
|
||||
// TransferRate
|
||||
if (mTxn.isFieldPresent (sfTransferRate))
|
||||
{
|
||||
std::uint32_t uRate = mTxn.getFieldU32 (sfTransferRate);
|
||||
|
||||
if (uRate && (uRate < QUALITY_ONE))
|
||||
{
|
||||
j_.trace << "Malformed transaction: Bad transfer rate.";
|
||||
return temBAD_TRANSFER_RATE;
|
||||
}
|
||||
}
|
||||
|
||||
return Transactor::preCheck ();
|
||||
}
|
||||
|
||||
TER
|
||||
transact_SetAccount (
|
||||
STTx const& txn,
|
||||
ViewFlags params,
|
||||
TransactionEngine* engine)
|
||||
SetAccount::doApply ()
|
||||
{
|
||||
return SetAccount(txn, params, engine).apply ();
|
||||
std::uint32_t const uTxFlags = mTxn.getFlags ();
|
||||
|
||||
std::uint32_t const uFlagsIn = mTxnAccount->getFieldU32 (sfFlags);
|
||||
std::uint32_t uFlagsOut = uFlagsIn;
|
||||
|
||||
std::uint32_t const uSetFlag = mTxn.getFieldU32 (sfSetFlag);
|
||||
std::uint32_t const uClearFlag = mTxn.getFieldU32 (sfClearFlag);
|
||||
|
||||
// legacy AccountSet flags
|
||||
bool bSetRequireDest = (uTxFlags & TxFlag::requireDestTag) || (uSetFlag == asfRequireDest);
|
||||
bool bClearRequireDest = (uTxFlags & tfOptionalDestTag) || (uClearFlag == asfRequireDest);
|
||||
bool bSetRequireAuth = (uTxFlags & tfRequireAuth) || (uSetFlag == asfRequireAuth);
|
||||
bool bClearRequireAuth = (uTxFlags & tfOptionalAuth) || (uClearFlag == asfRequireAuth);
|
||||
bool bSetDisallowXRP = (uTxFlags & tfDisallowXRP) || (uSetFlag == asfDisallowXRP);
|
||||
bool bClearDisallowXRP = (uTxFlags & tfAllowXRP) || (uClearFlag == asfDisallowXRP);
|
||||
|
||||
//
|
||||
// RequireAuth
|
||||
//
|
||||
if (bSetRequireAuth && !(uFlagsIn & lsfRequireAuth))
|
||||
{
|
||||
if (! dirIsEmpty (view(),
|
||||
keylet::ownerDir(mTxnAccountID)))
|
||||
{
|
||||
j_.trace << "Retry: Owner directory not empty.";
|
||||
return (view().flags() & tapRETRY) ? terOWNERS : tecOWNERS;
|
||||
}
|
||||
|
||||
j_.trace << "Set RequireAuth.";
|
||||
uFlagsOut |= lsfRequireAuth;
|
||||
}
|
||||
|
||||
if (bClearRequireAuth && (uFlagsIn & lsfRequireAuth))
|
||||
{
|
||||
j_.trace << "Clear RequireAuth.";
|
||||
uFlagsOut &= ~lsfRequireAuth;
|
||||
}
|
||||
|
||||
//
|
||||
// RequireDestTag
|
||||
//
|
||||
if (bSetRequireDest && !(uFlagsIn & lsfRequireDestTag))
|
||||
{
|
||||
j_.trace << "Set lsfRequireDestTag.";
|
||||
uFlagsOut |= lsfRequireDestTag;
|
||||
}
|
||||
|
||||
if (bClearRequireDest && (uFlagsIn & lsfRequireDestTag))
|
||||
{
|
||||
j_.trace << "Clear lsfRequireDestTag.";
|
||||
uFlagsOut &= ~lsfRequireDestTag;
|
||||
}
|
||||
|
||||
//
|
||||
// DisallowXRP
|
||||
//
|
||||
if (bSetDisallowXRP && !(uFlagsIn & lsfDisallowXRP))
|
||||
{
|
||||
j_.trace << "Set lsfDisallowXRP.";
|
||||
uFlagsOut |= lsfDisallowXRP;
|
||||
}
|
||||
|
||||
if (bClearDisallowXRP && (uFlagsIn & lsfDisallowXRP))
|
||||
{
|
||||
j_.trace << "Clear lsfDisallowXRP.";
|
||||
uFlagsOut &= ~lsfDisallowXRP;
|
||||
}
|
||||
|
||||
//
|
||||
// DisableMaster
|
||||
//
|
||||
if ((uSetFlag == asfDisableMaster) && !(uFlagsIn & lsfDisableMaster))
|
||||
{
|
||||
if (!mSigMaster)
|
||||
{
|
||||
j_.trace << "Must use master key to disable master key.";
|
||||
return tecNEED_MASTER_KEY;
|
||||
}
|
||||
|
||||
if (!mTxnAccount->isFieldPresent (sfRegularKey))
|
||||
return tecNO_REGULAR_KEY;
|
||||
|
||||
j_.trace << "Set lsfDisableMaster.";
|
||||
uFlagsOut |= lsfDisableMaster;
|
||||
}
|
||||
|
||||
if ((uClearFlag == asfDisableMaster) && (uFlagsIn & lsfDisableMaster))
|
||||
{
|
||||
j_.trace << "Clear lsfDisableMaster.";
|
||||
uFlagsOut &= ~lsfDisableMaster;
|
||||
}
|
||||
|
||||
//
|
||||
// DefaultRipple
|
||||
//
|
||||
if (uSetFlag == asfDefaultRipple)
|
||||
{
|
||||
uFlagsOut |= lsfDefaultRipple;
|
||||
}
|
||||
else if (uClearFlag == asfDefaultRipple)
|
||||
{
|
||||
uFlagsOut &= ~lsfDefaultRipple;
|
||||
}
|
||||
|
||||
//
|
||||
// NoFreeze
|
||||
//
|
||||
if (uSetFlag == asfNoFreeze)
|
||||
{
|
||||
if (!mSigMaster && !(uFlagsIn & lsfDisableMaster))
|
||||
{
|
||||
j_.trace << "Can't use regular key to set NoFreeze.";
|
||||
return tecNEED_MASTER_KEY;
|
||||
}
|
||||
|
||||
j_.trace << "Set NoFreeze flag";
|
||||
uFlagsOut |= lsfNoFreeze;
|
||||
}
|
||||
|
||||
// Anyone may set global freeze
|
||||
if (uSetFlag == asfGlobalFreeze)
|
||||
{
|
||||
j_.trace << "Set GlobalFreeze flag";
|
||||
uFlagsOut |= lsfGlobalFreeze;
|
||||
}
|
||||
|
||||
// If you have set NoFreeze, you may not clear GlobalFreeze
|
||||
// This prevents those who have set NoFreeze from using
|
||||
// GlobalFreeze strategically.
|
||||
if ((uSetFlag != asfGlobalFreeze) && (uClearFlag == asfGlobalFreeze) &&
|
||||
((uFlagsOut & lsfNoFreeze) == 0))
|
||||
{
|
||||
j_.trace << "Clear GlobalFreeze flag";
|
||||
uFlagsOut &= ~lsfGlobalFreeze;
|
||||
}
|
||||
|
||||
//
|
||||
// Track transaction IDs signed by this account in its root
|
||||
//
|
||||
if ((uSetFlag == asfAccountTxnID) && !mTxnAccount->isFieldPresent (sfAccountTxnID))
|
||||
{
|
||||
j_.trace << "Set AccountTxnID";
|
||||
mTxnAccount->makeFieldPresent (sfAccountTxnID);
|
||||
}
|
||||
|
||||
if ((uClearFlag == asfAccountTxnID) && mTxnAccount->isFieldPresent (sfAccountTxnID))
|
||||
{
|
||||
j_.trace << "Clear AccountTxnID";
|
||||
mTxnAccount->makeFieldAbsent (sfAccountTxnID);
|
||||
}
|
||||
|
||||
//
|
||||
// EmailHash
|
||||
//
|
||||
if (mTxn.isFieldPresent (sfEmailHash))
|
||||
{
|
||||
uint128 const uHash = mTxn.getFieldH128 (sfEmailHash);
|
||||
|
||||
if (!uHash)
|
||||
{
|
||||
j_.trace << "unset email hash";
|
||||
mTxnAccount->makeFieldAbsent (sfEmailHash);
|
||||
}
|
||||
else
|
||||
{
|
||||
j_.trace << "set email hash";
|
||||
mTxnAccount->setFieldH128 (sfEmailHash, uHash);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// WalletLocator
|
||||
//
|
||||
if (mTxn.isFieldPresent (sfWalletLocator))
|
||||
{
|
||||
uint256 const uHash = mTxn.getFieldH256 (sfWalletLocator);
|
||||
|
||||
if (!uHash)
|
||||
{
|
||||
j_.trace << "unset wallet locator";
|
||||
mTxnAccount->makeFieldAbsent (sfWalletLocator);
|
||||
}
|
||||
else
|
||||
{
|
||||
j_.trace << "set wallet locator";
|
||||
mTxnAccount->setFieldH256 (sfWalletLocator, uHash);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// MessageKey
|
||||
//
|
||||
if (mTxn.isFieldPresent (sfMessageKey))
|
||||
{
|
||||
Blob const messageKey = mTxn.getFieldVL (sfMessageKey);
|
||||
|
||||
if (messageKey.size () > PUBLIC_BYTES_MAX)
|
||||
{
|
||||
j_.trace << "message key too long";
|
||||
return telBAD_PUBLIC_KEY;
|
||||
}
|
||||
|
||||
if (messageKey.empty ())
|
||||
{
|
||||
j_.debug << "set message key";
|
||||
mTxnAccount->makeFieldAbsent (sfMessageKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
j_.debug << "set message key";
|
||||
mTxnAccount->setFieldVL (sfMessageKey, messageKey);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Domain
|
||||
//
|
||||
if (mTxn.isFieldPresent (sfDomain))
|
||||
{
|
||||
Blob const domain = mTxn.getFieldVL (sfDomain);
|
||||
|
||||
if (domain.size () > DOMAIN_BYTES_MAX)
|
||||
{
|
||||
j_.trace << "domain too long";
|
||||
return telBAD_DOMAIN;
|
||||
}
|
||||
|
||||
if (domain.empty ())
|
||||
{
|
||||
j_.trace << "unset domain";
|
||||
mTxnAccount->makeFieldAbsent (sfDomain);
|
||||
}
|
||||
else
|
||||
{
|
||||
j_.trace << "set domain";
|
||||
mTxnAccount->setFieldVL (sfDomain, domain);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// TransferRate
|
||||
//
|
||||
if (mTxn.isFieldPresent (sfTransferRate))
|
||||
{
|
||||
std::uint32_t uRate = mTxn.getFieldU32 (sfTransferRate);
|
||||
|
||||
if (uRate == 0 || uRate == QUALITY_ONE)
|
||||
{
|
||||
j_.trace << "unset transfer rate";
|
||||
mTxnAccount->makeFieldAbsent (sfTransferRate);
|
||||
}
|
||||
else if (uRate > QUALITY_ONE)
|
||||
{
|
||||
j_.trace << "set transfer rate";
|
||||
mTxnAccount->setFieldU32 (sfTransferRate, uRate);
|
||||
}
|
||||
}
|
||||
|
||||
if (uFlagsIn != uFlagsOut)
|
||||
mTxnAccount->setFieldU32 (sfFlags, uFlagsOut);
|
||||
|
||||
return tesSUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user