Example #1
0
/** Check if an expanded path violates freeze rules */
void PathState::checkFreeze()
{
    assert (nodes_.size() >= 2);

    // A path with no intermediaries -- pure issue/redeem
    // cannot be frozen.
    if (nodes_.size() == 2)
        return;

    SLE::pointer sle;

    for (std::size_t i = 0; i < (nodes_.size() - 1); ++i)
    {
        // Check each order book for a global freeze
        if (nodes_[i].uFlags & STPathElement::typeIssuer)
        {
            sle = view().peek (keylet::account(nodes_[i].issue_.account));

            if (sle && sle->isFlag (lsfGlobalFreeze))
            {
                terStatus = terNO_LINE;
                return;
            }
        }

        // Check each account change to make sure funds can leave
        if (nodes_[i].uFlags & STPathElement::typeAccount)
        {
            Currency const& currencyID = nodes_[i].issue_.currency;
            AccountID const& inAccount = nodes_[i].account_;
            AccountID const& outAccount = nodes_[i+1].account_;

            if (inAccount != outAccount)
            {
                sle = view().peek (keylet::account(outAccount));

                if (sle && sle->isFlag (lsfGlobalFreeze))
                {
                    terStatus = terNO_LINE;
                    return;
                }

                sle = view().peek (keylet::line(inAccount,
                        outAccount, currencyID));

                if (sle && sle->isFlag (
                    (outAccount > inAccount) ? lsfHighFreeze : lsfLowFreeze))
                {
                    terStatus = terNO_LINE;
                    return;
                }
            }
        }
    }
}
Example #2
0
/** Check if an expanded path violates freeze rules */
void PathState::checkFreeze()
{
    assert(vpnNodes.size() >= 2);
    
    // A path with no intermediaries -- pure issue/redeem
    // cannot be frozen.
    if(vpnNodes.size() == 2)
        return;
       
    for(std::size_t i = 0; i < (vpnNodes.size() - 1); ++i)
    {  
        // Check each account change to make sure funds can leave
        if(vpnNodes[i].uFlags & STPathElement::typeAccount)
        {
            uint160 const& currencyID = vpnNodes[i].uCurrencyID;
            uint160 const& inAccount = vpnNodes[i].uAccountID;
       
            uint160 const& issuingAccount = vpnNodes[i+1].uAccountID;
            
            if(inAccount != issuingAccount)
            {
                SLE::pointer sle = lesEntries.entryCache(ltACCOUNT_ROOT,
                    Ledger::getAccountRootIndex(issuingAccount));
                
                if(sle && sle->isFlag(lsfRequireAuth))
                {
                    sle = lesEntries.entryCache(ltRIPPLE_STATE,
                        Ledger::getRippleStateIndex(inAccount,
                        issuingAccount, currencyID));
                
                    if(sle && !sle->isFlag(
                        (issuingAccount > inAccount) ? lsfHighAuth : lsfLowAuth))
                    {
                        terStatus = terNO_LINE;
                        return;
                    }
                    
                }
            }
        }
    }
}
Example #3
0
TER
SetSignerList::destroySignerList ()
{
    auto const accountKeylet = keylet::account (account_);
    // Destroying the signer list is only allowed if either the master key
    // is enabled or there is a regular key.
    SLE::pointer ledgerEntry = view().peek (accountKeylet);
    if ((ledgerEntry->isFlag (lsfDisableMaster)) &&
        (!ledgerEntry->isFieldPresent (sfRegularKey)))
            return tecNO_ALTERNATIVE_KEY;

    auto const ownerDirKeylet = keylet::ownerDir (account_);
    auto const signerListKeylet = keylet::signers (account_);
    return removeSignersFromLedger(
        accountKeylet, ownerDirKeylet, signerListKeylet);
}