Fix transaction engine sense of ripple balances.

This commit is contained in:
Arthur Britto
2012-08-20 16:23:23 -07:00
parent a99f814c20
commit 58644fc806
3 changed files with 18 additions and 4 deletions

View File

@@ -105,7 +105,11 @@ bool STAmount::setFullValue(const std::string& sAmount, const std::string& sCurr
// Figure out the currency. // Figure out the currency.
// //
if (!currencyFromString(mCurrency, sCurrency)) if (!currencyFromString(mCurrency, sCurrency))
{
Log(lsINFO) << "Currency malformed: " << sCurrency;
return false; return false;
}
mIsNative = !mCurrency; mIsNative = !mCurrency;
@@ -116,13 +120,21 @@ bool STAmount::setFullValue(const std::string& sAmount, const std::string& sCurr
// Issuer must be "" or a valid account string. // Issuer must be "" or a valid account string.
if (!naIssuerID.setAccountID(sIssuer)) if (!naIssuerID.setAccountID(sIssuer))
{
Log(lsINFO) << "Issuer malformed: " << sIssuer;
return false; return false;
}
mIssuer = naIssuerID.getAccountID(); mIssuer = naIssuerID.getAccountID();
// Stamps not must have an issuer. // Stamps not must have an issuer.
if (mIsNative && !mIssuer.isZero()) if (mIsNative && !mIssuer.isZero())
{
Log(lsINFO) << "Issuer specified for stamps: " << sIssuer;
return false; return false;
}
uint64 uValue; uint64 uValue;
int iOffset; int iOffset;
@@ -137,6 +149,8 @@ bool STAmount::setFullValue(const std::string& sAmount, const std::string& sCurr
} }
catch (...) catch (...)
{ {
Log(lsINFO) << "Bad integer amount: " << sAmount;
return false; return false;
} }
iOffset = 0; iOffset = 0;

View File

@@ -48,7 +48,7 @@ Json::Value RPCServer::RPCError(int iError)
{ rpcDST_AMT_MALFORMED, "dstAmtMalformed", "Destination amount/currency is malformed." }, { rpcDST_AMT_MALFORMED, "dstAmtMalformed", "Destination amount/currency is malformed." },
{ rpcFAIL_GEN_DECRPYT, "failGenDecrypt", "Failed to decrypt generator." }, { rpcFAIL_GEN_DECRPYT, "failGenDecrypt", "Failed to decrypt generator." },
{ rpcGETS_ACT_MALFORMED, "getsActMalformed", "Gets account malformed." }, { rpcGETS_ACT_MALFORMED, "getsActMalformed", "Gets account malformed." },
{ rpcGETS_AMT_MALFORMED, "getsAmtMalformed", "Gets ammount malformed." }, { rpcGETS_AMT_MALFORMED, "getsAmtMalformed", "Gets amount malformed." },
{ rpcHOST_IP_MALFORMED, "hostIpMalformed", "Host IP is malformed." }, { rpcHOST_IP_MALFORMED, "hostIpMalformed", "Host IP is malformed." },
{ rpcINSUF_FUNDS, "insufFunds", "Insufficient funds." }, { rpcINSUF_FUNDS, "insufFunds", "Insufficient funds." },
{ rpcINTERNAL, "internal", "Internal error." }, { rpcINTERNAL, "internal", "Internal error." },

View File

@@ -224,8 +224,8 @@ STAmount TransactionEngine::rippleHolds(const uint160& uAccountID, const uint160
{ {
saBalance = sleRippleState->getIValueFieldAmount(sfBalance); saBalance = sleRippleState->getIValueFieldAmount(sfBalance);
if (uAccountID < uIssuerID) if (uAccountID > uIssuerID)
saBalance.negate(); // Put balance in low terms. saBalance.negate(); // Put balance in uAccountID terms.
} }
return saBalance; return saBalance;
@@ -4213,7 +4213,7 @@ Log(lsWARNING) << "doOfferCreate: saTakerGets=" << saTakerGets.getFullText();
} }
else if (!accountFunds(mTxnAccountID, saTakerGets).isPositive()) else if (!accountFunds(mTxnAccountID, saTakerGets).isPositive())
{ {
Log(lsWARNING) << "doOfferCreate: delay: offers must be funded"; Log(lsWARNING) << "doOfferCreate: delay: Offers must be at least partially funded.";
terResult = terUNFUNDED; terResult = terUNFUNDED;
} }