TER Transactor::apply ()
{
    TER terResult (preCheck ());

    if (terResult != tesSUCCESS)
        return (terResult);

    // Restructure this to avoid the dependency on LedgerBase::mLock
    Ledger::ScopedLockType sl (mEngine->getLedger ()->mLock);

    mTxnAccount = mEngine->entryCache (ltACCOUNT_ROOT,
        Ledger::getAccountRootIndex (mTxnAccountID));
    calculateFee ();

    // Find source account
    // If are only forwarding, due to resource limitations, we might verifying
    // only some transactions, this would be probabilistic.

    if (!mTxnAccount)
    {
        if (mustHaveValidAccount ())
        {
            m_journal.trace <<
                "apply: delay transaction: source account does not exist " <<
                mTxn.getSourceAccount ().humanAccountID ();
            return terNO_ACCOUNT;
        }
    }
    else
    {
        mPriorBalance   = mTxnAccount->getFieldAmount (sfBalance);
        mSourceBalance  = mPriorBalance;
        mHasAuthKey     = mTxnAccount->isFieldPresent (sfRegularKey);
    }

    terResult = checkSeq ();

    if (terResult != tesSUCCESS) return (terResult);

    terResult = payFee ();

    if (terResult != tesSUCCESS) return (terResult);

    terResult = checkSig ();

    if (terResult != tesSUCCESS) return (terResult);

    terResult = precheckAgainstLedger();

    if (terResult != tesSUCCESS) return (terResult);

    if (!mEngine->mClosingLedger) {
        return tesSUCCESS;
    }

    if (mTxnAccount)
        mEngine->entryModify (mTxnAccount);

    return doApply ();
}
bool TransactionVerifier::checkSigs() const
{
   for (unsigned i = 0; i < theTx_.txins_.size(); i++)
   {
      try
      {
         if (checkSig(i))
            continue;
      }
      catch (ScriptException &e)
      {
         LOGERR << "tx verification failed with error: ";
         LOGERR << e.what();

      }
      catch (exception &e)
      {
         LOGERR << "tx verification failed with error: ";
         LOGERR << e.what();
      }
      catch (...)
      {
         LOGERR << "tx verification failed with unkown error";
      }
         
      return false;
   }

   return true;
}
bool TransactionVerifier::checkSigs_NoCatch() const
{
   for (unsigned i = 0; i < theTx_.txins_.size(); i++)
   {
      if (!checkSig(i))
         return false;
   }

   return true;
}
Beispiel #4
0
TER Transactor::apply ()
{
    TER     terResult   = tesSUCCESS;
    terResult = preCheck ();

    if (terResult != tesSUCCESS) return (terResult);

    Ledger::ScopedLockType sl (mEngine->getLedger ()->mLock, __FILE__, __LINE__);

    mTxnAccount = mEngine->entryCache (ltACCOUNT_ROOT, Ledger::getAccountRootIndex (mTxnAccountID));
    calculateFee ();

    // Find source account
    // If are only forwarding, due to resource limitations, we might verifying only some transactions, this would be probabilistic.

    if (!mTxnAccount)
    {
        if (mustHaveValidAccount ())
        {
            WriteLog (lsTRACE, Transactor) << boost::str (boost::format ("applyTransaction: Delay transaction: source account does not exist: %s") %
                                           mTxn.getSourceAccount ().humanAccountID ());

            return terNO_ACCOUNT;
        }
    }
    else
    {
        mPriorBalance   = mTxnAccount->getFieldAmount (sfBalance);
        mSourceBalance  = mPriorBalance;
        mHasAuthKey     = mTxnAccount->isFieldPresent (sfRegularKey);
    }

    terResult = checkSeq ();

    if (terResult != tesSUCCESS) return (terResult);

    terResult = payFee ();

    if (terResult != tesSUCCESS) return (terResult);

    terResult = checkSig ();

    if (terResult != tesSUCCESS) return (terResult);

    if (mTxnAccount)
        mEngine->entryModify (mTxnAccount);

    return doApply ();
}
void ClassAnalyzer::visit(MemberFct* m)
{
    checkSig(m);
    checkStmnts(m);
}