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 into continuousClose
Conflicts: src/Ledger.h src/LedgerNode.cpp src/Version.h
This commit is contained in:
@@ -256,10 +256,11 @@ STAmount::STAmount(const char* name, int64 value) : SerializedType(name), mOffse
|
||||
|
||||
void STAmount::setValue(const STAmount &a)
|
||||
{
|
||||
mCurrency = a.mCurrency;
|
||||
mValue = a.mValue;
|
||||
mOffset = a.mOffset;
|
||||
mIsNative = a.mIsNative;
|
||||
mCurrency = a.mCurrency;
|
||||
mIssuer = a.mIssuer;
|
||||
mValue = a.mValue;
|
||||
mOffset = a.mOffset;
|
||||
mIsNative = a.mIsNative;
|
||||
mIsNegative = a.mIsNegative;
|
||||
}
|
||||
|
||||
@@ -455,11 +456,13 @@ STAmount STAmount::operator-(void) const
|
||||
|
||||
STAmount& STAmount::operator=(const STAmount& a)
|
||||
{
|
||||
mValue = a.mValue;
|
||||
mOffset = a.mOffset;
|
||||
mCurrency = a.mCurrency;
|
||||
mIsNative = a.mIsNative;
|
||||
mValue = a.mValue;
|
||||
mOffset = a.mOffset;
|
||||
mIssuer = a.mIssuer;
|
||||
mCurrency = a.mCurrency;
|
||||
mIsNative = a.mIsNative;
|
||||
mIsNegative = a.mIsNegative;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -469,6 +472,7 @@ STAmount& STAmount::operator=(uint64 v)
|
||||
mValue = v;
|
||||
mIsNegative = false;
|
||||
if (!mIsNative) canonicalize();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -477,6 +481,7 @@ STAmount& STAmount::operator+=(uint64 v)
|
||||
if (mIsNative)
|
||||
setSNValue(getSNValue() + static_cast<int64>(v));
|
||||
else *this += STAmount(mCurrency, v);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -485,6 +490,7 @@ STAmount& STAmount::operator-=(uint64 v)
|
||||
if (mIsNative)
|
||||
setSNValue(getSNValue() - static_cast<int64>(v));
|
||||
else *this -= STAmount(mCurrency, v);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -697,15 +703,24 @@ STAmount STAmount::multiply(const STAmount& v1, const STAmount& v2, const uint16
|
||||
else return STAmount(currencyOut, v.getulong(), offset1 + offset2 + 14);
|
||||
}
|
||||
|
||||
// Convert an offer into an index amount so they sort by rate.
|
||||
// A taker will take the best, lowest, rate first.
|
||||
// (e.g. a taker will prefer pay 1 get 3 over pay 1 get 2.
|
||||
// --> offerOut: takerGets: How much the offerer is selling to the taker.
|
||||
// --> offerIn: takerPays: How much the offerer is receiving from the taker.
|
||||
// <-- uRate: normalize(offerIn/offerOut)
|
||||
// A lower rate is better for the person taking the order.
|
||||
// The taker gets more for less with a lower rate.
|
||||
uint64 STAmount::getRate(const STAmount& offerOut, const STAmount& offerIn)
|
||||
{ // Convert an offer into an index amount so they sort (lower is better)
|
||||
// offerOut = how much comes out of the offer, from the offeror to the taker
|
||||
// offerIn = how much goes into the offer, from the taker to the offeror
|
||||
{
|
||||
if (offerOut.isZero()) throw std::runtime_error("Worthless offer");
|
||||
|
||||
STAmount r = divide(offerIn, offerOut, uint160(1));
|
||||
|
||||
assert((r.getExponent() >= -100) && (r.getExponent() <= 155));
|
||||
|
||||
uint64 ret = r.getExponent() + 100;
|
||||
|
||||
return (ret << (64 - 8)) | r.getMantissa();
|
||||
}
|
||||
|
||||
@@ -746,11 +761,19 @@ STAmount STAmount::getClaimed(STAmount& offerOut, STAmount& offerIn, STAmount& p
|
||||
return ret;
|
||||
}
|
||||
|
||||
STAmount STAmount::getNeeded(const STAmount& offerOut, const STAmount& offerIn, const STAmount& needed)
|
||||
STAmount STAmount::getPay(const STAmount& offerOut, const STAmount& offerIn, const STAmount& needed)
|
||||
{ // Someone wants to get (needed) out of the offer, how much should they pay in?
|
||||
if (offerOut.isZero()) return STAmount(offerIn.getCurrency());
|
||||
if (needed >= offerOut) return needed;
|
||||
if (offerOut.isZero())
|
||||
return STAmount(offerIn.getCurrency());
|
||||
|
||||
if (needed >= offerOut)
|
||||
{
|
||||
// They need more than offered, pay full amount.
|
||||
return needed;
|
||||
}
|
||||
|
||||
STAmount ret = divide(multiply(needed, offerIn, uint160(1)), offerOut, offerIn.getCurrency());
|
||||
|
||||
return (ret > offerIn) ? offerIn : ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#define SECTION_FEE_ACCOUNT_CREATE "fee_account_create"
|
||||
#define SECTION_FEE_DEFAULT "fee_default"
|
||||
#define SECTION_FEE_NICKNAME_CREATE "fee_nickname_create"
|
||||
#define SECTION_FEE_OFFER "fee_offer"
|
||||
#define SECTION_IPS "ips"
|
||||
#define SECTION_NETWORK_QUORUM "network_quorum"
|
||||
#define SECTION_PEER_CONNECT_LOW_WATER "peer_connect_low_water"
|
||||
@@ -31,9 +32,10 @@
|
||||
#define SECTION_VALIDATORS_SITE "validators_site"
|
||||
|
||||
// Fees are in XNB.
|
||||
#define DEFAULT_FEE_DEFAULT 100
|
||||
#define DEFAULT_FEE_ACCOUNT_CREATE 1000
|
||||
#define DEFAULT_FEE_NICKNAME_CREATE 1000
|
||||
#define DEFAULT_FEE_DEFAULT 100
|
||||
#define DEFAULT_FEE_OFFER DEFAULT_FEE_DEFAULT
|
||||
|
||||
Config theConfig;
|
||||
|
||||
@@ -140,6 +142,7 @@ void Config::setup(const std::string& strConf)
|
||||
|
||||
FEE_ACCOUNT_CREATE = DEFAULT_FEE_ACCOUNT_CREATE;
|
||||
FEE_NICKNAME_CREATE = DEFAULT_FEE_NICKNAME_CREATE;
|
||||
FEE_OFFER = DEFAULT_FEE_OFFER;
|
||||
FEE_DEFAULT = DEFAULT_FEE_DEFAULT;
|
||||
|
||||
ACCOUNT_PROBE_MAX = 10;
|
||||
@@ -240,6 +243,9 @@ void Config::load()
|
||||
if (sectionSingleB(secConfig, SECTION_FEE_NICKNAME_CREATE, strTemp))
|
||||
FEE_NICKNAME_CREATE = boost::lexical_cast<int>(strTemp);
|
||||
|
||||
if (sectionSingleB(secConfig, SECTION_FEE_OFFER, strTemp))
|
||||
FEE_OFFER = boost::lexical_cast<int>(strTemp);
|
||||
|
||||
if (sectionSingleB(secConfig, SECTION_FEE_DEFAULT, strTemp))
|
||||
FEE_DEFAULT = boost::lexical_cast<int>(strTemp);
|
||||
|
||||
|
||||
@@ -94,6 +94,7 @@ public:
|
||||
uint64 FEE_DEFAULT; // Default fee.
|
||||
uint64 FEE_ACCOUNT_CREATE; // Fee to create an account.
|
||||
uint64 FEE_NICKNAME_CREATE; // Fee to create a nickname.
|
||||
uint64 FEE_OFFER; // Rate per day.
|
||||
|
||||
// Client behavior
|
||||
int ACCOUNT_PROBE_MAX; // How far to scan for accounts.
|
||||
|
||||
46
src/Ledger.h
46
src/Ledger.h
@@ -65,7 +65,7 @@ private:
|
||||
uint256 mHash, mParentHash, mTransHash, mAccountHash;
|
||||
uint64 mTotCoins;
|
||||
uint64 mCloseTime; // when this ledger should close / did close
|
||||
uint64 mPrevClose; // when the previous ledger closed
|
||||
uint64 mParentCloseTime;
|
||||
uint32 mLedgerSeq;
|
||||
bool mClosed, mValidHash, mAccepted, mImmutable;
|
||||
|
||||
@@ -118,6 +118,7 @@ public:
|
||||
uint64 getTotalCoins() const { return mTotCoins; }
|
||||
void destroyCoins(uint64 fee) { mTotCoins -= fee; }
|
||||
uint64 getCloseTimeNC() const { return mCloseTime; }
|
||||
uint64 getParentCloseTimeNC() const { return mParentCloseTime; }
|
||||
uint32 getLedgerSeq() const { return mLedgerSeq; }
|
||||
|
||||
// close time functions
|
||||
@@ -189,36 +190,59 @@ public:
|
||||
|
||||
static uint256 getNicknameIndex(const uint256& uNickname);
|
||||
|
||||
//
|
||||
// Order book functions
|
||||
//
|
||||
|
||||
// Order book dirs have a base so we can use next to step through them in quality order.
|
||||
static uint256 getBookBase(const uint160& uCurrencyIn, const uint160& uAccountIn,
|
||||
const uint160& uCurrencyOut, const uint160& uAccountOut);
|
||||
|
||||
//
|
||||
// Offer functions
|
||||
//
|
||||
|
||||
static uint160 getOfferBase(const uint160& currencyIn, const uint160& accountIn,
|
||||
const uint160& currencyOut, const uint160& accountOut);
|
||||
SLE::pointer getOffer(LedgerStateParms& parms, const uint256& uIndex);
|
||||
SLE::pointer getOffer(LedgerStateParms& parms, const uint160& uAccountID, uint32 uSequence)
|
||||
{ return getOffer(parms, getOfferIndex(uAccountID, uSequence)); }
|
||||
|
||||
static uint256 getOfferIndex(const uint160& offerBase, uint64 rate, int skip = 0);
|
||||
// The index of an offer.
|
||||
static uint256 getOfferIndex(const uint160& uAccountID, uint32 uSequence);
|
||||
|
||||
static int getOfferSkip(const uint256& offerId);
|
||||
//
|
||||
// Owner functions
|
||||
//
|
||||
|
||||
// All items controlled by an account are here: offers
|
||||
static uint256 getOwnerDirIndex(const uint160& uAccountID);
|
||||
|
||||
//
|
||||
// Directory functions
|
||||
//
|
||||
// Directories are doubly linked lists of nodes.
|
||||
|
||||
static uint256 getDirIndex(const uint256& uBase, const uint64 uNodeDir=0);
|
||||
// Given a directory root and and index compute the index of a node.
|
||||
static uint256 getDirNodeIndex(const uint256& uDirRoot, const uint64 uNodeIndex=0);
|
||||
|
||||
SLE::pointer getDirRoot(LedgerStateParms& parms, const uint256& uRootIndex);
|
||||
// Return a node: root or normal
|
||||
SLE::pointer getDirNode(LedgerStateParms& parms, const uint256& uNodeIndex);
|
||||
|
||||
//
|
||||
// Ripple functions
|
||||
// Quality
|
||||
//
|
||||
|
||||
static uint256 getQualityIndex(const uint256& uBase, const uint64 uNodeDir=0);
|
||||
static uint256 getQualityNext(const uint256& uBase);
|
||||
|
||||
//
|
||||
// Ripple functions : credit lines
|
||||
//
|
||||
|
||||
// Index of node which is the ripple state between to accounts for a currency.
|
||||
static uint256 getRippleStateIndex(const NewcoinAddress& naA, const NewcoinAddress& naB, const uint160& uCurrency);
|
||||
static uint256 getRippleStateIndex(const uint160& uiA, const uint160& uiB, const uint160& uCurrency)
|
||||
{ return getRippleStateIndex(NewcoinAddress::createAccountID(uiA), NewcoinAddress::createAccountID(uiB), uCurrency); }
|
||||
|
||||
static uint256 getRippleStateIndex(const NewcoinAddress& naA, const NewcoinAddress& naB)
|
||||
{ return getRippleStateIndex(naA, naB, uint160()); }
|
||||
// Directory of lines indexed by an account (not all lines are indexed)
|
||||
static uint256 getRippleDirIndex(const uint160& uAccountID);
|
||||
|
||||
RippleState::pointer getRippleState(const uint256& uNode);
|
||||
|
||||
@@ -16,20 +16,16 @@ LedgerEntryFormat LedgerFormats[]=
|
||||
{ S_FIELD(EmailHash), STI_HASH128, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(WalletLocator), STI_HASH256, SOE_IFFLAG, 4 },
|
||||
{ S_FIELD(MessageKey), STI_VL, SOE_IFFLAG, 8 },
|
||||
{ S_FIELD(TransitRate), STI_UINT32, SOE_IFFLAG, 16 },
|
||||
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x01000000 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "DirectoryRoot", ltDIR_ROOT, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(FirstNode), STI_UINT64, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(LastNode), STI_UINT64, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(TransferRate), STI_UINT32, SOE_IFFLAG, 16 },
|
||||
{ S_FIELD(Domain), STI_VL, SOE_IFFLAG, 32 },
|
||||
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x01000000 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "DirectoryNode", ltDIR_NODE, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Indexes), STI_VECTOR256, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(IndexNext), STI_UINT64, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(IndexPrevious), STI_UINT64, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x01000000 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
@@ -46,6 +42,18 @@ LedgerEntryFormat LedgerFormats[]=
|
||||
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x01000000 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "Offer", ltOFFER, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Account), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Sequence), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(AmountIn), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(AmountOut), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Expiration), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(OwnerNode), STI_UINT64, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(BookNode), STI_UINT64, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x01000000 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "RippleState", ltRIPPLE_STATE, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Balance), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
@@ -53,7 +61,8 @@ LedgerEntryFormat LedgerFormats[]=
|
||||
{ S_FIELD(LowLimit), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(HighID), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(HighLimit), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(AcceptRate), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(QualityIn), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(QualityOut), STI_UINT32, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x01000000 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
|
||||
@@ -6,38 +6,42 @@
|
||||
// Used as the type of a transaction or the type of a ledger entry.
|
||||
enum LedgerEntryType
|
||||
{
|
||||
ltINVALID = -1,
|
||||
ltACCOUNT_ROOT,
|
||||
ltDIR_ROOT,
|
||||
ltDIR_NODE,
|
||||
ltGENERATOR_MAP,
|
||||
ltRIPPLE_STATE,
|
||||
ltNICKNAME
|
||||
ltINVALID = -1,
|
||||
ltACCOUNT_ROOT = 'a',
|
||||
ltDIR_NODE = 'd',
|
||||
ltGENERATOR_MAP = 'g',
|
||||
ltRIPPLE_STATE = 'r',
|
||||
ltNICKNAME = 'n',
|
||||
ltOFFER = 'o',
|
||||
};
|
||||
|
||||
// Used as a prefix for computing ledger indexes (keys).
|
||||
enum LedgerNameSpace
|
||||
{
|
||||
spaceAccount = 0,
|
||||
spaceGenerator = 1,
|
||||
spaceNickname = 2,
|
||||
spaceRipple = 3,
|
||||
spaceRippleDir = 4,
|
||||
spaceOffer = 5,
|
||||
spaceOfferDir = 6,
|
||||
spaceBond = 7,
|
||||
spaceInvoice = 8,
|
||||
spaceMultiSig = 9,
|
||||
spaceAccount = 'a',
|
||||
spaceDirNode = 'd',
|
||||
spaceGenerator = 'g',
|
||||
spaceNickname = 'n',
|
||||
spaceRipple = 'r',
|
||||
spaceRippleDir = 'R',
|
||||
spaceOffer = 'o', // Entry for an offer.
|
||||
spaceOwnerDir = 'O', // Directory of things owned by an account.
|
||||
spaceBookDir = 'B', // Directory of order books.
|
||||
spaceBond = 'b',
|
||||
spaceInvoice = 'i',
|
||||
};
|
||||
|
||||
enum LedgerSpecificFlags
|
||||
{
|
||||
// ltACCOUNT_ROOT
|
||||
lsfPasswordSpent = 0x00010000, // True if password set fee is spent.
|
||||
|
||||
// ltOFFER
|
||||
lsfPassive = 0x00010000,
|
||||
|
||||
// ltRIPPLE_STATE
|
||||
lsfLowIndexed = 0x00010000,
|
||||
lsfHighIndexed = 0x00020000,
|
||||
|
||||
// ltACCOUNT_ROOT
|
||||
lsfPasswordSpent = 0x00010000, // True if password set fee is spent.
|
||||
};
|
||||
|
||||
struct LedgerEntryFormat
|
||||
|
||||
@@ -1,12 +1,87 @@
|
||||
|
||||
#include "Ledger.h"
|
||||
|
||||
// For an entry put in the 64 bit index or quality.
|
||||
uint256 Ledger::getQualityIndex(const uint256& uBase, const uint64 uNodeDir)
|
||||
{
|
||||
// Indexes are stored in big endian format: they print as hex as stored.
|
||||
// Most significant bytes are first. Least significant bytes repesent adjcent entries.
|
||||
// We place uNodeDir in the 8 right most bytes to be adjcent.
|
||||
// Want uNodeDir in big endian format so ++ goes to the next entry for indexes.
|
||||
uint256 uNode(uBase);
|
||||
|
||||
((uint64*) uNode.end())[-1] = htobe64(uNodeDir);
|
||||
|
||||
return uNode;
|
||||
}
|
||||
|
||||
uint256 Ledger::getQualityNext(const uint256& uBase)
|
||||
{
|
||||
static uint256 uNext("10000000000000000");
|
||||
|
||||
uint256 uResult = uBase;
|
||||
|
||||
uResult += uNext;
|
||||
|
||||
return uResult;
|
||||
}
|
||||
|
||||
uint256 Ledger::getAccountRootIndex(const uint160& uAccountID)
|
||||
{
|
||||
Serializer s;
|
||||
Serializer s(22);
|
||||
|
||||
s.add16(spaceAccount);
|
||||
s.add160(uAccountID);
|
||||
s.add16(spaceAccount); // 2
|
||||
s.add160(uAccountID); // 20
|
||||
|
||||
return s.getSHA512Half();
|
||||
}
|
||||
|
||||
uint256 Ledger::getBookBase(const uint160& uCurrencyIn, const uint160& uAccountIn,
|
||||
const uint160& uCurrencyOut, const uint160& uAccountOut)
|
||||
{
|
||||
bool bInNative = uCurrencyIn.isZero();
|
||||
bool bOutNative = uCurrencyOut.isZero();
|
||||
|
||||
assert(!bInNative || !bOutNative); // Stamps to stamps not allowed.
|
||||
assert(bInNative == !uAccountIn.isZero()); // Make sure issuer is specified as needed.
|
||||
assert(bOutNative == !uAccountOut.isZero()); // Make sure issuer is specified as needed.
|
||||
assert(uCurrencyIn != uCurrencyOut || uAccountIn != uAccountOut); // Currencies or accounts must differ.
|
||||
|
||||
Serializer s(82);
|
||||
|
||||
s.add16(spaceBookDir); // 2
|
||||
s.add160(uCurrencyIn); // 20
|
||||
s.add160(uCurrencyOut); // 20
|
||||
s.add160(uAccountIn); // 20
|
||||
s.add160(uAccountOut); // 20
|
||||
|
||||
return getQualityIndex(s.getSHA512Half()); // Return with quality 0.
|
||||
}
|
||||
|
||||
uint256 Ledger::getDirNodeIndex(const uint256& uDirRoot, const uint64 uNodeIndex)
|
||||
{
|
||||
if (uNodeIndex)
|
||||
{
|
||||
Serializer s(42);
|
||||
|
||||
s.add16(spaceDirNode); // 2
|
||||
s.add256(uDirRoot); // 32
|
||||
s.add64(uNodeIndex); // 8
|
||||
|
||||
return s.getSHA512Half();
|
||||
}
|
||||
else
|
||||
{
|
||||
return uDirRoot;
|
||||
}
|
||||
}
|
||||
|
||||
uint256 Ledger::getGeneratorIndex(const uint160& uGeneratorID)
|
||||
{
|
||||
Serializer s(22);
|
||||
|
||||
s.add16(spaceGenerator); // 2
|
||||
s.add160(uGeneratorID); // 20
|
||||
|
||||
return s.getSHA512Half();
|
||||
}
|
||||
@@ -16,20 +91,41 @@ uint256 Ledger::getAccountRootIndex(const uint160& uAccountID)
|
||||
// <-- SHA512/2: for consistency and speed in generating indexes.
|
||||
uint256 Ledger::getNicknameIndex(const uint256& uNickname)
|
||||
{
|
||||
Serializer s;
|
||||
Serializer s(34);
|
||||
|
||||
s.add16(spaceNickname);
|
||||
s.add256(uNickname);
|
||||
s.add16(spaceNickname); // 2
|
||||
s.add256(uNickname); // 32
|
||||
|
||||
return s.getSHA512Half();
|
||||
}
|
||||
|
||||
uint256 Ledger::getGeneratorIndex(const uint160& uGeneratorID)
|
||||
uint256 Ledger::getOfferIndex(const uint160& uAccountID, uint32 uSequence)
|
||||
{
|
||||
Serializer s;
|
||||
Serializer s(26);
|
||||
|
||||
s.add16(spaceGenerator);
|
||||
s.add160(uGeneratorID);
|
||||
s.add16(spaceOffer); // 2
|
||||
s.add160(uAccountID); // 20
|
||||
s.add32(uSequence); // 4
|
||||
|
||||
return s.getSHA512Half();
|
||||
}
|
||||
|
||||
uint256 Ledger::getOwnerDirIndex(const uint160& uAccountID)
|
||||
{
|
||||
Serializer s(22);
|
||||
|
||||
s.add16(spaceOwnerDir); // 2
|
||||
s.add160(uAccountID); // 20
|
||||
|
||||
return s.getSHA512Half();
|
||||
}
|
||||
|
||||
uint256 Ledger::getRippleDirIndex(const uint160& uAccountID)
|
||||
{
|
||||
Serializer s(22);
|
||||
|
||||
s.add16(spaceRippleDir); // 2
|
||||
s.add160(uAccountID); // 20
|
||||
|
||||
return s.getSHA512Half();
|
||||
}
|
||||
@@ -39,75 +135,14 @@ uint256 Ledger::getRippleStateIndex(const NewcoinAddress& naA, const NewcoinAddr
|
||||
uint160 uAID = naA.getAccountID();
|
||||
uint160 uBID = naB.getAccountID();
|
||||
bool bAltB = uAID < uBID;
|
||||
Serializer s;
|
||||
Serializer s(62);
|
||||
|
||||
s.add16(spaceRipple);
|
||||
s.add160(bAltB ? uAID : uBID);
|
||||
s.add160(bAltB ? uBID : uAID);
|
||||
s.add160(uCurrency);
|
||||
s.add16(spaceRipple); // 2
|
||||
s.add160(bAltB ? uAID : uBID); // 20
|
||||
s.add160(bAltB ? uBID : uAID); // 20
|
||||
s.add160(uCurrency); // 20
|
||||
|
||||
return s.getSHA512Half();
|
||||
}
|
||||
|
||||
uint256 Ledger::getRippleDirIndex(const uint160& uAccountID)
|
||||
{
|
||||
Serializer s;
|
||||
|
||||
s.add16(spaceRippleDir);
|
||||
s.add160(uAccountID);
|
||||
|
||||
return s.getSHA512Half();
|
||||
}
|
||||
|
||||
uint160 Ledger::getOfferBase(const uint160& currencyIn, const uint160& accountIn,
|
||||
const uint160& currencyOut, const uint160& accountOut)
|
||||
{
|
||||
bool inNative = currencyIn.isZero();
|
||||
bool outNative = currencyOut.isZero();
|
||||
|
||||
if (inNative && outNative)
|
||||
throw std::runtime_error("native to native offer");
|
||||
|
||||
Serializer s(80);
|
||||
|
||||
if (inNative)
|
||||
{
|
||||
if (!currencyIn) throw std::runtime_error("native currencies are untied");
|
||||
s.add32(0); // prevent collisions by ensuring different lengths
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!!currencyIn) throw std::runtime_error("national currencies must be tied");
|
||||
s.add160(currencyIn);
|
||||
s.add160(accountIn);
|
||||
}
|
||||
|
||||
if (outNative)
|
||||
{
|
||||
if (!currencyOut) throw std::runtime_error("native currencies are untied");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!!currencyOut) throw std::runtime_error("national currencies must be tied");
|
||||
s.add160(currencyOut);
|
||||
s.add160(accountOut);
|
||||
}
|
||||
|
||||
return s.getRIPEMD160();
|
||||
}
|
||||
|
||||
uint256 Ledger::getOfferIndex(const uint160& offerBase, uint64 rate, int skip)
|
||||
{ // the node for an offer index
|
||||
Serializer s;
|
||||
s.add160(offerBase);
|
||||
s.add64(rate);
|
||||
s.add32(skip);
|
||||
return s.get256(0);
|
||||
}
|
||||
|
||||
int Ledger::getOfferSkip(const uint256& offerId)
|
||||
{ // how far ahead we skip if an index node is full
|
||||
return *offerId.begin();
|
||||
}
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "utils.h"
|
||||
#include "Log.h"
|
||||
|
||||
// XXX Use shared locks where possible?
|
||||
|
||||
LedgerStateParms Ledger::writeBack(LedgerStateParms parms, SLE::pointer entry)
|
||||
{
|
||||
ScopedLock l(mAccountStateMap->Lock());
|
||||
@@ -98,7 +100,7 @@ SLE::pointer Ledger::getASNode(LedgerStateParms& parms, const uint256& nodeID,
|
||||
SLE::pointer sle =
|
||||
boost::make_shared<SLE>(account->peekSerializer(), nodeID);
|
||||
|
||||
if(sle->getType() != let)
|
||||
if (sle->getType() != let)
|
||||
{ // maybe it's a currency or something
|
||||
parms = parms | lepWRONGTYPE;
|
||||
return SLE::pointer();
|
||||
@@ -122,6 +124,17 @@ SLE::pointer Ledger::getAccountRoot(LedgerStateParms& parms, const NewcoinAddres
|
||||
return getAccountRoot(parms, naAccountID.getAccountID());
|
||||
}
|
||||
|
||||
//
|
||||
// Directory
|
||||
//
|
||||
|
||||
SLE::pointer Ledger::getDirNode(LedgerStateParms& parms, const uint256& uNodeIndex)
|
||||
{
|
||||
ScopedLock l(mAccountStateMap->Lock());
|
||||
|
||||
return getASNode(parms, uNodeIndex, ltDIR_NODE);
|
||||
}
|
||||
|
||||
//
|
||||
// Generator Map
|
||||
//
|
||||
@@ -144,6 +157,18 @@ SLE::pointer Ledger::getNickname(LedgerStateParms& parms, const uint256& uNickna
|
||||
return getASNode(parms, uNickname, ltNICKNAME);
|
||||
}
|
||||
|
||||
//
|
||||
// Offer
|
||||
//
|
||||
|
||||
|
||||
SLE::pointer Ledger::getOffer(LedgerStateParms& parms, const uint256& uIndex)
|
||||
{
|
||||
ScopedLock l(mAccountStateMap->Lock());
|
||||
|
||||
return getASNode(parms, uIndex, ltOFFER);
|
||||
}
|
||||
|
||||
//
|
||||
// Ripple State
|
||||
//
|
||||
@@ -155,36 +180,4 @@ SLE::pointer Ledger::getRippleState(LedgerStateParms& parms, const uint256& uNod
|
||||
return getASNode(parms, uNode, ltRIPPLE_STATE);
|
||||
}
|
||||
|
||||
//
|
||||
// Directory
|
||||
//
|
||||
|
||||
// For a directory entry put in the 64 bit index or quality.
|
||||
uint256 Ledger::getDirIndex(const uint256& uBase, const uint64 uNodeDir)
|
||||
{
|
||||
// Indexes are stored in big endian format: they print as hex as stored.
|
||||
// Most significant bytes are first. Least significant bytes repesent adjcent entries.
|
||||
// We place uNodeDir in the 8 right most bytes to be adjcent.
|
||||
// Want uNodeDir in big endian format so ++ goes to the next entry for indexes.
|
||||
uint256 uNode(uBase);
|
||||
|
||||
((uint64*) uNode.end())[-1] = htobe64(uNodeDir);
|
||||
|
||||
return uNode;
|
||||
}
|
||||
|
||||
SLE::pointer Ledger::getDirRoot(LedgerStateParms& parms, const uint256& uRootIndex)
|
||||
{
|
||||
ScopedLock l(mAccountStateMap->Lock());
|
||||
|
||||
return getASNode(parms, uRootIndex, ltDIR_ROOT);
|
||||
}
|
||||
|
||||
SLE::pointer Ledger::getDirNode(LedgerStateParms& parms, const uint256& uNodeIndex)
|
||||
{
|
||||
ScopedLock l(mAccountStateMap->Lock());
|
||||
|
||||
return getASNode(parms, uNodeIndex, ltDIR_NODE);
|
||||
}
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -98,7 +98,7 @@ Transaction::pointer NetworkOPs::processTransaction(Transaction::pointer trans,
|
||||
return trans;
|
||||
}
|
||||
|
||||
Log(lsDEBUG) << "Status other than success " << r ;
|
||||
Log(lsDEBUG) << "Status other than success " << r;
|
||||
if ((mMode != omFULL) && (mMode != omTRACKING) && (theApp->isNew(trans->getID())))
|
||||
{
|
||||
newcoin::TMTransaction tx;
|
||||
@@ -171,53 +171,32 @@ SLE::pointer NetworkOPs::getGenerator(const uint256& uLedger, const uint160& uGe
|
||||
//
|
||||
|
||||
// <-- false : no entrieS
|
||||
bool NetworkOPs::getDirInfo(
|
||||
const uint256& uLedger,
|
||||
const uint256& uBase,
|
||||
uint256& uDirLineNodeFirst,
|
||||
uint256& uDirLineNodeLast)
|
||||
STVector256 NetworkOPs::getDirNodeInfo(
|
||||
const uint256& uLedger,
|
||||
const uint256& uNodeIndex,
|
||||
uint64& uNodePrevious,
|
||||
uint64& uNodeNext)
|
||||
{
|
||||
uint256 uRootIndex = Ledger::getDirIndex(uBase, 0);
|
||||
LedgerStateParms lspRoot = lepNONE;
|
||||
SLE::pointer sleRoot = mLedgerMaster->getLedgerByHash(uLedger)->getDirRoot(lspRoot, uRootIndex);
|
||||
|
||||
if (sleRoot)
|
||||
{
|
||||
Log(lsDEBUG) << "getDirInfo: root index: " << uRootIndex.ToString() ;
|
||||
|
||||
Log(lsTRACE) << "getDirInfo: first: " << strHex(sleRoot->getIFieldU64(sfFirstNode)) ;
|
||||
Log(lsTRACE) << "getDirInfo: last: " << strHex(sleRoot->getIFieldU64(sfLastNode)) ;
|
||||
|
||||
uDirLineNodeFirst = Ledger::getDirIndex(uBase, sleRoot->getIFieldU64(sfFirstNode));
|
||||
uDirLineNodeLast = Ledger::getDirIndex(uBase, sleRoot->getIFieldU64(sfLastNode));
|
||||
|
||||
Log(lsTRACE) << "getDirInfo: first: " << uDirLineNodeFirst.ToString() ;
|
||||
Log(lsTRACE) << "getDirInfo: last: " << uDirLineNodeLast.ToString() ;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log(lsINFO) << "getDirInfo: root index: NOT FOUND: " << uRootIndex.ToString() ;
|
||||
}
|
||||
|
||||
return !!sleRoot;
|
||||
}
|
||||
|
||||
STVector256 NetworkOPs::getDirNode(const uint256& uLedger, const uint256& uDirLineNode)
|
||||
{
|
||||
STVector256 svIndexes;
|
||||
|
||||
STVector256 svIndexes;
|
||||
LedgerStateParms lspNode = lepNONE;
|
||||
SLE::pointer sleNode = mLedgerMaster->getLedgerByHash(uLedger)->getDirNode(lspNode, uDirLineNode);
|
||||
SLE::pointer sleNode = mLedgerMaster->getLedgerByHash(uLedger)->getDirNode(lspNode, uNodeIndex);
|
||||
|
||||
if (sleNode)
|
||||
{
|
||||
Log(lsWARNING) << "getDirNode: node index: " << uDirLineNode.ToString() ;
|
||||
Log(lsDEBUG) << "getDirNodeInfo: node index: " << uNodeIndex.ToString();
|
||||
|
||||
svIndexes = sleNode->getIFieldV256(sfIndexes);
|
||||
Log(lsTRACE) << "getDirNodeInfo: first: " << strHex(sleNode->getIFieldU64(sfIndexPrevious));
|
||||
Log(lsTRACE) << "getDirNodeInfo: last: " << strHex(sleNode->getIFieldU64(sfIndexNext));
|
||||
|
||||
uNodePrevious = sleNode->getIFieldU64(sfIndexPrevious);
|
||||
uNodeNext = sleNode->getIFieldU64(sfIndexNext);
|
||||
|
||||
Log(lsTRACE) << "getDirNodeInfo: first: " << strHex(uNodePrevious);
|
||||
Log(lsTRACE) << "getDirNodeInfo: last: " << strHex(uNodeNext);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log(lsINFO) << "getDirNode: node index: NOT FOUND: " << uDirLineNode.ToString() ;
|
||||
Log(lsINFO) << "getDirNodeInfo: node index: NOT FOUND: " << uNodeIndex.ToString();
|
||||
}
|
||||
|
||||
return svIndexes;
|
||||
@@ -472,7 +451,7 @@ bool NetworkOPs::checkLastClosedLedger(const std::vector<Peer::pointer>& peerLis
|
||||
void NetworkOPs::switchLastClosedLedger(Ledger::pointer newLedger)
|
||||
{ // set the newledger as our last closed ledger -- this is abnormal code
|
||||
|
||||
Log(lsERROR) << "ABNORMAL Switching last closed ledger to " << newLedger->getHash().GetHex() ;
|
||||
Log(lsERROR) << "ABNORMAL Switching last closed ledger to " << newLedger->getHash().GetHex();
|
||||
|
||||
if (mConsensus)
|
||||
{
|
||||
@@ -498,7 +477,7 @@ void NetworkOPs::switchLastClosedLedger(Ledger::pointer newLedger)
|
||||
|
||||
int NetworkOPs::beginConsensus(const uint256& networkClosed, Ledger::pointer closingLedger)
|
||||
{
|
||||
Log(lsINFO) << "Ledger close time for ledger " << closingLedger->getLedgerSeq() ;
|
||||
Log(lsINFO) << "Ledger close time for ledger " << closingLedger->getLedgerSeq();
|
||||
Log(lsINFO) << " LCL is " << closingLedger->getParentHash().GetHex();
|
||||
|
||||
Ledger::pointer prevLedger = mLedgerMaster->getLedgerByHash(closingLedger->getParentHash());
|
||||
|
||||
@@ -110,9 +110,8 @@ public:
|
||||
// Directory functions
|
||||
//
|
||||
|
||||
bool getDirInfo(const uint256& uLedger, const uint256& uBase,
|
||||
uint256& uDirNodeFirst, uint256& uDirNodeLast);
|
||||
STVector256 getDirNode(const uint256& uLedger, const uint256& uDirLineNode);
|
||||
STVector256 getDirNodeInfo(const uint256& uLedger, const uint256& uRootIndex,
|
||||
uint64& uNodePrevious, uint64& uNodeNext);
|
||||
|
||||
//
|
||||
// Nickname functions
|
||||
@@ -124,8 +123,14 @@ public:
|
||||
// Ripple functions
|
||||
//
|
||||
|
||||
bool getDirLineInfo(const uint256& uLedger, const NewcoinAddress& naAccount, uint256& uDirLineNodeFirst, uint256& uDirLineNodeLast)
|
||||
{ return getDirInfo(uLedger, Ledger::getRippleDirIndex(naAccount.getAccountID()), uDirLineNodeFirst, uDirLineNodeLast); }
|
||||
bool getDirLineInfo(const uint256& uLedger, const NewcoinAddress& naAccount, uint256& uRootIndex)
|
||||
{
|
||||
LedgerStateParms lspNode = lepNONE;
|
||||
|
||||
uRootIndex = Ledger::getRippleDirIndex(naAccount.getAccountID());
|
||||
|
||||
return !!mLedgerMaster->getLedgerByHash(uLedger)->getDirNode(lspNode, uRootIndex);
|
||||
}
|
||||
|
||||
RippleState::pointer getRippleState(const uint256& uLedger, const uint256& uIndex);
|
||||
|
||||
|
||||
@@ -487,18 +487,18 @@ Json::Value RPCServer::doAccountInfo(const Json::Value ¶ms)
|
||||
|
||||
// Get info on account.
|
||||
|
||||
uint256 uClosed = mNetOps->getClosedLedger();
|
||||
Json::Value jClosed = accountFromString(uClosed, naAccount, bIndex, strIdent, iIndex);
|
||||
uint256 uAccepted = mNetOps->getClosedLedger();
|
||||
Json::Value jAccepted = accountFromString(uAccepted, naAccount, bIndex, strIdent, iIndex);
|
||||
|
||||
if (jClosed.empty())
|
||||
if (jAccepted.empty())
|
||||
{
|
||||
AccountState::pointer asClosed = mNetOps->getAccountState(uClosed, naAccount);
|
||||
AccountState::pointer asAccepted = mNetOps->getAccountState(uAccepted, naAccount);
|
||||
|
||||
if (asClosed)
|
||||
asClosed->addJson(jClosed);
|
||||
if (asAccepted)
|
||||
asAccepted->addJson(jAccepted);
|
||||
}
|
||||
|
||||
ret["closed"] = jClosed;
|
||||
ret["accepted"] = jAccepted;
|
||||
|
||||
uint256 uCurrent = mNetOps->getCurrentLedger();
|
||||
Json::Value jCurrent = accountFromString(uCurrent, naAccount, bIndex, strIdent, iIndex);
|
||||
@@ -514,7 +514,7 @@ Json::Value RPCServer::doAccountInfo(const Json::Value ¶ms)
|
||||
ret["current"] = jCurrent;
|
||||
|
||||
#if 0
|
||||
if (!jClosed && !asCurrent)
|
||||
if (!jAccepted && !asCurrent)
|
||||
{
|
||||
ret["account"] = naAccount.humanAccountID();
|
||||
ret["status"] = "NotFound";
|
||||
@@ -525,95 +525,6 @@ Json::Value RPCServer::doAccountInfo(const Json::Value ¶ms)
|
||||
return ret;
|
||||
}
|
||||
|
||||
// account_lines <account>|<nickname>|<account_public_key> [<index>]
|
||||
Json::Value RPCServer::doAccountLines(const Json::Value ¶ms)
|
||||
{
|
||||
// uint256 uClosed = mNetOps->getClosedLedger();
|
||||
uint256 uCurrent = mNetOps->getCurrentLedger();
|
||||
|
||||
std::string strIdent = params[0u].asString();
|
||||
bool bIndex;
|
||||
int iIndex = 2 == params.size()? lexical_cast_s<int>(params[1u].asString()) : 0;
|
||||
|
||||
NewcoinAddress naAccount;
|
||||
|
||||
Json::Value ret;
|
||||
|
||||
ret = accountFromString(uCurrent, naAccount, bIndex, strIdent, iIndex);
|
||||
|
||||
if (!ret.empty())
|
||||
return ret;
|
||||
|
||||
// Get info on account.
|
||||
ret = Json::Value(Json::objectValue);
|
||||
|
||||
ret["account"] = naAccount.humanAccountID();
|
||||
if (bIndex)
|
||||
ret["index"] = iIndex;
|
||||
|
||||
AccountState::pointer as = mNetOps->getAccountState(uCurrent, naAccount);
|
||||
if (as)
|
||||
{
|
||||
Json::Value jsonLines = Json::Value(Json::objectValue);
|
||||
|
||||
ret["account"] = naAccount.humanAccountID();
|
||||
|
||||
// We access a committed ledger and need not worry about changes.
|
||||
uint256 uDirLineNodeFirst;
|
||||
uint256 uDirLineNodeLast;
|
||||
|
||||
if (mNetOps->getDirLineInfo(uCurrent, naAccount, uDirLineNodeFirst, uDirLineNodeLast))
|
||||
{
|
||||
for (; uDirLineNodeFirst <= uDirLineNodeLast; uDirLineNodeFirst++)
|
||||
{
|
||||
STVector256 svRippleNodes = mNetOps->getDirNode(uCurrent, uDirLineNodeFirst);
|
||||
|
||||
BOOST_FOREACH(uint256& uNode, svRippleNodes.peekValue())
|
||||
{
|
||||
NewcoinAddress naAccountPeer;
|
||||
STAmount saBalance;
|
||||
STAmount saLimit;
|
||||
STAmount saLimitPeer;
|
||||
|
||||
RippleState::pointer rsLine = mNetOps->getRippleState(uCurrent, uNode);
|
||||
|
||||
if (rsLine)
|
||||
{
|
||||
rsLine->setViewAccount(naAccount);
|
||||
|
||||
naAccountPeer = rsLine->getAccountIDPeer();
|
||||
saBalance = rsLine->getBalance();
|
||||
saLimit = rsLine->getLimit();
|
||||
saLimitPeer = rsLine->getLimitPeer();
|
||||
|
||||
Json::Value jPeer = Json::Value(Json::objectValue);
|
||||
|
||||
jPeer["node"] = uNode.ToString();
|
||||
|
||||
jPeer["balance"] = saBalance.getText();
|
||||
jPeer["currency"] = saBalance.getCurrencyHuman();
|
||||
jPeer["limit"] = saLimit.getJson(0);
|
||||
jPeer["limit_peer"] = saLimitPeer.getJson(0);
|
||||
|
||||
jsonLines[naAccountPeer.humanAccountID()] = jPeer;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "doAccountLines: Bad index: " << uNode.ToString() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ret["lines"] = jsonLines;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret["status"] = "NotFound";
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// account_message_set <seed> <paying_account> <pub_key>
|
||||
Json::Value RPCServer::doAccountMessageSet(const Json::Value& params) {
|
||||
NewcoinAddress naSrcAccountID;
|
||||
@@ -747,69 +658,6 @@ Json::Value RPCServer::doConnect(const Json::Value& params)
|
||||
return "connecting";
|
||||
}
|
||||
|
||||
// credit_set <seed> <paying_account> <destination_account> <limit_amount> [<currency>] [<accept_rate>]
|
||||
Json::Value RPCServer::doCreditSet(const Json::Value& params)
|
||||
{
|
||||
NewcoinAddress naSeed;
|
||||
NewcoinAddress naSrcAccountID;
|
||||
NewcoinAddress naDstAccountID;
|
||||
STAmount saLimitAmount;
|
||||
uint256 uLedger = mNetOps->getCurrentLedger();
|
||||
uint32 uAcceptRate = params.size() >= 6 ? lexical_cast_s<uint32>(params[5u].asString()) : 0;
|
||||
|
||||
if (!naSeed.setSeedGeneric(params[0u].asString()))
|
||||
{
|
||||
return RPCError(rpcBAD_SEED);
|
||||
}
|
||||
else if (!naSrcAccountID.setAccountID(params[1u].asString()))
|
||||
{
|
||||
return RPCError(rpcSRC_ACT_MALFORMED);
|
||||
}
|
||||
else if (!naDstAccountID.setAccountID(params[2u].asString()))
|
||||
{
|
||||
return RPCError(rpcDST_ACT_MALFORMED);
|
||||
}
|
||||
else if (!saLimitAmount.setValue(params[3u].asString(), params.size() >= 5 ? params[4u].asString() : ""))
|
||||
{
|
||||
return RPCError(rpcSRC_AMT_MALFORMED);
|
||||
}
|
||||
else
|
||||
{
|
||||
NewcoinAddress naMasterGenerator;
|
||||
NewcoinAddress naAccountPublic;
|
||||
NewcoinAddress naAccountPrivate;
|
||||
AccountState::pointer asSrc;
|
||||
STAmount saSrcBalance;
|
||||
Json::Value obj = authorize(uLedger, naSeed, naSrcAccountID, naAccountPublic, naAccountPrivate,
|
||||
saSrcBalance, theConfig.FEE_DEFAULT, asSrc, naMasterGenerator);
|
||||
|
||||
if (!obj.empty())
|
||||
return obj;
|
||||
|
||||
Transaction::pointer trans = Transaction::sharedCreditSet(
|
||||
naAccountPublic, naAccountPrivate,
|
||||
naSrcAccountID,
|
||||
asSrc->getSeq(),
|
||||
theConfig.FEE_DEFAULT,
|
||||
0, // YYY No source tag
|
||||
naDstAccountID,
|
||||
saLimitAmount,
|
||||
uAcceptRate);
|
||||
|
||||
(void) mNetOps->processTransaction(trans);
|
||||
|
||||
obj["transaction"] = trans->getSTransaction()->getJson(0);
|
||||
obj["status"] = trans->getStatus();
|
||||
obj["seed"] = naSeed.humanSeed();
|
||||
obj["srcAccountID"] = naSrcAccountID.humanAccountID();
|
||||
obj["dstAccountID"] = naDstAccountID.humanAccountID();
|
||||
obj["limitAmount"] = saLimitAmount.getText();
|
||||
obj["acceptRate"] = uAcceptRate;
|
||||
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
// data_delete <key>
|
||||
Json::Value RPCServer::doDataDelete(const Json::Value& params)
|
||||
{
|
||||
@@ -1142,6 +990,170 @@ Json::Value RPCServer::doPeers(const Json::Value& params)
|
||||
return obj;
|
||||
}
|
||||
|
||||
// ripple_line_set <seed> <paying_account> <destination_account> <limit_amount> [<currency>] [<accept_rate>]
|
||||
Json::Value RPCServer::doRippleLineSet(const Json::Value& params)
|
||||
{
|
||||
NewcoinAddress naSeed;
|
||||
NewcoinAddress naSrcAccountID;
|
||||
NewcoinAddress naDstAccountID;
|
||||
STAmount saLimitAmount;
|
||||
uint256 uLedger = mNetOps->getCurrentLedger();
|
||||
uint32 uAcceptRate = params.size() >= 6 ? lexical_cast_s<uint32>(params[5u].asString()) : 0;
|
||||
|
||||
if (!naSeed.setSeedGeneric(params[0u].asString()))
|
||||
{
|
||||
return RPCError(rpcBAD_SEED);
|
||||
}
|
||||
else if (!naSrcAccountID.setAccountID(params[1u].asString()))
|
||||
{
|
||||
return RPCError(rpcSRC_ACT_MALFORMED);
|
||||
}
|
||||
else if (!naDstAccountID.setAccountID(params[2u].asString()))
|
||||
{
|
||||
return RPCError(rpcDST_ACT_MALFORMED);
|
||||
}
|
||||
else if (!saLimitAmount.setValue(params[3u].asString(), params.size() >= 5 ? params[4u].asString() : ""))
|
||||
{
|
||||
return RPCError(rpcSRC_AMT_MALFORMED);
|
||||
}
|
||||
else
|
||||
{
|
||||
NewcoinAddress naMasterGenerator;
|
||||
NewcoinAddress naAccountPublic;
|
||||
NewcoinAddress naAccountPrivate;
|
||||
AccountState::pointer asSrc;
|
||||
STAmount saSrcBalance;
|
||||
Json::Value obj = authorize(uLedger, naSeed, naSrcAccountID, naAccountPublic, naAccountPrivate,
|
||||
saSrcBalance, theConfig.FEE_DEFAULT, asSrc, naMasterGenerator);
|
||||
|
||||
if (!obj.empty())
|
||||
return obj;
|
||||
|
||||
Transaction::pointer trans = Transaction::sharedCreditSet(
|
||||
naAccountPublic, naAccountPrivate,
|
||||
naSrcAccountID,
|
||||
asSrc->getSeq(),
|
||||
theConfig.FEE_DEFAULT,
|
||||
0, // YYY No source tag
|
||||
naDstAccountID,
|
||||
saLimitAmount,
|
||||
uAcceptRate);
|
||||
|
||||
(void) mNetOps->processTransaction(trans);
|
||||
|
||||
obj["transaction"] = trans->getSTransaction()->getJson(0);
|
||||
obj["status"] = trans->getStatus();
|
||||
obj["seed"] = naSeed.humanSeed();
|
||||
obj["srcAccountID"] = naSrcAccountID.humanAccountID();
|
||||
obj["dstAccountID"] = naDstAccountID.humanAccountID();
|
||||
obj["limitAmount"] = saLimitAmount.getText();
|
||||
obj["acceptRate"] = uAcceptRate;
|
||||
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
// ripple_lines_get <account>|<nickname>|<account_public_key> [<index>]
|
||||
Json::Value RPCServer::doRippleLinesGet(const Json::Value ¶ms)
|
||||
{
|
||||
// uint256 uAccepted = mNetOps->getClosedLedger();
|
||||
uint256 uCurrent = mNetOps->getCurrentLedger();
|
||||
|
||||
std::string strIdent = params[0u].asString();
|
||||
bool bIndex;
|
||||
int iIndex = 2 == params.size()? lexical_cast_s<int>(params[1u].asString()) : 0;
|
||||
|
||||
NewcoinAddress naAccount;
|
||||
|
||||
Json::Value ret;
|
||||
|
||||
ret = accountFromString(uCurrent, naAccount, bIndex, strIdent, iIndex);
|
||||
|
||||
if (!ret.empty())
|
||||
return ret;
|
||||
|
||||
// Get info on account.
|
||||
ret = Json::Value(Json::objectValue);
|
||||
|
||||
ret["account"] = naAccount.humanAccountID();
|
||||
if (bIndex)
|
||||
ret["index"] = iIndex;
|
||||
|
||||
AccountState::pointer as = mNetOps->getAccountState(uCurrent, naAccount);
|
||||
if (as)
|
||||
{
|
||||
Json::Value jsonLines = Json::Value(Json::objectValue);
|
||||
|
||||
ret["account"] = naAccount.humanAccountID();
|
||||
|
||||
// We access a committed ledger and need not worry about changes.
|
||||
uint256 uRootIndex;
|
||||
|
||||
if (mNetOps->getDirLineInfo(uCurrent, naAccount, uRootIndex))
|
||||
{
|
||||
bool bDone = false;
|
||||
|
||||
while (!bDone)
|
||||
{
|
||||
uint64 uNodePrevious;
|
||||
uint64 uNodeNext;
|
||||
STVector256 svRippleNodes = mNetOps->getDirNodeInfo(uCurrent, uRootIndex, uNodePrevious, uNodeNext);
|
||||
|
||||
BOOST_FOREACH(uint256& uNode, svRippleNodes.peekValue())
|
||||
{
|
||||
NewcoinAddress naAccountPeer;
|
||||
STAmount saBalance;
|
||||
STAmount saLimit;
|
||||
STAmount saLimitPeer;
|
||||
|
||||
RippleState::pointer rsLine = mNetOps->getRippleState(uCurrent, uNode);
|
||||
|
||||
if (rsLine)
|
||||
{
|
||||
rsLine->setViewAccount(naAccount);
|
||||
|
||||
naAccountPeer = rsLine->getAccountIDPeer();
|
||||
saBalance = rsLine->getBalance();
|
||||
saLimit = rsLine->getLimit();
|
||||
saLimitPeer = rsLine->getLimitPeer();
|
||||
|
||||
Json::Value jPeer = Json::Value(Json::objectValue);
|
||||
|
||||
jPeer["node"] = uNode.ToString();
|
||||
|
||||
jPeer["balance"] = saBalance.getText();
|
||||
jPeer["currency"] = saBalance.getCurrencyHuman();
|
||||
jPeer["limit"] = saLimit.getJson(0);
|
||||
jPeer["limit_peer"] = saLimitPeer.getJson(0);
|
||||
|
||||
jsonLines[naAccountPeer.humanAccountID()] = jPeer;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "doAccountLines: Bad index: " << uNode.ToString() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (uNodeNext)
|
||||
{
|
||||
uCurrent = Ledger::getDirNodeIndex(uRootIndex, uNodeNext);
|
||||
}
|
||||
else
|
||||
{
|
||||
bDone = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
ret["lines"] = jsonLines;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret["status"] = "NotFound";
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// send regular_seed paying_account account_id amount [currency] [send_max] [send_currency]
|
||||
Json::Value RPCServer::doSend(const Json::Value& params)
|
||||
{
|
||||
@@ -1282,77 +1294,6 @@ Json::Value RPCServer::doServerInfo(const Json::Value& params)
|
||||
return ret;
|
||||
}
|
||||
|
||||
// transit_set <seed> <paying_account> <transit_rate> <starts> <expires>
|
||||
Json::Value RPCServer::doTransitSet(const Json::Value& params)
|
||||
{
|
||||
NewcoinAddress naSeed;
|
||||
NewcoinAddress naSrcAccountID;
|
||||
std::string sTransitRate;
|
||||
std::string sTransitStart;
|
||||
std::string sTransitExpire;
|
||||
uint32 uTransitRate;
|
||||
uint32 uTransitStart;
|
||||
uint32 uTransitExpire;
|
||||
uint256 uLedger = mNetOps->getCurrentLedger();
|
||||
|
||||
if (params.size() >= 6)
|
||||
sTransitRate = params[6u].asString();
|
||||
|
||||
if (params.size() >= 7)
|
||||
sTransitStart = params[7u].asString();
|
||||
|
||||
if (params.size() >= 8)
|
||||
sTransitExpire = params[8u].asString();
|
||||
|
||||
if (!naSeed.setSeedGeneric(params[0u].asString()))
|
||||
{
|
||||
return RPCError(rpcBAD_SEED);
|
||||
}
|
||||
else if (!naSrcAccountID.setAccountID(params[1u].asString()))
|
||||
{
|
||||
return RPCError(rpcSRC_ACT_MALFORMED);
|
||||
}
|
||||
else
|
||||
{
|
||||
NewcoinAddress naMasterGenerator;
|
||||
NewcoinAddress naAccountPublic;
|
||||
NewcoinAddress naAccountPrivate;
|
||||
AccountState::pointer asSrc;
|
||||
STAmount saSrcBalance;
|
||||
Json::Value obj = authorize(uLedger, naSeed, naSrcAccountID, naAccountPublic, naAccountPrivate,
|
||||
saSrcBalance, theConfig.FEE_DEFAULT, asSrc, naMasterGenerator);
|
||||
|
||||
if (!obj.empty())
|
||||
return obj;
|
||||
|
||||
uTransitRate = 0;
|
||||
uTransitStart = 0;
|
||||
uTransitExpire = 0;
|
||||
|
||||
Transaction::pointer trans = Transaction::sharedTransitSet(
|
||||
naAccountPublic, naAccountPrivate,
|
||||
naSrcAccountID,
|
||||
asSrc->getSeq(),
|
||||
theConfig.FEE_DEFAULT,
|
||||
0, // YYY No source tag
|
||||
uTransitRate,
|
||||
uTransitStart,
|
||||
uTransitExpire);
|
||||
|
||||
(void) mNetOps->processTransaction(trans);
|
||||
|
||||
obj["transaction"] = trans->getSTransaction()->getJson(0);
|
||||
obj["status"] = trans->getStatus();
|
||||
obj["seed"] = naSeed.humanSeed();
|
||||
obj["srcAccountID"] = naSrcAccountID.humanAccountID();
|
||||
obj["transitRate"] = uTransitRate;
|
||||
obj["transitStart"] = uTransitStart;
|
||||
obj["transitExpire"] = uTransitExpire;
|
||||
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
Json::Value RPCServer::doTx(const Json::Value& params)
|
||||
{
|
||||
// tx <txID>
|
||||
@@ -2029,12 +1970,10 @@ Json::Value RPCServer::doCommand(const std::string& command, Json::Value& params
|
||||
} commandsA[] = {
|
||||
{ "account_email_set", &RPCServer::doAccountEmailSet, 2, 3, false, optCurrent },
|
||||
{ "account_info", &RPCServer::doAccountInfo, 1, 2, false, optCurrent },
|
||||
{ "account_lines", &RPCServer::doAccountLines, 1, 2, false, optCurrent|optClosed },
|
||||
{ "account_message_set", &RPCServer::doAccountMessageSet, 3, 3, false, optCurrent },
|
||||
{ "account_tx", &RPCServer::doAccountTransactions, 2, 3, false, optNetwork },
|
||||
{ "account_wallet_set", &RPCServer::doAccountWalletSet, 2, 3, false, optCurrent },
|
||||
{ "connect", &RPCServer::doConnect, 1, 2, true },
|
||||
{ "credit_set", &RPCServer::doCreditSet, 4, 6, false, optCurrent },
|
||||
{ "data_delete", &RPCServer::doDataDelete, 1, 1, true },
|
||||
{ "data_fetch", &RPCServer::doDataFetch, 1, 1, true },
|
||||
{ "data_store", &RPCServer::doDataStore, 2, 2, true },
|
||||
@@ -2046,10 +1985,11 @@ Json::Value RPCServer::doCommand(const std::string& command, Json::Value& params
|
||||
{ "password_fund", &RPCServer::doPasswordFund, 2, 3, false, optCurrent },
|
||||
{ "password_set", &RPCServer::doPasswordSet, 2, 3, false, optNetwork },
|
||||
{ "peers", &RPCServer::doPeers, 0, 0, true },
|
||||
{ "ripple_lines_get", &RPCServer::doRippleLinesGet, 1, 2, false, optCurrent|optClosed },
|
||||
{ "ripple_line_set", &RPCServer::doRippleLineSet, 4, 6, false, optCurrent },
|
||||
{ "send", &RPCServer::doSend, 3, 7, false, optCurrent },
|
||||
{ "server_info", &RPCServer::doServerInfo, 0, 0, true },
|
||||
{ "stop", &RPCServer::doStop, 0, 0, true },
|
||||
{ "transit_set", &RPCServer::doTransitSet, 5, 5, true, optCurrent },
|
||||
{ "tx", &RPCServer::doTx, 1, 1, true },
|
||||
|
||||
{ "unl_add", &RPCServer::doUnlAdd, 1, 2, true },
|
||||
|
||||
@@ -123,12 +123,10 @@ private:
|
||||
|
||||
Json::Value doAccountEmailSet(const Json::Value ¶ms);
|
||||
Json::Value doAccountInfo(const Json::Value& params);
|
||||
Json::Value doAccountLines(const Json::Value ¶ms);
|
||||
Json::Value doAccountMessageSet(const Json::Value ¶ms);
|
||||
Json::Value doAccountTransactions(const Json::Value& params);
|
||||
Json::Value doAccountWalletSet(const Json::Value ¶ms);
|
||||
Json::Value doConnect(const Json::Value& params);
|
||||
Json::Value doCreditSet(const Json::Value& params);
|
||||
Json::Value doDataDelete(const Json::Value& params);
|
||||
Json::Value doDataFetch(const Json::Value& params);
|
||||
Json::Value doDataStore(const Json::Value& params);
|
||||
@@ -140,6 +138,8 @@ private:
|
||||
Json::Value doPasswordFund(const Json::Value& params);
|
||||
Json::Value doPasswordSet(const Json::Value& params);
|
||||
Json::Value doPeers(const Json::Value& params);
|
||||
Json::Value doRippleLinesGet(const Json::Value ¶ms);
|
||||
Json::Value doRippleLineSet(const Json::Value& params);
|
||||
Json::Value doSend(const Json::Value& params);
|
||||
Json::Value doServerInfo(const Json::Value& params);
|
||||
Json::Value doSessionClose(const Json::Value& params);
|
||||
|
||||
@@ -57,9 +57,11 @@ std::string SerializedLedgerEntry::getText() const
|
||||
Json::Value SerializedLedgerEntry::getJson(int options) const
|
||||
{
|
||||
Json::Value ret(mObject.getJson(options));
|
||||
ret["type"] = mFormat->t_name;
|
||||
ret["index"] = mIndex.GetHex();
|
||||
ret["version"] = mVersion.getText();
|
||||
|
||||
ret["type"] = mFormat->t_name;
|
||||
ret["index"] = mIndex.GetHex();
|
||||
ret["version"] = std::string(1, mVersion);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
#include "SerializedObject.h"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include "../json/writer.h"
|
||||
@@ -654,6 +655,18 @@ Json::Value STObject::getJson(int options) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
Json::Value STVector256::getJson(int options) const
|
||||
{
|
||||
Json::Value ret(Json::arrayValue);
|
||||
|
||||
BOOST_FOREACH(std::vector<uint256>::const_iterator::value_type vEntry, mValue)
|
||||
{
|
||||
ret.append(vEntry.ToString());
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static SOElement testSOElements[2][16] =
|
||||
{ // field, name, id, type, flags
|
||||
{
|
||||
|
||||
@@ -34,6 +34,7 @@ enum SOE_Field
|
||||
sfAmountOut,
|
||||
sfAuthorizedKey,
|
||||
sfBalance,
|
||||
sfBookNode,
|
||||
sfBorrowExpire,
|
||||
sfBorrowRate,
|
||||
sfBorrowStart,
|
||||
@@ -43,8 +44,9 @@ enum SOE_Field
|
||||
sfCurrencyIn,
|
||||
sfCurrencyOut,
|
||||
sfDestination,
|
||||
sfDomain,
|
||||
sfEmailHash,
|
||||
sfExpireLedger,
|
||||
sfExpiration,
|
||||
sfExtensions,
|
||||
sfFirstNode,
|
||||
sfFlags,
|
||||
@@ -55,7 +57,11 @@ enum SOE_Field
|
||||
sfHighLimit,
|
||||
sfIdentifier,
|
||||
sfIndexes,
|
||||
sfIndexNext,
|
||||
sfIndexPrevious,
|
||||
sfInvoiceID,
|
||||
sfIssuerIn,
|
||||
sfIssuerOut,
|
||||
sfLastNode,
|
||||
sfLastReceive,
|
||||
sfLastTxn,
|
||||
@@ -72,9 +78,12 @@ enum SOE_Field
|
||||
sfNextTransitRate,
|
||||
sfNextTransitStart,
|
||||
sfNickname,
|
||||
sfOfferCurrency,
|
||||
sfOfferSequence,
|
||||
sfOwnerNode,
|
||||
sfPaths,
|
||||
sfPubKey,
|
||||
sfQualityIn,
|
||||
sfQualityOut,
|
||||
sfSendMax,
|
||||
sfSequence,
|
||||
sfSignature,
|
||||
@@ -82,9 +91,7 @@ enum SOE_Field
|
||||
sfSourceTag,
|
||||
sfTarget,
|
||||
sfTargetLedger,
|
||||
sfTransitExpire,
|
||||
sfTransitRate,
|
||||
sfTransitStart,
|
||||
sfTransferRate,
|
||||
sfVersion,
|
||||
sfWalletLocator,
|
||||
|
||||
|
||||
@@ -207,6 +207,7 @@ class STAmount : public SerializedType
|
||||
|
||||
protected:
|
||||
uint160 mCurrency;
|
||||
uint160 mIssuer; // Only for access, not compared.
|
||||
|
||||
uint64 mValue;
|
||||
int mOffset;
|
||||
@@ -282,7 +283,10 @@ public:
|
||||
void negate() { if (!isZero()) mIsNegative = !mIsNegative; }
|
||||
void zero() { mOffset = mIsNative ? -100 : 0; mValue = 0; mIsNegative = false; }
|
||||
|
||||
const uint160& getCurrency() const { return mCurrency; }
|
||||
const uint160& getIssuer() const { return mIssuer; }
|
||||
void setIssuer(const uint160& uIssuer) { mIssuer = uIssuer; }
|
||||
|
||||
const uint160& getCurrency() const { return mCurrency; }
|
||||
bool setValue(const std::string& sAmount, const std::string& sCurrency);
|
||||
void setValue(const STAmount &);
|
||||
|
||||
@@ -329,7 +333,7 @@ public:
|
||||
static STAmount getClaimed(STAmount& offerOut, STAmount& offerIn, STAmount& paid);
|
||||
|
||||
// Someone is offering X for Y, I need Z, how much do I pay
|
||||
static STAmount getNeeded(const STAmount& offerOut, const STAmount& offerIn, const STAmount& needed);
|
||||
static STAmount getPay(const STAmount& offerOut, const STAmount& offerIn, const STAmount& needed);
|
||||
|
||||
// Native currency conversions, to/from display format
|
||||
static uint64 convertToDisplayAmount(const STAmount& internalAmount, uint64 totalNow, uint64 totalInit);
|
||||
@@ -640,6 +644,8 @@ public:
|
||||
|
||||
void setValue(const STVector256& v) { mValue = v.mValue; }
|
||||
void setValue(const std::vector<uint256>& v) { mValue = v; }
|
||||
|
||||
Json::Value getJson(int) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -107,7 +107,6 @@ public:
|
||||
void reserve(size_t n) { mData.reserve(n); }
|
||||
void resize(size_t n) { mData.resize(n); }
|
||||
size_t capacity() const { return mData.capacity(); }
|
||||
|
||||
|
||||
bool operator==(const std::vector<unsigned char>& v) { return v == mData; }
|
||||
bool operator!=(const std::vector<unsigned char>& v) { return v != mData; }
|
||||
|
||||
@@ -413,43 +413,6 @@ Transaction::pointer Transaction::sharedPayment(
|
||||
return tResult->setPayment(naPrivateKey, naDstAccountID, saAmount, saSendMax, saPaths);
|
||||
}
|
||||
|
||||
//
|
||||
// TransitSet
|
||||
//
|
||||
|
||||
Transaction::pointer Transaction::setTransitSet(
|
||||
const NewcoinAddress& naPrivateKey,
|
||||
uint32 uTransitRate,
|
||||
uint32 uTransitStart,
|
||||
uint32 uTransitExpire)
|
||||
{
|
||||
if (uTransitRate)
|
||||
mTransaction->setITFieldU32(sfTransitRate, uTransitRate);
|
||||
if (uTransitStart)
|
||||
mTransaction->setITFieldU32(sfTransitStart, uTransitStart);
|
||||
if (uTransitExpire)
|
||||
mTransaction->setITFieldU32(sfTransitExpire, uTransitExpire);
|
||||
|
||||
sign(naPrivateKey);
|
||||
|
||||
return shared_from_this();
|
||||
}
|
||||
|
||||
Transaction::pointer Transaction::sharedTransitSet(
|
||||
const NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey,
|
||||
const NewcoinAddress& naSourceAccount,
|
||||
uint32 uSeq,
|
||||
const STAmount& saFee,
|
||||
uint32 uSourceTag,
|
||||
uint32 uTransitRate,
|
||||
uint32 uTransitStart,
|
||||
uint32 uTransitExpire)
|
||||
{
|
||||
pointer tResult = boost::make_shared<Transaction>(ttTRANSIT_SET, naPublicKey, naSourceAccount, uSeq, saFee, uSourceTag);
|
||||
|
||||
return tResult->setTransitSet(naPrivateKey, uTransitRate, uTransitStart, uTransitExpire);
|
||||
}
|
||||
|
||||
//
|
||||
// WalletAdd
|
||||
//
|
||||
|
||||
@@ -96,12 +96,6 @@ private:
|
||||
const STAmount& saSendMax,
|
||||
const STPathSet& spPaths);
|
||||
|
||||
Transaction::pointer setTransitSet(
|
||||
const NewcoinAddress& naPrivateKey,
|
||||
uint32 uTransitRate,
|
||||
uint32 uTransitStart,
|
||||
uint32 uTransitExpire);
|
||||
|
||||
Transaction::pointer setWalletAdd(
|
||||
const NewcoinAddress& naPrivateKey,
|
||||
const STAmount& saAmount,
|
||||
@@ -206,17 +200,6 @@ public:
|
||||
const STAmount& saSendMax,
|
||||
const STPathSet& saPaths);
|
||||
|
||||
// Set transit fees.
|
||||
static Transaction::pointer sharedTransitSet(
|
||||
const NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey,
|
||||
const NewcoinAddress& naSourceAccount,
|
||||
uint32 uSeq,
|
||||
const STAmount& saFee,
|
||||
uint32 uSourceTag,
|
||||
uint32 uTransitRate,
|
||||
uint32 uTransitStart,
|
||||
uint32 uTransitExpire);
|
||||
|
||||
// Add an account to a wallet.
|
||||
static Transaction::pointer sharedWalletAdd(
|
||||
const NewcoinAddress& naPublicKey, const NewcoinAddress& naPrivateKey,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,7 +19,10 @@ enum TransactionEngineResult
|
||||
tenBAD_ADD_AUTH,
|
||||
tenBAD_AMOUNT,
|
||||
tenBAD_CLAIM_ID,
|
||||
tenBAD_EXPIRATION,
|
||||
tenBAD_GEN_AUTH,
|
||||
tenBAD_ISSUER,
|
||||
tenBAD_OFFER,
|
||||
tenBAD_SET_ID,
|
||||
tenCREATEXNS,
|
||||
tenDST_IS_SRC,
|
||||
@@ -33,6 +36,7 @@ enum TransactionEngineResult
|
||||
tenBAD_AUTH_MASTER,
|
||||
tenBAD_RIPPLE,
|
||||
tenCREATED,
|
||||
tenEXPIRED,
|
||||
tenMSG_SET,
|
||||
terALREADY,
|
||||
|
||||
@@ -48,6 +52,7 @@ enum TransactionEngineResult
|
||||
// Conflict with ledger database: Fee claimed
|
||||
// Might succeed if not conflict is not caused by transaction ordering.
|
||||
terBAD_AUTH,
|
||||
terBAD_LEDGER,
|
||||
terBAD_RIPPLE,
|
||||
terBAD_SEQ,
|
||||
terCREATED,
|
||||
@@ -62,6 +67,7 @@ enum TransactionEngineResult
|
||||
terNO_DST,
|
||||
terNO_LINE_NO_ZERO,
|
||||
terNO_PATH,
|
||||
terOFFER_NOT_FOUND,
|
||||
terOVER_LIMIT,
|
||||
terPAST_LEDGER,
|
||||
terPAST_SEQ,
|
||||
@@ -97,20 +103,44 @@ private:
|
||||
TransactionEngineResult dirAdd(
|
||||
std::vector<AffectedAccount>& accounts,
|
||||
uint64& uNodeDir, // Node of entry.
|
||||
const uint256& uBase,
|
||||
const uint256& uRootIndex,
|
||||
const uint256& uLedgerIndex);
|
||||
|
||||
TransactionEngineResult dirDelete(
|
||||
std::vector<AffectedAccount>& accounts,
|
||||
const uint64& uNodeDir, // Node item is mentioned in.
|
||||
const uint256& uBase, // Key of item.
|
||||
const uint256& uRootIndex,
|
||||
const uint256& uLedgerIndex); // Item being deleted
|
||||
|
||||
#ifdef WORK_IN_PROGRESS
|
||||
typedef struct {
|
||||
STAmount saWanted; // What this node wants from upstream.
|
||||
|
||||
STAmount saIOURedeem; // What this node will redeem downstream.
|
||||
STAmount saIOUIssue; // What this node will issue downstream.
|
||||
STAmount saSend; // Amount of stamps this node will send.
|
||||
|
||||
STAmount saIOUForgive; // Amount of IOUs to forgive.
|
||||
STAmount saIOUAccept; // Amount of IOUs to accept.
|
||||
STAmount saRecieve; // Amount stamps to receive.
|
||||
|
||||
STAccount saAccount;
|
||||
} paymentNode;
|
||||
|
||||
typedef struct {
|
||||
boost::unordered_set<....> offersDeletedAlways;
|
||||
boost::unordered_set<....> offersDeletedOnSuccess;
|
||||
std::vector<paymentNode> vpnNodes;
|
||||
bool bAllowPartial;
|
||||
} paymentGroup;
|
||||
#endif
|
||||
|
||||
TransactionEngineResult setAuthorized(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts, bool bMustSetGenerator);
|
||||
|
||||
protected:
|
||||
Ledger::pointer mDefaultLedger, mAlternateLedger;
|
||||
Ledger::pointer mLedger;
|
||||
uint64 mLedgerParentCloseTime;
|
||||
|
||||
TransactionEngineResult doAccountSet(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts);
|
||||
TransactionEngineResult doClaim(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts);
|
||||
@@ -118,7 +148,10 @@ protected:
|
||||
const uint160& uSrcAccountID);
|
||||
TransactionEngineResult doDelete(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts);
|
||||
TransactionEngineResult doInvoice(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts);
|
||||
TransactionEngineResult doOffer(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts);
|
||||
TransactionEngineResult doOfferCreate(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts,
|
||||
const uint160& uSrcAccountID);
|
||||
TransactionEngineResult doOfferCancel(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts,
|
||||
const uint160& uSrcAccountID);
|
||||
TransactionEngineResult doNicknameSet(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts,
|
||||
const uint160& uSrcAccountID);
|
||||
TransactionEngineResult doPasswordFund(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts,
|
||||
@@ -128,7 +161,6 @@ protected:
|
||||
const uint160& uSrcAccountID);
|
||||
TransactionEngineResult doStore(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts);
|
||||
TransactionEngineResult doTake(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts);
|
||||
TransactionEngineResult doTransitSet(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts);
|
||||
TransactionEngineResult doWalletAdd(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts);
|
||||
|
||||
public:
|
||||
|
||||
@@ -7,10 +7,11 @@ TransactionFormat InnerTxnFormats[]=
|
||||
{
|
||||
{ "AccountSet", ttACCOUNT_SET, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(EmailHash), STI_HASH128, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(WalletLocator), STI_HASH256, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(MessageKey), STI_VL, SOE_IFFLAG, 4 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 8 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(EmailHash), STI_HASH128, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(WalletLocator), STI_HASH256, SOE_IFFLAG, 4 },
|
||||
{ S_FIELD(MessageKey), STI_VL, SOE_IFFLAG, 8 },
|
||||
{ S_FIELD(Domain), STI_VL, SOE_IFFLAG, 16 },
|
||||
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x02000000 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
@@ -53,14 +54,20 @@ TransactionFormat InnerTxnFormats[]=
|
||||
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x02000000 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "Offer", ttOFFER, {
|
||||
{ "OfferCreate", ttOFFER_CREATE, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(AmountIn), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(AmountOut), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(Destination), STI_ACCOUNT, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(ExpireLedger), STI_UINT32, SOE_IFFLAG, 4 },
|
||||
{ S_FIELD(Identifier), STI_VL, SOE_IFFLAG, 8 },
|
||||
{ S_FIELD(Expiration), STI_UINT32, SOE_IFFLAG, 4 },
|
||||
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x02000000 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "OfferCancel", ttOFFER_CANCEL, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(OfferSequence), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x02000000 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
@@ -92,15 +99,6 @@ TransactionFormat InnerTxnFormats[]=
|
||||
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x02000000 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "TransitSet", ttTRANSIT_SET, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(TransitRate), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(TransitStart), STI_UINT32, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(TransitExpire), STI_UINT32, SOE_IFFLAG, 4 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 8 },
|
||||
{ S_FIELD(Extensions), STI_TL, SOE_IFFLAG, 0x02000000 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "WalletAdd", ttWALLET_ADD, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Amount), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
|
||||
@@ -13,10 +13,10 @@ enum TransactionType
|
||||
ttPASSWORD_FUND = 4,
|
||||
ttPASSWORD_SET = 5,
|
||||
ttNICKNAME_SET = 6,
|
||||
ttOFFER_CREATE = 7,
|
||||
ttOFFER_CANCEL = 8,
|
||||
ttCREDIT_SET = 20,
|
||||
ttTRANSIT_SET = 21,
|
||||
ttINVOICE = 10,
|
||||
ttOFFER = 11,
|
||||
};
|
||||
|
||||
struct TransactionFormat
|
||||
@@ -39,6 +39,8 @@ const int TransactionMaxLen = 1048576;
|
||||
const uint32 tfCreateAccount = 0x00010000;
|
||||
const uint32 tfNoRippleDirect = 0x00020000;
|
||||
|
||||
const uint32 tfPassive = 0x00010000;
|
||||
|
||||
const uint32 tfUnsetEmailHash = 0x00010000;
|
||||
const uint32 tfUnsetWalletLocator = 0x00020000;
|
||||
|
||||
|
||||
@@ -1,26 +1,30 @@
|
||||
|
||||
#ifndef __VERSIONS__
|
||||
#define __VERSIONS__
|
||||
//
|
||||
// Versions
|
||||
|
||||
#ifndef SERVER_VERSION_MAJOR
|
||||
//
|
||||
|
||||
#define SERVER_VERSION_MAJOR 0
|
||||
#define SERVER_VERSION_MINOR 2
|
||||
#define SERVER_VERSION_SUB "-a"
|
||||
#define SERVER_NAME "NewCoin"
|
||||
|
||||
#define SV_STRINGIZE(x) SV_STRINGIZE2(x)
|
||||
#define SV_STRINGIZE2(x) #x
|
||||
#define SERVER_VERSION \
|
||||
#define SV_STRINGIZE(x) SV_STRINGIZE2(x)
|
||||
#define SV_STRINGIZE2(x) #x
|
||||
#define SERVER_VERSION \
|
||||
(SERVER_NAME "-" SV_STRINGIZE(SERVER_VERSION_MAJOR) "." SV_STRINGIZE(SERVER_VERSION_MINOR) SERVER_VERSION_SUB)
|
||||
|
||||
#define PROTO_VERSION_MAJOR 0
|
||||
#define PROTO_VERSION_MINOR 2
|
||||
// Version we prefer to speak:
|
||||
#define PROTO_VERSION_MAJOR 0
|
||||
#define PROTO_VERSION_MINOR 2
|
||||
|
||||
#define MIN_PROTO_MAJOR 0
|
||||
#define MIN_PROTO_MINOR 2
|
||||
// Version we wil speak to:
|
||||
#define MIN_PROTO_MAJOR 0
|
||||
#define MIN_PROTO_MINOR 2
|
||||
|
||||
#define MAKE_VERSION_INT(maj,min) ((maj << 16) | min)
|
||||
#define GET_VERSION_MAJOR(ver) (ver >> 16)
|
||||
#define GET_VERSION_MINOR(ver) (ver & 0xff)
|
||||
|
||||
#endif
|
||||
// vim:ts=4
|
||||
|
||||
@@ -41,11 +41,9 @@ void printHelp(const po::options_description& desc)
|
||||
cout << " account_email_set <seed> <paying_account> [<email_address>]" << endl;
|
||||
cout << " account_info <account>|<nickname>" << endl;
|
||||
cout << " account_info <seed>|<pass_phrase>|<key> [<index>]" << endl;
|
||||
cout << " account_lines <account>|<nickname>" << endl;
|
||||
cout << " account_message_set <seed> <paying_account> <pub_key>" << endl;
|
||||
cout << " account_wallet_set <seed> <paying_account> [<wallet_hash>]" << endl;
|
||||
cout << " connect <ip> [<port>]" << endl;
|
||||
cout << " credit_set <seed> <paying_account> <destination_account> <limit_amount> <currency> [<account_rate>]" << endl;
|
||||
cout << " data_delete <key>" << endl;
|
||||
cout << " data_fetch <key>" << endl;
|
||||
cout << " data_store <key> <value>" << endl;
|
||||
@@ -55,9 +53,10 @@ void printHelp(const po::options_description& desc)
|
||||
cout << " password_fund <seed> <paying_account> [<account>]" << endl;
|
||||
cout << " password_set <master_seed> <regular_seed> [<account>]" << endl;
|
||||
cout << " peers" << endl;
|
||||
cout << " ripple_lines_get <account>|<nickname>|<account_public_key> [<index>]" << endl;
|
||||
cout << " ripple_line_set <seed> <paying_account> <destination_account> <limit_amount> <currency> [<account_rate>]" << endl;
|
||||
cout << " send <seed> <paying_account> <account_id> <amount> [<currency>] [<send_max>] [<send_currency>]" << endl;
|
||||
cout << " stop" << endl;
|
||||
cout << " transit_set <seed> <paying_account> <transit_rate> <starts> <expires>" << endl;
|
||||
cout << " tx <id>" << endl;
|
||||
cout << " unl_add <domain>|<public> [<comment>]" << endl;
|
||||
cout << " unl_delete <domain>|<public_key>" << endl;
|
||||
|
||||
@@ -138,6 +138,20 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
base_uint& operator+=(const base_uint& b)
|
||||
{
|
||||
uint64 carry = 0;
|
||||
|
||||
for (int i = 0; i < WIDTH; i++)
|
||||
{
|
||||
uint64 n = carry + pn[i] + b.pn[i];
|
||||
pn[i] = n & 0xffffffff;
|
||||
carry = n >> 32;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::size_t hash_combine(std::size_t& seed) const
|
||||
{
|
||||
for (int i = 0; i < WIDTH; ++i)
|
||||
|
||||
Reference in New Issue
Block a user