mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Merge branch 'master' of github.com:jedmccaleb/NewCoin
This commit is contained in:
@@ -1421,6 +1421,8 @@ bool PathState::lessPriority(PathState::ref lhs, PathState::ref rhs)
|
||||
|
||||
// Make sure the path delivers to uAccountID: uCurrencyID from uIssuerID.
|
||||
//
|
||||
// If the unadded next node as specified by arguments would not work as is, then add the necessary nodes so it would work.
|
||||
//
|
||||
// Rules:
|
||||
// - Currencies must be converted via an offer.
|
||||
// - A node names it's output.
|
||||
@@ -1449,13 +1451,14 @@ TER PathState::pushImply(
|
||||
ACCOUNT_ONE, // Placeholder for offers.
|
||||
uCurrencyID, // The offer's output is what is now wanted.
|
||||
uIssuerID);
|
||||
|
||||
}
|
||||
|
||||
const PaymentNode& pnBck = vpnNodes.back();
|
||||
|
||||
// For ripple, non-stamps, ensure the issuer is on at least one side of the transaction.
|
||||
if (tesSUCCESS == terResult
|
||||
&& !!uCurrencyID // Not stamps.
|
||||
&& (pnPrv.uAccountID != uIssuerID // Previous is not issuing own IOUs.
|
||||
&& (pnBck.uAccountID != uIssuerID // Previous is not issuing own IOUs.
|
||||
&& uAccountID != uIssuerID)) // Current is not receiving own IOUs.
|
||||
{
|
||||
// Need to ripple through uIssuerID's account.
|
||||
@@ -1514,13 +1517,19 @@ TER PathState::pushNode(
|
||||
pnCur.saRevRedeem = STAmount(uCurrencyID, uAccountID);
|
||||
pnCur.saRevIssue = STAmount(uCurrencyID, uAccountID);
|
||||
|
||||
if (!bFirst)
|
||||
if (bFirst)
|
||||
{
|
||||
// The first node is always correct as is.
|
||||
|
||||
nothing();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add required intermediate nodes to deliver to current account.
|
||||
terResult = pushImply(
|
||||
pnCur.uAccountID, // Current account.
|
||||
pnCur.uCurrencyID, // Wanted currency.
|
||||
!!pnCur.uCurrencyID ? uAccountID : ACCOUNT_XNS); // Account as issuer.
|
||||
!!pnCur.uCurrencyID ? uAccountID : ACCOUNT_XNS); // Account as wanted issuer.
|
||||
|
||||
// Note: pnPrv may no longer be the immediately previous node.
|
||||
}
|
||||
@@ -1532,7 +1541,7 @@ TER PathState::pushNode(
|
||||
|
||||
if (bBckAccount)
|
||||
{
|
||||
SLE::pointer sleRippleState = mLedger->getSLE(Ledger::getRippleStateIndex(pnBck.uAccountID, pnCur.uAccountID, pnPrv.uCurrencyID));
|
||||
SLE::pointer sleRippleState = lesEntries.entryCache(ltRIPPLE_STATE, Ledger::getRippleStateIndex(pnBck.uAccountID, pnCur.uAccountID, pnPrv.uCurrencyID));
|
||||
|
||||
if (!sleRippleState)
|
||||
{
|
||||
@@ -1541,7 +1550,7 @@ TER PathState::pushNode(
|
||||
<< " and "
|
||||
<< RippleAddress::createHumanAccountID(pnCur.uAccountID)
|
||||
<< " for "
|
||||
<< STAmount::createHumanCurrency(pnPrv.uCurrencyID)
|
||||
<< STAmount::createHumanCurrency(pnCur.uCurrencyID)
|
||||
<< "." ;
|
||||
|
||||
cLog(lsINFO) << getJson();
|
||||
@@ -1555,12 +1564,12 @@ TER PathState::pushNode(
|
||||
<< " and "
|
||||
<< RippleAddress::createHumanAccountID(pnCur.uAccountID)
|
||||
<< " for "
|
||||
<< STAmount::createHumanCurrency(pnPrv.uCurrencyID)
|
||||
<< STAmount::createHumanCurrency(pnCur.uCurrencyID)
|
||||
<< "." ;
|
||||
|
||||
STAmount saOwed = lesEntries.rippleOwed(pnCur.uAccountID, pnBck.uAccountID, uCurrencyID);
|
||||
STAmount saOwed = lesEntries.rippleOwed(pnCur.uAccountID, pnBck.uAccountID, pnCur.uCurrencyID);
|
||||
|
||||
if (!saOwed.isPositive() && *saOwed.negate() >= lesEntries.rippleLimit(pnCur.uAccountID, pnBck.uAccountID, uCurrencyID))
|
||||
if (!saOwed.isPositive() && *saOwed.negate() >= lesEntries.rippleLimit(pnCur.uAccountID, pnBck.uAccountID, pnCur.uCurrencyID))
|
||||
{
|
||||
terResult = tepPATH_DRY;
|
||||
}
|
||||
|
||||
@@ -1112,23 +1112,24 @@ std::auto_ptr<STObject> STObject::parseJson(const Json::Value& object, SField::r
|
||||
data.push_back(new STPathSet(field));
|
||||
STPathSet* tail = dynamic_cast<STPathSet*>(&data.back());
|
||||
assert(tail);
|
||||
for (Json::UInt i = 0; !object.isValidIndex(i); ++i)
|
||||
for (Json::UInt i = 0; value.isValidIndex(i); ++i)
|
||||
{
|
||||
STPath p;
|
||||
if (!object[i].isArray())
|
||||
if (!value[i].isArray())
|
||||
throw std::runtime_error("Path must be array");
|
||||
for (Json::UInt j = 0; !object[i].isValidIndex(j); ++j)
|
||||
for (Json::UInt j = 0; value[i].isValidIndex(j); ++j)
|
||||
{ // each element in this path has some combination of account, currency, or issuer
|
||||
|
||||
Json::Value pathEl = object[i][j];
|
||||
Json::Value pathEl = value[i][j];
|
||||
if (!pathEl.isObject())
|
||||
throw std::runtime_error("Path elements must be objects");
|
||||
const Json::Value& account = pathEl["account"];
|
||||
const Json::Value& currency = pathEl["currency"];
|
||||
const Json::Value& issuer = pathEl["issuer"];
|
||||
|
||||
const Json::Value& account = pathEl["account"];
|
||||
const Json::Value& currency = pathEl["currency"];
|
||||
const Json::Value& issuer = pathEl["issuer"];
|
||||
bool hasCurrency = false;
|
||||
uint160 uAccount, uCurrency, uIssuer;
|
||||
bool hasCurrency;
|
||||
|
||||
if (!account.isNull())
|
||||
{ // human account id
|
||||
if (!account.isString())
|
||||
@@ -1138,7 +1139,7 @@ std::auto_ptr<STObject> STObject::parseJson(const Json::Value& object, SField::r
|
||||
uAccount.SetHex(strValue);
|
||||
{
|
||||
RippleAddress a;
|
||||
if (!a.setAccountPublic(strValue))
|
||||
if (!a.setAccountID(strValue))
|
||||
throw std::runtime_error("Account in path element invalid");
|
||||
uAccount = a.getAccountID();
|
||||
}
|
||||
@@ -1162,7 +1163,7 @@ std::auto_ptr<STObject> STObject::parseJson(const Json::Value& object, SField::r
|
||||
else
|
||||
{
|
||||
RippleAddress a;
|
||||
if (!a.setAccountPublic(issuer.asString()))
|
||||
if (!a.setAccountID(issuer.asString()))
|
||||
throw std::runtime_error("path element issuer invalid");
|
||||
uIssuer = a.getAccountID();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user