mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Merge branch 'master' of github.com:jedmccaleb/NewCoin into serialize
Conflicts: src/TransactionFormats.cpp Fast forward.
This commit is contained in:
@@ -1544,7 +1544,6 @@ Json::Value RPCServer::doRippleLineSet(const Json::Value& params)
|
||||
NewcoinAddress naSrcAccountID;
|
||||
NewcoinAddress naDstAccountID;
|
||||
STAmount saLimitAmount;
|
||||
bool bLimitAmount = true;
|
||||
bool bQualityIn = params.size() >= 6;
|
||||
bool bQualityOut = params.size() >= 7;
|
||||
uint32 uQualityIn = 0;
|
||||
@@ -1562,7 +1561,7 @@ Json::Value RPCServer::doRippleLineSet(const Json::Value& params)
|
||||
{
|
||||
return RPCError(rpcDST_ACT_MALFORMED);
|
||||
}
|
||||
else if (!saLimitAmount.setFullValue(params[3u].asString(), params.size() >= 5 ? params[4u].asString() : ""))
|
||||
else if (!saLimitAmount.setFullValue(params[3u].asString(), params.size() >= 5 ? params[4u].asString() : "", params[2u].asString()))
|
||||
{
|
||||
return RPCError(rpcSRC_AMT_MALFORMED);
|
||||
}
|
||||
@@ -1593,8 +1592,7 @@ Json::Value RPCServer::doRippleLineSet(const Json::Value& params)
|
||||
asSrc->getSeq(),
|
||||
theConfig.FEE_DEFAULT,
|
||||
0, // YYY No source tag
|
||||
naDstAccountID,
|
||||
bLimitAmount, saLimitAmount,
|
||||
saLimitAmount,
|
||||
bQualityIn, uQualityIn,
|
||||
bQualityOut, uQualityOut);
|
||||
|
||||
@@ -1779,17 +1777,17 @@ Json::Value RPCServer::doSend(const Json::Value& params)
|
||||
// Destination exists, ordinary send.
|
||||
|
||||
STPathSet spsPaths;
|
||||
/*
|
||||
uint160 srcCurrencyID;
|
||||
bool ret_b;
|
||||
ret_b = false;
|
||||
STAmount::currencyFromString(srcCurrencyID, sSrcCurrency);
|
||||
bool ret_b;
|
||||
ret_b = false;
|
||||
|
||||
Pathfinder pf(naSrcAccountID, naDstAccountID, srcCurrencyID, saDstAmount);
|
||||
|
||||
ret_b = pf.findPaths(5, 1, spsPaths);
|
||||
// TODO: Nope; the above can't be right
|
||||
*/
|
||||
if (!saSrcAmountMax.isNative() || !saDstAmount.isNative())
|
||||
{
|
||||
STAmount::currencyFromString(srcCurrencyID, sSrcCurrency);
|
||||
Pathfinder pf(naSrcAccountID, naDstAccountID, srcCurrencyID, saDstAmount);
|
||||
ret_b = pf.findPaths(5, 1, spsPaths);
|
||||
}
|
||||
|
||||
trans = Transaction::sharedPayment(
|
||||
naAccountPublic, naAccountPrivate,
|
||||
naSrcAccountID,
|
||||
|
||||
@@ -744,7 +744,7 @@ void RippleCalc::calcNodeRipple(
|
||||
{
|
||||
const uint160 uCurrencyID = saCur.getCurrency();
|
||||
const uint160 uCurIssuerID = saCur.getIssuer();
|
||||
const uint160 uPrvIssuerID = saPrv.getIssuer();
|
||||
// const uint160 uPrvIssuerID = saPrv.getIssuer();
|
||||
|
||||
STAmount saCurIn = STAmount::divide(STAmount::multiply(saCur, uQualityOut, uCurrencyID, uCurIssuerID), uQualityIn, uCurrencyID, uCurIssuerID);
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ std::string SerializedLedgerEntry::getFullText() const
|
||||
|
||||
std::string SerializedLedgerEntry::getText() const
|
||||
{
|
||||
return str(boost::format("{ %s, %s, %s }")
|
||||
return str(boost::format("{ %s, %s }")
|
||||
% mIndex.GetHex()
|
||||
% STObject::getText());
|
||||
}
|
||||
|
||||
@@ -251,18 +251,13 @@ Transaction::pointer Transaction::sharedCreate(
|
||||
|
||||
Transaction::pointer Transaction::setCreditSet(
|
||||
const NewcoinAddress& naPrivateKey,
|
||||
const NewcoinAddress& naDstAccountID,
|
||||
bool bLimitAmount,
|
||||
const STAmount& saLimitAmount,
|
||||
bool bQualityIn,
|
||||
uint32 uQualityIn,
|
||||
bool bQualityOut,
|
||||
uint32 uQualityOut)
|
||||
{
|
||||
mTransaction->setITFieldAccount(sfDestination, naDstAccountID);
|
||||
|
||||
if (bLimitAmount)
|
||||
mTransaction->setITFieldAmount(sfLimitAmount, saLimitAmount);
|
||||
mTransaction->setITFieldAmount(sfLimitAmount, saLimitAmount);
|
||||
|
||||
if (bQualityIn)
|
||||
mTransaction->setITFieldU32(sfQualityIn, uQualityIn);
|
||||
@@ -281,8 +276,6 @@ Transaction::pointer Transaction::sharedCreditSet(
|
||||
uint32 uSeq,
|
||||
const STAmount& saFee,
|
||||
uint32 uSourceTag,
|
||||
const NewcoinAddress& naDstAccountID,
|
||||
bool bLimitAmount,
|
||||
const STAmount& saLimitAmount,
|
||||
bool bQualityIn,
|
||||
uint32 uQualityIn,
|
||||
@@ -291,8 +284,8 @@ Transaction::pointer Transaction::sharedCreditSet(
|
||||
{
|
||||
pointer tResult = boost::make_shared<Transaction>(ttCREDIT_SET, naPublicKey, naSourceAccount, uSeq, saFee, uSourceTag);
|
||||
|
||||
return tResult->setCreditSet(naPrivateKey, naDstAccountID,
|
||||
bLimitAmount, saLimitAmount,
|
||||
return tResult->setCreditSet(naPrivateKey,
|
||||
saLimitAmount,
|
||||
bQualityIn, uQualityIn,
|
||||
bQualityOut, uQualityOut);
|
||||
}
|
||||
|
||||
@@ -74,8 +74,6 @@ private:
|
||||
|
||||
Transaction::pointer setCreditSet(
|
||||
const NewcoinAddress& naPrivateKey,
|
||||
const NewcoinAddress& naDstAccountID,
|
||||
bool bLimitAmount,
|
||||
const STAmount& saLimitAmount,
|
||||
bool bQualityIn,
|
||||
uint32 uQualityIn,
|
||||
@@ -185,8 +183,6 @@ public:
|
||||
uint32 uSeq,
|
||||
const STAmount& saFee,
|
||||
uint32 uSourceTag,
|
||||
const NewcoinAddress& naDstAccountID,
|
||||
bool bLimitAmount,
|
||||
const STAmount& saLimitAmount,
|
||||
bool bQualityIn,
|
||||
uint32 uQualityIn,
|
||||
|
||||
@@ -241,8 +241,17 @@ TER TransactionEngine::doCreditSet(const SerializedTransaction& txn)
|
||||
TER terResult = tesSUCCESS;
|
||||
Log(lsINFO) << "doCreditSet>";
|
||||
|
||||
const STAmount saLimitAmount = txn.getITFieldAmount(sfLimitAmount);
|
||||
const bool bQualityIn = txn.getITFieldPresent(sfQualityIn);
|
||||
const uint32 uQualityIn = bQualityIn ? txn.getITFieldU32(sfQualityIn) : 0;
|
||||
const bool bQualityOut = txn.getITFieldPresent(sfQualityOut);
|
||||
const uint32 uQualityOut = bQualityIn ? txn.getITFieldU32(sfQualityOut) : 0;
|
||||
const uint160 uCurrencyID = saLimitAmount.getCurrency();
|
||||
uint160 uDstAccountID = saLimitAmount.getIssuer();
|
||||
const bool bFlipped = mTxnAccountID > uDstAccountID; // true, iff current is not lowest.
|
||||
bool bDelIndex = false;
|
||||
|
||||
// Check if destination makes sense.
|
||||
uint160 uDstAccountID = txn.getITFieldAccount(sfDestination);
|
||||
|
||||
if (!uDstAccountID)
|
||||
{
|
||||
@@ -265,22 +274,8 @@ TER TransactionEngine::doCreditSet(const SerializedTransaction& txn)
|
||||
return terNO_DST;
|
||||
}
|
||||
|
||||
const bool bFlipped = mTxnAccountID > uDstAccountID; // true, iff current is not lowest.
|
||||
const bool bLimitAmount = txn.getITFieldPresent(sfLimitAmount);
|
||||
const STAmount saLimitAmount = bLimitAmount ? txn.getITFieldAmount(sfLimitAmount) : STAmount();
|
||||
const bool bQualityIn = txn.getITFieldPresent(sfQualityIn);
|
||||
const uint32 uQualityIn = bQualityIn ? txn.getITFieldU32(sfQualityIn) : 0;
|
||||
const bool bQualityOut = txn.getITFieldPresent(sfQualityOut);
|
||||
const uint32 uQualityOut = bQualityIn ? txn.getITFieldU32(sfQualityOut) : 0;
|
||||
const uint160 uCurrencyID = saLimitAmount.getCurrency();
|
||||
bool bDelIndex = false;
|
||||
|
||||
if (bLimitAmount && saLimitAmount.getIssuer() != mTxnAccountID)
|
||||
{
|
||||
Log(lsINFO) << "doCreditSet: Malformed transaction: issuer must be signer";
|
||||
|
||||
return temBAD_ISSUER;
|
||||
}
|
||||
STAmount saLimitAllow = saLimitAmount;
|
||||
saLimitAllow.setIssuer(mTxnAccountID);
|
||||
|
||||
SLE::pointer sleRippleState = entryCache(ltRIPPLE_STATE, Ledger::getRippleStateIndex(mTxnAccountID, uDstAccountID, uCurrencyID));
|
||||
if (sleRippleState)
|
||||
@@ -312,8 +307,7 @@ TER TransactionEngine::doCreditSet(const SerializedTransaction& txn)
|
||||
|
||||
if (!bDelIndex)
|
||||
{
|
||||
if (bLimitAmount)
|
||||
sleRippleState->setIFieldAmount(bFlipped ? sfHighLimit: sfLowLimit, saLimitAmount);
|
||||
sleRippleState->setIFieldAmount(bFlipped ? sfHighLimit: sfLowLimit, saLimitAllow);
|
||||
|
||||
if (!bQualityIn)
|
||||
{
|
||||
@@ -361,7 +355,7 @@ TER TransactionEngine::doCreditSet(const SerializedTransaction& txn)
|
||||
Log(lsINFO) << "doCreditSet: Creating ripple line: " << sleRippleState->getIndex().ToString();
|
||||
|
||||
sleRippleState->setIFieldAmount(sfBalance, STAmount(uCurrencyID, ACCOUNT_ONE)); // Zero balance in currency.
|
||||
sleRippleState->setIFieldAmount(bFlipped ? sfHighLimit : sfLowLimit, saLimitAmount);
|
||||
sleRippleState->setIFieldAmount(bFlipped ? sfHighLimit : sfLowLimit, saLimitAllow);
|
||||
sleRippleState->setIFieldAmount(bFlipped ? sfLowLimit : sfHighLimit, STAmount(uCurrencyID, uDstAccountID));
|
||||
|
||||
if (uQualityIn)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
#include "TransactionFormats.h"
|
||||
#include "TransactionFormats.h"
|
||||
|
||||
#define TF_BASE \
|
||||
{ sfTransactionType, SOE_REQUIRED }, \
|
||||
@@ -9,7 +8,7 @@
|
||||
{ sfSequence, SOE_REQUIRED }, \
|
||||
{ sfFee, SOE_REQUIRED }, \
|
||||
{ sfSigningPubKey, SOE_REQUIRED }, \
|
||||
{ sfSignature, SOE_OPTIONAL },
|
||||
{ sfTxnSignature, SOE_OPTIONAL },
|
||||
|
||||
TransactionFormat InnerTxnFormats[]=
|
||||
{
|
||||
@@ -26,10 +25,10 @@ TransactionFormat InnerTxnFormats[]=
|
||||
{ "Claim", ttCLAIM, { TF_BASE
|
||||
{ sfGenerator, SOE_REQUIRED },
|
||||
{ sfPublicKey, SOE_REQUIRED },
|
||||
{ sfSignature, SOE_REQUIRED },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "CreditSet", ttCREDIT_SET, { TF_BASE
|
||||
{ sfDestination, SOE_REQUIRED },
|
||||
{ sfLimitAmount, SOE_OPTIONAL },
|
||||
{ sfQualityIn, SOE_OPTIONAL },
|
||||
{ sfQualityOut, SOE_OPTIONAL },
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
// This is a light weight, untrusted interface for web clients.
|
||||
// For now we don't provide proof. Later we will.
|
||||
//
|
||||
// Might need to support this header for browsers: Access-Control-Allow-Origin: *
|
||||
// - https://developer.mozilla.org/en-US/docs/HTTP_access_control
|
||||
//
|
||||
|
||||
//
|
||||
// Strategy:
|
||||
|
||||
Reference in New Issue
Block a user