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:
@@ -17,7 +17,7 @@ AccountState::AccountState(const NewcoinAddress& naAccountID) : mAccountID(naAcc
|
||||
|
||||
mLedgerEntry = boost::make_shared<SerializedLedgerEntry>(ltACCOUNT_ROOT);
|
||||
mLedgerEntry->setIndex(Ledger::getAccountRootIndex(naAccountID));
|
||||
mLedgerEntry->setIFieldAccount(sfAccount, naAccountID.getAccountID());
|
||||
mLedgerEntry->setFieldAccount(sfAccount, naAccountID.getAccountID());
|
||||
|
||||
mValid = true;
|
||||
}
|
||||
@@ -48,8 +48,8 @@ void AccountState::addJson(Json::Value& val)
|
||||
|
||||
if (mValid)
|
||||
{
|
||||
if (mLedgerEntry->getIFieldPresent(sfEmailHash))
|
||||
val["UrlGravatar"] = createGravatarUrl(mLedgerEntry->getIFieldH128(sfEmailHash));
|
||||
if (mLedgerEntry->isFieldPresent(sfEmailHash))
|
||||
val["UrlGravatar"] = createGravatarUrl(mLedgerEntry->getFieldH128(sfEmailHash));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -33,16 +33,16 @@ public:
|
||||
|
||||
bool bHaveAuthorizedKey()
|
||||
{
|
||||
return mLedgerEntry->getIFieldPresent(sfAuthorizedKey);
|
||||
return mLedgerEntry->isFieldPresent(sfAuthorizedKey);
|
||||
}
|
||||
|
||||
NewcoinAddress getAuthorizedKey()
|
||||
{
|
||||
return mLedgerEntry->getIValueFieldAccount(sfAuthorizedKey);
|
||||
return mLedgerEntry->getFieldAccount(sfAuthorizedKey);
|
||||
}
|
||||
|
||||
STAmount getBalance() const { return mLedgerEntry->getIValueFieldAmount(sfBalance); }
|
||||
uint32 getSeq() const { return mLedgerEntry->getIFieldU32(sfSequence); }
|
||||
STAmount getBalance() const { return mLedgerEntry->getFieldAmount(sfBalance); }
|
||||
uint32 getSeq() const { return mLedgerEntry->getFieldU32(sfSequence); }
|
||||
|
||||
SerializedLedgerEntry::pointer getSLE() { return mLedgerEntry; }
|
||||
const SerializedLedgerEntry& peekSLE() const { return *mLedgerEntry; }
|
||||
|
||||
@@ -299,18 +299,11 @@ void STAmount::add(Serializer& s) const
|
||||
}
|
||||
}
|
||||
|
||||
STAmount::STAmount(const char* name, int64 value) : SerializedType(name), mOffset(0), mIsNative(true)
|
||||
STAmount STAmount::createFromInt64(SField::ref name, int64 value)
|
||||
{
|
||||
if (value >= 0)
|
||||
{
|
||||
mIsNegative = false;
|
||||
mValue = static_cast<uint64>(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
mIsNegative = true;
|
||||
mValue = static_cast<uint64>(-value);
|
||||
}
|
||||
return value >= 0
|
||||
? STAmount(name, static_cast<uint64>(value), false)
|
||||
: STAmount(name, static_cast<uint64>(-value), true);
|
||||
}
|
||||
|
||||
void STAmount::setValue(const STAmount &a)
|
||||
@@ -325,13 +318,14 @@ void STAmount::setValue(const STAmount &a)
|
||||
|
||||
uint64 STAmount::toUInt64() const
|
||||
{ // makes them sort easily
|
||||
if (mValue == 0) return 0x4000000000000000ull;
|
||||
if (mValue == 0)
|
||||
return 0x4000000000000000ull;
|
||||
if (mIsNegative)
|
||||
return mValue | (static_cast<uint64>(mOffset + 97) << (64 - 10));
|
||||
return mValue | (static_cast<uint64>(mOffset + 256 + 97) << (64 - 10));
|
||||
}
|
||||
|
||||
STAmount* STAmount::construct(SerializerIterator& sit, const char *name)
|
||||
STAmount* STAmount::construct(SerializerIterator& sit, SField::ref name)
|
||||
{
|
||||
uint64 value = sit.get64();
|
||||
|
||||
@@ -351,8 +345,6 @@ STAmount* STAmount::construct(SerializerIterator& sit, const char *name)
|
||||
int offset = static_cast<int>(value >> (64 - 10)); // 10 bits for the offset, sign and "not native" flag
|
||||
value &= ~(1023ull << (64-10));
|
||||
|
||||
STAmount* sapResult;
|
||||
|
||||
if (value)
|
||||
{
|
||||
bool isNegative = (offset & 256) == 0;
|
||||
@@ -360,17 +352,12 @@ STAmount* STAmount::construct(SerializerIterator& sit, const char *name)
|
||||
if ((value < cMinValue) || (value > cMaxValue) || (offset < cMinOffset) || (offset > cMaxOffset))
|
||||
throw std::runtime_error("invalid currency value");
|
||||
|
||||
sapResult = new STAmount(name, uCurrencyID, uIssuerID, value, offset, isNegative);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (offset != 512)
|
||||
throw std::runtime_error("invalid currency value");
|
||||
|
||||
sapResult = new STAmount(name, uCurrencyID, uIssuerID);
|
||||
return new STAmount(name, uCurrencyID, uIssuerID, value, offset, isNegative);
|
||||
}
|
||||
|
||||
return sapResult;
|
||||
if (offset != 512)
|
||||
throw std::runtime_error("invalid currency value");
|
||||
return new STAmount(name, uCurrencyID, uIssuerID);
|
||||
}
|
||||
|
||||
int64 STAmount::getSNValue() const
|
||||
@@ -520,7 +507,7 @@ STAmount& STAmount::operator-=(const STAmount& a)
|
||||
STAmount STAmount::operator-(void) const
|
||||
{
|
||||
if (mValue == 0) return *this;
|
||||
return STAmount(name, mCurrency, mIssuer, mValue, mOffset, mIsNative, !mIsNegative);
|
||||
return STAmount(getFName(), mCurrency, mIssuer, mValue, mOffset, mIsNative, !mIsNegative);
|
||||
}
|
||||
|
||||
STAmount& STAmount::operator=(uint64 v)
|
||||
@@ -573,12 +560,12 @@ bool STAmount::operator>=(uint64 v) const
|
||||
|
||||
STAmount STAmount::operator+(uint64 v) const
|
||||
{
|
||||
return STAmount(name, getSNValue() + static_cast<int64>(v));
|
||||
return STAmount(getFName(), getSNValue() + static_cast<int64>(v));
|
||||
}
|
||||
|
||||
STAmount STAmount::operator-(uint64 v) const
|
||||
{
|
||||
return STAmount(name, getSNValue() - static_cast<int64>(v));
|
||||
return STAmount(getFName(), getSNValue() - static_cast<int64>(v));
|
||||
}
|
||||
|
||||
STAmount::operator double() const
|
||||
@@ -596,7 +583,7 @@ STAmount operator+(const STAmount& v1, const STAmount& v2)
|
||||
|
||||
v1.throwComparable(v2);
|
||||
if (v1.mIsNative)
|
||||
return STAmount(v1.name, v1.getSNValue() + v2.getSNValue());
|
||||
return STAmount(v1.getFName(), v1.getSNValue() + v2.getSNValue());
|
||||
|
||||
|
||||
int ov1 = v1.mOffset, ov2 = v2.mOffset;
|
||||
@@ -618,9 +605,9 @@ STAmount operator+(const STAmount& v1, const STAmount& v2)
|
||||
|
||||
int64 fv = vv1 + vv2;
|
||||
if (fv >= 0)
|
||||
return STAmount(v1.name, v1.mCurrency, v1.mIssuer, fv, ov1, false);
|
||||
return STAmount(v1.getFName(), v1.mCurrency, v1.mIssuer, fv, ov1, false);
|
||||
else
|
||||
return STAmount(v1.name, v1.mCurrency, v1.mIssuer, -fv, ov1, true);
|
||||
return STAmount(v1.getFName(), v1.mCurrency, v1.mIssuer, -fv, ov1, true);
|
||||
}
|
||||
|
||||
STAmount operator-(const STAmount& v1, const STAmount& v2)
|
||||
@@ -629,7 +616,10 @@ STAmount operator-(const STAmount& v1, const STAmount& v2)
|
||||
|
||||
v1.throwComparable(v2);
|
||||
if (v2.mIsNative)
|
||||
return STAmount(v1.name, v1.getSNValue() - v2.getSNValue());
|
||||
{
|
||||
// XXX This could be better, check for overflow and that maximum range is covered.
|
||||
return STAmount::createFromInt64(v1.getFName(), v1.getSNValue() - v2.getSNValue());
|
||||
}
|
||||
|
||||
int ov1 = v1.mOffset, ov2 = v2.mOffset;
|
||||
int64 vv1 = static_cast<int64>(v1.mValue), vv2 = static_cast<int64>(v2.mValue);
|
||||
@@ -650,9 +640,9 @@ STAmount operator-(const STAmount& v1, const STAmount& v2)
|
||||
|
||||
int64 fv = vv1 - vv2;
|
||||
if (fv >= 0)
|
||||
return STAmount(v1.name, v1.mCurrency, v1.mIssuer, fv, ov1, false);
|
||||
return STAmount(v1.getFName(), v1.mCurrency, v1.mIssuer, fv, ov1, false);
|
||||
else
|
||||
return STAmount(v1.name, v1.mCurrency, v1.mIssuer, -fv, ov1, true);
|
||||
return STAmount(v1.getFName(), v1.mCurrency, v1.mIssuer, -fv, ov1, true);
|
||||
}
|
||||
|
||||
STAmount STAmount::divide(const STAmount& num, const STAmount& den, const uint160& uCurrencyID, const uint160& uIssuerID)
|
||||
@@ -704,7 +694,7 @@ STAmount STAmount::multiply(const STAmount& v1, const STAmount& v2, const uint16
|
||||
return STAmount(uCurrencyID, uIssuerID);
|
||||
|
||||
if (v1.mIsNative && v2.mIsNative) // FIXME: overflow
|
||||
return STAmount(v1.name, v1.getSNValue() * v2.getSNValue());
|
||||
return STAmount(v1.getFName(), v1.getSNValue() * v2.getSNValue());
|
||||
|
||||
uint64 value1 = v1.mValue, value2 = v2.mValue;
|
||||
int offset1 = v1.mOffset, offset2 = v2.mOffset;
|
||||
@@ -883,19 +873,15 @@ uint64 STAmount::convertToDisplayAmount(const STAmount& internalAmount, uint64 t
|
||||
return muldiv(internalAmount.getNValue(), totalInit, totalNow);
|
||||
}
|
||||
|
||||
STAmount STAmount::convertToInternalAmount(uint64 displayAmount, uint64 totalNow, uint64 totalInit,
|
||||
const char *name)
|
||||
STAmount STAmount::convertToInternalAmount(uint64 displayAmount, uint64 totalNow, uint64 totalInit, SField::ref name)
|
||||
{ // Convert a display/request currency amount to an internal amount
|
||||
return STAmount(name, muldiv(displayAmount, totalNow, totalInit));
|
||||
}
|
||||
|
||||
STAmount STAmount::deserialize(SerializerIterator& it)
|
||||
{
|
||||
STAmount *s = construct(it);
|
||||
std::auto_ptr<STAmount> s(dynamic_cast<STAmount*>(construct(it, sfGeneric)));
|
||||
STAmount ret(*s);
|
||||
|
||||
delete s;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,97 @@
|
||||
|
||||
#include "FieldNames.h"
|
||||
|
||||
#define FIELD(name, type, index) { sf##name, #name, STI_##type, index },
|
||||
#include <map>
|
||||
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
|
||||
// These must stay at the top of this file
|
||||
std::map<int, SField::ptr> SField::codeToField;
|
||||
boost::mutex SField::mapMutex;
|
||||
|
||||
SField sfInvalid(-1), sfGeneric(0);
|
||||
SField sfLedgerEntry(FIELD_CODE(STI_LEDGERENTRY, 1), STI_LEDGERENTRY, 1, "LedgerEntry");
|
||||
SField sfTransaction(FIELD_CODE(STI_TRANSACTION, 1), STI_TRANSACTION, 1, "Transaction");
|
||||
SField sfValidation(FIELD_CODE(STI_VALIDATION, 1), STI_VALIDATION, 1, "Validation");
|
||||
|
||||
#define FIELD(name, type, index) SField sf##name(FIELD_CODE(STI_##type, index), STI_##type, index, #name);
|
||||
#define TYPE(name, type, index)
|
||||
|
||||
FieldName FieldNames[]=
|
||||
{
|
||||
#include "SerializeProto.h"
|
||||
};
|
||||
|
||||
#undef FIELD
|
||||
#undef TYPE
|
||||
|
||||
|
||||
SField::ref SField::getField(int code)
|
||||
{
|
||||
int type = code >> 16;
|
||||
int field = code % 0xffff;
|
||||
|
||||
if ((type <= 0) || (type >= 256) || (field <= 0) || (field >= 256))
|
||||
return sfInvalid;
|
||||
|
||||
boost::mutex::scoped_lock sl(mapMutex);
|
||||
|
||||
std::map<int, SField::ptr>::iterator it = codeToField.find(code);
|
||||
if (it != codeToField.end())
|
||||
return *(it->second);
|
||||
|
||||
switch (type)
|
||||
{ // types we are willing to dynamically extend
|
||||
|
||||
#define FIELD(name, type, index)
|
||||
#define TYPE(name, type, index) case STI_##type:
|
||||
#include "SerializeProto.h"
|
||||
#undef FIELD
|
||||
#undef TYPE
|
||||
|
||||
break;
|
||||
default:
|
||||
return sfInvalid;
|
||||
}
|
||||
|
||||
return *(new SField(code, static_cast<SerializedTypeID>(type), field, NULL));
|
||||
}
|
||||
|
||||
int SField::compare(SField::ref f1, SField::ref f2)
|
||||
{ // -1 = f1 comes before f2, 0 = illegal combination, 1 = f1 comes after f2
|
||||
if ((f1.fieldCode <= 0) || (f2.fieldCode <= 0))
|
||||
return 0;
|
||||
|
||||
if (f1.fieldCode < f2.fieldCode)
|
||||
return -1;
|
||||
|
||||
if (f2.fieldCode < f1.fieldCode)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SField::ref SField::getField(int type, int value)
|
||||
{
|
||||
return getField(FIELD_CODE(type, value));
|
||||
}
|
||||
|
||||
std::string SField::getName() const
|
||||
{
|
||||
if (!fieldName.empty())
|
||||
return fieldName;
|
||||
if (fieldValue == 0)
|
||||
return "";
|
||||
return boost::lexical_cast<std::string>(static_cast<int>(fieldType)) + "/" +
|
||||
boost::lexical_cast<std::string>(fieldValue);
|
||||
}
|
||||
|
||||
SField::ref SField::getField(const std::string& fieldName)
|
||||
{ // OPTIMIZEME me with a map. CHECKME this is case sensitive
|
||||
boost::mutex::scoped_lock sl(mapMutex);
|
||||
typedef std::pair<const int, SField::ptr> int_sfref_pair;
|
||||
BOOST_FOREACH(const int_sfref_pair& fieldPair, codeToField)
|
||||
{
|
||||
if (fieldPair.second->fieldName == fieldName)
|
||||
return *(fieldPair.second);
|
||||
}
|
||||
return sfInvalid;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,85 @@
|
||||
#ifndef __FIELDNAMES__
|
||||
#define __FIELDNAMES__
|
||||
|
||||
#include "SerializedTypes.h"
|
||||
#include "SerializedObject.h"
|
||||
#include <string>
|
||||
|
||||
struct FieldName
|
||||
#include <boost/thread/mutex.hpp>
|
||||
|
||||
#define FIELD_CODE(type, index) ((static_cast<int>(type) << 16) | index)
|
||||
|
||||
enum SerializedTypeID
|
||||
{
|
||||
SOE_Field field;
|
||||
const char *fieldName;
|
||||
SerializedTypeID fieldType;
|
||||
int fieldValue;
|
||||
int fieldID;
|
||||
// special types
|
||||
STI_UNKNOWN = -2,
|
||||
STI_DONE = -1,
|
||||
STI_NOTPRESENT = 0,
|
||||
|
||||
#define TYPE(name, field, value) STI_##field = value,
|
||||
#define FIELD(name, field, value)
|
||||
#include "SerializeProto.h"
|
||||
#undef TYPE
|
||||
#undef FIELD
|
||||
|
||||
// high level types
|
||||
STI_TRANSACTION = 10001,
|
||||
STI_LEDGERENTRY = 10002,
|
||||
STI_VALIDATION = 10003,
|
||||
};
|
||||
|
||||
enum SOE_Flags
|
||||
{
|
||||
SOE_END = -1, // marks end of object
|
||||
SOE_REQUIRED = 0, // required
|
||||
SOE_OPTIONAL = 1, // optional
|
||||
};
|
||||
|
||||
class SField
|
||||
{
|
||||
public:
|
||||
typedef const SField& ref;
|
||||
typedef SField const * ptr;
|
||||
|
||||
protected:
|
||||
static std::map<int, ptr> codeToField;
|
||||
static boost::mutex mapMutex;
|
||||
|
||||
public:
|
||||
|
||||
const int fieldCode; // (type<<16)|index
|
||||
const SerializedTypeID fieldType; // STI_*
|
||||
const int fieldValue; // Code number for protocol
|
||||
std::string fieldName;
|
||||
|
||||
SField(int fc, SerializedTypeID tid, int fv, const char* fn) :
|
||||
fieldCode(fc), fieldType(tid), fieldValue(fv), fieldName(fn)
|
||||
{ codeToField[fc] = this; }
|
||||
|
||||
SField(int fc) : fieldCode(fc), fieldType(STI_UNKNOWN), fieldValue(0) { ; }
|
||||
|
||||
static SField::ref getField(int fieldCode);
|
||||
static SField::ref getField(int fieldType, int fieldValue);
|
||||
static SField::ref getField(const std::string& fieldName);
|
||||
static SField::ref getField(SerializedTypeID type, int value) { return getField(FIELD_CODE(type, value)); }
|
||||
|
||||
std::string getName() const;
|
||||
bool hasName() const { return !fieldName.empty(); }
|
||||
|
||||
bool isGeneric() const { return fieldCode == 0; }
|
||||
bool isInvalid() const { return fieldCode == -1; }
|
||||
bool isKnown() const { return fieldType != STI_UNKNOWN; }
|
||||
|
||||
bool operator==(const SField& f) const { return fieldCode == f.fieldCode; }
|
||||
bool operator!=(const SField& f) const { return fieldCode != f.fieldCode; }
|
||||
|
||||
static int compare(SField::ref f1, SField::ref f2);
|
||||
};
|
||||
|
||||
extern SField sfInvalid, sfGeneric, sfLedgerEntry, sfTransaction, sfValidation;
|
||||
|
||||
#define FIELD(name, type, index) extern SField sf##name;
|
||||
#define TYPE(name, type, index)
|
||||
#include "SerializeProto.h"
|
||||
#undef FIELD
|
||||
#undef TYPE
|
||||
|
||||
#endif
|
||||
|
||||
@@ -27,8 +27,8 @@ Ledger::Ledger(const NewcoinAddress& masterID, uint64 startAmount) : mTotCoins(s
|
||||
{
|
||||
// special case: put coins in root account
|
||||
AccountState::pointer startAccount = boost::make_shared<AccountState>(masterID);
|
||||
startAccount->peekSLE().setIFieldAmount(sfBalance, startAmount);
|
||||
startAccount->peekSLE().setIFieldU32(sfSequence, 1);
|
||||
startAccount->peekSLE().setFieldAmount(sfBalance, startAmount);
|
||||
startAccount->peekSLE().setFieldU32(sfSequence, 1);
|
||||
writeBack(lepCREATE, startAccount->getSLE());
|
||||
#if 0
|
||||
std::cerr << "Root account:";
|
||||
|
||||
@@ -977,21 +977,23 @@ void LedgerConsensus::applyTransaction(TransactionEngine& engine, const Serializ
|
||||
{
|
||||
#endif
|
||||
TER result = engine.applyTransaction(*txn, parms);
|
||||
if (result > 0)
|
||||
if (isTerRetry(result))
|
||||
{
|
||||
Log(lsINFO) << " retry";
|
||||
assert(!ledger->hasTransaction(txn->getTransactionID()));
|
||||
failedTransactions.push_back(txn);
|
||||
}
|
||||
else if (result == 0)
|
||||
else if (isTepSuccess(result)) // FIXME: Need to do partial success
|
||||
{
|
||||
Log(lsTRACE) << " success";
|
||||
assert(ledger->hasTransaction(txn->getTransactionID()));
|
||||
}
|
||||
else
|
||||
else if (isTemMalformed(result) || isTefFailure(result))
|
||||
{
|
||||
Log(lsINFO) << " hard fail";
|
||||
}
|
||||
else
|
||||
assert(false);
|
||||
#ifndef TRUST_NETWORK
|
||||
}
|
||||
catch (...)
|
||||
|
||||
@@ -383,28 +383,28 @@ void LedgerEntrySet::calcRawMeta(Serializer& s)
|
||||
assert(origNode);
|
||||
threadOwners(origNode, mLedger, newMod);
|
||||
|
||||
if (origNode->getIFieldPresent(sfAmount))
|
||||
if (origNode->isFieldPresent(sfAmount))
|
||||
{ // node has an amount, covers ripple state nodes
|
||||
STAmount amount = origNode->getIValueFieldAmount(sfAmount);
|
||||
STAmount amount = origNode->getFieldAmount(sfAmount);
|
||||
if (amount.isNonZero())
|
||||
metaNode.addAmount(TMSPrevBalance, amount);
|
||||
amount = curNode->getIValueFieldAmount(sfAmount);
|
||||
amount = curNode->getFieldAmount(sfAmount);
|
||||
if (amount.isNonZero())
|
||||
metaNode.addAmount(TMSFinalBalance, amount);
|
||||
|
||||
if (origNode->getType() == ltRIPPLE_STATE)
|
||||
{
|
||||
metaNode.addAccount(TMSLowID, NewcoinAddress::createAccountID(origNode->getIValueFieldAmount(sfLowLimit).getIssuer()));
|
||||
metaNode.addAccount(TMSHighID, NewcoinAddress::createAccountID(origNode->getIValueFieldAmount(sfHighLimit).getIssuer()));
|
||||
metaNode.addAccount(TMSLowID, NewcoinAddress::createAccountID(origNode->getFieldAmount(sfLowLimit).getIssuer()));
|
||||
metaNode.addAccount(TMSHighID, NewcoinAddress::createAccountID(origNode->getFieldAmount(sfHighLimit).getIssuer()));
|
||||
}
|
||||
}
|
||||
|
||||
if (origNode->getType() == ltOFFER)
|
||||
{ // check for non-zero balances
|
||||
STAmount amount = origNode->getIValueFieldAmount(sfTakerPays);
|
||||
STAmount amount = origNode->getFieldAmount(sfTakerPays);
|
||||
if (amount.isNonZero())
|
||||
metaNode.addAmount(TMSFinalTakerPays, amount);
|
||||
amount = origNode->getIValueFieldAmount(sfTakerGets);
|
||||
amount = origNode->getFieldAmount(sfTakerGets);
|
||||
if (amount.isNonZero())
|
||||
metaNode.addAmount(TMSFinalTakerGets, amount);
|
||||
}
|
||||
@@ -429,20 +429,20 @@ void LedgerEntrySet::calcRawMeta(Serializer& s)
|
||||
if (nType == TMNModifiedNode)
|
||||
{
|
||||
assert(origNode);
|
||||
if (origNode->getIFieldPresent(sfAmount))
|
||||
if (origNode->isFieldPresent(sfAmount))
|
||||
{ // node has an amount, covers account root nodes and ripple nodes
|
||||
STAmount amount = origNode->getIValueFieldAmount(sfAmount);
|
||||
if (amount != curNode->getIValueFieldAmount(sfAmount))
|
||||
STAmount amount = origNode->getFieldAmount(sfAmount);
|
||||
if (amount != curNode->getFieldAmount(sfAmount))
|
||||
metaNode.addAmount(TMSPrevBalance, amount);
|
||||
}
|
||||
|
||||
if (origNode->getType() == ltOFFER)
|
||||
{
|
||||
STAmount amount = origNode->getIValueFieldAmount(sfTakerPays);
|
||||
if (amount != curNode->getIValueFieldAmount(sfTakerPays))
|
||||
STAmount amount = origNode->getFieldAmount(sfTakerPays);
|
||||
if (amount != curNode->getFieldAmount(sfTakerPays))
|
||||
metaNode.addAmount(TMSPrevTakerPays, amount);
|
||||
amount = origNode->getIValueFieldAmount(sfTakerGets);
|
||||
if (amount != curNode->getIValueFieldAmount(sfTakerGets))
|
||||
amount = origNode->getFieldAmount(sfTakerGets);
|
||||
if (amount != curNode->getFieldAmount(sfTakerGets))
|
||||
metaNode.addAmount(TMSPrevTakerGets, amount);
|
||||
}
|
||||
|
||||
@@ -485,7 +485,7 @@ TER LedgerEntrySet::dirAdd(
|
||||
}
|
||||
else
|
||||
{
|
||||
uNodeDir = sleRoot->getIFieldU64(sfIndexPrevious); // Get index to last directory node.
|
||||
uNodeDir = sleRoot->getFieldU64(sfIndexPrevious); // Get index to last directory node.
|
||||
|
||||
if (uNodeDir)
|
||||
{
|
||||
@@ -500,7 +500,7 @@ TER LedgerEntrySet::dirAdd(
|
||||
sleNode = sleRoot;
|
||||
}
|
||||
|
||||
svIndexes = sleNode->getIFieldV256(sfIndexes);
|
||||
svIndexes = sleNode->getFieldV256(sfIndexes);
|
||||
|
||||
if (DIR_NODE_MAX != svIndexes.peekValue().size())
|
||||
{
|
||||
@@ -519,7 +519,7 @@ TER LedgerEntrySet::dirAdd(
|
||||
{
|
||||
// Previous node is root node.
|
||||
|
||||
sleRoot->setIFieldU64(sfIndexNext, uNodeDir);
|
||||
sleRoot->setFieldU64(sfIndexNext, uNodeDir);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -527,14 +527,14 @@ TER LedgerEntrySet::dirAdd(
|
||||
|
||||
SLE::pointer slePrevious = entryCache(ltDIR_NODE, Ledger::getDirNodeIndex(uRootIndex, uNodeDir-1));
|
||||
|
||||
slePrevious->setIFieldU64(sfIndexNext, uNodeDir);
|
||||
slePrevious->setFieldU64(sfIndexNext, uNodeDir);
|
||||
entryModify(slePrevious);
|
||||
|
||||
sleNode->setIFieldU64(sfIndexPrevious, uNodeDir-1);
|
||||
sleNode->setFieldU64(sfIndexPrevious, uNodeDir-1);
|
||||
}
|
||||
|
||||
// Have root point to new node.
|
||||
sleRoot->setIFieldU64(sfIndexPrevious, uNodeDir);
|
||||
sleRoot->setFieldU64(sfIndexPrevious, uNodeDir);
|
||||
entryModify(sleRoot);
|
||||
|
||||
// Create the new node.
|
||||
@@ -544,7 +544,7 @@ TER LedgerEntrySet::dirAdd(
|
||||
}
|
||||
|
||||
svIndexes.peekValue().push_back(uLedgerIndex); // Append entry.
|
||||
sleNode->setIFieldV256(sfIndexes, svIndexes); // Save entry.
|
||||
sleNode->setFieldV256(sfIndexes, svIndexes); // Save entry.
|
||||
|
||||
Log(lsINFO) << "dirAdd: creating: root: " << uRootIndex.ToString();
|
||||
Log(lsINFO) << "dirAdd: appending: Entry: " << uLedgerIndex.ToString();
|
||||
@@ -574,7 +574,7 @@ TER LedgerEntrySet::dirDelete(
|
||||
return tefBAD_LEDGER;
|
||||
}
|
||||
|
||||
STVector256 svIndexes = sleNode->getIFieldV256(sfIndexes);
|
||||
STVector256 svIndexes = sleNode->getFieldV256(sfIndexes);
|
||||
std::vector<uint256>& vuiIndexes = svIndexes.peekValue();
|
||||
std::vector<uint256>::iterator it;
|
||||
|
||||
@@ -608,14 +608,14 @@ TER LedgerEntrySet::dirDelete(
|
||||
vuiIndexes.clear();
|
||||
}
|
||||
|
||||
sleNode->setIFieldV256(sfIndexes, svIndexes);
|
||||
sleNode->setFieldV256(sfIndexes, svIndexes);
|
||||
entryModify(sleNode);
|
||||
|
||||
if (vuiIndexes.empty())
|
||||
{
|
||||
// May be able to delete nodes.
|
||||
uint64 uNodePrevious = sleNode->getIFieldU64(sfIndexPrevious);
|
||||
uint64 uNodeNext = sleNode->getIFieldU64(sfIndexNext);
|
||||
uint64 uNodePrevious = sleNode->getFieldU64(sfIndexPrevious);
|
||||
uint64 uNodeNext = sleNode->getFieldU64(sfIndexNext);
|
||||
|
||||
if (!uNodeCur)
|
||||
{
|
||||
@@ -646,7 +646,7 @@ TER LedgerEntrySet::dirDelete(
|
||||
|
||||
assert(sleLast);
|
||||
|
||||
if (sleLast->getIFieldV256(sfIndexes).peekValue().empty())
|
||||
if (sleLast->getFieldV256(sfIndexes).peekValue().empty())
|
||||
{
|
||||
// Both nodes are empty.
|
||||
|
||||
@@ -690,11 +690,11 @@ TER LedgerEntrySet::dirDelete(
|
||||
}
|
||||
|
||||
// Fix previous to point to its new next.
|
||||
slePrevious->setIFieldU64(sfIndexNext, uNodeNext);
|
||||
slePrevious->setFieldU64(sfIndexNext, uNodeNext);
|
||||
entryModify(slePrevious);
|
||||
|
||||
// Fix next to point to its new previous.
|
||||
sleNext->setIFieldU64(sfIndexPrevious, uNodePrevious);
|
||||
sleNext->setFieldU64(sfIndexPrevious, uNodePrevious);
|
||||
entryModify(sleNext);
|
||||
}
|
||||
// Last node.
|
||||
@@ -712,7 +712,7 @@ TER LedgerEntrySet::dirDelete(
|
||||
|
||||
assert(sleRoot);
|
||||
|
||||
if (sleRoot->getIFieldV256(sfIndexes).peekValue().empty())
|
||||
if (sleRoot->getFieldV256(sfIndexes).peekValue().empty())
|
||||
{
|
||||
// Both nodes are empty.
|
||||
|
||||
@@ -755,12 +755,12 @@ bool LedgerEntrySet::dirNext(
|
||||
unsigned int& uDirEntry, // <-> next entry
|
||||
uint256& uEntryIndex) // <-- The entry, if available. Otherwise, zero.
|
||||
{
|
||||
STVector256 svIndexes = sleNode->getIFieldV256(sfIndexes);
|
||||
STVector256 svIndexes = sleNode->getFieldV256(sfIndexes);
|
||||
std::vector<uint256>& vuiIndexes = svIndexes.peekValue();
|
||||
|
||||
if (uDirEntry == vuiIndexes.size())
|
||||
{
|
||||
uint64 uNodeNext = sleNode->getIFieldU64(sfIndexNext);
|
||||
uint64 uNodeNext = sleNode->getFieldU64(sfIndexNext);
|
||||
|
||||
if (!uNodeNext)
|
||||
{
|
||||
@@ -785,13 +785,13 @@ Log(lsINFO) << boost::str(boost::format("dirNext: uDirEntry=%d uEntryIndex=%s")
|
||||
|
||||
TER LedgerEntrySet::offerDelete(const SLE::pointer& sleOffer, const uint256& uOfferIndex, const uint160& uOwnerID)
|
||||
{
|
||||
uint64 uOwnerNode = sleOffer->getIFieldU64(sfOwnerNode);
|
||||
uint64 uOwnerNode = sleOffer->getFieldU64(sfOwnerNode);
|
||||
TER terResult = dirDelete(false, uOwnerNode, Ledger::getOwnerDirIndex(uOwnerID), uOfferIndex, false);
|
||||
|
||||
if (tesSUCCESS == terResult)
|
||||
{
|
||||
uint256 uDirectory = sleOffer->getIFieldH256(sfBookDirectory);
|
||||
uint64 uBookNode = sleOffer->getIFieldU64(sfBookNode);
|
||||
uint256 uDirectory = sleOffer->getFieldH256(sfBookDirectory);
|
||||
uint64 uBookNode = sleOffer->getFieldU64(sfBookNode);
|
||||
|
||||
terResult = dirDelete(false, uBookNode, uDirectory, uOfferIndex, true);
|
||||
}
|
||||
@@ -804,7 +804,7 @@ TER LedgerEntrySet::offerDelete(const SLE::pointer& sleOffer, const uint256& uOf
|
||||
TER LedgerEntrySet::offerDelete(const uint256& uOfferIndex)
|
||||
{
|
||||
SLE::pointer sleOffer = entryCache(ltOFFER, uOfferIndex);
|
||||
const uint160 uOwnerID = sleOffer->getIValueFieldAccount(sfAccount).getAccountID();
|
||||
const uint160 uOwnerID = sleOffer->getFieldAccount(sfAccount).getAccountID();
|
||||
|
||||
return offerDelete(sleOffer, uOfferIndex, uOwnerID);
|
||||
}
|
||||
@@ -818,7 +818,7 @@ STAmount LedgerEntrySet::rippleOwed(const uint160& uToAccountID, const uint160&
|
||||
|
||||
if (sleRippleState)
|
||||
{
|
||||
saBalance = sleRippleState->getIValueFieldAmount(sfBalance);
|
||||
saBalance = sleRippleState->getFieldAmount(sfBalance);
|
||||
if (uToAccountID < uFromAccountID)
|
||||
saBalance.negate();
|
||||
saBalance.setIssuer(uToAccountID);
|
||||
@@ -849,7 +849,7 @@ STAmount LedgerEntrySet::rippleLimit(const uint160& uToAccountID, const uint160&
|
||||
assert(sleRippleState);
|
||||
if (sleRippleState)
|
||||
{
|
||||
saLimit = sleRippleState->getIValueFieldAmount(uToAccountID < uFromAccountID ? sfLowLimit : sfHighLimit);
|
||||
saLimit = sleRippleState->getFieldAmount(uToAccountID < uFromAccountID ? sfLowLimit : sfHighLimit);
|
||||
saLimit.setIssuer(uToAccountID);
|
||||
}
|
||||
|
||||
@@ -861,8 +861,8 @@ uint32 LedgerEntrySet::rippleTransferRate(const uint160& uIssuerID)
|
||||
{
|
||||
SLE::pointer sleAccount = entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(uIssuerID));
|
||||
|
||||
uint32 uQuality = sleAccount && sleAccount->getIFieldPresent(sfTransferRate)
|
||||
? sleAccount->getIFieldU32(sfTransferRate)
|
||||
uint32 uQuality = sleAccount && sleAccount->isFieldPresent(sfTransferRate)
|
||||
? sleAccount->getFieldU32(sfTransferRate)
|
||||
: QUALITY_ONE;
|
||||
|
||||
Log(lsINFO) << boost::str(boost::format("rippleTransferRate: uIssuerID=%s account_exists=%d transfer_rate=%f")
|
||||
@@ -876,7 +876,7 @@ uint32 LedgerEntrySet::rippleTransferRate(const uint160& uIssuerID)
|
||||
}
|
||||
|
||||
// XXX Might not need this, might store in nodes on calc reverse.
|
||||
uint32 LedgerEntrySet::rippleQualityIn(const uint160& uToAccountID, const uint160& uFromAccountID, const uint160& uCurrencyID, const SOE_Field sfLow, const SOE_Field sfHigh)
|
||||
uint32 LedgerEntrySet::rippleQualityIn(const uint160& uToAccountID, const uint160& uFromAccountID, const uint160& uCurrencyID, SField::ref sfLow, SField::ref sfHigh)
|
||||
{
|
||||
uint32 uQuality = QUALITY_ONE;
|
||||
SLE::pointer sleRippleState;
|
||||
@@ -891,10 +891,10 @@ uint32 LedgerEntrySet::rippleQualityIn(const uint160& uToAccountID, const uint16
|
||||
|
||||
if (sleRippleState)
|
||||
{
|
||||
SOE_Field sfField = uToAccountID < uFromAccountID ? sfLow: sfHigh;
|
||||
SField::ref sfField = uToAccountID < uFromAccountID ? sfLow: sfHigh;
|
||||
|
||||
uQuality = sleRippleState->getIFieldPresent(sfField)
|
||||
? sleRippleState->getIFieldU32(sfField)
|
||||
uQuality = sleRippleState->isFieldPresent(sfField)
|
||||
? sleRippleState->getFieldU32(sfField)
|
||||
: QUALITY_ONE;
|
||||
|
||||
if (!uQuality)
|
||||
@@ -924,7 +924,7 @@ STAmount LedgerEntrySet::rippleHolds(const uint160& uAccountID, const uint160& u
|
||||
|
||||
if (sleRippleState)
|
||||
{
|
||||
saBalance = sleRippleState->getIValueFieldAmount(sfBalance);
|
||||
saBalance = sleRippleState->getFieldAmount(sfBalance);
|
||||
|
||||
if (uAccountID > uIssuerID)
|
||||
saBalance.negate(); // Put balance in uAccountID terms.
|
||||
@@ -942,7 +942,7 @@ STAmount LedgerEntrySet::accountHolds(const uint160& uAccountID, const uint160&
|
||||
{
|
||||
SLE::pointer sleAccount = entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(uAccountID));
|
||||
|
||||
saAmount = sleAccount->getIValueFieldAmount(sfBalance);
|
||||
saAmount = sleAccount->getFieldAmount(sfBalance);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1031,13 +1031,13 @@ void LedgerEntrySet::rippleCredit(const uint160& uSenderID, const uint160& uRece
|
||||
if (!bFlipped)
|
||||
saBalance.negate();
|
||||
|
||||
sleRippleState->setIFieldAmount(sfBalance, saBalance);
|
||||
sleRippleState->setIFieldAmount(bFlipped ? sfHighLimit : sfLowLimit, STAmount(uCurrencyID, uSenderID));
|
||||
sleRippleState->setIFieldAmount(bFlipped ? sfLowLimit : sfHighLimit, STAmount(uCurrencyID, uReceiverID));
|
||||
sleRippleState->setFieldAmount(sfBalance, saBalance);
|
||||
sleRippleState->setFieldAmount(bFlipped ? sfHighLimit : sfLowLimit, STAmount(uCurrencyID, uSenderID));
|
||||
sleRippleState->setFieldAmount(bFlipped ? sfLowLimit : sfHighLimit, STAmount(uCurrencyID, uReceiverID));
|
||||
}
|
||||
else
|
||||
{
|
||||
STAmount saBalance = sleRippleState->getIValueFieldAmount(sfBalance);
|
||||
STAmount saBalance = sleRippleState->getFieldAmount(sfBalance);
|
||||
|
||||
if (!bFlipped)
|
||||
saBalance.negate(); // Put balance in low terms.
|
||||
@@ -1047,7 +1047,7 @@ void LedgerEntrySet::rippleCredit(const uint160& uSenderID, const uint160& uRece
|
||||
if (!bFlipped)
|
||||
saBalance.negate();
|
||||
|
||||
sleRippleState->setIFieldAmount(sfBalance, saBalance);
|
||||
sleRippleState->setFieldAmount(sfBalance, saBalance);
|
||||
|
||||
entryModify(sleRippleState);
|
||||
}
|
||||
@@ -1106,28 +1106,28 @@ void LedgerEntrySet::accountSend(const uint160& uSenderID, const uint160& uRecei
|
||||
|
||||
Log(lsINFO) << boost::str(boost::format("accountSend> %s (%s) -> %s (%s) : %s")
|
||||
% NewcoinAddress::createHumanAccountID(uSenderID)
|
||||
% (sleSender ? (sleSender->getIValueFieldAmount(sfBalance)).getFullText() : "-")
|
||||
% (sleSender ? (sleSender->getFieldAmount(sfBalance)).getFullText() : "-")
|
||||
% NewcoinAddress::createHumanAccountID(uReceiverID)
|
||||
% (sleReceiver ? (sleReceiver->getIValueFieldAmount(sfBalance)).getFullText() : "-")
|
||||
% (sleReceiver ? (sleReceiver->getFieldAmount(sfBalance)).getFullText() : "-")
|
||||
% saAmount.getFullText());
|
||||
|
||||
if (sleSender)
|
||||
{
|
||||
sleSender->setIFieldAmount(sfBalance, sleSender->getIValueFieldAmount(sfBalance) - saAmount);
|
||||
sleSender->setFieldAmount(sfBalance, sleSender->getFieldAmount(sfBalance) - saAmount);
|
||||
entryModify(sleSender);
|
||||
}
|
||||
|
||||
if (sleReceiver)
|
||||
{
|
||||
sleReceiver->setIFieldAmount(sfBalance, sleReceiver->getIValueFieldAmount(sfBalance) + saAmount);
|
||||
sleReceiver->setFieldAmount(sfBalance, sleReceiver->getFieldAmount(sfBalance) + saAmount);
|
||||
entryModify(sleReceiver);
|
||||
}
|
||||
|
||||
Log(lsINFO) << boost::str(boost::format("accountSend< %s (%s) -> %s (%s) : %s")
|
||||
% NewcoinAddress::createHumanAccountID(uSenderID)
|
||||
% (sleSender ? (sleSender->getIValueFieldAmount(sfBalance)).getFullText() : "-")
|
||||
% (sleSender ? (sleSender->getFieldAmount(sfBalance)).getFullText() : "-")
|
||||
% NewcoinAddress::createHumanAccountID(uReceiverID)
|
||||
% (sleReceiver ? (sleReceiver->getIValueFieldAmount(sfBalance)).getFullText() : "-")
|
||||
% (sleReceiver ? (sleReceiver->getFieldAmount(sfBalance)).getFullText() : "-")
|
||||
% saAmount.getFullText());
|
||||
}
|
||||
else
|
||||
|
||||
@@ -104,7 +104,8 @@ public:
|
||||
uint32 rippleTransferRate(const uint160& uIssuerID);
|
||||
STAmount rippleOwed(const uint160& uToAccountID, const uint160& uFromAccountID, const uint160& uCurrencyID);
|
||||
STAmount rippleLimit(const uint160& uToAccountID, const uint160& uFromAccountID, const uint160& uCurrencyID);
|
||||
uint32 rippleQualityIn(const uint160& uToAccountID, const uint160& uFromAccountID, const uint160& uCurrencyID, const SOE_Field sfLow=sfLowQualityIn, const SOE_Field sfHigh=sfHighQualityIn);
|
||||
uint32 rippleQualityIn(const uint160& uToAccountID, const uint160& uFromAccountID, const uint160& uCurrencyID,
|
||||
SField::ref sfLow = sfLowQualityIn, SField::ref sfHigh = sfHighQualityIn);
|
||||
uint32 rippleQualityOut(const uint160& uToAccountID, const uint160& uFromAccountID, const uint160& uCurrencyID)
|
||||
{ return rippleQualityIn(uToAccountID, uFromAccountID, uCurrencyID, sfLowQualityOut, sfHighQualityOut); }
|
||||
|
||||
|
||||
@@ -1,100 +1,106 @@
|
||||
|
||||
#include "LedgerFormats.h"
|
||||
|
||||
#define S_FIELD(x) sf##x, #x
|
||||
#define LEF_BASE \
|
||||
{ sfLedgerIndex, SOE_OPTIONAL }, \
|
||||
{ sfLedgerEntryType, SOE_REQUIRED }, \
|
||||
{ sfFlags, SOE_REQUIRED },
|
||||
|
||||
LedgerEntryFormat LedgerFormats[]=
|
||||
{
|
||||
{ "AccountRoot", ltACCOUNT_ROOT, {
|
||||
{ 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(Balance), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(LastTxnID), STI_HASH256, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(LastTxnSeq), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(AuthorizedKey), STI_ACCOUNT, 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(TransferRate), STI_UINT32, SOE_IFFLAG, 16 },
|
||||
{ S_FIELD(Domain), STI_VL, SOE_IFFLAG, 32 },
|
||||
{ S_FIELD(PublishHash), STI_HASH256, SOE_IFFLAG, 64 },
|
||||
{ S_FIELD(PublishSize), STI_UINT32, SOE_IFFLAG, 128 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ "AccountRoot", ltACCOUNT_ROOT, { LEF_BASE
|
||||
{ sfAccount, SOE_REQUIRED },
|
||||
{ sfSequence, SOE_REQUIRED },
|
||||
{ sfBalance, SOE_REQUIRED },
|
||||
{ sfLastTxnID, SOE_REQUIRED },
|
||||
{ sfLastTxnSeq, SOE_REQUIRED },
|
||||
{ sfAuthorizedKey, SOE_OPTIONAL },
|
||||
{ sfEmailHash, SOE_OPTIONAL },
|
||||
{ sfWalletLocator, SOE_OPTIONAL },
|
||||
{ sfMessageKey, SOE_OPTIONAL },
|
||||
{ sfTransferRate, SOE_OPTIONAL },
|
||||
{ sfDomain, SOE_OPTIONAL },
|
||||
{ sfPublishHash, SOE_OPTIONAL },
|
||||
{ sfPublishSize, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "Contract", ltCONTRACT, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Account), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Balance), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(LastTxnID), STI_HASH256, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(LastTxnSeq), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Issuer), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Owner), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Expiration), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(BondAmount), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(CreateCode), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(FundCode), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(RemoveCode), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(ExpireCode), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ "Contract", ltCONTRACT, { LEF_BASE
|
||||
{ sfAccount, SOE_REQUIRED },
|
||||
{ sfBalance, SOE_REQUIRED },
|
||||
{ sfLastTxnID, SOE_REQUIRED },
|
||||
{ sfLastTxnSeq, SOE_REQUIRED },
|
||||
{ sfIssuer, SOE_REQUIRED },
|
||||
{ sfOwner, SOE_REQUIRED },
|
||||
{ sfExpiration, SOE_REQUIRED },
|
||||
{ sfBondAmount, SOE_REQUIRED },
|
||||
{ sfCreateCode, SOE_REQUIRED },
|
||||
{ sfFundCode, SOE_REQUIRED },
|
||||
{ sfRemoveCode, SOE_REQUIRED },
|
||||
{ sfExpireCode, SOE_REQUIRED },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "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 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ "DirectoryNode", ltDIR_NODE, { LEF_BASE
|
||||
{ sfIndexes, SOE_REQUIRED },
|
||||
{ sfIndexNext, SOE_OPTIONAL },
|
||||
{ sfIndexPrevious, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "GeneratorMap", ltGENERATOR_MAP, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Generator), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ "GeneratorMap", ltGENERATOR_MAP, { LEF_BASE
|
||||
{ sfGenerator, SOE_REQUIRED },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "Nickname", ltNICKNAME, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Account), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(MinimumOffer), STI_AMOUNT, SOE_IFFLAG, 1 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ "Nickname", ltNICKNAME, { LEF_BASE
|
||||
{ sfAccount, SOE_REQUIRED },
|
||||
{ sfMinimumOffer, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "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(TakerPays), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(TakerGets), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(BookDirectory), STI_HASH256, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(BookNode), STI_UINT64, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(OwnerNode), STI_UINT64, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(LastTxnID), STI_HASH256, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(LastTxnSeq), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Expiration), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ "Offer", ltOFFER, { LEF_BASE
|
||||
{ sfAccount, SOE_REQUIRED },
|
||||
{ sfSequence, SOE_REQUIRED },
|
||||
{ sfTakerPays, SOE_REQUIRED },
|
||||
{ sfTakerGets, SOE_REQUIRED },
|
||||
{ sfBookDirectory, SOE_REQUIRED },
|
||||
{ sfBookNode, SOE_REQUIRED },
|
||||
{ sfOwnerNode, SOE_REQUIRED },
|
||||
{ sfLastTxnID, SOE_REQUIRED },
|
||||
{ sfLastTxnSeq, SOE_REQUIRED },
|
||||
{ sfExpiration, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "RippleState", ltRIPPLE_STATE, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Balance), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(LowLimit), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(HighLimit), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(LastTxnID), STI_HASH256, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(LastTxnSeq), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(LowQualityIn), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(LowQualityOut), STI_UINT32, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(HighQualityIn), STI_UINT32, SOE_IFFLAG, 4 },
|
||||
{ S_FIELD(HighQualityOut), STI_UINT32, SOE_IFFLAG, 8 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ "RippleState", ltRIPPLE_STATE, { LEF_BASE
|
||||
{ sfBalance, SOE_REQUIRED },
|
||||
{ sfLowLimit, SOE_REQUIRED },
|
||||
{ sfHighLimit, SOE_REQUIRED },
|
||||
{ sfLastTxnID, SOE_REQUIRED },
|
||||
{ sfLastTxnSeq, SOE_REQUIRED },
|
||||
{ sfLowQualityIn, SOE_OPTIONAL },
|
||||
{ sfLowQualityOut, SOE_OPTIONAL },
|
||||
{ sfHighQualityIn, SOE_OPTIONAL },
|
||||
{ sfHighQualityOut, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ NULL, ltINVALID }
|
||||
};
|
||||
|
||||
|
||||
LedgerEntryFormat* getLgrFormat(LedgerEntryType t)
|
||||
{
|
||||
LedgerEntryFormat* f = LedgerFormats;
|
||||
while (f->t_name != NULL)
|
||||
{
|
||||
if (f->t_type == t) return f;
|
||||
++f;
|
||||
}
|
||||
return getLgrFormat(static_cast<int>(t));
|
||||
}
|
||||
|
||||
LedgerEntryFormat* getLgrFormat(int t)
|
||||
{
|
||||
for (LedgerEntryFormat* f = LedgerFormats; f->t_name != NULL; ++f)
|
||||
if (f->t_type == t)
|
||||
return f;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LedgerEntryFormat* getLgrFormat(const std::string& t)
|
||||
{
|
||||
for (LedgerEntryFormat* f = LedgerFormats; f->t_name != NULL; ++f)
|
||||
if (t == f->t_name)
|
||||
return f;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -41,12 +41,14 @@ enum LedgerSpecificFlags
|
||||
|
||||
struct LedgerEntryFormat
|
||||
{
|
||||
const char *t_name;
|
||||
LedgerEntryType t_type;
|
||||
SOElement elements[20];
|
||||
const char * t_name;
|
||||
LedgerEntryType t_type;
|
||||
SOElement elements[24];
|
||||
};
|
||||
|
||||
extern LedgerEntryFormat LedgerFormats[];
|
||||
extern LedgerEntryFormat* getLgrFormat(LedgerEntryType t);
|
||||
extern LedgerEntryFormat* getLgrFormat(const std::string& t);
|
||||
extern LedgerEntryFormat* getLgrFormat(int t);
|
||||
#endif
|
||||
// vim:ts=4
|
||||
|
||||
@@ -83,17 +83,18 @@ uint32 NetworkOPs::getCurrentLedgerID()
|
||||
Transaction::pointer NetworkOPs::submitTransaction(const Transaction::pointer& tpTrans)
|
||||
{
|
||||
Serializer s;
|
||||
|
||||
tpTrans->getSTransaction()->add(s);
|
||||
|
||||
std::vector<unsigned char> vucTransaction = s.getData();
|
||||
|
||||
SerializerIterator sit(s);
|
||||
|
||||
Transaction::pointer tpTransNew = Transaction::sharedTransaction(s.getData(), true);
|
||||
|
||||
assert(tpTransNew);
|
||||
assert(tpTransNew->getSTransaction()->isEquivalent(*tpTrans->getSTransaction()));
|
||||
|
||||
if(!tpTransNew->getSTransaction()->isEquivalent(*tpTrans->getSTransaction()))
|
||||
{
|
||||
Log(lsFATAL) << "Transaction reconstruction failure";
|
||||
Log(lsFATAL) << tpTransNew->getSTransaction()->getJson(0);
|
||||
Log(lsFATAL) << tpTrans->getSTransaction()->getJson(0);
|
||||
assert(false);
|
||||
}
|
||||
|
||||
(void) NetworkOPs::processTransaction(tpTransNew);
|
||||
|
||||
@@ -244,12 +245,12 @@ STVector256 NetworkOPs::getDirNodeInfo(
|
||||
{
|
||||
Log(lsDEBUG) << "getDirNodeInfo: node index: " << uNodeIndex.ToString();
|
||||
|
||||
Log(lsTRACE) << "getDirNodeInfo: first: " << strHex(sleNode->getIFieldU64(sfIndexPrevious));
|
||||
Log(lsTRACE) << "getDirNodeInfo: last: " << strHex(sleNode->getIFieldU64(sfIndexNext));
|
||||
Log(lsTRACE) << "getDirNodeInfo: first: " << strHex(sleNode->getFieldU64(sfIndexPrevious));
|
||||
Log(lsTRACE) << "getDirNodeInfo: last: " << strHex(sleNode->getFieldU64(sfIndexNext));
|
||||
|
||||
uNodePrevious = sleNode->getIFieldU64(sfIndexPrevious);
|
||||
uNodeNext = sleNode->getIFieldU64(sfIndexNext);
|
||||
svIndexes = sleNode->getIFieldV256(sfIndexes);
|
||||
uNodePrevious = sleNode->getFieldU64(sfIndexPrevious);
|
||||
uNodeNext = sleNode->getFieldU64(sfIndexNext);
|
||||
svIndexes = sleNode->getFieldV256(sfIndexes);
|
||||
|
||||
Log(lsTRACE) << "getDirNodeInfo: first: " << strHex(uNodePrevious);
|
||||
Log(lsTRACE) << "getDirNodeInfo: last: " << strHex(uNodeNext);
|
||||
@@ -298,7 +299,7 @@ Json::Value NetworkOPs::getOwnerInfo(Ledger::pointer lpLedger, const NewcoinAddr
|
||||
|
||||
do
|
||||
{
|
||||
STVector256 svIndexes = sleNode->getIFieldV256(sfIndexes);
|
||||
STVector256 svIndexes = sleNode->getFieldV256(sfIndexes);
|
||||
const std::vector<uint256>& vuiIndexes = svIndexes.peekValue();
|
||||
|
||||
BOOST_FOREACH(const uint256& uDirEntry, vuiIndexes)
|
||||
@@ -331,7 +332,7 @@ Json::Value NetworkOPs::getOwnerInfo(Ledger::pointer lpLedger, const NewcoinAddr
|
||||
}
|
||||
}
|
||||
|
||||
uNodeDir = sleNode->getIFieldU64(sfIndexNext);
|
||||
uNodeDir = sleNode->getFieldU64(sfIndexNext);
|
||||
if (uNodeDir)
|
||||
{
|
||||
lspNode = lepNONE;
|
||||
|
||||
@@ -8,19 +8,19 @@ NicknameState::NicknameState(SerializedLedgerEntry::pointer ledgerEntry) :
|
||||
|
||||
bool NicknameState::haveMinimumOffer() const
|
||||
{
|
||||
return mLedgerEntry->getIFieldPresent(sfMinimumOffer);
|
||||
return mLedgerEntry->isFieldPresent(sfMinimumOffer);
|
||||
}
|
||||
|
||||
STAmount NicknameState::getMinimumOffer() const
|
||||
{
|
||||
return mLedgerEntry->getIFieldPresent(sfMinimumOffer)
|
||||
? mLedgerEntry->getIValueFieldAmount(sfMinimumOffer)
|
||||
return mLedgerEntry->isFieldPresent(sfMinimumOffer)
|
||||
? mLedgerEntry->getFieldAmount(sfMinimumOffer)
|
||||
: STAmount();
|
||||
}
|
||||
|
||||
NewcoinAddress NicknameState::getAccountID() const
|
||||
{
|
||||
return mLedgerEntry->getIValueFieldAccount(sfAccount);
|
||||
return mLedgerEntry->getFieldAccount(sfAccount);
|
||||
}
|
||||
|
||||
void NicknameState::addJson(Json::Value& val)
|
||||
|
||||
@@ -10,8 +10,8 @@ OrderBook::pointer OrderBook::newOrderBook(SerializedLedgerEntry::pointer ledger
|
||||
|
||||
OrderBook::OrderBook(SerializedLedgerEntry::pointer ledgerEntry)
|
||||
{
|
||||
const STAmount saTakerGets = ledgerEntry->getIValueFieldAmount(sfTakerGets);
|
||||
const STAmount saTakerPays = ledgerEntry->getIValueFieldAmount(sfTakerPays);
|
||||
const STAmount saTakerGets = ledgerEntry->getFieldAmount(sfTakerGets);
|
||||
const STAmount saTakerPays = ledgerEntry->getFieldAmount(sfTakerPays);
|
||||
|
||||
mCurrencyIn = saTakerGets.getCurrency();
|
||||
mCurrencyOut = saTakerPays.getCurrency();
|
||||
|
||||
@@ -252,7 +252,7 @@ Json::Value RPCServer::getMasterGenerator(const uint256& uLedger, const NewcoinA
|
||||
return RPCError(rpcNO_ACCOUNT);
|
||||
}
|
||||
|
||||
std::vector<unsigned char> vucCipher = sleGen->getIFieldVL(sfGenerator);
|
||||
std::vector<unsigned char> vucCipher = sleGen->getFieldVL(sfGenerator);
|
||||
std::vector<unsigned char> vucMasterGenerator = na0Private.accountPrivateDecrypt(na0Public, vucCipher);
|
||||
if (vucMasterGenerator.empty())
|
||||
{
|
||||
@@ -355,7 +355,9 @@ Json::Value RPCServer::authorize(const uint256& uLedger,
|
||||
}
|
||||
else
|
||||
{
|
||||
Log(lsINFO) << "authorize: before: fee=" << saFee.getFullText() << " balance=" << saSrcBalance.getFullText();
|
||||
saSrcBalance -= saFee;
|
||||
Log(lsINFO) << "authorize: after: fee=" << saFee.getFullText() << " balance=" << saSrcBalance.getFullText();
|
||||
}
|
||||
|
||||
Json::Value obj;
|
||||
@@ -400,7 +402,7 @@ Json::Value RPCServer::accountFromString(const uint256& uLedger, NewcoinAddress&
|
||||
else
|
||||
{
|
||||
// Found master public key.
|
||||
std::vector<unsigned char> vucCipher = sleGen->getIFieldVL(sfGenerator);
|
||||
std::vector<unsigned char> vucCipher = sleGen->getFieldVL(sfGenerator);
|
||||
std::vector<unsigned char> vucMasterGenerator = naRegular0Private.accountPrivateDecrypt(naRegular0Public, vucCipher);
|
||||
if (vucMasterGenerator.empty())
|
||||
{
|
||||
@@ -958,7 +960,6 @@ Json::Value RPCServer::doNicknameSet(const Json::Value& params)
|
||||
std::string strOfferCurrency;
|
||||
std::string strNickname = params[2u].asString();
|
||||
boost::trim(strNickname);
|
||||
std::vector<unsigned char> vucSignature;
|
||||
|
||||
if (strNickname.empty())
|
||||
{
|
||||
@@ -1010,8 +1011,7 @@ Json::Value RPCServer::doNicknameSet(const Json::Value& params)
|
||||
0, // YYY No source tag
|
||||
Ledger::getNicknameHash(strNickname),
|
||||
bSetOffer,
|
||||
saMinimumOffer,
|
||||
vucSignature);
|
||||
saMinimumOffer);
|
||||
|
||||
trans = mNetOps->submitTransaction(trans);
|
||||
|
||||
@@ -1778,16 +1778,17 @@ Json::Value RPCServer::doSend(const Json::Value& params)
|
||||
|
||||
STPathSet spsPaths;
|
||||
uint160 srcCurrencyID;
|
||||
bool ret_b;
|
||||
ret_b = false;
|
||||
// bool ret_b;
|
||||
// ret_b = false;
|
||||
|
||||
if (!saSrcAmountMax.isNative() || !saDstAmount.isNative())
|
||||
if (!saSrcAmountMax.isNative() || !saDstAmount.isNative())
|
||||
{
|
||||
STAmount::currencyFromString(srcCurrencyID, sSrcCurrency);
|
||||
Pathfinder pf(naSrcAccountID, naDstAccountID, srcCurrencyID, saDstAmount);
|
||||
ret_b = pf.findPaths(5, 1, spsPaths);
|
||||
// ret_b = pf.findPaths(5, 1, spsPaths);
|
||||
pf.findPaths(5, 1, spsPaths);
|
||||
}
|
||||
|
||||
|
||||
trans = Transaction::sharedPayment(
|
||||
naAccountPublic, naAccountPrivate,
|
||||
naSrcAccountID,
|
||||
|
||||
@@ -116,8 +116,8 @@ TER RippleCalc::calcNodeAdvance(
|
||||
{
|
||||
if (bFundsDirty)
|
||||
{
|
||||
saTakerPays = sleOffer->getIValueFieldAmount(sfTakerPays);
|
||||
saTakerGets = sleOffer->getIValueFieldAmount(sfTakerGets);
|
||||
saTakerPays = sleOffer->getFieldAmount(sfTakerPays);
|
||||
saTakerGets = sleOffer->getFieldAmount(sfTakerGets);
|
||||
|
||||
saOfferFunds = lesActive.accountFunds(uOfrOwnerID, saTakerGets); // Funds left.
|
||||
bFundsDirty = false;
|
||||
@@ -153,13 +153,13 @@ TER RippleCalc::calcNodeAdvance(
|
||||
{
|
||||
// Got a new offer.
|
||||
sleOffer = lesActive.entryCache(ltOFFER, uOfferIndex);
|
||||
uOfrOwnerID = sleOffer->getIValueFieldAccount(sfAccount).getAccountID();
|
||||
uOfrOwnerID = sleOffer->getFieldAccount(sfAccount).getAccountID();
|
||||
|
||||
const aciSource asLine = boost::make_tuple(uOfrOwnerID, uCurCurrencyID, uCurIssuerID);
|
||||
|
||||
Log(lsINFO) << boost::str(boost::format("calcNodeAdvance: uOfrOwnerID=%s") % NewcoinAddress::createHumanAccountID(uOfrOwnerID));
|
||||
|
||||
if (sleOffer->getIFieldPresent(sfExpiration) && sleOffer->getIFieldU32(sfExpiration) <= lesActive.getLedger()->getParentCloseTimeNC())
|
||||
if (sleOffer->isFieldPresent(sfExpiration) && sleOffer->getFieldU32(sfExpiration) <= lesActive.getLedger()->getParentCloseTimeNC())
|
||||
{
|
||||
// Offer is expired.
|
||||
Log(lsINFO) << "calcNodeAdvance: expired offer";
|
||||
@@ -207,8 +207,8 @@ TER RippleCalc::calcNodeAdvance(
|
||||
continue;
|
||||
}
|
||||
|
||||
saTakerPays = sleOffer->getIValueFieldAmount(sfTakerPays);
|
||||
saTakerGets = sleOffer->getIValueFieldAmount(sfTakerGets);
|
||||
saTakerPays = sleOffer->getFieldAmount(sfTakerPays);
|
||||
saTakerGets = sleOffer->getFieldAmount(sfTakerGets);
|
||||
|
||||
saOfferFunds = lesActive.accountFunds(uOfrOwnerID, saTakerGets); // Funds left.
|
||||
|
||||
@@ -430,8 +430,8 @@ TER RippleCalc::calcNodeDeliverRev(
|
||||
lesActive.accountSend(uOfrOwnerID, uCurIssuerID, saOutPass);
|
||||
|
||||
// Adjust offer
|
||||
sleOffer->setIFieldAmount(sfTakerGets, saTakerGets - saOutPass);
|
||||
sleOffer->setIFieldAmount(sfTakerPays, saTakerPays - saInPassAct);
|
||||
sleOffer->setFieldAmount(sfTakerGets, saTakerGets - saOutPass);
|
||||
sleOffer->setFieldAmount(sfTakerPays, saTakerPays - saInPassAct);
|
||||
|
||||
lesActive.entryModify(sleOffer);
|
||||
|
||||
@@ -580,8 +580,8 @@ TER RippleCalc::calcNodeDeliverFwd(
|
||||
lesActive.accountSend(uInAccountID, uOfrOwnerID, saInPassAct);
|
||||
|
||||
// Adjust offer
|
||||
sleOffer->setIFieldAmount(sfTakerGets, saTakerGets - saOutPassAct);
|
||||
sleOffer->setIFieldAmount(sfTakerPays, saTakerPays - saInPassAct);
|
||||
sleOffer->setFieldAmount(sfTakerGets, saTakerGets - saOutPassAct);
|
||||
sleOffer->setFieldAmount(sfTakerPays, saTakerPays - saInPassAct);
|
||||
|
||||
lesActive.entryModify(sleOffer);
|
||||
|
||||
@@ -2092,11 +2092,11 @@ void TransactionEngine::calcOfferBridgeNext(
|
||||
|
||||
SLE::pointer sleOffer = entryCache(ltOFFER, uOfferIndex);
|
||||
|
||||
uint160 uOfferOwnerID = sleOffer->getIValueFieldAccount(sfAccount).getAccountID();
|
||||
STAmount saOfferPays = sleOffer->getIValueFieldAmount(sfTakerGets);
|
||||
STAmount saOfferGets = sleOffer->getIValueFieldAmount(sfTakerPays);
|
||||
uint160 uOfferOwnerID = sleOffer->getFieldAccount(sfAccount).getAccountID();
|
||||
STAmount saOfferPays = sleOffer->getFieldAmount(sfTakerGets);
|
||||
STAmount saOfferGets = sleOffer->getFieldAmount(sfTakerPays);
|
||||
|
||||
if (sleOffer->getIFieldPresent(sfExpiration) && sleOffer->getIFieldU32(sfExpiration) <= mLedger->getParentCloseTimeNC())
|
||||
if (sleOffer->isFieldPresent(sfExpiration) && sleOffer->getFieldU32(sfExpiration) <= mLedger->getParentCloseTimeNC())
|
||||
{
|
||||
// Offer is expired.
|
||||
Log(lsINFO) << "calcOfferFirst: encountered expired offer";
|
||||
|
||||
@@ -25,7 +25,7 @@ void RippleLines::fillLines(const uint160& accountID, Ledger::pointer ledger)
|
||||
SLE::pointer rippleDir=ledger->getDirNode(lspNode, currentIndex);
|
||||
if (!rippleDir) return;
|
||||
|
||||
STVector256 svOwnerNodes = rippleDir->getIFieldV256(sfIndexes);
|
||||
STVector256 svOwnerNodes = rippleDir->getFieldV256(sfIndexes);
|
||||
BOOST_FOREACH(uint256& uNode, svOwnerNodes.peekValue())
|
||||
{
|
||||
SLE::pointer sleCur = ledger->getSLE(uNode);
|
||||
@@ -45,7 +45,7 @@ void RippleLines::fillLines(const uint160& accountID, Ledger::pointer ledger)
|
||||
}
|
||||
}
|
||||
|
||||
uint64 uNodeNext = rippleDir->getIFieldU64(sfIndexNext);
|
||||
uint64 uNodeNext = rippleDir->getFieldU64(sfIndexNext);
|
||||
if (!uNodeNext) return;
|
||||
|
||||
currentIndex = Ledger::getDirNodeIndex(rootIndex, uNodeNext);
|
||||
|
||||
@@ -7,19 +7,19 @@ RippleState::RippleState(SerializedLedgerEntry::pointer ledgerEntry) :
|
||||
{
|
||||
if (!mLedgerEntry || mLedgerEntry->getType() != ltRIPPLE_STATE) return;
|
||||
|
||||
mLowLimit = mLedgerEntry->getIValueFieldAmount(sfLowLimit);
|
||||
mHighLimit = mLedgerEntry->getIValueFieldAmount(sfHighLimit);
|
||||
mLowLimit = mLedgerEntry->getFieldAmount(sfLowLimit);
|
||||
mHighLimit = mLedgerEntry->getFieldAmount(sfHighLimit);
|
||||
|
||||
mLowID = NewcoinAddress::createAccountID(mLowLimit.getIssuer());
|
||||
mHighID = NewcoinAddress::createAccountID(mHighLimit.getIssuer());
|
||||
|
||||
mLowQualityIn = mLedgerEntry->getIFieldU32(sfLowQualityIn);
|
||||
mLowQualityOut = mLedgerEntry->getIFieldU32(sfLowQualityOut);
|
||||
mLowQualityIn = mLedgerEntry->getFieldU32(sfLowQualityIn);
|
||||
mLowQualityOut = mLedgerEntry->getFieldU32(sfLowQualityOut);
|
||||
|
||||
mHighQualityIn = mLedgerEntry->getIFieldU32(sfHighQualityIn);
|
||||
mHighQualityOut = mLedgerEntry->getIFieldU32(sfHighQualityOut);
|
||||
mHighQualityIn = mLedgerEntry->getFieldU32(sfHighQualityIn);
|
||||
mHighQualityOut = mLedgerEntry->getFieldU32(sfHighQualityOut);
|
||||
|
||||
mBalance = mLedgerEntry->getIValueFieldAmount(sfBalance);
|
||||
mBalance = mLedgerEntry->getFieldAmount(sfBalance);
|
||||
|
||||
mValid = true;
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
// appropriate #define statements.
|
||||
|
||||
// types (common)
|
||||
TYPE("Int32", UINT32, 1)
|
||||
TYPE("Int64", UINT64, 2)
|
||||
TYPE("Hash128", HASH128, 3)
|
||||
TYPE("Hash256", HASH256, 4)
|
||||
// 5 is reserved
|
||||
TYPE("Int16", UINT16, 1)
|
||||
TYPE("Int32", UINT32, 2)
|
||||
TYPE("Int64", UINT64, 3)
|
||||
TYPE("Hash128", HASH128, 4)
|
||||
TYPE("Hash256", HASH256, 5)
|
||||
TYPE("Amount", AMOUNT, 6)
|
||||
TYPE("VariableLength", VL, 7)
|
||||
TYPE("Account", ACCOUNT, 8)
|
||||
@@ -16,28 +16,32 @@
|
||||
|
||||
// types (uncommon)
|
||||
TYPE("Int8", UINT8, 16)
|
||||
TYPE("Int16", UINT16, 17)
|
||||
TYPE("Hash160", HASH160, 18)
|
||||
TYPE("PathSet", PATHSET, 19)
|
||||
TYPE("Vector256", VECTOR256, 20)
|
||||
TYPE("Hash160", HASH160, 17)
|
||||
TYPE("PathSet", PATHSET, 18)
|
||||
TYPE("Vector256", VECTOR256, 19)
|
||||
|
||||
|
||||
|
||||
// 8-bit integers
|
||||
FIELD(CloseResolution, UINT8, 1)
|
||||
|
||||
// 16-bit integers
|
||||
FIELD(LedgerEntryType, UINT16, 1)
|
||||
FIELD(TransactionType, UINT16, 2)
|
||||
|
||||
// 32-bit integers (common)
|
||||
FIELD(Flags, UINT32, 1)
|
||||
FIELD(SourceTag, UINT32, 2)
|
||||
FIELD(Sequence, UINT32, 3)
|
||||
FIELD(LastTxnSeq, UINT32, 4)
|
||||
FIELD(LedgerSequence, UINT32, 5)
|
||||
FIELD(CloseTime, UINT32, 6)
|
||||
FIELD(ParentCloseTime, UINT32, 7)
|
||||
FIELD(SigningTime, UINT32, 8)
|
||||
FIELD(Expiration, UINT32, 9)
|
||||
FIELD(TransferRate, UINT32, 10)
|
||||
FIELD(PublishSize, UINT32, 11)
|
||||
FIELD(ObjectType, UINT32, 1)
|
||||
FIELD(Flags, UINT32, 2)
|
||||
FIELD(SourceTag, UINT32, 3)
|
||||
FIELD(Sequence, UINT32, 4)
|
||||
FIELD(LastTxnSeq, UINT32, 5)
|
||||
FIELD(LedgerSequence, UINT32, 6)
|
||||
FIELD(CloseTime, UINT32, 7)
|
||||
FIELD(ParentCloseTime, UINT32, 8)
|
||||
FIELD(SigningTime, UINT32, 9)
|
||||
FIELD(Expiration, UINT32, 10)
|
||||
FIELD(TransferRate, UINT32, 11)
|
||||
FIELD(PublishSize, UINT32, 12)
|
||||
|
||||
// 32-bit integers (uncommon)
|
||||
FIELD(HighQualityIn, UINT32, 16)
|
||||
@@ -59,7 +63,7 @@
|
||||
FIELD(BaseFee, UINT64, 5)
|
||||
|
||||
// 128-bit
|
||||
FIELD(EmailHash, HASH128, 2)
|
||||
FIELD(EmailHash, HASH128, 1)
|
||||
|
||||
// 256-bit (common)
|
||||
FIELD(LedgerHash, HASH256, 1)
|
||||
@@ -67,8 +71,9 @@
|
||||
FIELD(TransactionHash, HASH256, 3)
|
||||
FIELD(AccountHash, HASH256, 4)
|
||||
FIELD(LastTxnID, HASH256, 5)
|
||||
FIELD(WalletLocator, HASH256, 6)
|
||||
FIELD(PublishHash, HASH256, 7)
|
||||
FIELD(LedgerIndex, HASH256, 6)
|
||||
FIELD(WalletLocator, HASH256, 7)
|
||||
FIELD(PublishHash, HASH256, 8)
|
||||
|
||||
// 256-bit (uncommon)
|
||||
FIELD(BookDirectory, HASH256, 16)
|
||||
@@ -83,6 +88,7 @@
|
||||
FIELD(TakerGets, AMOUNT, 5)
|
||||
FIELD(LowLimit, AMOUNT, 6)
|
||||
FIELD(HighLimit, AMOUNT, 7)
|
||||
FIELD(Fee, AMOUNT, 8)
|
||||
FIELD(SendMax, AMOUNT, 9)
|
||||
|
||||
// current amount (uncommon)
|
||||
@@ -92,14 +98,15 @@
|
||||
// variable length
|
||||
FIELD(PublicKey, VL, 1)
|
||||
FIELD(MessageKey, VL, 2)
|
||||
FIELD(SigningKey, VL, 3)
|
||||
FIELD(Signature, VL, 4)
|
||||
FIELD(SigningPubKey, VL, 3)
|
||||
FIELD(TxnSignature, VL, 4)
|
||||
FIELD(Generator, VL, 5)
|
||||
FIELD(Domain, VL, 6)
|
||||
FIELD(FundCode, VL, 7)
|
||||
FIELD(RemoveCode, VL, 8)
|
||||
FIELD(ExpireCode, VL, 9)
|
||||
FIELD(CreateCode, VL, 10)
|
||||
FIELD(Signature, VL, 6)
|
||||
FIELD(Domain, VL, 7)
|
||||
FIELD(FundCode, VL, 8)
|
||||
FIELD(RemoveCode, VL, 9)
|
||||
FIELD(ExpireCode, VL, 10)
|
||||
FIELD(CreateCode, VL, 11)
|
||||
|
||||
// account
|
||||
FIELD(Account, ACCOUNT, 1)
|
||||
@@ -119,9 +126,9 @@
|
||||
|
||||
// inner object
|
||||
// OBJECT/1 is reserved for end of object
|
||||
FIELD(MiddleTransaction, OBJECT, 2)
|
||||
FIELD(InnerTransaction, OBJECT, 3)
|
||||
|
||||
// array of objects
|
||||
// ARRAY/1 is reserved for end of array
|
||||
FIELD(SigningAccounts, ARRAY, 2)
|
||||
FIELD(TxnSignatures, ARRAY, 3)
|
||||
FIELD(Signatures, ARRAY, 4)
|
||||
|
||||
@@ -6,35 +6,43 @@
|
||||
#include "Log.h"
|
||||
|
||||
SerializedLedgerEntry::SerializedLedgerEntry(SerializerIterator& sit, const uint256& index)
|
||||
: SerializedType("LedgerEntry"), mIndex(index)
|
||||
: STObject(sfLedgerEntry), mIndex(index)
|
||||
{
|
||||
uint16 type = sit.get16();
|
||||
set(sit);
|
||||
uint16 type = getFieldU16(sfLedgerEntryType);
|
||||
mFormat = getLgrFormat(static_cast<LedgerEntryType>(type));
|
||||
if (mFormat == NULL) throw std::runtime_error("invalid ledger entry type");
|
||||
if (mFormat == NULL)
|
||||
throw std::runtime_error("invalid ledger entry type");
|
||||
mType = mFormat->t_type;
|
||||
mVersion.setValue(type);
|
||||
mObject = STObject(mFormat->elements, sit);
|
||||
if (!setType(mFormat->elements))
|
||||
throw std::runtime_error("ledger entry not valid for type");
|
||||
}
|
||||
|
||||
SerializedLedgerEntry::SerializedLedgerEntry(const Serializer& s, const uint256& index)
|
||||
: SerializedType("LedgerEntry"), mIndex(index)
|
||||
: STObject(sfLedgerEntry), mIndex(index)
|
||||
{
|
||||
SerializerIterator sit(s);
|
||||
set(sit);
|
||||
|
||||
uint16 type = sit.get16();
|
||||
uint16 type = getFieldU16(sfLedgerEntryType);
|
||||
mFormat = getLgrFormat(static_cast<LedgerEntryType>(type));
|
||||
if (mFormat == NULL) throw std::runtime_error("invalid ledger entry type");
|
||||
if (mFormat == NULL)
|
||||
throw std::runtime_error("invalid ledger entry type");
|
||||
mType = mFormat->t_type;
|
||||
mVersion.setValue(type);
|
||||
mObject.set(mFormat->elements, sit);
|
||||
if (!setType(mFormat->elements))
|
||||
{
|
||||
Log(lsWARNING) << "Ledger entry not valid for type " << mFormat->t_name;
|
||||
Log(lsWARNING) << getJson(0);
|
||||
throw std::runtime_error("ledger entry not valid for type");
|
||||
}
|
||||
}
|
||||
|
||||
SerializedLedgerEntry::SerializedLedgerEntry(LedgerEntryType type) : SerializedType("LedgerEntry"), mType(type)
|
||||
SerializedLedgerEntry::SerializedLedgerEntry(LedgerEntryType type) : STObject(sfLedgerEntry), mType(type)
|
||||
{
|
||||
mFormat = getLgrFormat(type);
|
||||
if (mFormat == NULL) throw std::runtime_error("invalid ledger entry type");
|
||||
mVersion.setValue(static_cast<uint16>(mFormat->t_type));
|
||||
mObject.set(mFormat->elements);
|
||||
set(mFormat->elements);
|
||||
setFieldU16(sfLedgerEntryType, static_cast<uint16>(mFormat->t_type));
|
||||
}
|
||||
|
||||
std::string SerializedLedgerEntry::getFullText() const
|
||||
@@ -44,76 +52,64 @@ std::string SerializedLedgerEntry::getFullText() const
|
||||
ret += "\" = { ";
|
||||
ret += mFormat->t_name;
|
||||
ret += ", ";
|
||||
ret += mObject.getFullText();
|
||||
ret += STObject::getFullText();
|
||||
ret += "}";
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string SerializedLedgerEntry::getText() const
|
||||
{
|
||||
return str(boost::format("{ %s, %s, %s }")
|
||||
return str(boost::format("{ %s, %s }")
|
||||
% mIndex.GetHex()
|
||||
% mVersion.getText()
|
||||
% mObject.getText());
|
||||
% STObject::getText());
|
||||
}
|
||||
|
||||
Json::Value SerializedLedgerEntry::getJson(int options) const
|
||||
{
|
||||
Json::Value ret(mObject.getJson(options));
|
||||
Json::Value ret(STObject::getJson(options));
|
||||
|
||||
ret["type"] = mFormat->t_name;
|
||||
ret["index"] = mIndex.GetHex();
|
||||
ret["version"] = std::string(1, mVersion);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool SerializedLedgerEntry::isEquivalent(const SerializedType& t) const
|
||||
{ // locators are not compared
|
||||
const SerializedLedgerEntry* v = dynamic_cast<const SerializedLedgerEntry*>(&t);
|
||||
if (!v) return false;
|
||||
if (mType != v->mType) return false;
|
||||
if (mObject != v->mObject) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SerializedLedgerEntry::isThreadedType()
|
||||
{
|
||||
return getIFieldIndex(sfLastTxnID) != -1;
|
||||
return getFieldIndex(sfLastTxnID) != -1;
|
||||
}
|
||||
|
||||
bool SerializedLedgerEntry::isThreaded()
|
||||
{
|
||||
return getIFieldPresent(sfLastTxnID);
|
||||
return isFieldPresent(sfLastTxnID);
|
||||
}
|
||||
|
||||
uint256 SerializedLedgerEntry::getThreadedTransaction()
|
||||
{
|
||||
return getIFieldH256(sfLastTxnID);
|
||||
return getFieldH256(sfLastTxnID);
|
||||
}
|
||||
|
||||
uint32 SerializedLedgerEntry::getThreadedLedger()
|
||||
{
|
||||
return getIFieldU32(sfLastTxnSeq);
|
||||
return getFieldU32(sfLastTxnSeq);
|
||||
}
|
||||
|
||||
bool SerializedLedgerEntry::thread(const uint256& txID, uint32 ledgerSeq, uint256& prevTxID, uint32& prevLedgerID)
|
||||
{
|
||||
uint256 oldPrevTxID = getIFieldH256(sfLastTxnID);
|
||||
uint256 oldPrevTxID = getFieldH256(sfLastTxnID);
|
||||
Log(lsTRACE) << "Thread Tx:" << txID << " prev:" << oldPrevTxID;
|
||||
if (oldPrevTxID == txID)
|
||||
return false;
|
||||
prevTxID = oldPrevTxID;
|
||||
prevLedgerID = getIFieldU32(sfLastTxnSeq);
|
||||
prevLedgerID = getFieldU32(sfLastTxnSeq);
|
||||
assert(prevTxID != txID);
|
||||
setIFieldH256(sfLastTxnID, txID);
|
||||
setIFieldU32(sfLastTxnSeq, ledgerSeq);
|
||||
setFieldH256(sfLastTxnID, txID);
|
||||
setFieldU32(sfLastTxnSeq, ledgerSeq);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SerializedLedgerEntry::hasOneOwner()
|
||||
{
|
||||
return (mType != ltACCOUNT_ROOT) && (getIFieldIndex(sfAccount) != -1);
|
||||
return (mType != ltACCOUNT_ROOT) && (getFieldIndex(sfAccount) != -1);
|
||||
}
|
||||
|
||||
bool SerializedLedgerEntry::hasTwoOwners()
|
||||
@@ -123,17 +119,17 @@ bool SerializedLedgerEntry::hasTwoOwners()
|
||||
|
||||
NewcoinAddress SerializedLedgerEntry::getOwner()
|
||||
{
|
||||
return getIValueFieldAccount(sfAccount);
|
||||
return getFieldAccount(sfAccount);
|
||||
}
|
||||
|
||||
NewcoinAddress SerializedLedgerEntry::getFirstOwner()
|
||||
{
|
||||
return NewcoinAddress::createAccountID(getIValueFieldAmount(sfLowLimit).getIssuer());
|
||||
return NewcoinAddress::createAccountID(getFieldAmount(sfLowLimit).getIssuer());
|
||||
}
|
||||
|
||||
NewcoinAddress SerializedLedgerEntry::getSecondOwner()
|
||||
{
|
||||
return NewcoinAddress::createAccountID(getIValueFieldAmount(sfHighLimit).getIssuer());
|
||||
return NewcoinAddress::createAccountID(getFieldAmount(sfHighLimit).getIssuer());
|
||||
}
|
||||
|
||||
std::vector<uint256> SerializedLedgerEntry::getOwners()
|
||||
@@ -141,30 +137,24 @@ std::vector<uint256> SerializedLedgerEntry::getOwners()
|
||||
std::vector<uint256> owners;
|
||||
uint160 account;
|
||||
|
||||
for (int i = 0, fields = getIFieldCount(); i < fields; ++i)
|
||||
for (int i = 0, fields = getCount(); i < fields; ++i)
|
||||
{
|
||||
switch (getIFieldSType(i))
|
||||
SField::ref fc = getFieldSType(i);
|
||||
if ((fc == sfAccount) || (fc == sfOwner))
|
||||
{
|
||||
case sfAccount:
|
||||
{
|
||||
const STAccount* entry = dynamic_cast<const STAccount *>(mObject.peekAtPIndex(i));
|
||||
if ((entry != NULL) && entry->getValueH160(account))
|
||||
owners.push_back(Ledger::getAccountRootIndex(account));
|
||||
}
|
||||
break;
|
||||
|
||||
case sfLowLimit:
|
||||
case sfHighLimit:
|
||||
{
|
||||
const STAmount* entry = dynamic_cast<const STAmount *>(mObject.peekAtPIndex(i));
|
||||
if ((entry != NULL))
|
||||
owners.push_back(Ledger::getAccountRootIndex(entry->getIssuer()));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
nothing();
|
||||
break;
|
||||
const STAccount* entry = dynamic_cast<const STAccount *>(peekAtPIndex(i));
|
||||
if ((entry != NULL) && entry->getValueH160(account))
|
||||
owners.push_back(Ledger::getAccountRootIndex(account));
|
||||
}
|
||||
if ((fc == sfLowLimit) || (fc == sfHighLimit))
|
||||
{
|
||||
const STAmount* entry = dynamic_cast<const STAmount *>(peekAtPIndex(i));
|
||||
if ((entry != NULL))
|
||||
{
|
||||
uint160 issuer = entry->getIssuer();
|
||||
if (issuer.isNonZero())
|
||||
owners.push_back(Ledger::getAccountRootIndex(issuer));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "LedgerFormats.h"
|
||||
#include "NewcoinAddress.h"
|
||||
|
||||
class SerializedLedgerEntry : public SerializedType
|
||||
class SerializedLedgerEntry : public STObject
|
||||
{
|
||||
public:
|
||||
typedef boost::shared_ptr<SerializedLedgerEntry> pointer;
|
||||
@@ -14,8 +14,6 @@ public:
|
||||
protected:
|
||||
uint256 mIndex;
|
||||
LedgerEntryType mType;
|
||||
STUInt16 mVersion;
|
||||
STObject mObject;
|
||||
const LedgerEntryFormat* mFormat;
|
||||
|
||||
SerializedLedgerEntry* duplicate() const { return new SerializedLedgerEntry(*this); }
|
||||
@@ -25,45 +23,18 @@ public:
|
||||
SerializedLedgerEntry(SerializerIterator& sit, const uint256& index);
|
||||
SerializedLedgerEntry(LedgerEntryType type);
|
||||
|
||||
int getLength() const { return mVersion.getLength() + mObject.getLength(); }
|
||||
SerializedTypeID getSType() const { return STI_LEDGERENTRY; }
|
||||
std::string getFullText() const;
|
||||
std::string getText() const;
|
||||
Json::Value getJson(int options) const;
|
||||
void add(Serializer& s) const { mVersion.add(s); mObject.add(s); }
|
||||
virtual bool isEquivalent(const SerializedType& t) const;
|
||||
|
||||
bool setFlag(uint32 uSet) { return mObject.setFlag(uSet); }
|
||||
bool clearFlag(uint32 uClear) { return mObject.clearFlag(uClear); }
|
||||
uint32 getFlags() const { return mObject.getFlags(); }
|
||||
|
||||
const uint256& getIndex() const { return mIndex; }
|
||||
void setIndex(const uint256& i) { mIndex = i; }
|
||||
const uint256& getIndex() const { return mIndex; }
|
||||
void setIndex(const uint256& i) { mIndex = i; }
|
||||
|
||||
LedgerEntryType getType() const { return mType; }
|
||||
uint16 getVersion() const { return mVersion.getValue(); }
|
||||
uint16 getVersion() const { return getFieldU16(sfLedgerEntryType); }
|
||||
const LedgerEntryFormat* getFormat() { return mFormat; }
|
||||
|
||||
int getIFieldIndex(SOE_Field field) const { return mObject.getFieldIndex(field); }
|
||||
int getIFieldCount() const { return mObject.getCount(); }
|
||||
const SerializedType& peekIField(SOE_Field field) const { return mObject.peekAtField(field); }
|
||||
SerializedType& getIField(SOE_Field field) { return mObject.getField(field); }
|
||||
SOE_Field getIFieldSType(int index) { return mObject.getFieldSType(index); }
|
||||
|
||||
std::string getIFieldString(SOE_Field field) const { return mObject.getFieldString(field); }
|
||||
unsigned char getIFieldU8(SOE_Field field) const { return mObject.getValueFieldU8(field); }
|
||||
uint16 getIFieldU16(SOE_Field field) const { return mObject.getValueFieldU16(field); }
|
||||
uint32 getIFieldU32(SOE_Field field) const { return mObject.getValueFieldU32(field); }
|
||||
uint64 getIFieldU64(SOE_Field field) const { return mObject.getValueFieldU64(field); }
|
||||
uint128 getIFieldH128(SOE_Field field) const { return mObject.getValueFieldH128(field); }
|
||||
uint160 getIFieldH160(SOE_Field field) const { return mObject.getValueFieldH160(field); }
|
||||
uint256 getIFieldH256(SOE_Field field) const { return mObject.getValueFieldH256(field); }
|
||||
std::vector<unsigned char> getIFieldVL(SOE_Field field) const { return mObject.getValueFieldVL(field); }
|
||||
std::vector<TaggedListItem> getIFieldTL(SOE_Field field) const { return mObject.getValueFieldTL(field); }
|
||||
NewcoinAddress getIValueFieldAccount(SOE_Field field) const { return mObject.getValueFieldAccount(field); }
|
||||
STAmount getIValueFieldAmount(SOE_Field field) const { return mObject.getValueFieldAmount(field); }
|
||||
STVector256 getIFieldV256(SOE_Field field) { return mObject.getValueFieldV256(field); }
|
||||
|
||||
bool isThreadedType(); // is this a ledger entry that can be threaded
|
||||
bool isThreaded(); // is this ledger entry actually threaded
|
||||
bool hasOneOwner(); // This node has one other node that owns it (like nickname)
|
||||
@@ -75,29 +46,6 @@ public:
|
||||
uint32 getThreadedLedger();
|
||||
bool thread(const uint256& txID, uint32 ledgerSeq, uint256& prevTxID, uint32& prevLedgerID);
|
||||
std::vector<uint256> getOwners(); // nodes notified if this node is deleted
|
||||
|
||||
void setIFieldU8(SOE_Field field, unsigned char v) { return mObject.setValueFieldU8(field, v); }
|
||||
void setIFieldU16(SOE_Field field, uint16 v) { return mObject.setValueFieldU16(field, v); }
|
||||
void setIFieldU32(SOE_Field field, uint32 v) { return mObject.setValueFieldU32(field, v); }
|
||||
void setIFieldU64(SOE_Field field, uint64 v) { return mObject.setValueFieldU64(field, v); }
|
||||
void setIFieldH128(SOE_Field field, const uint128& v) { return mObject.setValueFieldH128(field, v); }
|
||||
void setIFieldH160(SOE_Field field, const uint160& v) { return mObject.setValueFieldH160(field, v); }
|
||||
void setIFieldH256(SOE_Field field, const uint256& v) { return mObject.setValueFieldH256(field, v); }
|
||||
void setIFieldVL(SOE_Field field, const std::vector<unsigned char>& v)
|
||||
{ return mObject.setValueFieldVL(field, v); }
|
||||
void setIFieldTL(SOE_Field field, const std::vector<TaggedListItem>& v)
|
||||
{ return mObject.setValueFieldTL(field, v); }
|
||||
void setIFieldAccount(SOE_Field field, const uint160& account)
|
||||
{ return mObject.setValueFieldAccount(field, account); }
|
||||
void setIFieldAccount(SOE_Field field, const NewcoinAddress& account)
|
||||
{ return mObject.setValueFieldAccount(field, account); }
|
||||
void setIFieldAmount(SOE_Field field, const STAmount& amount)
|
||||
{ return mObject.setValueFieldAmount(field, amount); }
|
||||
void setIFieldV256(SOE_Field field, const STVector256& v) { return mObject.setValueFieldV256(field, v); }
|
||||
|
||||
bool getIFieldPresent(SOE_Field field) const { return mObject.isFieldPresent(field); }
|
||||
void makeIFieldPresent(SOE_Field field) { mObject.makeFieldPresent(field); }
|
||||
void makeIFieldAbsent(SOE_Field field) { return mObject.makeFieldAbsent(field); }
|
||||
};
|
||||
|
||||
typedef SerializedLedgerEntry SLE;
|
||||
|
||||
@@ -3,13 +3,18 @@
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include "../json/writer.h"
|
||||
|
||||
#include "Log.h"
|
||||
#include "LedgerFormats.h"
|
||||
#include "TransactionFormats.h"
|
||||
|
||||
std::auto_ptr<SerializedType> STObject::makeDefaultObject(SerializedTypeID id, const char *name)
|
||||
std::auto_ptr<SerializedType> STObject::makeDefaultObject(SerializedTypeID id, SField::ref name)
|
||||
{
|
||||
assert((id == STI_NOTPRESENT) || (id == name.fieldType));
|
||||
|
||||
switch(id)
|
||||
{
|
||||
case STI_NOTPRESENT:
|
||||
@@ -48,13 +53,19 @@ std::auto_ptr<SerializedType> STObject::makeDefaultObject(SerializedTypeID id, c
|
||||
case STI_PATHSET:
|
||||
return std::auto_ptr<SerializedType>(new STPathSet(name));
|
||||
|
||||
case STI_OBJECT:
|
||||
return std::auto_ptr<SerializedType>(new STObject(name));
|
||||
|
||||
case STI_ARRAY:
|
||||
return std::auto_ptr<SerializedType>(new STArray(name));
|
||||
|
||||
default:
|
||||
throw std::runtime_error("Unknown object type");
|
||||
}
|
||||
}
|
||||
|
||||
std::auto_ptr<SerializedType> STObject::makeDeserializedObject(SerializedTypeID id, const char *name,
|
||||
SerializerIterator& sit)
|
||||
std::auto_ptr<SerializedType> STObject::makeDeserializedObject(SerializedTypeID id, SField::ref name,
|
||||
SerializerIterator& sit, int depth)
|
||||
{
|
||||
switch(id)
|
||||
{
|
||||
@@ -94,89 +105,128 @@ std::auto_ptr<SerializedType> STObject::makeDeserializedObject(SerializedTypeID
|
||||
case STI_PATHSET:
|
||||
return STPathSet::deserialize(sit, name);
|
||||
|
||||
case STI_ARRAY:
|
||||
return STArray::deserialize(sit, name);
|
||||
|
||||
case STI_OBJECT:
|
||||
return STObject::deserialize(sit, name);
|
||||
|
||||
default:
|
||||
throw std::runtime_error("Unknown object type");
|
||||
}
|
||||
}
|
||||
|
||||
void STObject::set(const SOElement* elem)
|
||||
void STObject::set(SOElement::ptr elem)
|
||||
{
|
||||
mData.empty();
|
||||
mType.empty();
|
||||
mFlagIdx = -1;
|
||||
|
||||
while (elem->e_id != STI_DONE)
|
||||
while (elem->flags != SOE_END)
|
||||
{
|
||||
if (elem->e_type == SOE_FLAGS) mFlagIdx = mType.size();
|
||||
mType.push_back(elem);
|
||||
if (elem->e_type == SOE_IFFLAG)
|
||||
giveObject(makeDefaultObject(STI_NOTPRESENT, elem->e_name));
|
||||
if (elem->flags == SOE_OPTIONAL)
|
||||
giveObject(makeNonPresentObject(elem->e_field));
|
||||
else
|
||||
giveObject(makeDefaultObject(elem->e_id, elem->e_name));
|
||||
giveObject(makeDefaultObject(elem->e_field));
|
||||
++elem;
|
||||
}
|
||||
}
|
||||
|
||||
STObject::STObject(const SOElement* elem, const char *name) : SerializedType(name)
|
||||
bool STObject::setType(SOElement::ptrList t)
|
||||
{
|
||||
set(elem);
|
||||
}
|
||||
boost::ptr_vector<SerializedType> newData;
|
||||
bool valid = true;
|
||||
|
||||
void STObject::set(const SOElement* elem, SerializerIterator& sit)
|
||||
{
|
||||
mData.empty();
|
||||
mType.empty();
|
||||
mFlagIdx = -1;
|
||||
|
||||
int flags = -1;
|
||||
while (elem->e_id != STI_DONE)
|
||||
while (t->flags != SOE_END)
|
||||
{
|
||||
mType.push_back(elem);
|
||||
bool done = false;
|
||||
if (elem->e_type == SOE_IFFLAG)
|
||||
{
|
||||
assert(flags >= 0);
|
||||
if ((flags&elem->e_flags) == 0)
|
||||
bool match = false;
|
||||
for (boost::ptr_vector<SerializedType>::iterator it = mData.begin(); it != mData.end(); ++it)
|
||||
if (it->getFName() == t->e_field)
|
||||
{
|
||||
done = true;
|
||||
giveObject(makeDefaultObject(STI_NOTPRESENT, elem->e_name));
|
||||
match = true;
|
||||
newData.push_back(mData.release(it).release());
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (elem->e_type == SOE_IFNFLAG)
|
||||
|
||||
if (!match)
|
||||
{
|
||||
assert(flags >= 0);
|
||||
if ((flags&elem->e_flags) != 0)
|
||||
if (t->flags != SOE_OPTIONAL)
|
||||
{
|
||||
done = true;
|
||||
giveObject(makeDefaultObject(elem->e_id, elem->e_name));
|
||||
Log(lsTRACE) << "setType !valid missing";
|
||||
valid = false;
|
||||
}
|
||||
newData.push_back(makeNonPresentObject(t->e_field));
|
||||
}
|
||||
else if (elem->e_type == SOE_FLAGS)
|
||||
{
|
||||
assert(elem->e_id == STI_UINT32);
|
||||
flags = sit.get32();
|
||||
mFlagIdx = giveObject(new STUInt32(elem->e_name, flags));
|
||||
done = true;
|
||||
}
|
||||
if (!done)
|
||||
giveObject(makeDeserializedObject(elem->e_id, elem->e_name, sit));
|
||||
elem++;
|
||||
|
||||
mType.push_back(t++);
|
||||
}
|
||||
if (mData.size() != 0)
|
||||
{
|
||||
Log(lsTRACE) << "setType !valid leftover";
|
||||
valid = false;
|
||||
}
|
||||
mData.swap(newData);
|
||||
return valid;
|
||||
}
|
||||
|
||||
STObject::STObject(const SOElement* elem, SerializerIterator& sit, const char *name)
|
||||
: SerializedType(name), mFlagIdx(-1)
|
||||
bool STObject::isValidForType()
|
||||
{
|
||||
set(elem, sit);
|
||||
boost::ptr_vector<SerializedType>::iterator it = mData.begin();
|
||||
BOOST_FOREACH(SOElement::ptr elem, mType)
|
||||
{
|
||||
if (it == mData.end())
|
||||
return false;
|
||||
if (elem->e_field != it->getFName())
|
||||
return false;
|
||||
++it;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool STObject::isFieldAllowed(SField::ref field)
|
||||
{
|
||||
BOOST_FOREACH(SOElement::ptr elem, mType)
|
||||
{ // are any required elemnents missing
|
||||
if (elem->e_field == field)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool STObject::set(SerializerIterator& sit, int depth)
|
||||
{ // return true = terminated with end-of-object
|
||||
mData.empty();
|
||||
while (!sit.empty())
|
||||
{
|
||||
int type, field;
|
||||
sit.getFieldID(type, field);
|
||||
if ((type == STI_OBJECT) && (field == 1)) // end of object indicator
|
||||
return true;
|
||||
SField::ref fn = SField::getField(type, field);
|
||||
if (fn.isInvalid())
|
||||
throw std::runtime_error("Unknown field");
|
||||
giveObject(makeDeserializedObject(fn.fieldType, fn, sit, depth + 1));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::auto_ptr<SerializedType> STObject::deserialize(SerializerIterator& sit, SField::ref name)
|
||||
{
|
||||
STObject *o;
|
||||
std::auto_ptr<SerializedType> object(o = new STObject(name));
|
||||
o->set(sit, 1);
|
||||
return object;
|
||||
}
|
||||
|
||||
std::string STObject::getFullText() const
|
||||
{
|
||||
std::string ret;
|
||||
bool first = true;
|
||||
if (name != NULL)
|
||||
if (fName->hasName())
|
||||
{
|
||||
ret = name;
|
||||
ret = fName->getName();
|
||||
ret += " = {";
|
||||
}
|
||||
else ret = "{";
|
||||
@@ -193,18 +243,33 @@ std::string STObject::getFullText() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
int STObject::getLength() const
|
||||
void STObject::add(Serializer& s, bool withSigningFields) const
|
||||
{
|
||||
int ret = 0;
|
||||
BOOST_FOREACH(const SerializedType& it, mData)
|
||||
ret += it.getLength();
|
||||
return ret;
|
||||
}
|
||||
std::map<int, const SerializedType*> fields;
|
||||
|
||||
void STObject::add(Serializer& s) const
|
||||
{
|
||||
BOOST_FOREACH(const SerializedType& it, mData)
|
||||
it.add(s);
|
||||
{ // pick out the fields and sort them
|
||||
if (it.getSType() != STI_NOTPRESENT)
|
||||
{
|
||||
SField::ref fName = it.getFName();
|
||||
if (withSigningFields || ((fName != sfTxnSignature) && (fName != sfTxnSignatures)))
|
||||
fields.insert(std::make_pair(it.getFName().fieldCode, &it));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
typedef std::pair<const int, const SerializedType*> field_iterator;
|
||||
BOOST_FOREACH(field_iterator& it, fields)
|
||||
{ // insert them in sorted order
|
||||
const SerializedType* field = it.second;
|
||||
|
||||
field->addFieldID(s);
|
||||
field->add(s);
|
||||
if (dynamic_cast<const STArray*>(field) != NULL)
|
||||
s.addFieldID(STI_ARRAY, 1);
|
||||
else if (dynamic_cast<const STObject*>(field) != NULL)
|
||||
s.addFieldID(STI_OBJECT, 1);
|
||||
}
|
||||
}
|
||||
|
||||
std::string STObject::getText() const
|
||||
@@ -227,7 +292,8 @@ std::string STObject::getText() const
|
||||
bool STObject::isEquivalent(const SerializedType& t) const
|
||||
{
|
||||
const STObject* v = dynamic_cast<const STObject*>(&t);
|
||||
if (!v) return false;
|
||||
if (!v)
|
||||
return false;
|
||||
boost::ptr_vector<SerializedType>::const_iterator it1 = mData.begin(), end1 = mData.end();
|
||||
boost::ptr_vector<SerializedType>::const_iterator it2 = v->mData.begin(), end2 = v->mData.end();
|
||||
while ((it1 != end1) && (it2 != end2))
|
||||
@@ -240,15 +306,35 @@ bool STObject::isEquivalent(const SerializedType& t) const
|
||||
return (it1 == end1) && (it2 == end2);
|
||||
}
|
||||
|
||||
int STObject::getFieldIndex(SOE_Field field) const
|
||||
uint256 STObject::getHash(uint32 prefix) const
|
||||
{
|
||||
Serializer s;
|
||||
s.add32(prefix);
|
||||
add(s, true);
|
||||
return s.getSHA512Half();
|
||||
}
|
||||
|
||||
uint256 STObject::getSigningHash(uint32 prefix) const
|
||||
{
|
||||
Serializer s;
|
||||
s.add32(prefix);
|
||||
add(s, false);
|
||||
return s.getSHA512Half();
|
||||
}
|
||||
|
||||
int STObject::getFieldIndex(SField::ref field) const
|
||||
{
|
||||
int i = 0;
|
||||
for (std::vector<const SOElement*>::const_iterator it = mType.begin(), end = mType.end(); it != end; ++it, ++i)
|
||||
if ((*it)->e_field == field) return i;
|
||||
BOOST_FOREACH(const SerializedType& elem, mData)
|
||||
{
|
||||
if (elem.getFName() == field)
|
||||
return i;
|
||||
++i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
const SerializedType& STObject::peekAtField(SOE_Field field) const
|
||||
const SerializedType& STObject::peekAtField(SField::ref field) const
|
||||
{
|
||||
int index = getFieldIndex(field);
|
||||
if (index == -1)
|
||||
@@ -256,7 +342,7 @@ const SerializedType& STObject::peekAtField(SOE_Field field) const
|
||||
return peekAtIndex(index);
|
||||
}
|
||||
|
||||
SerializedType& STObject::getField(SOE_Field field)
|
||||
SerializedType& STObject::getField(SField::ref field)
|
||||
{
|
||||
int index = getFieldIndex(field);
|
||||
if (index == -1)
|
||||
@@ -264,12 +350,12 @@ SerializedType& STObject::getField(SOE_Field field)
|
||||
return getIndex(index);
|
||||
}
|
||||
|
||||
SOE_Field STObject::getFieldSType(int index) const
|
||||
SField::ref STObject::getFieldSType(int index) const
|
||||
{
|
||||
return mType[index]->e_field;
|
||||
return mData[index].getFName();
|
||||
}
|
||||
|
||||
const SerializedType* STObject::peekAtPField(SOE_Field field) const
|
||||
const SerializedType* STObject::peekAtPField(SField::ref field) const
|
||||
{
|
||||
int index = getFieldIndex(field);
|
||||
if (index == -1)
|
||||
@@ -277,7 +363,7 @@ const SerializedType* STObject::peekAtPField(SOE_Field field) const
|
||||
return peekAtPIndex(index);
|
||||
}
|
||||
|
||||
SerializedType* STObject::getPField(SOE_Field field)
|
||||
SerializedType* STObject::getPField(SField::ref field)
|
||||
{
|
||||
int index = getFieldIndex(field);
|
||||
if (index == -1)
|
||||
@@ -285,7 +371,7 @@ SerializedType* STObject::getPField(SOE_Field field)
|
||||
return getPIndex(index);
|
||||
}
|
||||
|
||||
bool STObject::isFieldPresent(SOE_Field field) const
|
||||
bool STObject::isFieldPresent(SField::ref field) const
|
||||
{
|
||||
int index = getFieldIndex(field);
|
||||
if (index == -1)
|
||||
@@ -295,76 +381,78 @@ bool STObject::isFieldPresent(SOE_Field field) const
|
||||
|
||||
bool STObject::setFlag(uint32 f)
|
||||
{
|
||||
if (mFlagIdx < 0) return false;
|
||||
STUInt32* t = dynamic_cast<STUInt32*>(getPIndex(mFlagIdx));
|
||||
assert(t);
|
||||
STUInt32* t = dynamic_cast<STUInt32*>(getPField(sfFlags));
|
||||
if (!t)
|
||||
return false;
|
||||
t->setValue(t->getValue() | f);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool STObject::clearFlag(uint32 f)
|
||||
{
|
||||
if (mFlagIdx < 0) return false;
|
||||
STUInt32* t = dynamic_cast<STUInt32*>(getPIndex(mFlagIdx));
|
||||
assert(t);
|
||||
STUInt32* t = dynamic_cast<STUInt32*>(getPField(sfFlags));
|
||||
if (!t)
|
||||
return false;
|
||||
t->setValue(t->getValue() & ~f);
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32 STObject::getFlags(void) const
|
||||
{
|
||||
if (mFlagIdx < 0) return 0;
|
||||
const STUInt32* t = dynamic_cast<const STUInt32*>(peekAtPIndex(mFlagIdx));
|
||||
assert(t);
|
||||
const STUInt32* t = dynamic_cast<const STUInt32*>(peekAtPField(sfFlags));
|
||||
if (!t)
|
||||
return 0;
|
||||
return t->getValue();
|
||||
}
|
||||
|
||||
SerializedType* STObject::makeFieldPresent(SOE_Field field)
|
||||
SerializedType* STObject::makeFieldPresent(SField::ref field)
|
||||
{
|
||||
int index = getFieldIndex(field);
|
||||
if (index == -1)
|
||||
throw std::runtime_error("Field not found");
|
||||
if ((mType[index]->e_type != SOE_IFFLAG) && (mType[index]->e_type != SOE_IFNFLAG))
|
||||
throw std::runtime_error("field is not optional");
|
||||
|
||||
SerializedType* f = getPIndex(index);
|
||||
if (f->getSType() != STI_NOTPRESENT) return f;
|
||||
mData.replace(index, makeDefaultObject(mType[index]->e_id, mType[index]->e_name));
|
||||
f = getPIndex(index);
|
||||
|
||||
if (mType[index]->e_type == SOE_IFFLAG)
|
||||
setFlag(mType[index]->e_flags);
|
||||
else if (mType[index]->e_type == SOE_IFNFLAG)
|
||||
clearFlag(mType[index]->e_flags);
|
||||
|
||||
return f;
|
||||
if (f->getSType() != STI_NOTPRESENT)
|
||||
return f;
|
||||
mData.replace(index, makeDefaultObject(f->getFName()));
|
||||
return getPIndex(index);
|
||||
}
|
||||
|
||||
void STObject::makeFieldAbsent(SOE_Field field)
|
||||
void STObject::makeFieldAbsent(SField::ref field)
|
||||
{
|
||||
int index = getFieldIndex(field);
|
||||
if (index == -1)
|
||||
throw std::runtime_error("Field not found");
|
||||
if ((mType[index]->e_type != SOE_IFFLAG) && (mType[index]->e_type != SOE_IFNFLAG))
|
||||
throw std::runtime_error("field is not optional");
|
||||
|
||||
if (peekAtIndex(index).getSType() == STI_NOTPRESENT) return;
|
||||
mData.replace(index, new SerializedType(mType[index]->e_name));
|
||||
const SerializedType& f = peekAtIndex(index);
|
||||
if (f.getSType() == STI_NOTPRESENT)
|
||||
return;
|
||||
|
||||
if (mType[index]->e_type == SOE_IFFLAG)
|
||||
clearFlag(mType[index]->e_flags);
|
||||
else if (mType[index]->e_type == SOE_IFNFLAG)
|
||||
setFlag(mType[index]->e_flags);
|
||||
mData.replace(index, makeDefaultObject(f.getFName()));
|
||||
}
|
||||
|
||||
std::string STObject::getFieldString(SOE_Field field) const
|
||||
bool STObject::delField(SField::ref field)
|
||||
{
|
||||
int index = getFieldIndex(field);
|
||||
if (index == -1)
|
||||
return false;
|
||||
delField(index);
|
||||
return true;
|
||||
}
|
||||
|
||||
void STObject::delField(int index)
|
||||
{
|
||||
mData.erase(mData.begin() + index);
|
||||
}
|
||||
|
||||
std::string STObject::getFieldString(SField::ref field) const
|
||||
{
|
||||
const SerializedType* rf = peekAtPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
return rf->getText();
|
||||
}
|
||||
|
||||
unsigned char STObject::getValueFieldU8(SOE_Field field) const
|
||||
unsigned char STObject::getFieldU8(SField::ref field) const
|
||||
{
|
||||
const SerializedType* rf = peekAtPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
@@ -375,7 +463,7 @@ unsigned char STObject::getValueFieldU8(SOE_Field field) const
|
||||
return cf->getValue();
|
||||
}
|
||||
|
||||
uint16 STObject::getValueFieldU16(SOE_Field field) const
|
||||
uint16 STObject::getFieldU16(SField::ref field) const
|
||||
{
|
||||
const SerializedType* rf = peekAtPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
@@ -386,7 +474,7 @@ uint16 STObject::getValueFieldU16(SOE_Field field) const
|
||||
return cf->getValue();
|
||||
}
|
||||
|
||||
uint32 STObject::getValueFieldU32(SOE_Field field) const
|
||||
uint32 STObject::getFieldU32(SField::ref field) const
|
||||
{
|
||||
const SerializedType* rf = peekAtPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
@@ -397,7 +485,7 @@ uint32 STObject::getValueFieldU32(SOE_Field field) const
|
||||
return cf->getValue();
|
||||
}
|
||||
|
||||
uint64 STObject::getValueFieldU64(SOE_Field field) const
|
||||
uint64 STObject::getFieldU64(SField::ref field) const
|
||||
{
|
||||
const SerializedType* rf = peekAtPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
@@ -408,7 +496,7 @@ uint64 STObject::getValueFieldU64(SOE_Field field) const
|
||||
return cf->getValue();
|
||||
}
|
||||
|
||||
uint128 STObject::getValueFieldH128(SOE_Field field) const
|
||||
uint128 STObject::getFieldH128(SField::ref field) const
|
||||
{
|
||||
const SerializedType* rf = peekAtPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
@@ -419,7 +507,7 @@ uint128 STObject::getValueFieldH128(SOE_Field field) const
|
||||
return cf->getValue();
|
||||
}
|
||||
|
||||
uint160 STObject::getValueFieldH160(SOE_Field field) const
|
||||
uint160 STObject::getFieldH160(SField::ref field) const
|
||||
{
|
||||
const SerializedType* rf = peekAtPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
@@ -430,7 +518,7 @@ uint160 STObject::getValueFieldH160(SOE_Field field) const
|
||||
return cf->getValue();
|
||||
}
|
||||
|
||||
uint256 STObject::getValueFieldH256(SOE_Field field) const
|
||||
uint256 STObject::getFieldH256(SField::ref field) const
|
||||
{
|
||||
const SerializedType* rf = peekAtPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
@@ -441,7 +529,7 @@ uint256 STObject::getValueFieldH256(SOE_Field field) const
|
||||
return cf->getValue();
|
||||
}
|
||||
|
||||
NewcoinAddress STObject::getValueFieldAccount(SOE_Field field) const
|
||||
NewcoinAddress STObject::getFieldAccount(SField::ref field) const
|
||||
{
|
||||
const SerializedType* rf = peekAtPField(field);
|
||||
if (!rf)
|
||||
@@ -459,7 +547,29 @@ NewcoinAddress STObject::getValueFieldAccount(SOE_Field field) const
|
||||
return cf->getValueNCA();
|
||||
}
|
||||
|
||||
std::vector<unsigned char> STObject::getValueFieldVL(SOE_Field field) const
|
||||
uint160 STObject::getFieldAccount160(SField::ref field) const
|
||||
{
|
||||
uint160 a;
|
||||
const SerializedType* rf = peekAtPField(field);
|
||||
if (!rf)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
std::cerr << "Account field not found" << std::endl;
|
||||
std::cerr << getFullText() << std::endl;
|
||||
#endif
|
||||
throw std::runtime_error("Field not found");
|
||||
}
|
||||
SerializedTypeID id = rf->getSType();
|
||||
if (id != STI_NOTPRESENT)
|
||||
{
|
||||
const STAccount* cf = dynamic_cast<const STAccount *>(rf);
|
||||
if (!cf) throw std::runtime_error("Wrong field type");
|
||||
cf->getValueH160(a);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
std::vector<unsigned char> STObject::getFieldVL(SField::ref field) const
|
||||
{
|
||||
const SerializedType* rf = peekAtPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
@@ -470,7 +580,7 @@ std::vector<unsigned char> STObject::getValueFieldVL(SOE_Field field) const
|
||||
return cf->getValue();
|
||||
}
|
||||
|
||||
STAmount STObject::getValueFieldAmount(SOE_Field field) const
|
||||
STAmount STObject::getFieldAmount(SField::ref field) const
|
||||
{
|
||||
const SerializedType* rf = peekAtPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
@@ -481,7 +591,7 @@ STAmount STObject::getValueFieldAmount(SOE_Field field) const
|
||||
return *cf;
|
||||
}
|
||||
|
||||
STPathSet STObject::getValueFieldPathSet(SOE_Field field) const
|
||||
STPathSet STObject::getFieldPathSet(SField::ref field) const
|
||||
{
|
||||
const SerializedType* rf = peekAtPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
@@ -492,7 +602,7 @@ STPathSet STObject::getValueFieldPathSet(SOE_Field field) const
|
||||
return *cf;
|
||||
}
|
||||
|
||||
STVector256 STObject::getValueFieldV256(SOE_Field field) const
|
||||
STVector256 STObject::getFieldV256(SField::ref field) const
|
||||
{
|
||||
const SerializedType* rf = peekAtPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
@@ -503,7 +613,7 @@ STVector256 STObject::getValueFieldV256(SOE_Field field) const
|
||||
return *cf;
|
||||
}
|
||||
|
||||
void STObject::setValueFieldU8(SOE_Field field, unsigned char v)
|
||||
void STObject::setFieldU8(SField::ref field, unsigned char v)
|
||||
{
|
||||
SerializedType* rf = getPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
@@ -513,7 +623,7 @@ void STObject::setValueFieldU8(SOE_Field field, unsigned char v)
|
||||
cf->setValue(v);
|
||||
}
|
||||
|
||||
void STObject::setValueFieldU16(SOE_Field field, uint16 v)
|
||||
void STObject::setFieldU16(SField::ref field, uint16 v)
|
||||
{
|
||||
SerializedType* rf = getPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
@@ -523,7 +633,7 @@ void STObject::setValueFieldU16(SOE_Field field, uint16 v)
|
||||
cf->setValue(v);
|
||||
}
|
||||
|
||||
void STObject::setValueFieldU32(SOE_Field field, uint32 v)
|
||||
void STObject::setFieldU32(SField::ref field, uint32 v)
|
||||
{
|
||||
SerializedType* rf = getPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
@@ -533,7 +643,7 @@ void STObject::setValueFieldU32(SOE_Field field, uint32 v)
|
||||
cf->setValue(v);
|
||||
}
|
||||
|
||||
void STObject::setValueFieldU64(SOE_Field field, uint64 v)
|
||||
void STObject::setFieldU64(SField::ref field, uint64 v)
|
||||
{
|
||||
SerializedType* rf = getPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
@@ -543,7 +653,7 @@ void STObject::setValueFieldU64(SOE_Field field, uint64 v)
|
||||
cf->setValue(v);
|
||||
}
|
||||
|
||||
void STObject::setValueFieldH128(SOE_Field field, const uint128& v)
|
||||
void STObject::setFieldH128(SField::ref field, const uint128& v)
|
||||
{
|
||||
SerializedType* rf = getPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
@@ -553,7 +663,7 @@ void STObject::setValueFieldH128(SOE_Field field, const uint128& v)
|
||||
cf->setValue(v);
|
||||
}
|
||||
|
||||
void STObject::setValueFieldH160(SOE_Field field, const uint160& v)
|
||||
void STObject::setFieldH160(SField::ref field, const uint160& v)
|
||||
{
|
||||
SerializedType* rf = getPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
@@ -563,7 +673,7 @@ void STObject::setValueFieldH160(SOE_Field field, const uint160& v)
|
||||
cf->setValue(v);
|
||||
}
|
||||
|
||||
void STObject::setValueFieldH256(SOE_Field field, const uint256& v)
|
||||
void STObject::setFieldH256(SField::ref field, const uint256& v)
|
||||
{
|
||||
SerializedType* rf = getPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
@@ -573,7 +683,7 @@ void STObject::setValueFieldH256(SOE_Field field, const uint256& v)
|
||||
cf->setValue(v);
|
||||
}
|
||||
|
||||
void STObject::setValueFieldV256(SOE_Field field, const STVector256& v)
|
||||
void STObject::setFieldV256(SField::ref field, const STVector256& v)
|
||||
{
|
||||
SerializedType* rf = getPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
@@ -583,7 +693,7 @@ void STObject::setValueFieldV256(SOE_Field field, const STVector256& v)
|
||||
cf->setValue(v);
|
||||
}
|
||||
|
||||
void STObject::setValueFieldAccount(SOE_Field field, const uint160& v)
|
||||
void STObject::setFieldAccount(SField::ref field, const uint160& v)
|
||||
{
|
||||
SerializedType* rf = getPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
@@ -593,7 +703,7 @@ void STObject::setValueFieldAccount(SOE_Field field, const uint160& v)
|
||||
cf->setValueH160(v);
|
||||
}
|
||||
|
||||
void STObject::setValueFieldVL(SOE_Field field, const std::vector<unsigned char>& v)
|
||||
void STObject::setFieldVL(SField::ref field, const std::vector<unsigned char>& v)
|
||||
{
|
||||
SerializedType* rf = getPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
@@ -603,7 +713,7 @@ void STObject::setValueFieldVL(SOE_Field field, const std::vector<unsigned char>
|
||||
cf->setValue(v);
|
||||
}
|
||||
|
||||
void STObject::setValueFieldAmount(SOE_Field field, const STAmount &v)
|
||||
void STObject::setFieldAmount(SField::ref field, const STAmount &v)
|
||||
{
|
||||
SerializedType* rf = getPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
@@ -613,7 +723,7 @@ void STObject::setValueFieldAmount(SOE_Field field, const STAmount &v)
|
||||
(*cf) = v;
|
||||
}
|
||||
|
||||
void STObject::setValueFieldPathSet(SOE_Field field, const STPathSet &v)
|
||||
void STObject::setFieldPathSet(SField::ref field, const STPathSet &v)
|
||||
{
|
||||
SerializedType* rf = getPField(field);
|
||||
if (!rf) throw std::runtime_error("Field not found");
|
||||
@@ -631,9 +741,10 @@ Json::Value STObject::getJson(int options) const
|
||||
{
|
||||
if (it.getSType() != STI_NOTPRESENT)
|
||||
{
|
||||
if (it.getName() == NULL)
|
||||
if (!it.getFName().hasName())
|
||||
ret[boost::lexical_cast<std::string>(index)] = it.getJson(options);
|
||||
else ret[it.getName()] = it.getJson(options);
|
||||
else
|
||||
ret[it.getName()] = it.getJson(options);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@@ -649,6 +760,210 @@ Json::Value STVector256::getJson(int options) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string STArray::getFullText() const
|
||||
{
|
||||
return "WRITEME";
|
||||
}
|
||||
|
||||
std::string STArray::getText() const
|
||||
{
|
||||
return "WRITEME";
|
||||
}
|
||||
|
||||
Json::Value STArray::getJson(int) const
|
||||
{
|
||||
return Json::Value("WRITEME");
|
||||
}
|
||||
|
||||
void STArray::add(Serializer& s) const
|
||||
{
|
||||
BOOST_FOREACH(const STObject& object, value)
|
||||
{
|
||||
object.addFieldID(s);
|
||||
object.add(s);
|
||||
s.addFieldID(STI_OBJECT, 1);
|
||||
}
|
||||
}
|
||||
|
||||
bool STArray::isEquivalent(const SerializedType& t) const
|
||||
{
|
||||
const STArray* v = dynamic_cast<const STArray*>(&t);
|
||||
if (!v)
|
||||
return false;
|
||||
return value == v->value;
|
||||
}
|
||||
|
||||
STArray* STArray::construct(SerializerIterator& sit, SField::ref field)
|
||||
{
|
||||
vector value;
|
||||
|
||||
while (!sit.empty())
|
||||
{
|
||||
int type, field;
|
||||
sit.getFieldID(type, field);
|
||||
if ((type == STI_ARRAY) && (field == 1))
|
||||
break;
|
||||
|
||||
SField::ref fn = SField::getField(type, field);
|
||||
if (fn.isInvalid())
|
||||
throw std::runtime_error("Unknown field");
|
||||
|
||||
value.push_back(STObject(fn));
|
||||
value.rbegin()->set(sit, 1);
|
||||
}
|
||||
|
||||
return new STArray(field, value);
|
||||
}
|
||||
|
||||
std::auto_ptr<STObject> STObject::parseJson(const Json::Value& object, SField::ref inName, int depth)
|
||||
{
|
||||
if (!object.isObject())
|
||||
throw std::runtime_error("Value is not an object");
|
||||
|
||||
SField::ptr name = &inName;
|
||||
|
||||
boost::ptr_vector<SerializedType> data;
|
||||
Json::Value::Members members(object.getMemberNames());
|
||||
for (Json::Value::Members::iterator it = members.begin(), end = members.end(); it != end; ++it)
|
||||
{
|
||||
const std::string& fieldName = *it;
|
||||
const Json::Value& value = object[fieldName];
|
||||
|
||||
SField::ref field = SField::getField(fieldName);
|
||||
if (field == sfInvalid)
|
||||
throw std::runtime_error("Unknown field: " + fieldName);
|
||||
|
||||
switch (field.fieldType)
|
||||
{
|
||||
case STI_UINT8:
|
||||
if (value.isString())
|
||||
data.push_back(new STUInt8(field, boost::lexical_cast<unsigned char>(value.asString())));
|
||||
else if (value.isInt())
|
||||
data.push_back(new STUInt8(field, boost::lexical_cast<unsigned char>(value.asInt())));
|
||||
else if (value.isUInt())
|
||||
data.push_back(new STUInt8(field, boost::lexical_cast<unsigned char>(value.asUInt())));
|
||||
else
|
||||
throw std::runtime_error("Incorrect type");
|
||||
break;
|
||||
|
||||
case STI_UINT16:
|
||||
if (value.isString())
|
||||
{
|
||||
std::string strValue = value.asString();
|
||||
if (!strValue.empty() && ((strValue[0] < '0') || (strValue[0] > '9')))
|
||||
{
|
||||
if (field == sfTransactionType)
|
||||
{
|
||||
TransactionFormat* f = getTxnFormat(strValue);
|
||||
if (!f)
|
||||
throw std::runtime_error("Unknown transaction type");
|
||||
data.push_back(new STUInt16(field, static_cast<uint16>(f->t_type)));
|
||||
if (*name == sfGeneric)
|
||||
name = &sfTransaction;
|
||||
}
|
||||
else if (field == sfLedgerEntryType)
|
||||
{
|
||||
LedgerEntryFormat* f = getLgrFormat(strValue);
|
||||
if (!f)
|
||||
throw std::runtime_error("Unknown ledger entry type");
|
||||
data.push_back(new STUInt16(field, static_cast<uint16>(f->t_type)));
|
||||
if (*name == sfGeneric)
|
||||
name = &sfLedgerEntry;
|
||||
}
|
||||
else
|
||||
throw std::runtime_error("Invalid field data");
|
||||
}
|
||||
else
|
||||
data.push_back(new STUInt16(field, boost::lexical_cast<uint16>(strValue)));
|
||||
}
|
||||
else if (value.isInt())
|
||||
data.push_back(new STUInt16(field, boost::lexical_cast<uint16>(value.asInt())));
|
||||
else if (value.isUInt())
|
||||
data.push_back(new STUInt16(field, boost::lexical_cast<uint16>(value.asUInt())));
|
||||
else
|
||||
throw std::runtime_error("Incorrect type");
|
||||
break;
|
||||
|
||||
case STI_UINT32:
|
||||
if (value.isString())
|
||||
data.push_back(new STUInt32(field, boost::lexical_cast<uint32>(value.asString())));
|
||||
else if (value.isInt())
|
||||
data.push_back(new STUInt32(field, boost::lexical_cast<uint32>(value.asInt())));
|
||||
else if (value.isUInt())
|
||||
data.push_back(new STUInt32(field, boost::lexical_cast<uint32>(value.asUInt())));
|
||||
else
|
||||
throw std::runtime_error("Incorrect type");
|
||||
break;
|
||||
|
||||
case STI_UINT64:
|
||||
if (value.isString())
|
||||
data.push_back(new STUInt64(field, boost::lexical_cast<uint64>(value.asString())));
|
||||
else if (value.isInt())
|
||||
data.push_back(new STUInt64(field, boost::lexical_cast<uint64>(value.asInt())));
|
||||
else if (value.isUInt())
|
||||
data.push_back(new STUInt64(field, boost::lexical_cast<uint64>(value.asUInt())));
|
||||
else
|
||||
throw std::runtime_error("Incorrect type");
|
||||
break;
|
||||
|
||||
|
||||
case STI_HASH128:
|
||||
if (value.isString())
|
||||
data.push_back(new STHash128(field, value.asString()));
|
||||
else
|
||||
throw std::runtime_error("Incorrect type");
|
||||
break;
|
||||
|
||||
case STI_HASH160:
|
||||
if (value.isString())
|
||||
data.push_back(new STHash160(field, value.asString()));
|
||||
else
|
||||
throw std::runtime_error("Incorrect type");
|
||||
break;
|
||||
|
||||
case STI_HASH256:
|
||||
if (value.isString())
|
||||
data.push_back(new STHash256(field, value.asString()));
|
||||
else
|
||||
throw std::runtime_error("Incorrect type");
|
||||
break;
|
||||
|
||||
case STI_VL:
|
||||
// WRITEME
|
||||
|
||||
case STI_AMOUNT:
|
||||
// WRITEME
|
||||
|
||||
case STI_VECTOR256:
|
||||
// WRITEME
|
||||
|
||||
case STI_PATHSET:
|
||||
// WRITEME
|
||||
|
||||
case STI_OBJECT:
|
||||
case STI_ACCOUNT:
|
||||
case STI_TRANSACTION:
|
||||
case STI_LEDGERENTRY:
|
||||
case STI_VALIDATION:
|
||||
if (!value.isObject())
|
||||
throw std::runtime_error("Inner value is not an object");
|
||||
if (depth > 64)
|
||||
throw std::runtime_error("Json nest depth exceeded");
|
||||
data.push_back(parseJson(value, field, depth + 1));
|
||||
break;
|
||||
|
||||
case STI_ARRAY:
|
||||
// WRITEME
|
||||
|
||||
default:
|
||||
throw std::runtime_error("Invalid field type");
|
||||
}
|
||||
}
|
||||
return std::auto_ptr<STObject>(new STObject(*name, data));
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
static SOElement testSOElements[2][16] =
|
||||
{ // field, name, id, type, flags
|
||||
{
|
||||
@@ -673,7 +988,7 @@ void STObject::unitTest()
|
||||
if (!object1.isFieldPresent(sfTest2)) throw std::runtime_error("STObject Error");
|
||||
|
||||
if ((object1.getFlags() != 1) || (object2.getFlags() != 0)) throw std::runtime_error("STObject error");
|
||||
if (object1.getValueFieldH256(sfTest2) != uint256()) throw std::runtime_error("STObject error");
|
||||
if (object1.getFieldH256(sfTest2) != uint256()) throw std::runtime_error("STObject error");
|
||||
|
||||
if (object1.getSerializer() == object2.getSerializer()) throw std::runtime_error("STObject error");
|
||||
object1.makeFieldAbsent(sfTest2);
|
||||
@@ -685,7 +1000,7 @@ void STObject::unitTest()
|
||||
if (object1.isFieldPresent(sfTest2)) throw std::runtime_error("STObject error");
|
||||
if (copy.isFieldPresent(sfTest2)) throw std::runtime_error("STObject error");
|
||||
if (object1.getSerializer() != copy.getSerializer()) throw std::runtime_error("STObject error");
|
||||
copy.setValueFieldU32(sfTest3, 1);
|
||||
copy.setFieldU32(sfTest3, 1);
|
||||
if (object1.getSerializer() == copy.getSerializer()) throw std::runtime_error("STObject error");
|
||||
#ifdef DEBUG
|
||||
Log(lsDEBUG) << copy.getJson(0);
|
||||
@@ -695,17 +1010,19 @@ void STObject::unitTest()
|
||||
{
|
||||
std::cerr << "tol: i=" << i << std::endl;
|
||||
std::vector<unsigned char> j(i, 2);
|
||||
object1.setValueFieldVL(sfTest1, j);
|
||||
object1.setFieldVL(sfTest1, j);
|
||||
|
||||
Serializer s;
|
||||
object1.add(s);
|
||||
SerializerIterator it(s);
|
||||
STObject object3(testSOElements[0], it, "TestElement3");
|
||||
|
||||
if (object1.getValueFieldVL(sfTest1) != j) throw std::runtime_error("STObject error");
|
||||
if (object3.getValueFieldVL(sfTest1) != j) throw std::runtime_error("STObject error");
|
||||
if (object1.getFieldVL(sfTest1) != j) throw std::runtime_error("STObject error");
|
||||
if (object3.getFieldVL(sfTest1) != j) throw std::runtime_error("STObject error");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -9,62 +9,56 @@
|
||||
|
||||
#include "SerializedTypes.h"
|
||||
|
||||
enum SOE_Type
|
||||
{
|
||||
SOE_NEVER = -1, // never occurs (marks end of object)
|
||||
SOE_REQUIRED = 0, // required
|
||||
SOE_FLAGS = 1, // flags field
|
||||
SOE_IFFLAG = 2, // present if flag set
|
||||
SOE_IFNFLAG = 3 // present if flag not set
|
||||
};
|
||||
// Serializable object/array types
|
||||
|
||||
enum SOE_Field
|
||||
{
|
||||
sfInvalid = -1,
|
||||
sfGeneric = 0,
|
||||
|
||||
#define FIELD(name, type, index) sf##name,
|
||||
#define TYPE(name, type, index)
|
||||
#include "SerializeProto.h"
|
||||
#undef FIELD
|
||||
#undef TYPE
|
||||
|
||||
// test fields
|
||||
sfTest1, sfTest2, sfTest3, sfTest4
|
||||
};
|
||||
|
||||
struct SOElement
|
||||
class SOElement
|
||||
{ // An element in the description of a serialized object
|
||||
SOE_Field e_field;
|
||||
const char *e_name;
|
||||
SerializedTypeID e_id;
|
||||
SOE_Type e_type;
|
||||
int e_flags;
|
||||
public:
|
||||
typedef SOElement const * ptr; // used to point to one element
|
||||
typedef SOElement const * ptrList; // used to point to a terminated list of elements
|
||||
|
||||
SField::ref e_field;
|
||||
const SOE_Flags flags;
|
||||
};
|
||||
|
||||
class STObject : public SerializedType
|
||||
{
|
||||
protected:
|
||||
int mFlagIdx; // the offset to the flags object, -1 if none
|
||||
boost::ptr_vector<SerializedType> mData;
|
||||
std::vector<const SOElement*> mType;
|
||||
std::vector<SOElement::ptr> mType;
|
||||
|
||||
STObject* duplicate() const { return new STObject(*this); }
|
||||
STObject(SField::ref name, boost::ptr_vector<SerializedType>& data) : SerializedType(name) { mData.swap(data); }
|
||||
|
||||
public:
|
||||
STObject(const char *n = NULL) : SerializedType(n), mFlagIdx(-1) { ; }
|
||||
STObject(const SOElement *t, const char *n = NULL);
|
||||
STObject(const SOElement *t, SerializerIterator& u, const char *n = NULL);
|
||||
STObject() { ; }
|
||||
|
||||
STObject(SField::ref name) : SerializedType(name) { ; }
|
||||
|
||||
STObject(SOElement::ptrList type, SField::ref name) : SerializedType(name)
|
||||
{ set(type); }
|
||||
|
||||
STObject(SOElement::ptrList type, SerializerIterator& sit, SField::ref name) : SerializedType(name)
|
||||
{ set(sit); setType(type); }
|
||||
|
||||
static std::auto_ptr<STObject> parseJson(const Json::Value& value, SField::ref name = sfGeneric, int depth = 0);
|
||||
|
||||
virtual ~STObject() { ; }
|
||||
|
||||
void set(const SOElement* t);
|
||||
void set(const SOElement* t, SerializerIterator& u);
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name);
|
||||
|
||||
bool setType(SOElement::ptrList);
|
||||
bool isValidForType();
|
||||
bool isFieldAllowed(SField::ref);
|
||||
|
||||
void set(SOElement::ptrList);
|
||||
bool set(SerializerIterator& u, int depth = 0);
|
||||
|
||||
int getLength() const;
|
||||
virtual SerializedTypeID getSType() const { return STI_OBJECT; }
|
||||
virtual bool isEquivalent(const SerializedType& t) const;
|
||||
|
||||
void add(Serializer& s) const;
|
||||
virtual void add(Serializer& s) const { add(s, true); } // just inner elements
|
||||
void add(Serializer& s, bool withSignature) const;
|
||||
Serializer getSerializer() const { Serializer s; add(s); return s; }
|
||||
std::string getFullText() const;
|
||||
std::string getText() const;
|
||||
@@ -82,64 +76,133 @@ public:
|
||||
bool clearFlag(uint32);
|
||||
uint32 getFlags() const;
|
||||
|
||||
uint256 getHash(uint32 prefix) const;
|
||||
uint256 getSigningHash(uint32 prefix) const;
|
||||
|
||||
const SerializedType& peekAtIndex(int offset) const { return mData[offset]; }
|
||||
SerializedType& getIndex(int offset) { return mData[offset]; }
|
||||
const SerializedType* peekAtPIndex(int offset) const { return &(mData[offset]); }
|
||||
SerializedType* getPIndex(int offset) { return &(mData[offset]); }
|
||||
|
||||
int getFieldIndex(SOE_Field field) const;
|
||||
SOE_Field getFieldSType(int index) const;
|
||||
int getFieldIndex(SField::ref field) const;
|
||||
SField::ref getFieldSType(int index) const;
|
||||
|
||||
const SerializedType& peekAtField(SOE_Field field) const;
|
||||
SerializedType& getField(SOE_Field field);
|
||||
const SerializedType* peekAtPField(SOE_Field field) const;
|
||||
SerializedType* getPField(SOE_Field field);
|
||||
const SOElement* getFieldType(SOE_Field field) const;
|
||||
const SerializedType& peekAtField(SField::ref field) const;
|
||||
SerializedType& getField(SField::ref field);
|
||||
const SerializedType* peekAtPField(SField::ref field) const;
|
||||
SerializedType* getPField(SField::ref field);
|
||||
|
||||
// these throw if the field type doesn't match, or return default values if the
|
||||
// field is optional but not present
|
||||
std::string getFieldString(SOE_Field field) const;
|
||||
unsigned char getValueFieldU8(SOE_Field field) const;
|
||||
uint16 getValueFieldU16(SOE_Field field) const;
|
||||
uint32 getValueFieldU32(SOE_Field field) const;
|
||||
uint64 getValueFieldU64(SOE_Field field) const;
|
||||
uint128 getValueFieldH128(SOE_Field field) const;
|
||||
uint160 getValueFieldH160(SOE_Field field) const;
|
||||
uint256 getValueFieldH256(SOE_Field field) const;
|
||||
NewcoinAddress getValueFieldAccount(SOE_Field field) const;
|
||||
std::vector<unsigned char> getValueFieldVL(SOE_Field field) const;
|
||||
std::vector<TaggedListItem> getValueFieldTL(SOE_Field field) const;
|
||||
STAmount getValueFieldAmount(SOE_Field field) const;
|
||||
STPathSet getValueFieldPathSet(SOE_Field field) const;
|
||||
STVector256 getValueFieldV256(SOE_Field field) const;
|
||||
std::string getFieldString(SField::ref field) const;
|
||||
unsigned char getFieldU8(SField::ref field) const;
|
||||
uint16 getFieldU16(SField::ref field) const;
|
||||
uint32 getFieldU32(SField::ref field) const;
|
||||
uint64 getFieldU64(SField::ref field) const;
|
||||
uint128 getFieldH128(SField::ref field) const;
|
||||
uint160 getFieldH160(SField::ref field) const;
|
||||
uint256 getFieldH256(SField::ref field) const;
|
||||
NewcoinAddress getFieldAccount(SField::ref field) const;
|
||||
uint160 getFieldAccount160(SField::ref field) const;
|
||||
std::vector<unsigned char> getFieldVL(SField::ref field) const;
|
||||
std::vector<TaggedListItem> getFieldTL(SField::ref field) const;
|
||||
STAmount getFieldAmount(SField::ref field) const;
|
||||
STPathSet getFieldPathSet(SField::ref field) const;
|
||||
STVector256 getFieldV256(SField::ref field) const;
|
||||
|
||||
void setValueFieldU8(SOE_Field field, unsigned char);
|
||||
void setValueFieldU16(SOE_Field field, uint16);
|
||||
void setValueFieldU32(SOE_Field field, uint32);
|
||||
void setValueFieldU64(SOE_Field field, uint64);
|
||||
void setValueFieldH128(SOE_Field field, const uint128&);
|
||||
void setValueFieldH160(SOE_Field field, const uint160&);
|
||||
void setValueFieldH256(SOE_Field field, const uint256&);
|
||||
void setValueFieldVL(SOE_Field field, const std::vector<unsigned char>&);
|
||||
void setValueFieldTL(SOE_Field field, const std::vector<TaggedListItem>&);
|
||||
void setValueFieldAccount(SOE_Field field, const uint160&);
|
||||
void setValueFieldAccount(SOE_Field field, const NewcoinAddress& addr)
|
||||
{ setValueFieldAccount(field, addr.getAccountID()); }
|
||||
void setValueFieldAmount(SOE_Field field, const STAmount&);
|
||||
void setValueFieldPathSet(SOE_Field field, const STPathSet&);
|
||||
void setValueFieldV256(SOE_Field field, const STVector256& v);
|
||||
void setFieldU8(SField::ref field, unsigned char);
|
||||
void setFieldU16(SField::ref field, uint16);
|
||||
void setFieldU32(SField::ref field, uint32);
|
||||
void setFieldU64(SField::ref field, uint64);
|
||||
void setFieldH128(SField::ref field, const uint128&);
|
||||
void setFieldH160(SField::ref field, const uint160&);
|
||||
void setFieldH256(SField::ref field, const uint256&);
|
||||
void setFieldVL(SField::ref field, const std::vector<unsigned char>&);
|
||||
void setFieldTL(SField::ref field, const std::vector<TaggedListItem>&);
|
||||
void setFieldAccount(SField::ref field, const uint160&);
|
||||
void setFieldAccount(SField::ref field, const NewcoinAddress& addr)
|
||||
{ setFieldAccount(field, addr.getAccountID()); }
|
||||
void setFieldAmount(SField::ref field, const STAmount&);
|
||||
void setFieldPathSet(SField::ref field, const STPathSet&);
|
||||
void setFieldV256(SField::ref field, const STVector256& v);
|
||||
|
||||
bool isFieldPresent(SOE_Field field) const;
|
||||
SerializedType* makeFieldPresent(SOE_Field field);
|
||||
void makeFieldAbsent(SOE_Field field);
|
||||
bool isFieldPresent(SField::ref field) const;
|
||||
SerializedType* makeFieldPresent(SField::ref field);
|
||||
void makeFieldAbsent(SField::ref field);
|
||||
bool delField(SField::ref field);
|
||||
void delField(int index);
|
||||
|
||||
static std::auto_ptr<SerializedType> makeDefaultObject(SerializedTypeID id, const char *name);
|
||||
static std::auto_ptr<SerializedType> makeDeserializedObject(SerializedTypeID id, const char *name,
|
||||
SerializerIterator&);
|
||||
static std::auto_ptr<SerializedType> makeDefaultObject(SerializedTypeID id, SField::ref name);
|
||||
static std::auto_ptr<SerializedType> makeDeserializedObject(SerializedTypeID id, SField::ref name,
|
||||
SerializerIterator&, int depth);
|
||||
|
||||
static std::auto_ptr<SerializedType> makeNonPresentObject(SField::ref name)
|
||||
{ return makeDefaultObject(STI_NOTPRESENT, name); }
|
||||
static std::auto_ptr<SerializedType> makeDefaultObject(SField::ref name)
|
||||
{ return makeDefaultObject(name.fieldType, name); }
|
||||
|
||||
static void unitTest();
|
||||
};
|
||||
|
||||
class STArray : public SerializedType
|
||||
{
|
||||
public:
|
||||
typedef std::vector<STObject> vector;
|
||||
typedef std::vector<STObject>::iterator iterator;
|
||||
typedef std::vector<STObject>::const_iterator const_iterator;
|
||||
typedef std::vector<STObject>::reverse_iterator reverse_iterator;
|
||||
typedef std::vector<STObject>::const_reverse_iterator const_reverse_iterator;
|
||||
typedef std::vector<STObject>::size_type size_type;
|
||||
|
||||
protected:
|
||||
|
||||
vector value;
|
||||
|
||||
STArray* duplicate() const { return new STArray(*this); }
|
||||
static STArray* construct(SerializerIterator&, SField::ref);
|
||||
|
||||
public:
|
||||
|
||||
STArray() { ; }
|
||||
STArray(SField::ref f) : SerializedType(f) { ; }
|
||||
STArray(SField::ref f, const vector& v) : SerializedType(f), value(v) { ; }
|
||||
STArray(vector& v) : value(v) { ; }
|
||||
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
const vector& getValue() const { return value; }
|
||||
vector& getValue() { return value; }
|
||||
|
||||
// vector-like functions
|
||||
void push_back(const STObject& object) { value.push_back(object); }
|
||||
STObject& operator[](int j) { return value[j]; }
|
||||
const STObject& operator[](int j) const { return value[j]; }
|
||||
iterator begin() { return value.begin(); }
|
||||
const_iterator begin() const { return value.begin(); }
|
||||
iterator end() { return value.end(); }
|
||||
const_iterator end() const { return value.end(); }
|
||||
size_type size() const { return value.size(); }
|
||||
reverse_iterator rbegin() { return value.rbegin(); }
|
||||
const_reverse_iterator rbegin() const { return value.rbegin(); }
|
||||
reverse_iterator rend() { return value.rend(); }
|
||||
const_reverse_iterator rend() const { return value.rend(); }
|
||||
iterator erase(iterator pos) { return value.erase(pos); }
|
||||
void pop_back() { value.pop_back(); }
|
||||
bool empty() const { return value.empty(); }
|
||||
void clear() { value.clear(); }
|
||||
|
||||
virtual std::string getFullText() const;
|
||||
virtual std::string getText() const;
|
||||
virtual Json::Value getJson(int) const;
|
||||
virtual void add(Serializer& s) const;
|
||||
|
||||
bool operator==(const STArray &s) { return value == s.value; }
|
||||
bool operator!=(const STArray &s) { return value != s.value; }
|
||||
|
||||
virtual SerializedTypeID getSType() const { return STI_ARRAY; }
|
||||
virtual bool isEquivalent(const SerializedType& t) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
// vim:ts=4
|
||||
|
||||
@@ -7,21 +7,16 @@
|
||||
#include "Log.h"
|
||||
#include "HashPrefixes.h"
|
||||
|
||||
SerializedTransaction::SerializedTransaction(TransactionType type) : mType(type)
|
||||
SerializedTransaction::SerializedTransaction(TransactionType type) : STObject(sfTransaction), mType(type)
|
||||
{
|
||||
mFormat = getTxnFormat(type);
|
||||
if (mFormat == NULL) throw std::runtime_error("invalid transaction type");
|
||||
|
||||
mMiddleTxn.giveObject(new STVariableLength("SigningPubKey"));
|
||||
mMiddleTxn.giveObject(new STAccount("SourceAccount"));
|
||||
mMiddleTxn.giveObject(new STUInt32("Sequence"));
|
||||
mMiddleTxn.giveObject(new STUInt16("Type", static_cast<uint16>(type)));
|
||||
mMiddleTxn.giveObject(new STAmount("Fee"));
|
||||
|
||||
mInnerTxn = STObject(mFormat->elements, "InnerTransaction");
|
||||
if (mFormat == NULL)
|
||||
throw std::runtime_error("invalid transaction type");
|
||||
set(mFormat->elements);
|
||||
setFieldU16(sfTransactionType, mFormat->t_type);
|
||||
}
|
||||
|
||||
SerializedTransaction::SerializedTransaction(SerializerIterator& sit)
|
||||
SerializedTransaction::SerializedTransaction(SerializerIterator& sit) : STObject(sfTransaction)
|
||||
{
|
||||
int length = sit.getBytesLeft();
|
||||
if ((length < TransactionMinLen) || (length > TransactionMaxLen))
|
||||
@@ -30,32 +25,17 @@ SerializedTransaction::SerializedTransaction(SerializerIterator& sit)
|
||||
throw std::runtime_error("Transaction length invalid");
|
||||
}
|
||||
|
||||
mSignature.setValue(sit.getVL());
|
||||
set(sit);
|
||||
mType = static_cast<TransactionType>(getFieldU16(sfTransactionType));
|
||||
|
||||
mMiddleTxn.giveObject(new STVariableLength("SigningPubKey", sit.getVL()));
|
||||
|
||||
STAccount sa("SourceAccount", sit.getVL());
|
||||
mSourceAccount = sa.getValueNCA();
|
||||
mMiddleTxn.giveObject(new STAccount(sa));
|
||||
|
||||
mMiddleTxn.giveObject(new STUInt32("Sequence", sit.get32()));
|
||||
|
||||
mType = static_cast<TransactionType>(sit.get16());
|
||||
mMiddleTxn.giveObject(new STUInt16("Type", static_cast<uint16>(mType)));
|
||||
mFormat = getTxnFormat(mType);
|
||||
if (!mFormat)
|
||||
throw std::runtime_error("invalid transaction type");
|
||||
if (!setType(mFormat->elements))
|
||||
{
|
||||
Log(lsERROR) << "Transaction has invalid type";
|
||||
throw std::runtime_error("Transaction has invalid type");
|
||||
assert(false);
|
||||
throw std::runtime_error("transaction not valid");
|
||||
}
|
||||
mMiddleTxn.giveObject(STAmount::deserialize(sit, "Fee"));
|
||||
|
||||
mInnerTxn = STObject(mFormat->elements, sit, "InnerTransaction");
|
||||
}
|
||||
|
||||
int SerializedTransaction::getLength() const
|
||||
{
|
||||
return mSignature.getLength() + mMiddleTxn.getLength() + mInnerTxn.getLength();
|
||||
}
|
||||
|
||||
std::string SerializedTransaction::getFullText() const
|
||||
@@ -63,29 +43,21 @@ std::string SerializedTransaction::getFullText() const
|
||||
std::string ret = "\"";
|
||||
ret += getTransactionID().GetHex();
|
||||
ret += "\" = {";
|
||||
ret += mSignature.getFullText();
|
||||
ret += mMiddleTxn.getFullText();
|
||||
ret += mInnerTxn.getFullText();
|
||||
ret += STObject::getFullText();
|
||||
ret += "}";
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string SerializedTransaction::getText() const
|
||||
{
|
||||
std::string ret = "{";
|
||||
ret += mSignature.getText();
|
||||
ret += mMiddleTxn.getText();
|
||||
ret += mInnerTxn.getText();
|
||||
ret += "}";
|
||||
return ret;
|
||||
return STObject::getText();
|
||||
}
|
||||
|
||||
std::vector<NewcoinAddress> SerializedTransaction::getAffectedAccounts() const
|
||||
{
|
||||
std::vector<NewcoinAddress> accounts;
|
||||
accounts.push_back(mSourceAccount);
|
||||
|
||||
BOOST_FOREACH(const SerializedType& it, mInnerTxn.peekData())
|
||||
BOOST_FOREACH(const SerializedType& it, peekData())
|
||||
{
|
||||
const STAccount* sa = dynamic_cast<const STAccount*>(&it);
|
||||
if (sa != NULL)
|
||||
@@ -108,197 +80,61 @@ std::vector<NewcoinAddress> SerializedTransaction::getAffectedAccounts() const
|
||||
return accounts;
|
||||
}
|
||||
|
||||
void SerializedTransaction::add(Serializer& s) const
|
||||
{
|
||||
mSignature.add(s);
|
||||
mMiddleTxn.add(s);
|
||||
mInnerTxn.add(s);
|
||||
}
|
||||
|
||||
bool SerializedTransaction::isEquivalent(const SerializedType& t) const
|
||||
{ // Signatures are not compared
|
||||
const SerializedTransaction* v = dynamic_cast<const SerializedTransaction*>(&t);
|
||||
if (!v) return false;
|
||||
if (mType != v->mType) return false;
|
||||
if (mMiddleTxn != v->mMiddleTxn) return false;
|
||||
if (mInnerTxn != v->mInnerTxn) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
uint256 SerializedTransaction::getSigningHash() const
|
||||
{
|
||||
Serializer s;
|
||||
s.add32(sHP_TransactionSign);
|
||||
mMiddleTxn.add(s);
|
||||
mInnerTxn.add(s);
|
||||
return s.getSHA512Half();
|
||||
return STObject::getSigningHash(sHP_TransactionSign);
|
||||
}
|
||||
|
||||
uint256 SerializedTransaction::getTransactionID() const
|
||||
{ // perhaps we should cache this
|
||||
Serializer s;
|
||||
s.add32(sHP_TransactionID);
|
||||
mSignature.add(s);
|
||||
mMiddleTxn.add(s);
|
||||
mInnerTxn.add(s);
|
||||
return s.getSHA512Half();
|
||||
return getHash(sHP_TransactionID);
|
||||
}
|
||||
|
||||
std::vector<unsigned char> SerializedTransaction::getSignature() const
|
||||
{
|
||||
return mSignature.getValue();
|
||||
try
|
||||
{
|
||||
return getFieldVL(sfTxnSignature);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return std::vector<unsigned char>();
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<unsigned char>& SerializedTransaction::peekSignature() const
|
||||
void SerializedTransaction::sign(const NewcoinAddress& naAccountPrivate)
|
||||
{
|
||||
return mSignature.peekValue();
|
||||
}
|
||||
|
||||
bool SerializedTransaction::sign(const NewcoinAddress& naAccountPrivate)
|
||||
{
|
||||
return naAccountPrivate.accountPrivateSign(getSigningHash(), mSignature.peekValue());
|
||||
std::vector<unsigned char> signature;
|
||||
naAccountPrivate.accountPrivateSign(getSigningHash(), signature);
|
||||
setFieldVL(sfTxnSignature, signature);
|
||||
}
|
||||
|
||||
bool SerializedTransaction::checkSign(const NewcoinAddress& naAccountPublic) const
|
||||
{
|
||||
return naAccountPublic.accountPublicVerify(getSigningHash(), mSignature.getValue());
|
||||
try
|
||||
{
|
||||
return naAccountPublic.accountPublicVerify(getSigningHash(), getFieldVL(sfTxnSignature));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void SerializedTransaction::setSignature(const std::vector<unsigned char>& sig)
|
||||
void SerializedTransaction::setSigningPubKey(const NewcoinAddress& naSignPubKey)
|
||||
{
|
||||
mSignature.setValue(sig);
|
||||
setFieldVL(sfSigningPubKey, naSignPubKey.getAccountPublic());
|
||||
}
|
||||
|
||||
STAmount SerializedTransaction::getTransactionFee() const
|
||||
void SerializedTransaction::setSourceAccount(const NewcoinAddress& naSource)
|
||||
{
|
||||
const STAmount* v = dynamic_cast<const STAmount*>(mMiddleTxn.peekAtPIndex(TransactionIFee));
|
||||
if (!v) throw std::runtime_error("corrupt transaction");
|
||||
return *v;
|
||||
}
|
||||
|
||||
void SerializedTransaction::setTransactionFee(const STAmount& fee)
|
||||
{
|
||||
STAmount* v = dynamic_cast<STAmount*>(mMiddleTxn.getPIndex(TransactionIFee));
|
||||
if (!v) throw std::runtime_error("corrupt transaction");
|
||||
v->setValue(fee);
|
||||
}
|
||||
|
||||
uint32 SerializedTransaction::getSequence() const
|
||||
{
|
||||
const STUInt32* v = dynamic_cast<const STUInt32*>(mMiddleTxn.peekAtPIndex(TransactionISequence));
|
||||
if (!v) throw std::runtime_error("corrupt transaction");
|
||||
return v->getValue();
|
||||
}
|
||||
|
||||
void SerializedTransaction::setSequence(uint32 seq)
|
||||
{
|
||||
STUInt32* v = dynamic_cast<STUInt32*>(mMiddleTxn.getPIndex(TransactionISequence));
|
||||
if (!v) throw std::runtime_error("corrupt transaction");
|
||||
v->setValue(seq);
|
||||
}
|
||||
|
||||
std::vector<unsigned char> SerializedTransaction::getSigningPubKey() const
|
||||
{
|
||||
const STVariableLength* v =
|
||||
dynamic_cast<const STVariableLength*>(mMiddleTxn.peekAtPIndex(TransactionISigningPubKey));
|
||||
if (!v) throw std::runtime_error("corrupt transaction");
|
||||
return v->getValue();
|
||||
}
|
||||
|
||||
const std::vector<unsigned char>& SerializedTransaction::peekSigningPubKey() const
|
||||
{
|
||||
const STVariableLength* v=
|
||||
dynamic_cast<const STVariableLength*>(mMiddleTxn.peekAtPIndex(TransactionISigningPubKey));
|
||||
if (!v) throw std::runtime_error("corrupt transaction");
|
||||
return v->peekValue();
|
||||
}
|
||||
|
||||
std::vector<unsigned char>& SerializedTransaction::peekSigningPubKey()
|
||||
{
|
||||
STVariableLength* v = dynamic_cast<STVariableLength*>(mMiddleTxn.getPIndex(TransactionISigningPubKey));
|
||||
if (!v) throw std::runtime_error("corrupt transaction");
|
||||
return v->peekValue();
|
||||
}
|
||||
|
||||
const NewcoinAddress& SerializedTransaction::setSigningPubKey(const NewcoinAddress& naSignPubKey)
|
||||
{
|
||||
mSignPubKey = naSignPubKey;
|
||||
|
||||
STVariableLength* v = dynamic_cast<STVariableLength*>(mMiddleTxn.getPIndex(TransactionISigningPubKey));
|
||||
if (!v) throw std::runtime_error("corrupt transaction");
|
||||
v->setValue(mSignPubKey.getAccountPublic());
|
||||
|
||||
return mSignPubKey;
|
||||
}
|
||||
|
||||
const NewcoinAddress& SerializedTransaction::setSourceAccount(const NewcoinAddress& naSource)
|
||||
{
|
||||
mSourceAccount = naSource;
|
||||
|
||||
STAccount* v = dynamic_cast<STAccount*>(mMiddleTxn.getPIndex(TransactionISourceID));
|
||||
if (!v) throw std::runtime_error("corrupt transaction");
|
||||
v->setValueNCA(mSourceAccount);
|
||||
return mSourceAccount;
|
||||
}
|
||||
|
||||
uint160 SerializedTransaction::getITFieldAccount(SOE_Field field) const
|
||||
{
|
||||
uint160 r;
|
||||
const SerializedType* st = mInnerTxn.peekAtPField(field);
|
||||
if (!st) return r;
|
||||
|
||||
const STAccount* ac = dynamic_cast<const STAccount*>(st);
|
||||
if (!ac) return r;
|
||||
ac->getValueH160(r);
|
||||
return r;
|
||||
}
|
||||
|
||||
int SerializedTransaction::getITFieldIndex(SOE_Field field) const
|
||||
{
|
||||
return mInnerTxn.getFieldIndex(field);
|
||||
}
|
||||
|
||||
int SerializedTransaction::getITFieldCount() const
|
||||
{
|
||||
return mInnerTxn.getCount();
|
||||
}
|
||||
|
||||
bool SerializedTransaction::getITFieldPresent(SOE_Field field) const
|
||||
{
|
||||
return mInnerTxn.isFieldPresent(field);
|
||||
}
|
||||
|
||||
const SerializedType& SerializedTransaction::peekITField(SOE_Field field) const
|
||||
{
|
||||
return mInnerTxn.peekAtField(field);
|
||||
}
|
||||
|
||||
SerializedType& SerializedTransaction::getITField(SOE_Field field)
|
||||
{
|
||||
return mInnerTxn.getField(field);
|
||||
}
|
||||
|
||||
void SerializedTransaction::makeITFieldPresent(SOE_Field field)
|
||||
{
|
||||
mInnerTxn.makeFieldPresent(field);
|
||||
}
|
||||
|
||||
void SerializedTransaction::makeITFieldAbsent(SOE_Field field)
|
||||
{
|
||||
return mInnerTxn.makeFieldAbsent(field);
|
||||
setFieldAccount(sfAccount, naSource);
|
||||
}
|
||||
|
||||
Json::Value SerializedTransaction::getJson(int options) const
|
||||
{
|
||||
Json::Value ret = Json::objectValue;
|
||||
Json::Value ret = STObject::getJson(0);
|
||||
ret["id"] = getTransactionID().GetHex();
|
||||
ret["signature"] = mSignature.getText();
|
||||
|
||||
Json::Value middle = mMiddleTxn.getJson(options);
|
||||
middle["type"] = mFormat->t_name;
|
||||
ret["middle"] = middle;
|
||||
|
||||
ret["inner"] = mInnerTxn.getJson(options);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,17 +17,13 @@
|
||||
#define TXN_SQL_INCLUDED 'I'
|
||||
#define TXN_SQL_UNKNOWN 'U'
|
||||
|
||||
class SerializedTransaction : public SerializedType
|
||||
class SerializedTransaction : public STObject
|
||||
{
|
||||
public:
|
||||
typedef boost::shared_ptr<SerializedTransaction> pointer;
|
||||
|
||||
protected:
|
||||
NewcoinAddress mSignPubKey;
|
||||
NewcoinAddress mSourceAccount;
|
||||
TransactionType mType;
|
||||
STVariableLength mSignature;
|
||||
STObject mMiddleTxn, mInnerTxn;
|
||||
const TransactionFormat* mFormat;
|
||||
|
||||
SerializedTransaction* duplicate() const { return new SerializedTransaction(*this); }
|
||||
@@ -37,84 +33,27 @@ public:
|
||||
SerializedTransaction(TransactionType type);
|
||||
|
||||
// STObject functions
|
||||
int getLength() const;
|
||||
SerializedTypeID getSType() const { return STI_TRANSACTION; }
|
||||
std::string getFullText() const;
|
||||
std::string getText() const;
|
||||
void add(Serializer& s) const;
|
||||
virtual bool isEquivalent(const SerializedType& t) const;
|
||||
|
||||
// outer transaction functions / signature functions
|
||||
std::vector<unsigned char> getSignature() const;
|
||||
const std::vector<unsigned char>& peekSignature() const;
|
||||
void setSignature(const std::vector<unsigned char>& s);
|
||||
void setSignature(const std::vector<unsigned char>& s) { setFieldVL(sfTxnSignature, s); }
|
||||
uint256 getSigningHash() const;
|
||||
|
||||
TransactionType getTxnType() const { return mType; }
|
||||
STAmount getTransactionFee() const;
|
||||
void setTransactionFee(const STAmount& fee);
|
||||
TransactionType getTxnType() const { return mType; }
|
||||
STAmount getTransactionFee() const { return getFieldAmount(sfFee); }
|
||||
void setTransactionFee(const STAmount& fee) { setFieldAmount(sfFee, fee); }
|
||||
|
||||
const NewcoinAddress& getSourceAccount() const { return mSourceAccount; }
|
||||
std::vector<unsigned char> getSigningPubKey() const;
|
||||
const std::vector<unsigned char>& peekSigningPubKey() const;
|
||||
std::vector<unsigned char>& peekSigningPubKey();
|
||||
const NewcoinAddress& setSigningPubKey(const NewcoinAddress& naSignPubKey);
|
||||
const NewcoinAddress& setSourceAccount(const NewcoinAddress& naSource);
|
||||
NewcoinAddress getSourceAccount() const { return getFieldAccount(sfAccount); }
|
||||
std::vector<unsigned char> getSigningPubKey() const { return getFieldVL(sfSigningPubKey); }
|
||||
void setSigningPubKey(const NewcoinAddress& naSignPubKey);
|
||||
void setSourceAccount(const NewcoinAddress& naSource);
|
||||
std::string getTransactionType() const { return mFormat->t_name; }
|
||||
|
||||
// inner transaction functions
|
||||
uint32 getFlags() const { return mInnerTxn.getFlags(); }
|
||||
void setFlag(uint32 v) { mInnerTxn.setFlag(v); }
|
||||
void clearFlag(uint32 v) { mInnerTxn.clearFlag(v); }
|
||||
|
||||
uint32 getSequence() const;
|
||||
void setSequence(uint32);
|
||||
|
||||
// inner transaction field functions
|
||||
int getITFieldIndex(SOE_Field field) const;
|
||||
int getITFieldCount() const;
|
||||
const SerializedType& peekITField(SOE_Field field) const;
|
||||
SerializedType& getITField(SOE_Field field);
|
||||
|
||||
// inner transaction field value functions
|
||||
std::string getITFieldString(SOE_Field field) const { return mInnerTxn.getFieldString(field); }
|
||||
unsigned char getITFieldU8(SOE_Field field) const { return mInnerTxn.getValueFieldU8(field); }
|
||||
uint16 getITFieldU16(SOE_Field field) const { return mInnerTxn.getValueFieldU16(field); }
|
||||
uint32 getITFieldU32(SOE_Field field) const { return mInnerTxn.getValueFieldU32(field); }
|
||||
uint64 getITFieldU64(SOE_Field field) const { return mInnerTxn.getValueFieldU64(field); }
|
||||
uint128 getITFieldH128(SOE_Field field) const { return mInnerTxn.getValueFieldH128(field); }
|
||||
uint160 getITFieldH160(SOE_Field field) const { return mInnerTxn.getValueFieldH160(field); }
|
||||
uint160 getITFieldAccount(SOE_Field field) const;
|
||||
uint256 getITFieldH256(SOE_Field field) const { return mInnerTxn.getValueFieldH256(field); }
|
||||
std::vector<unsigned char> getITFieldVL(SOE_Field field) const { return mInnerTxn.getValueFieldVL(field); }
|
||||
std::vector<TaggedListItem> getITFieldTL(SOE_Field field) const { return mInnerTxn.getValueFieldTL(field); }
|
||||
STAmount getITFieldAmount(SOE_Field field) const { return mInnerTxn.getValueFieldAmount(field); }
|
||||
STPathSet getITFieldPathSet(SOE_Field field) const { return mInnerTxn.getValueFieldPathSet(field); }
|
||||
|
||||
void setITFieldU8(SOE_Field field, unsigned char v) { return mInnerTxn.setValueFieldU8(field, v); }
|
||||
void setITFieldU16(SOE_Field field, uint16 v) { return mInnerTxn.setValueFieldU16(field, v); }
|
||||
void setITFieldU32(SOE_Field field, uint32 v) { return mInnerTxn.setValueFieldU32(field, v); }
|
||||
void setITFieldU64(SOE_Field field, uint32 v) { return mInnerTxn.setValueFieldU64(field, v); }
|
||||
void setITFieldH128(SOE_Field field, const uint128& v) { return mInnerTxn.setValueFieldH128(field, v); }
|
||||
void setITFieldH160(SOE_Field field, const uint160& v) { return mInnerTxn.setValueFieldH160(field, v); }
|
||||
void setITFieldH256(SOE_Field field, const uint256& v) { return mInnerTxn.setValueFieldH256(field, v); }
|
||||
void setITFieldVL(SOE_Field field, const std::vector<unsigned char>& v)
|
||||
{ return mInnerTxn.setValueFieldVL(field, v); }
|
||||
void setITFieldTL(SOE_Field field, const std::vector<TaggedListItem>& v)
|
||||
{ return mInnerTxn.setValueFieldTL(field, v); }
|
||||
void setITFieldAccount(SOE_Field field, const uint160& v)
|
||||
{ return mInnerTxn.setValueFieldAccount(field, v); }
|
||||
void setITFieldAccount(SOE_Field field, const NewcoinAddress& v)
|
||||
{ return mInnerTxn.setValueFieldAccount(field, v); }
|
||||
void setITFieldAmount(SOE_Field field, const STAmount& v)
|
||||
{ return mInnerTxn.setValueFieldAmount(field, v); }
|
||||
void setITFieldPathSet(SOE_Field field, const STPathSet& v)
|
||||
{ return mInnerTxn.setValueFieldPathSet(field, v); }
|
||||
|
||||
// optional field functions
|
||||
bool getITFieldPresent(SOE_Field field) const;
|
||||
void makeITFieldPresent(SOE_Field field);
|
||||
void makeITFieldAbsent(SOE_Field field);
|
||||
uint32 getSequence() const { return getFieldU32(sfSequence); }
|
||||
void setSequence(uint32 seq) { return setFieldU32(sfSequence, seq); }
|
||||
|
||||
std::vector<NewcoinAddress> getAffectedAccounts() const;
|
||||
|
||||
@@ -122,7 +61,7 @@ public:
|
||||
|
||||
virtual Json::Value getJson(int options) const;
|
||||
|
||||
bool sign(const NewcoinAddress& naAccountPrivate);
|
||||
void sign(const NewcoinAddress& naAccountPrivate);
|
||||
bool checkSign(const NewcoinAddress& naAccountPublic) const;
|
||||
|
||||
// SQL Functions
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "SerializedTypes.h"
|
||||
#include "SerializedObject.h"
|
||||
#include "TransactionFormats.h"
|
||||
#include "LedgerFormats.h"
|
||||
#include "FieldNames.h"
|
||||
#include "Log.h"
|
||||
#include "NewcoinAddress.h"
|
||||
#include "utils.h"
|
||||
@@ -17,9 +19,9 @@ std::string SerializedType::getFullText() const
|
||||
std::string ret;
|
||||
if (getSType() != STI_NOTPRESENT)
|
||||
{
|
||||
if(name != NULL)
|
||||
if(fName->hasName())
|
||||
{
|
||||
ret = name;
|
||||
ret = fName->fieldName;
|
||||
ret += " = ";
|
||||
}
|
||||
ret += getText();
|
||||
@@ -27,7 +29,7 @@ std::string SerializedType::getFullText() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
STUInt8* STUInt8::construct(SerializerIterator& u, const char *name)
|
||||
STUInt8* STUInt8::construct(SerializerIterator& u, SField::ref name)
|
||||
{
|
||||
return new STUInt8(name, u.get8());
|
||||
}
|
||||
@@ -43,13 +45,25 @@ bool STUInt8::isEquivalent(const SerializedType& t) const
|
||||
return v && (value == v->value);
|
||||
}
|
||||
|
||||
STUInt16* STUInt16::construct(SerializerIterator& u, const char *name)
|
||||
STUInt16* STUInt16::construct(SerializerIterator& u, SField::ref name)
|
||||
{
|
||||
return new STUInt16(name, u.get16());
|
||||
}
|
||||
|
||||
std::string STUInt16::getText() const
|
||||
{
|
||||
if (getFName() == sfLedgerEntryType)
|
||||
{
|
||||
LedgerEntryFormat *f = getLgrFormat(value);
|
||||
if (f != NULL)
|
||||
return f->t_name;
|
||||
}
|
||||
if (getFName() == sfTransactionType)
|
||||
{
|
||||
TransactionFormat *f = getTxnFormat(value);
|
||||
if (f != NULL)
|
||||
return f->t_name;
|
||||
}
|
||||
return boost::lexical_cast<std::string>(value);
|
||||
}
|
||||
|
||||
@@ -59,7 +73,7 @@ bool STUInt16::isEquivalent(const SerializedType& t) const
|
||||
return v && (value == v->value);
|
||||
}
|
||||
|
||||
STUInt32* STUInt32::construct(SerializerIterator& u, const char *name)
|
||||
STUInt32* STUInt32::construct(SerializerIterator& u, SField::ref name)
|
||||
{
|
||||
return new STUInt32(name, u.get32());
|
||||
}
|
||||
@@ -75,7 +89,7 @@ bool STUInt32::isEquivalent(const SerializedType& t) const
|
||||
return v && (value == v->value);
|
||||
}
|
||||
|
||||
STUInt64* STUInt64::construct(SerializerIterator& u, const char *name)
|
||||
STUInt64* STUInt64::construct(SerializerIterator& u, SField::ref name)
|
||||
{
|
||||
return new STUInt64(name, u.get64());
|
||||
}
|
||||
@@ -91,7 +105,7 @@ bool STUInt64::isEquivalent(const SerializedType& t) const
|
||||
return v && (value == v->value);
|
||||
}
|
||||
|
||||
STHash128* STHash128::construct(SerializerIterator& u, const char *name)
|
||||
STHash128* STHash128::construct(SerializerIterator& u, SField::ref name)
|
||||
{
|
||||
return new STHash128(name, u.get128());
|
||||
}
|
||||
@@ -107,7 +121,7 @@ bool STHash128::isEquivalent(const SerializedType& t) const
|
||||
return v && (value == v->value);
|
||||
}
|
||||
|
||||
STHash160* STHash160::construct(SerializerIterator& u, const char *name)
|
||||
STHash160* STHash160::construct(SerializerIterator& u, SField::ref name)
|
||||
{
|
||||
return new STHash160(name, u.get160());
|
||||
}
|
||||
@@ -123,7 +137,7 @@ bool STHash160::isEquivalent(const SerializedType& t) const
|
||||
return v && (value == v->value);
|
||||
}
|
||||
|
||||
STHash256* STHash256::construct(SerializerIterator& u, const char *name)
|
||||
STHash256* STHash256::construct(SerializerIterator& u, SField::ref name)
|
||||
{
|
||||
return new STHash256(name, u.get256());
|
||||
}
|
||||
@@ -139,7 +153,7 @@ bool STHash256::isEquivalent(const SerializedType& t) const
|
||||
return v && (value == v->value);
|
||||
}
|
||||
|
||||
STVariableLength::STVariableLength(SerializerIterator& st, const char *name) : SerializedType(name)
|
||||
STVariableLength::STVariableLength(SerializerIterator& st, SField::ref name) : SerializedType(name)
|
||||
{
|
||||
value = st.getVL();
|
||||
}
|
||||
@@ -149,16 +163,11 @@ std::string STVariableLength::getText() const
|
||||
return strHex(value);
|
||||
}
|
||||
|
||||
STVariableLength* STVariableLength::construct(SerializerIterator& u, const char *name)
|
||||
STVariableLength* STVariableLength::construct(SerializerIterator& u, SField::ref name)
|
||||
{
|
||||
return new STVariableLength(name, u.getVL());
|
||||
}
|
||||
|
||||
int STVariableLength::getLength() const
|
||||
{
|
||||
return Serializer::encodeLengthLength(value.size()) + value.size();
|
||||
}
|
||||
|
||||
bool STVariableLength::isEquivalent(const SerializedType& t) const
|
||||
{
|
||||
const STVariableLength* v = dynamic_cast<const STVariableLength*>(&t);
|
||||
@@ -176,7 +185,7 @@ std::string STAccount::getText() const
|
||||
return a.humanAccountID();
|
||||
}
|
||||
|
||||
STAccount* STAccount::construct(SerializerIterator& u, const char *name)
|
||||
STAccount* STAccount::construct(SerializerIterator& u, SField::ref name)
|
||||
{
|
||||
return new STAccount(name, u.getVL());
|
||||
}
|
||||
@@ -186,7 +195,7 @@ STAccount* STAccount::construct(SerializerIterator& u, const char *name)
|
||||
//
|
||||
|
||||
// Return a new object from a SerializerIterator.
|
||||
STVector256* STVector256::construct(SerializerIterator& u, const char *name)
|
||||
STVector256* STVector256::construct(SerializerIterator& u, SField::ref name)
|
||||
{
|
||||
std::vector<unsigned char> data = u.getVL();
|
||||
std::vector<uint256> value;
|
||||
@@ -255,7 +264,7 @@ void STAccount::setValueNCA(const NewcoinAddress& nca)
|
||||
setValueH160(nca.getAccountID());
|
||||
}
|
||||
|
||||
STPathSet* STPathSet::construct(SerializerIterator& s, const char *name)
|
||||
STPathSet* STPathSet::construct(SerializerIterator& s, SField::ref name)
|
||||
{
|
||||
std::vector<STPath> paths;
|
||||
std::vector<STPathElement> path;
|
||||
@@ -342,18 +351,6 @@ int STPath::getSerializeSize() const
|
||||
return iBytes;
|
||||
}
|
||||
|
||||
int STPathSet::getLength() const
|
||||
{
|
||||
int iBytes = 0;
|
||||
|
||||
BOOST_FOREACH(const STPath& spPath, value)
|
||||
{
|
||||
iBytes += spPath.getSerializeSize();
|
||||
}
|
||||
|
||||
return iBytes ? iBytes : 1;
|
||||
}
|
||||
|
||||
Json::Value STPath::getJson(int) const
|
||||
{
|
||||
Json::Value ret(Json::arrayValue);
|
||||
|
||||
@@ -8,28 +8,13 @@
|
||||
|
||||
#include "uint256.h"
|
||||
#include "Serializer.h"
|
||||
#include "FieldNames.h"
|
||||
|
||||
enum SerializedTypeID
|
||||
{
|
||||
// special types
|
||||
STI_DONE = -1,
|
||||
STI_NOTPRESENT = 0,
|
||||
|
||||
#define TYPE(name, field, value) STI_##field = value,
|
||||
#define FIELD(name, field, value)
|
||||
#include "SerializeProto.h"
|
||||
#undef TYPE
|
||||
#undef FIELD
|
||||
|
||||
// high level types
|
||||
STI_TRANSACTION = 100001,
|
||||
STI_LEDGERENTRY = 100002
|
||||
};
|
||||
|
||||
enum PathFlags
|
||||
{
|
||||
PF_END = 0x00, // End of current path & path list.
|
||||
PF_BOUNDRY = 0xFF, // End of current path & new path follows.
|
||||
PF_BOUNDARY = 0xFF, // End of current path & new path follows.
|
||||
|
||||
PF_ACCOUNT = 0x01,
|
||||
PF_OFFER = 0x02,
|
||||
@@ -48,24 +33,25 @@ enum PathFlags
|
||||
class SerializedType
|
||||
{
|
||||
protected:
|
||||
const char* name;
|
||||
SField::ptr fName;
|
||||
|
||||
virtual SerializedType* duplicate() const { return new SerializedType(name); }
|
||||
virtual SerializedType* duplicate() const { return new SerializedType(*fName); }
|
||||
SerializedType(SField::ptr n) : fName(n) { assert(fName); }
|
||||
|
||||
public:
|
||||
|
||||
SerializedType() : name(NULL) { ; }
|
||||
SerializedType(const char* n) : name(n) { ; }
|
||||
SerializedType(const SerializedType& n) : name(n.name) { ; }
|
||||
SerializedType() : fName(&sfGeneric) { ; }
|
||||
SerializedType(SField::ref n) : fName(&n) { assert(fName); }
|
||||
SerializedType(const SerializedType& n) : fName(n.fName) { ; }
|
||||
virtual ~SerializedType() { ; }
|
||||
|
||||
static std::auto_ptr<SerializedType> deserialize(const char* name)
|
||||
static std::auto_ptr<SerializedType> deserialize(SField::ref name)
|
||||
{ return std::auto_ptr<SerializedType>(new SerializedType(name)); }
|
||||
|
||||
void setName(const char* n) { name=n; }
|
||||
const char *getName() const { return name; }
|
||||
void setFName(SField::ref n) { fName = &n; assert(fName); }
|
||||
SField::ref getFName() const { return *fName; }
|
||||
std::string getName() const { return fName->fieldName; }
|
||||
|
||||
virtual int getLength() const { return 0; }
|
||||
virtual SerializedTypeID getSType() const { return STI_NOTPRESENT; }
|
||||
std::auto_ptr<SerializedType> clone() const { return std::auto_ptr<SerializedType>(duplicate()); }
|
||||
|
||||
@@ -75,13 +61,15 @@ public:
|
||||
virtual Json::Value getJson(int) const
|
||||
{ return getText(); }
|
||||
|
||||
virtual void add(Serializer& s) const { return; }
|
||||
virtual void add(Serializer& s) const { ; }
|
||||
|
||||
virtual bool isEquivalent(const SerializedType& t) const
|
||||
{ assert(getSType() == STI_NOTPRESENT); return t.getSType() == STI_NOTPRESENT; }
|
||||
|
||||
void addFieldID(Serializer& s) const { s.addFieldID(fName->fieldType, fName->fieldValue); }
|
||||
|
||||
SerializedType& operator=(const SerializedType& t)
|
||||
{ name = (name == NULL) ? t.name : name; return *this; }
|
||||
{ if (!fName->fieldCode) fName = t.fName; return *this; }
|
||||
bool operator==(const SerializedType& t) const
|
||||
{ return (getSType() == t.getSType()) && isEquivalent(t); }
|
||||
bool operator!=(const SerializedType& t) const
|
||||
@@ -97,23 +85,22 @@ class STUInt8 : public SerializedType
|
||||
protected:
|
||||
unsigned char value;
|
||||
|
||||
STUInt8* duplicate() const { return new STUInt8(name, value); }
|
||||
static STUInt8* construct(SerializerIterator&, const char* name = NULL);
|
||||
STUInt8* duplicate() const { return new STUInt8(*this); }
|
||||
static STUInt8* construct(SerializerIterator&, SField::ref f);
|
||||
|
||||
public:
|
||||
|
||||
STUInt8(unsigned char v=0) : value(v) { ; }
|
||||
STUInt8(const char* n, unsigned char v=0) : SerializedType(n), value(v) { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char* name)
|
||||
STUInt8(unsigned char v = 0) : value(v) { ; }
|
||||
STUInt8(SField::ref n, unsigned char v = 0) : SerializedType(n), value(v) { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
int getLength() const { return 1; }
|
||||
SerializedTypeID getSType() const { return STI_UINT8; }
|
||||
std::string getText() const;
|
||||
void add(Serializer& s) const { s.add8(value); }
|
||||
|
||||
unsigned char getValue() const { return value; }
|
||||
void setValue(unsigned char v) { value=v; }
|
||||
void setValue(unsigned char v) { value = v; }
|
||||
|
||||
operator unsigned char() const { return value; }
|
||||
virtual bool isEquivalent(const SerializedType& t) const;
|
||||
@@ -124,17 +111,16 @@ class STUInt16 : public SerializedType
|
||||
protected:
|
||||
uint16 value;
|
||||
|
||||
STUInt16* duplicate() const { return new STUInt16(name, value); }
|
||||
static STUInt16* construct(SerializerIterator&, const char* name = NULL);
|
||||
STUInt16* duplicate() const { return new STUInt16(*this); }
|
||||
static STUInt16* construct(SerializerIterator&, SField::ref name);
|
||||
|
||||
public:
|
||||
|
||||
STUInt16(uint16 v=0) : value(v) { ; }
|
||||
STUInt16(const char* n, uint16 v=0) : SerializedType(n), value(v) { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char* name)
|
||||
STUInt16(uint16 v = 0) : value(v) { ; }
|
||||
STUInt16(SField::ref n, uint16 v = 0) : SerializedType(n), value(v) { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
int getLength() const { return 2; }
|
||||
SerializedTypeID getSType() const { return STI_UINT16; }
|
||||
std::string getText() const;
|
||||
void add(Serializer& s) const { s.add16(value); }
|
||||
@@ -151,17 +137,16 @@ class STUInt32 : public SerializedType
|
||||
protected:
|
||||
uint32 value;
|
||||
|
||||
STUInt32* duplicate() const { return new STUInt32(name, value); }
|
||||
static STUInt32* construct(SerializerIterator&, const char* name = NULL);
|
||||
STUInt32* duplicate() const { return new STUInt32(*this); }
|
||||
static STUInt32* construct(SerializerIterator&, SField::ref name);
|
||||
|
||||
public:
|
||||
|
||||
STUInt32(uint32 v=0) : value(v) { ; }
|
||||
STUInt32(const char* n, uint32 v=0) : SerializedType(n), value(v) { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char* name)
|
||||
STUInt32(uint32 v = 0) : value(v) { ; }
|
||||
STUInt32(SField::ref n, uint32 v = 0) : SerializedType(n), value(v) { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
int getLength() const { return 4; }
|
||||
SerializedTypeID getSType() const { return STI_UINT32; }
|
||||
std::string getText() const;
|
||||
void add(Serializer& s) const { s.add32(value); }
|
||||
@@ -178,17 +163,16 @@ class STUInt64 : public SerializedType
|
||||
protected:
|
||||
uint64 value;
|
||||
|
||||
STUInt64* duplicate() const { return new STUInt64(name, value); }
|
||||
static STUInt64* construct(SerializerIterator&, const char* name = NULL);
|
||||
STUInt64* duplicate() const { return new STUInt64(*this); }
|
||||
static STUInt64* construct(SerializerIterator&, SField::ref name);
|
||||
|
||||
public:
|
||||
|
||||
STUInt64(uint64 v=0) : value(v) { ; }
|
||||
STUInt64(const char* n, uint64 v=0) : SerializedType(n), value(v) { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char* name)
|
||||
STUInt64(uint64 v = 0) : value(v) { ; }
|
||||
STUInt64(SField::ref n, uint64 v = 0) : SerializedType(n), value(v) { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
int getLength() const { return 8; }
|
||||
SerializedTypeID getSType() const { return STI_UINT64; }
|
||||
std::string getText() const;
|
||||
void add(Serializer& s) const { s.add64(value); }
|
||||
@@ -224,7 +208,7 @@ protected:
|
||||
|
||||
void canonicalize();
|
||||
STAmount* duplicate() const { return new STAmount(*this); }
|
||||
static STAmount* construct(SerializerIterator&, const char* name = NULL);
|
||||
static STAmount* construct(SerializerIterator&, SField::ref name);
|
||||
|
||||
static const int cMinOffset = -96, cMaxOffset = 80;
|
||||
static const uint64 cMinValue = 1000000000000000ull, cMaxValue = 9999999999999999ull;
|
||||
@@ -232,15 +216,12 @@ protected:
|
||||
static const uint64 cNotNative = 0x8000000000000000ull;
|
||||
static const uint64 cPosNative = 0x4000000000000000ull;
|
||||
|
||||
STAmount(bool isNeg, uint64 value) : mValue(value), mOffset(0), mIsNative(true), mIsNegative(isNeg) { ; }
|
||||
|
||||
STAmount(const char *name, uint64 value, bool isNegative)
|
||||
: SerializedType(name), mValue(value), mOffset(0), mIsNative(true), mIsNegative(isNegative)
|
||||
{ ; }
|
||||
STAmount(const char *n, const uint160& cur, const uint160& iss, uint64 val, int off, bool isNat, bool isNeg)
|
||||
: SerializedType(n), mCurrency(cur), mIssuer(iss), mValue(val), mOffset(off),
|
||||
STAmount(SField::ref name, const uint160& cur, const uint160& iss, uint64 val, int off, bool isNat, bool isNeg)
|
||||
: SerializedType(name), mCurrency(cur), mIssuer(iss), mValue(val), mOffset(off),
|
||||
mIsNative(isNat), mIsNegative(isNeg) { ; }
|
||||
|
||||
STAmount(SField::ref name, const Json::Value& value);
|
||||
|
||||
uint64 toUInt64() const;
|
||||
static uint64 muldiv(uint64, uint64, uint64);
|
||||
|
||||
@@ -248,38 +229,33 @@ public:
|
||||
static uint64 uRateOne;
|
||||
|
||||
STAmount(uint64 v = 0, bool isNeg = false) : mValue(v), mOffset(0), mIsNative(true), mIsNegative(isNeg)
|
||||
{ if (v==0) mIsNegative = false; }
|
||||
{ if (v == 0) mIsNegative = false; }
|
||||
|
||||
STAmount(const char* n, uint64 v = 0)
|
||||
: SerializedType(n), mValue(v), mOffset(0), mIsNative(true), mIsNegative(false)
|
||||
STAmount(SField::ref n, uint64 v = 0, bool isNeg = false)
|
||||
: SerializedType(n), mValue(v), mOffset(0), mIsNative(true), mIsNegative(isNeg)
|
||||
{ ; }
|
||||
|
||||
STAmount(const uint160& uCurrencyID, const uint160& uIssuerID, uint64 uV=0, int iOff=0, bool bNegative=false)
|
||||
STAmount(const uint160& uCurrencyID, const uint160& uIssuerID, uint64 uV = 0, int iOff = 0, bool bNegative = false)
|
||||
: mCurrency(uCurrencyID), mIssuer(uIssuerID), mValue(uV), mOffset(iOff), mIsNegative(bNegative)
|
||||
{ canonicalize(); }
|
||||
|
||||
// YYY This should probably require issuer too.
|
||||
STAmount(const char* n, const uint160& currency, const uint160& issuer,
|
||||
STAmount(SField::ref n, const uint160& currency, const uint160& issuer,
|
||||
uint64 v = 0, int off = 0, bool isNeg = false) :
|
||||
SerializedType(n), mCurrency(currency), mIssuer(issuer), mValue(v), mOffset(off), mIsNegative(isNeg)
|
||||
{ canonicalize(); }
|
||||
|
||||
STAmount(const char* n, int64 v);
|
||||
static STAmount createFromInt64(SField::ref n, int64 v);
|
||||
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char* name)
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
static STAmount saFromRate(uint64 uRate = 0)
|
||||
{
|
||||
return STAmount(CURRENCY_ONE, ACCOUNT_ONE, uRate, -9, false);
|
||||
}
|
||||
{ return STAmount(CURRENCY_ONE, ACCOUNT_ONE, uRate, -9, false); }
|
||||
|
||||
static STAmount saFromSigned(const uint160& uCurrencyID, const uint160& uIssuerID, int64 iV=0, int iOff=0)
|
||||
{
|
||||
return STAmount(uCurrencyID, uIssuerID, iV < 0 ? -iV : iV, iOff, iV < 0);
|
||||
}
|
||||
static STAmount saFromSigned(const uint160& uCurrencyID, const uint160& uIssuerID, int64 iV = 0, int iOff = 0)
|
||||
{ return STAmount(uCurrencyID, uIssuerID, iV < 0 ? -iV : iV, iOff, iV < 0); }
|
||||
|
||||
int getLength() const { return mIsNative ? 8 : 28; }
|
||||
SerializedTypeID getSType() const { return STI_AMOUNT; }
|
||||
std::string getText() const;
|
||||
std::string getRaw() const;
|
||||
@@ -377,7 +353,7 @@ public:
|
||||
// Native currency conversions, to/from display format
|
||||
static uint64 convertToDisplayAmount(const STAmount& internalAmount, uint64 totalNow, uint64 totalInit);
|
||||
static STAmount convertToInternalAmount(uint64 displayAmount, uint64 totalNow, uint64 totalInit,
|
||||
const char* name = NULL);
|
||||
SField::ref name = sfGeneric);
|
||||
|
||||
static std::string createHumanCurrency(const uint160& uCurrency);
|
||||
static STAmount deserialize(SerializerIterator&);
|
||||
@@ -394,19 +370,20 @@ class STHash128 : public SerializedType
|
||||
protected:
|
||||
uint128 value;
|
||||
|
||||
STHash128* duplicate() const { return new STHash128(name, value); }
|
||||
static STHash128* construct(SerializerIterator&, const char* name = NULL);
|
||||
STHash128* duplicate() const { return new STHash128(*this); }
|
||||
static STHash128* construct(SerializerIterator&, SField::ref name);
|
||||
|
||||
public:
|
||||
|
||||
STHash128(const uint128& v) : value(v) { ; }
|
||||
STHash128(const char* n, const uint128& v) : SerializedType(n), value(v) { ; }
|
||||
STHash128(const char* n) : SerializedType(n) { ; }
|
||||
STHash128(SField::ref n, const uint128& v) : SerializedType(n), value(v) { ; }
|
||||
STHash128(SField::ref n, const char *v) : SerializedType(n) { value.SetHex(v); }
|
||||
STHash128(SField::ref n, const std::string &v) : SerializedType(n) { value.SetHex(v); }
|
||||
STHash128(SField::ref n) : SerializedType(n) { ; }
|
||||
STHash128() { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char* name)
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
int getLength() const { return 20; }
|
||||
SerializedTypeID getSType() const { return STI_HASH128; }
|
||||
virtual std::string getText() const;
|
||||
void add(Serializer& s) const { s.add128(value); }
|
||||
@@ -423,19 +400,20 @@ class STHash160 : public SerializedType
|
||||
protected:
|
||||
uint160 value;
|
||||
|
||||
STHash160* duplicate() const { return new STHash160(name, value); }
|
||||
static STHash160* construct(SerializerIterator&, const char* name = NULL);
|
||||
STHash160* duplicate() const { return new STHash160(*this); }
|
||||
static STHash160* construct(SerializerIterator&, SField::ref name);
|
||||
|
||||
public:
|
||||
|
||||
STHash160(const uint160& v) : value(v) { ; }
|
||||
STHash160(const char* n, const uint160& v) : SerializedType(n), value(v) { ; }
|
||||
STHash160(const char* n) : SerializedType(n) { ; }
|
||||
STHash160(SField::ref n, const uint160& v) : SerializedType(n), value(v) { ; }
|
||||
STHash160(SField::ref n, const char *v) : SerializedType(n) { value.SetHex(v); }
|
||||
STHash160(SField::ref n, const std::string &v) : SerializedType(n) { value.SetHex(v); }
|
||||
STHash160(SField::ref n) : SerializedType(n) { ; }
|
||||
STHash160() { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char* name)
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
int getLength() const { return 20; }
|
||||
SerializedTypeID getSType() const { return STI_HASH160; }
|
||||
virtual std::string getText() const;
|
||||
void add(Serializer& s) const { s.add160(value); }
|
||||
@@ -452,19 +430,20 @@ class STHash256 : public SerializedType
|
||||
protected:
|
||||
uint256 value;
|
||||
|
||||
STHash256* duplicate() const { return new STHash256(name, value); }
|
||||
static STHash256* construct(SerializerIterator&, const char* name = NULL);
|
||||
STHash256* duplicate() const { return new STHash256(*this); }
|
||||
static STHash256* construct(SerializerIterator&, SField::ref);
|
||||
|
||||
public:
|
||||
|
||||
STHash256(const uint256& v) : value(v) { ; }
|
||||
STHash256(const char* n, const uint256& v) : SerializedType(n), value(v) { ; }
|
||||
STHash256(const char* n) : SerializedType(n) { ; }
|
||||
STHash256(SField::ref n, const uint256& v) : SerializedType(n), value(v) { ; }
|
||||
STHash256(SField::ref n, const char *v) : SerializedType(n) { value.SetHex(v); }
|
||||
STHash256(SField::ref n, const std::string &v) : SerializedType(n) { value.SetHex(v); }
|
||||
STHash256(SField::ref n) : SerializedType(n) { ; }
|
||||
STHash256() { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char* name)
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
int getLength() const { return 32; }
|
||||
SerializedTypeID getSType() const { return STI_HASH256; }
|
||||
std::string getText() const;
|
||||
void add(Serializer& s) const { s.add256(value); }
|
||||
@@ -481,20 +460,19 @@ class STVariableLength : public SerializedType
|
||||
protected:
|
||||
std::vector<unsigned char> value;
|
||||
|
||||
virtual STVariableLength* duplicate() const { return new STVariableLength(name, value); }
|
||||
static STVariableLength* construct(SerializerIterator&, const char* name = NULL);
|
||||
virtual STVariableLength* duplicate() const { return new STVariableLength(*this); }
|
||||
static STVariableLength* construct(SerializerIterator&, SField::ref);
|
||||
|
||||
public:
|
||||
|
||||
STVariableLength(const std::vector<unsigned char>& v) : value(v) { ; }
|
||||
STVariableLength(const char* n, const std::vector<unsigned char>& v) : SerializedType(n), value(v) { ; }
|
||||
STVariableLength(const char* n) : SerializedType(n) { ; }
|
||||
STVariableLength(SerializerIterator&, const char* name = NULL);
|
||||
STVariableLength(SField::ref n, const std::vector<unsigned char>& v) : SerializedType(n), value(v) { ; }
|
||||
STVariableLength(SField::ref n) : SerializedType(n) { ; }
|
||||
STVariableLength(SerializerIterator&, SField::ref name = sfGeneric);
|
||||
STVariableLength() { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char* name)
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
int getLength() const;
|
||||
virtual SerializedTypeID getSType() const { return STI_VL; }
|
||||
virtual std::string getText() const;
|
||||
void add(Serializer& s) const { s.addVL(value); }
|
||||
@@ -511,16 +489,16 @@ public:
|
||||
class STAccount : public STVariableLength
|
||||
{
|
||||
protected:
|
||||
virtual STAccount* duplicate() const { return new STAccount(name, value); }
|
||||
static STAccount* construct(SerializerIterator&, const char* name = NULL);
|
||||
virtual STAccount* duplicate() const { return new STAccount(*this); }
|
||||
static STAccount* construct(SerializerIterator&, SField::ref);
|
||||
|
||||
public:
|
||||
|
||||
STAccount(const std::vector<unsigned char>& v) : STVariableLength(v) { ; }
|
||||
STAccount(const char* n, const std::vector<unsigned char>& v) : STVariableLength(n, v) { ; }
|
||||
STAccount(const char* n) : STVariableLength(n) { ; }
|
||||
STAccount(SField::ref n, const std::vector<unsigned char>& v) : STVariableLength(n, v) { ; }
|
||||
STAccount(SField::ref n) : STVariableLength(n) { ; }
|
||||
STAccount() { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char* name)
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
SerializedTypeID getSType() const { return STI_ACCOUNT; }
|
||||
@@ -649,19 +627,18 @@ class STPathSet : public SerializedType
|
||||
protected:
|
||||
std::vector<STPath> value;
|
||||
|
||||
STPathSet* duplicate() const { return new STPathSet(name, value); }
|
||||
static STPathSet* construct(SerializerIterator&, const char* name = NULL);
|
||||
STPathSet* duplicate() const { return new STPathSet(*this); }
|
||||
static STPathSet* construct(SerializerIterator&, SField::ref);
|
||||
|
||||
public:
|
||||
|
||||
STPathSet() { ; }
|
||||
STPathSet(const char* n) : SerializedType(n) { ; }
|
||||
STPathSet(SField::ref n) : SerializedType(n) { ; }
|
||||
STPathSet(const std::vector<STPath>& v) : value(v) { ; }
|
||||
STPathSet(const char* n, const std::vector<STPath>& v) : SerializedType(n), value(v) { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char* name)
|
||||
STPathSet(SField::ref n, const std::vector<STPath>& v) : SerializedType(n), value(v) { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
int getLength() const;
|
||||
// std::string getText() const;
|
||||
void add(Serializer& s) const;
|
||||
virtual Json::Value getJson(int) const;
|
||||
@@ -722,20 +699,19 @@ class STVector256 : public SerializedType
|
||||
protected:
|
||||
std::vector<uint256> mValue;
|
||||
|
||||
STVector256* duplicate() const { return new STVector256(name, mValue); }
|
||||
static STVector256* construct(SerializerIterator&, const char* name = NULL);
|
||||
STVector256* duplicate() const { return new STVector256(*this); }
|
||||
static STVector256* construct(SerializerIterator&, SField::ref);
|
||||
|
||||
public:
|
||||
STVector256() { ; }
|
||||
STVector256(const char* n) : SerializedType(n) { ; }
|
||||
STVector256(const char* n, const std::vector<uint256>& v) : SerializedType(n), mValue(v) { ; }
|
||||
STVector256(SField::ref n) : SerializedType(n) { ; }
|
||||
STVector256(SField::ref n, const std::vector<uint256>& v) : SerializedType(n), mValue(v) { ; }
|
||||
STVector256(const std::vector<uint256>& vector) : mValue(vector) { ; }
|
||||
|
||||
SerializedTypeID getSType() const { return STI_VECTOR256; }
|
||||
int getLength() const { return Serializer::lengthVL(mValue.size() * (256 / 8)); }
|
||||
void add(Serializer& s) const;
|
||||
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char* name)
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
const std::vector<uint256>& peekValue() const { return mValue; }
|
||||
|
||||
@@ -4,29 +4,33 @@
|
||||
#include "HashPrefixes.h"
|
||||
|
||||
SOElement SerializedValidation::sValidationFormat[] = {
|
||||
{ sfFlags, "Flags", STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ sfLedgerHash, "LedgerHash", STI_HASH256, SOE_REQUIRED, 0 },
|
||||
{ sfSigningTime, "SignTime", STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ sfSigningKey, "SigningKey", STI_VL, SOE_REQUIRED, 0 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 },
|
||||
{ sfFlags, SOE_REQUIRED },
|
||||
{ sfLedgerHash, SOE_REQUIRED },
|
||||
{ sfLedgerSequence, SOE_OPTIONAL },
|
||||
{ sfCloseTime, SOE_OPTIONAL },
|
||||
{ sfLoadFee, SOE_OPTIONAL },
|
||||
{ sfBaseFee, SOE_OPTIONAL },
|
||||
{ sfSigningTime, SOE_REQUIRED },
|
||||
{ sfSigningPubKey, SOE_REQUIRED },
|
||||
{ sfInvalid, SOE_END }
|
||||
};
|
||||
|
||||
const uint32 SerializedValidation::sFullFlag = 0x00010000;
|
||||
|
||||
SerializedValidation::SerializedValidation(SerializerIterator& sit, bool checkSignature)
|
||||
: STObject(sValidationFormat, sit), mSignature(sit, "Signature"), mTrusted(false)
|
||||
: STObject(sValidationFormat, sit, sfValidation), mSignature(sit, sfSignature), mTrusted(false)
|
||||
{
|
||||
if (checkSignature && !isValid()) throw std::runtime_error("Invalid validation");
|
||||
}
|
||||
|
||||
SerializedValidation::SerializedValidation(const uint256& ledgerHash, uint32 signTime,
|
||||
const NewcoinAddress& naSeed, bool isFull)
|
||||
: STObject(sValidationFormat), mSignature("Signature"), mTrusted(false)
|
||||
: STObject(sValidationFormat, sfValidation), mSignature(sfSignature), mTrusted(false)
|
||||
{
|
||||
setValueFieldH256(sfLedgerHash, ledgerHash);
|
||||
setValueFieldU32(sfSigningTime, signTime);
|
||||
setFieldH256(sfLedgerHash, ledgerHash);
|
||||
setFieldU32(sfSigningTime, signTime);
|
||||
if (naSeed.isValid())
|
||||
setValueFieldVL(sfSigningKey, NewcoinAddress::createNodePublic(naSeed).getNodePublic());
|
||||
setFieldVL(sfSigningPubKey, NewcoinAddress::createNodePublic(naSeed).getNodePublic());
|
||||
if (!isFull) setFlag(sFullFlag);
|
||||
|
||||
NewcoinAddress::createNodePrivate(naSeed).signNodePrivate(getSigningHash(), mSignature.peekValue());
|
||||
@@ -47,17 +51,17 @@ uint256 SerializedValidation::getSigningHash() const
|
||||
|
||||
uint256 SerializedValidation::getLedgerHash() const
|
||||
{
|
||||
return getValueFieldH256(sfLedgerHash);
|
||||
return getFieldH256(sfLedgerHash);
|
||||
}
|
||||
|
||||
uint32 SerializedValidation::getSignTime() const
|
||||
{
|
||||
return getValueFieldU32(sfSigningTime);
|
||||
return getFieldU32(sfSigningTime);
|
||||
}
|
||||
|
||||
uint32 SerializedValidation::getFlags() const
|
||||
{
|
||||
return getValueFieldU32(sfFlags);
|
||||
return getFieldU32(sfFlags);
|
||||
}
|
||||
|
||||
bool SerializedValidation::isValid() const
|
||||
@@ -69,7 +73,7 @@ bool SerializedValidation::isValid(const uint256& signingHash) const
|
||||
{
|
||||
try
|
||||
{
|
||||
NewcoinAddress naPublicKey = NewcoinAddress::createNodePublic(getValueFieldVL(sfSigningKey));
|
||||
NewcoinAddress naPublicKey = NewcoinAddress::createNodePublic(getFieldVL(sfSigningPubKey));
|
||||
return naPublicKey.isValid() && naPublicKey.verifyNodePublic(signingHash, mSignature.peekValue());
|
||||
}
|
||||
catch (...)
|
||||
@@ -81,7 +85,7 @@ bool SerializedValidation::isValid(const uint256& signingHash) const
|
||||
NewcoinAddress SerializedValidation::getSignerPublic() const
|
||||
{
|
||||
NewcoinAddress a;
|
||||
a.setNodePublic(getValueFieldVL(sfSigningKey));
|
||||
a.setNodePublic(getFieldVL(sfSigningPubKey));
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "key.h"
|
||||
#include "uint256.h"
|
||||
#include "FieldNames.h"
|
||||
|
||||
typedef std::pair<int, std::vector<unsigned char> > TaggedListItem;
|
||||
|
||||
@@ -69,6 +70,7 @@ public:
|
||||
|
||||
bool getFieldID(int& type, int& name, int offset) const;
|
||||
int addFieldID(int type, int name);
|
||||
int addFieldID(SerializedTypeID type, int name) { return addFieldID(static_cast<int>(type), name); }
|
||||
|
||||
// normal hash functions
|
||||
uint160 getRIPEMD160(int size=-1) const;
|
||||
@@ -92,7 +94,7 @@ public:
|
||||
int getDataLength() const { return mData.size(); }
|
||||
const void* getDataPtr() const { return &mData.front(); }
|
||||
void* getDataPtr() { return &mData.front(); }
|
||||
int getLength() { return mData.size(); }
|
||||
int getLength() const { return mData.size(); }
|
||||
const std::vector<unsigned char>& peekData() const { return mData; }
|
||||
std::vector<unsigned char> getData() const { return mData; }
|
||||
std::string getString() const { return std::string(static_cast<const char *>(getDataPtr()), size()); }
|
||||
@@ -143,11 +145,12 @@ protected:
|
||||
public:
|
||||
SerializerIterator(const Serializer& s) : mSerializer(s), mPos(0) { ; }
|
||||
|
||||
void reset(void) { mPos=0; }
|
||||
void reset(void) { mPos = 0; }
|
||||
void setPos(int p) { mPos = p; }
|
||||
const Serializer& operator*(void) { return mSerializer; }
|
||||
|
||||
int getPos(void) { return mPos; }
|
||||
bool empty() { return mPos == mSerializer.getLength(); }
|
||||
int getBytesLeft();
|
||||
|
||||
// get functions throw on error
|
||||
|
||||
@@ -18,7 +18,7 @@ Transaction::Transaction(const SerializedTransaction::pointer& sit, bool bValida
|
||||
{
|
||||
try
|
||||
{
|
||||
mFromPubKey.setAccountPublic(mTransaction->peekSigningPubKey());
|
||||
mFromPubKey.setAccountPublic(mTransaction->getSigningPubKey());
|
||||
mTransactionID = mTransaction->getTransactionID();
|
||||
mAccountFrom = mTransaction->getSourceAccount();
|
||||
}
|
||||
@@ -78,8 +78,8 @@ Transaction::Transaction(
|
||||
|
||||
if (uSourceTag)
|
||||
{
|
||||
mTransaction->makeITFieldPresent(sfSourceTag);
|
||||
mTransaction->setITFieldU32(sfSourceTag, uSourceTag);
|
||||
mTransaction->makeFieldPresent(sfSourceTag);
|
||||
mTransaction->setFieldU32(sfSourceTag, uSourceTag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,12 +92,7 @@ bool Transaction::sign(const NewcoinAddress& naAccountPrivate)
|
||||
Log(lsWARNING) << "No private key for signing";
|
||||
bResult = false;
|
||||
}
|
||||
else if (!getSTransaction()->sign(naAccountPrivate))
|
||||
{
|
||||
Log(lsWARNING) << "Failed to make signature";
|
||||
assert(false);
|
||||
bResult = false;
|
||||
}
|
||||
getSTransaction()->sign(naAccountPrivate);
|
||||
|
||||
if (bResult)
|
||||
{
|
||||
@@ -132,24 +127,24 @@ Transaction::pointer Transaction::setAccountSet(
|
||||
)
|
||||
{
|
||||
if (!bEmailHash)
|
||||
mTransaction->setITFieldH128(sfEmailHash, uEmailHash);
|
||||
mTransaction->setFieldH128(sfEmailHash, uEmailHash);
|
||||
|
||||
if (!bWalletLocator)
|
||||
mTransaction->setITFieldH256(sfWalletLocator, uWalletLocator);
|
||||
mTransaction->setFieldH256(sfWalletLocator, uWalletLocator);
|
||||
|
||||
if (naMessagePublic.isValid())
|
||||
mTransaction->setITFieldVL(sfMessageKey, naMessagePublic.getAccountPublic());
|
||||
mTransaction->setFieldVL(sfMessageKey, naMessagePublic.getAccountPublic());
|
||||
|
||||
if (bDomain)
|
||||
mTransaction->setITFieldVL(sfDomain, vucDomain);
|
||||
mTransaction->setFieldVL(sfDomain, vucDomain);
|
||||
|
||||
if (bTransferRate)
|
||||
mTransaction->setITFieldU32(sfTransferRate, uTransferRate);
|
||||
mTransaction->setFieldU32(sfTransferRate, uTransferRate);
|
||||
|
||||
if (bPublish)
|
||||
{
|
||||
mTransaction->setITFieldH256(sfPublishHash, uPublishHash);
|
||||
mTransaction->setITFieldU32(sfPublishSize, uPublishSize);
|
||||
mTransaction->setFieldH256(sfPublishHash, uPublishHash);
|
||||
mTransaction->setFieldU32(sfPublishSize, uPublishSize);
|
||||
}
|
||||
|
||||
sign(naPrivateKey);
|
||||
@@ -193,9 +188,9 @@ Transaction::pointer Transaction::setClaim(
|
||||
const std::vector<unsigned char>& vucPubKey,
|
||||
const std::vector<unsigned char>& vucSignature)
|
||||
{
|
||||
mTransaction->setITFieldVL(sfGenerator, vucGenerator);
|
||||
mTransaction->setITFieldVL(sfPublicKey, vucPubKey);
|
||||
mTransaction->setITFieldVL(sfSignature, vucSignature);
|
||||
mTransaction->setFieldVL(sfGenerator, vucGenerator);
|
||||
mTransaction->setFieldVL(sfPublicKey, vucPubKey);
|
||||
mTransaction->setFieldVL(sfSignature, vucSignature);
|
||||
|
||||
sign(naPrivateKey);
|
||||
|
||||
@@ -227,9 +222,9 @@ Transaction::pointer Transaction::setCreate(
|
||||
const NewcoinAddress& naCreateAccountID,
|
||||
const STAmount& saFund)
|
||||
{
|
||||
mTransaction->setITFieldU32(sfFlags, tfCreateAccount);
|
||||
mTransaction->setITFieldAccount(sfDestination, naCreateAccountID);
|
||||
mTransaction->setITFieldAmount(sfAmount, saFund);
|
||||
mTransaction->setFieldU32(sfFlags, tfCreateAccount);
|
||||
mTransaction->setFieldAccount(sfDestination, naCreateAccountID);
|
||||
mTransaction->setFieldAmount(sfAmount, saFund);
|
||||
|
||||
sign(naPrivateKey);
|
||||
|
||||
@@ -262,13 +257,13 @@ Transaction::pointer Transaction::setCreditSet(
|
||||
bool bQualityOut,
|
||||
uint32 uQualityOut)
|
||||
{
|
||||
mTransaction->setITFieldAmount(sfLimitAmount, saLimitAmount);
|
||||
mTransaction->setFieldAmount(sfLimitAmount, saLimitAmount);
|
||||
|
||||
if (bQualityIn)
|
||||
mTransaction->setITFieldU32(sfQualityIn, uQualityIn);
|
||||
mTransaction->setFieldU32(sfQualityIn, uQualityIn);
|
||||
|
||||
if (bQualityOut)
|
||||
mTransaction->setITFieldU32(sfQualityOut, uQualityOut);
|
||||
mTransaction->setFieldU32(sfQualityOut, uQualityOut);
|
||||
|
||||
sign(naPrivateKey);
|
||||
|
||||
@@ -303,17 +298,13 @@ Transaction::pointer Transaction::setNicknameSet(
|
||||
const NewcoinAddress& naPrivateKey,
|
||||
const uint256& uNickname,
|
||||
bool bSetOffer,
|
||||
const STAmount& saMinimumOffer,
|
||||
const std::vector<unsigned char>& vucSignature)
|
||||
const STAmount& saMinimumOffer)
|
||||
{
|
||||
mTransaction->setITFieldH256(sfNickname, uNickname);
|
||||
mTransaction->setFieldH256(sfNickname, uNickname);
|
||||
|
||||
// XXX Make sure field is present even for 0!
|
||||
if (bSetOffer)
|
||||
mTransaction->setITFieldAmount(sfMinimumOffer, saMinimumOffer);
|
||||
|
||||
if (!vucSignature.empty())
|
||||
mTransaction->setITFieldVL(sfSignature, vucSignature);
|
||||
mTransaction->setFieldAmount(sfMinimumOffer, saMinimumOffer);
|
||||
|
||||
sign(naPrivateKey);
|
||||
|
||||
@@ -330,12 +321,11 @@ Transaction::pointer Transaction::sharedNicknameSet(
|
||||
uint32 uSourceTag,
|
||||
const uint256& uNickname,
|
||||
bool bSetOffer,
|
||||
const STAmount& saMinimumOffer,
|
||||
const std::vector<unsigned char>& vucSignature)
|
||||
const STAmount& saMinimumOffer)
|
||||
{
|
||||
pointer tResult = boost::make_shared<Transaction>(ttNICKNAME_SET, naPublicKey, naSourceAccount, uSeq, saFee, uSourceTag);
|
||||
|
||||
return tResult->setNicknameSet(naPrivateKey, uNickname, bSetOffer, saMinimumOffer, vucSignature);
|
||||
return tResult->setNicknameSet(naPrivateKey, uNickname, bSetOffer, saMinimumOffer);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -350,13 +340,13 @@ Transaction::pointer Transaction::setOfferCreate(
|
||||
uint32 uExpiration)
|
||||
{
|
||||
if (bPassive)
|
||||
mTransaction->setITFieldU32(sfFlags, tfPassive);
|
||||
mTransaction->setFieldU32(sfFlags, tfPassive);
|
||||
|
||||
mTransaction->setITFieldAmount(sfTakerPays, saTakerPays);
|
||||
mTransaction->setITFieldAmount(sfTakerGets, saTakerGets);
|
||||
mTransaction->setFieldAmount(sfTakerPays, saTakerPays);
|
||||
mTransaction->setFieldAmount(sfTakerGets, saTakerGets);
|
||||
|
||||
if (uExpiration)
|
||||
mTransaction->setITFieldU32(sfExpiration, uExpiration);
|
||||
mTransaction->setFieldU32(sfExpiration, uExpiration);
|
||||
|
||||
sign(naPrivateKey);
|
||||
|
||||
@@ -387,7 +377,7 @@ Transaction::pointer Transaction::setOfferCancel(
|
||||
const NewcoinAddress& naPrivateKey,
|
||||
uint32 uSequence)
|
||||
{
|
||||
mTransaction->setITFieldU32(sfOfferSequence, uSequence);
|
||||
mTransaction->setFieldU32(sfOfferSequence, uSequence);
|
||||
|
||||
sign(naPrivateKey);
|
||||
|
||||
@@ -415,7 +405,7 @@ Transaction::pointer Transaction::setPasswordFund(
|
||||
const NewcoinAddress& naPrivateKey,
|
||||
const NewcoinAddress& naDstAccountID)
|
||||
{
|
||||
mTransaction->setITFieldAccount(sfDestination, naDstAccountID);
|
||||
mTransaction->setFieldAccount(sfDestination, naDstAccountID);
|
||||
|
||||
sign(naPrivateKey);
|
||||
|
||||
@@ -446,10 +436,10 @@ Transaction::pointer Transaction::setPasswordSet(
|
||||
const std::vector<unsigned char>& vucPubKey,
|
||||
const std::vector<unsigned char>& vucSignature)
|
||||
{
|
||||
mTransaction->setITFieldAccount(sfAuthorizedKey, naAuthKeyID);
|
||||
mTransaction->setITFieldVL(sfGenerator, vucGenerator);
|
||||
mTransaction->setITFieldVL(sfPublicKey, vucPubKey);
|
||||
mTransaction->setITFieldVL(sfSignature, vucSignature);
|
||||
mTransaction->setFieldAccount(sfAuthorizedKey, naAuthKeyID);
|
||||
mTransaction->setFieldVL(sfGenerator, vucGenerator);
|
||||
mTransaction->setFieldVL(sfPublicKey, vucPubKey);
|
||||
mTransaction->setFieldVL(sfSignature, vucSignature);
|
||||
|
||||
sign(naPrivateKey);
|
||||
|
||||
@@ -486,17 +476,17 @@ Transaction::pointer Transaction::setPayment(
|
||||
const bool bPartial,
|
||||
const bool bLimit)
|
||||
{
|
||||
mTransaction->setITFieldAccount(sfDestination, naDstAccountID);
|
||||
mTransaction->setITFieldAmount(sfAmount, saAmount);
|
||||
mTransaction->setFieldAccount(sfDestination, naDstAccountID);
|
||||
mTransaction->setFieldAmount(sfAmount, saAmount);
|
||||
|
||||
if (saAmount != saSendMax || saAmount.getCurrency() != saSendMax.getCurrency())
|
||||
{
|
||||
mTransaction->setITFieldAmount(sfSendMax, saSendMax);
|
||||
mTransaction->setFieldAmount(sfSendMax, saSendMax);
|
||||
}
|
||||
|
||||
if (spsPaths.getPathCount())
|
||||
{
|
||||
mTransaction->setITFieldPathSet(sfPaths, spsPaths);
|
||||
mTransaction->setFieldPathSet(sfPaths, spsPaths);
|
||||
}
|
||||
|
||||
sign(naPrivateKey);
|
||||
@@ -533,10 +523,10 @@ Transaction::pointer Transaction::setWalletAdd(
|
||||
const NewcoinAddress& naNewPubKey,
|
||||
const std::vector<unsigned char>& vucSignature)
|
||||
{
|
||||
mTransaction->setITFieldAmount(sfAmount, saAmount);
|
||||
mTransaction->setITFieldAccount(sfAuthorizedKey, naAuthKeyID);
|
||||
mTransaction->setITFieldVL(sfPublicKey, naNewPubKey.getAccountPublic());
|
||||
mTransaction->setITFieldVL(sfSignature, vucSignature);
|
||||
mTransaction->setFieldAmount(sfAmount, saAmount);
|
||||
mTransaction->setFieldAccount(sfAuthorizedKey, naAuthKeyID);
|
||||
mTransaction->setFieldVL(sfPublicKey, naNewPubKey.getAccountPublic());
|
||||
mTransaction->setFieldVL(sfSignature, vucSignature);
|
||||
|
||||
sign(naPrivateKey);
|
||||
|
||||
|
||||
@@ -84,8 +84,7 @@ private:
|
||||
const NewcoinAddress& naPrivateKey,
|
||||
const uint256& uNickname,
|
||||
bool bSetOffer,
|
||||
const STAmount& saMinimumOffer,
|
||||
const std::vector<unsigned char>& vucSignature);
|
||||
const STAmount& saMinimumOffer);
|
||||
|
||||
Transaction::pointer setOfferCreate(
|
||||
const NewcoinAddress& naPrivateKey,
|
||||
@@ -198,8 +197,7 @@ public:
|
||||
uint32 uSourceTag,
|
||||
const uint256& uNickname,
|
||||
bool bSetOffer,
|
||||
const STAmount& saMinimumOffer,
|
||||
const std::vector<unsigned char>& vucSignature);
|
||||
const STAmount& saMinimumOffer);
|
||||
|
||||
// Pre-fund password change.
|
||||
static Transaction::pointer sharedPasswordFund(
|
||||
@@ -272,15 +270,15 @@ public:
|
||||
|
||||
SerializedTransaction::pointer getSTransaction() { return mTransaction; }
|
||||
|
||||
const uint256& getID() const { return mTransactionID; }
|
||||
const NewcoinAddress& getFromAccount() const { return mAccountFrom; }
|
||||
STAmount getAmount() const { return mTransaction->getITFieldU64(sfAmount); }
|
||||
STAmount getFee() const { return mTransaction->getTransactionFee(); }
|
||||
uint32 getFromAccountSeq() const { return mTransaction->getSequence(); }
|
||||
uint32 getIdent() const { return mTransaction->getITFieldU32(sfSourceTag); }
|
||||
std::vector<unsigned char> getSignature() const { return mTransaction->getSignature(); }
|
||||
uint32 getLedger() const { return mInLedger; }
|
||||
TransStatus getStatus() const { return mStatus; }
|
||||
const uint256& getID() const { return mTransactionID; }
|
||||
const NewcoinAddress& getFromAccount() const { return mAccountFrom; }
|
||||
STAmount getAmount() const { return mTransaction->getFieldU64(sfAmount); }
|
||||
STAmount getFee() const { return mTransaction->getTransactionFee(); }
|
||||
uint32 getFromAccountSeq() const { return mTransaction->getSequence(); }
|
||||
uint32 getIdent() const { return mTransaction->getFieldU32(sfSourceTag); }
|
||||
std::vector<unsigned char> getSignature() const { return mTransaction->getSignature(); }
|
||||
uint32 getLedger() const { return mInLedger; }
|
||||
TransStatus getStatus() const { return mStatus; }
|
||||
|
||||
void setStatus(TransStatus status, uint32 ledgerSeq);
|
||||
void setStatus(TransStatus status) { mStatus=status; }
|
||||
|
||||
@@ -29,9 +29,9 @@ TER TransactionEngine::setAuthorized(const SerializedTransaction& txn, bool bMus
|
||||
// Otherwise, people could deny access to generators.
|
||||
//
|
||||
|
||||
std::vector<unsigned char> vucCipher = txn.getITFieldVL(sfGenerator);
|
||||
std::vector<unsigned char> vucPubKey = txn.getITFieldVL(sfPublicKey);
|
||||
std::vector<unsigned char> vucSignature = txn.getITFieldVL(sfSignature);
|
||||
std::vector<unsigned char> vucCipher = txn.getFieldVL(sfGenerator);
|
||||
std::vector<unsigned char> vucPubKey = txn.getFieldVL(sfPublicKey);
|
||||
std::vector<unsigned char> vucSignature = txn.getFieldVL(sfSignature);
|
||||
NewcoinAddress naAccountPublic = NewcoinAddress::createAccountPublic(vucPubKey);
|
||||
|
||||
if (!naAccountPublic.accountPublicVerify(Serializer::getSHA512Half(vucCipher), vucSignature))
|
||||
@@ -52,7 +52,7 @@ TER TransactionEngine::setAuthorized(const SerializedTransaction& txn, bool bMus
|
||||
|
||||
sleGen = entryCreate(ltGENERATOR_MAP, Ledger::getGeneratorIndex(hGeneratorID));
|
||||
|
||||
sleGen->setIFieldVL(sfGenerator, vucCipher);
|
||||
sleGen->setFieldVL(sfGenerator, vucCipher);
|
||||
}
|
||||
else if (bMustSetGenerator)
|
||||
{
|
||||
@@ -66,9 +66,9 @@ TER TransactionEngine::setAuthorized(const SerializedTransaction& txn, bool bMus
|
||||
// Set the public key needed to use the account.
|
||||
uint160 uAuthKeyID = bMustSetGenerator
|
||||
? hGeneratorID // Claim
|
||||
: txn.getITFieldAccount(sfAuthorizedKey); // PasswordSet
|
||||
: txn.getFieldAccount160(sfAuthorizedKey); // PasswordSet
|
||||
|
||||
mTxnAccount->setIFieldAccount(sfAuthorizedKey, uAuthKeyID);
|
||||
mTxnAccount->setFieldAccount(sfAuthorizedKey, uAuthKeyID);
|
||||
|
||||
return tesSUCCESS;
|
||||
}
|
||||
@@ -81,21 +81,21 @@ TER TransactionEngine::doAccountSet(const SerializedTransaction& txn)
|
||||
// EmailHash
|
||||
//
|
||||
|
||||
if (txn.getITFieldPresent(sfEmailHash))
|
||||
if (txn.isFieldPresent(sfEmailHash))
|
||||
{
|
||||
uint128 uHash = txn.getITFieldH128(sfEmailHash);
|
||||
uint128 uHash = txn.getFieldH128(sfEmailHash);
|
||||
|
||||
if (!uHash)
|
||||
{
|
||||
Log(lsINFO) << "doAccountSet: unset email hash";
|
||||
|
||||
mTxnAccount->makeIFieldAbsent(sfEmailHash);
|
||||
mTxnAccount->makeFieldAbsent(sfEmailHash);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log(lsINFO) << "doAccountSet: set email hash";
|
||||
|
||||
mTxnAccount->setIFieldH128(sfEmailHash, uHash);
|
||||
mTxnAccount->setFieldH128(sfEmailHash, uHash);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,21 +103,21 @@ TER TransactionEngine::doAccountSet(const SerializedTransaction& txn)
|
||||
// WalletLocator
|
||||
//
|
||||
|
||||
if (txn.getITFieldPresent(sfWalletLocator))
|
||||
if (txn.isFieldPresent(sfWalletLocator))
|
||||
{
|
||||
uint256 uHash = txn.getITFieldH256(sfWalletLocator);
|
||||
uint256 uHash = txn.getFieldH256(sfWalletLocator);
|
||||
|
||||
if (!uHash)
|
||||
{
|
||||
Log(lsINFO) << "doAccountSet: unset wallet locator";
|
||||
|
||||
mTxnAccount->makeIFieldAbsent(sfEmailHash);
|
||||
mTxnAccount->makeFieldAbsent(sfEmailHash);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log(lsINFO) << "doAccountSet: set wallet locator";
|
||||
|
||||
mTxnAccount->setIFieldH256(sfWalletLocator, uHash);
|
||||
mTxnAccount->setFieldH256(sfWalletLocator, uHash);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ TER TransactionEngine::doAccountSet(const SerializedTransaction& txn)
|
||||
// MessageKey
|
||||
//
|
||||
|
||||
if (!txn.getITFieldPresent(sfMessageKey))
|
||||
if (!txn.isFieldPresent(sfMessageKey))
|
||||
{
|
||||
nothing();
|
||||
}
|
||||
@@ -133,28 +133,28 @@ TER TransactionEngine::doAccountSet(const SerializedTransaction& txn)
|
||||
{
|
||||
Log(lsINFO) << "doAccountSet: set message key";
|
||||
|
||||
mTxnAccount->setIFieldVL(sfMessageKey, txn.getITFieldVL(sfMessageKey));
|
||||
mTxnAccount->setFieldVL(sfMessageKey, txn.getFieldVL(sfMessageKey));
|
||||
}
|
||||
|
||||
//
|
||||
// Domain
|
||||
//
|
||||
|
||||
if (txn.getITFieldPresent(sfDomain))
|
||||
if (txn.isFieldPresent(sfDomain))
|
||||
{
|
||||
std::vector<unsigned char> vucDomain = txn.getITFieldVL(sfDomain);
|
||||
std::vector<unsigned char> vucDomain = txn.getFieldVL(sfDomain);
|
||||
|
||||
if (vucDomain.empty())
|
||||
{
|
||||
Log(lsINFO) << "doAccountSet: unset domain";
|
||||
|
||||
mTxnAccount->makeIFieldAbsent(sfDomain);
|
||||
mTxnAccount->makeFieldAbsent(sfDomain);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log(lsINFO) << "doAccountSet: set domain";
|
||||
|
||||
mTxnAccount->setIFieldVL(sfDomain, vucDomain);
|
||||
mTxnAccount->setFieldVL(sfDomain, vucDomain);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,21 +162,21 @@ TER TransactionEngine::doAccountSet(const SerializedTransaction& txn)
|
||||
// TransferRate
|
||||
//
|
||||
|
||||
if (txn.getITFieldPresent(sfTransferRate))
|
||||
if (txn.isFieldPresent(sfTransferRate))
|
||||
{
|
||||
uint32 uRate = txn.getITFieldU32(sfTransferRate);
|
||||
uint32 uRate = txn.getFieldU32(sfTransferRate);
|
||||
|
||||
if (!uRate || uRate == QUALITY_ONE)
|
||||
{
|
||||
Log(lsINFO) << "doAccountSet: unset transfer rate";
|
||||
|
||||
mTxnAccount->makeIFieldAbsent(sfTransferRate);
|
||||
mTxnAccount->makeFieldAbsent(sfTransferRate);
|
||||
}
|
||||
else if (uRate > QUALITY_ONE)
|
||||
{
|
||||
Log(lsINFO) << "doAccountSet: set transfer rate";
|
||||
|
||||
mTxnAccount->setIFieldU32(sfTransferRate, uRate);
|
||||
mTxnAccount->setFieldU32(sfTransferRate, uRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -190,8 +190,8 @@ TER TransactionEngine::doAccountSet(const SerializedTransaction& txn)
|
||||
// PublishHash && PublishSize
|
||||
//
|
||||
|
||||
bool bPublishHash = txn.getITFieldPresent(sfPublishHash);
|
||||
bool bPublishSize = txn.getITFieldPresent(sfPublishSize);
|
||||
bool bPublishHash = txn.isFieldPresent(sfPublishHash);
|
||||
bool bPublishSize = txn.isFieldPresent(sfPublishSize);
|
||||
|
||||
if (bPublishHash ^ bPublishSize)
|
||||
{
|
||||
@@ -201,22 +201,22 @@ TER TransactionEngine::doAccountSet(const SerializedTransaction& txn)
|
||||
}
|
||||
else if (bPublishHash && bPublishSize)
|
||||
{
|
||||
uint256 uHash = txn.getITFieldH256(sfPublishHash);
|
||||
uint32 uSize = txn.getITFieldU32(sfPublishSize);
|
||||
uint256 uHash = txn.getFieldH256(sfPublishHash);
|
||||
uint32 uSize = txn.getFieldU32(sfPublishSize);
|
||||
|
||||
if (!uHash)
|
||||
{
|
||||
Log(lsINFO) << "doAccountSet: unset publish";
|
||||
|
||||
mTxnAccount->makeIFieldAbsent(sfPublishHash);
|
||||
mTxnAccount->makeIFieldAbsent(sfPublishSize);
|
||||
mTxnAccount->makeFieldAbsent(sfPublishHash);
|
||||
mTxnAccount->makeFieldAbsent(sfPublishSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log(lsINFO) << "doAccountSet: set publish";
|
||||
|
||||
mTxnAccount->setIFieldH256(sfPublishHash, uHash);
|
||||
mTxnAccount->setIFieldU32(sfPublishSize, uSize);
|
||||
mTxnAccount->setFieldH256(sfPublishHash, uHash);
|
||||
mTxnAccount->setFieldU32(sfPublishSize, uSize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,11 +241,11 @@ 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 STAmount saLimitAmount = txn.getFieldAmount(sfLimitAmount);
|
||||
const bool bQualityIn = txn.isFieldPresent(sfQualityIn);
|
||||
const uint32 uQualityIn = bQualityIn ? txn.getFieldU32(sfQualityIn) : 0;
|
||||
const bool bQualityOut = txn.isFieldPresent(sfQualityOut);
|
||||
const uint32 uQualityOut = bQualityIn ? txn.getFieldU32(sfQualityOut) : 0;
|
||||
const uint160 uCurrencyID = saLimitAmount.getCurrency();
|
||||
uint160 uDstAccountID = saLimitAmount.getIssuer();
|
||||
const bool bFlipped = mTxnAccountID > uDstAccountID; // true, iff current is not lowest.
|
||||
@@ -285,12 +285,12 @@ TER TransactionEngine::doCreditSet(const SerializedTransaction& txn)
|
||||
if (!saLimitAmount)
|
||||
{
|
||||
// Zeroing line.
|
||||
uint160 uLowID = sleRippleState->getIValueFieldAmount(sfLowLimit).getIssuer();
|
||||
uint160 uHighID = sleRippleState->getIValueFieldAmount(sfHighLimit).getIssuer();
|
||||
uint160 uLowID = sleRippleState->getFieldAmount(sfLowLimit).getIssuer();
|
||||
uint160 uHighID = sleRippleState->getFieldAmount(sfHighLimit).getIssuer();
|
||||
bool bLow = uLowID == uSrcAccountID;
|
||||
bool bHigh = uLowID == uDstAccountID;
|
||||
bool bBalanceZero = !sleRippleState->getIValueFieldAmount(sfBalance);
|
||||
STAmount saDstLimit = sleRippleState->getIValueFieldAmount(bSendLow ? sfLowLimit : sfHighLimit);
|
||||
bool bBalanceZero = !sleRippleState->getFieldAmount(sfBalance);
|
||||
STAmount saDstLimit = sleRippleState->getFieldAmount(bSendLow ? sfLowLimit : sfHighLimit);
|
||||
bool bDstLimitZero = !saDstLimit;
|
||||
|
||||
assert(bLow || bHigh);
|
||||
@@ -307,7 +307,7 @@ TER TransactionEngine::doCreditSet(const SerializedTransaction& txn)
|
||||
|
||||
if (!bDelIndex)
|
||||
{
|
||||
sleRippleState->setIFieldAmount(bFlipped ? sfHighLimit: sfLowLimit, saLimitAllow);
|
||||
sleRippleState->setFieldAmount(bFlipped ? sfHighLimit: sfLowLimit, saLimitAllow);
|
||||
|
||||
if (!bQualityIn)
|
||||
{
|
||||
@@ -315,11 +315,11 @@ TER TransactionEngine::doCreditSet(const SerializedTransaction& txn)
|
||||
}
|
||||
else if (uQualityIn)
|
||||
{
|
||||
sleRippleState->setIFieldU32(bFlipped ? sfLowQualityIn : sfHighQualityIn, uQualityIn);
|
||||
sleRippleState->setFieldU32(bFlipped ? sfLowQualityIn : sfHighQualityIn, uQualityIn);
|
||||
}
|
||||
else
|
||||
{
|
||||
sleRippleState->makeIFieldAbsent(bFlipped ? sfLowQualityIn : sfHighQualityIn);
|
||||
sleRippleState->makeFieldAbsent(bFlipped ? sfLowQualityIn : sfHighQualityIn);
|
||||
}
|
||||
|
||||
if (!bQualityOut)
|
||||
@@ -328,11 +328,11 @@ TER TransactionEngine::doCreditSet(const SerializedTransaction& txn)
|
||||
}
|
||||
else if (uQualityOut)
|
||||
{
|
||||
sleRippleState->setIFieldU32(bFlipped ? sfLowQualityOut : sfHighQualityOut, uQualityOut);
|
||||
sleRippleState->setFieldU32(bFlipped ? sfLowQualityOut : sfHighQualityOut, uQualityOut);
|
||||
}
|
||||
else
|
||||
{
|
||||
sleRippleState->makeIFieldAbsent(bFlipped ? sfLowQualityOut : sfHighQualityOut);
|
||||
sleRippleState->makeFieldAbsent(bFlipped ? sfLowQualityOut : sfHighQualityOut);
|
||||
}
|
||||
|
||||
entryModify(sleRippleState);
|
||||
@@ -354,14 +354,14 @@ 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, saLimitAllow);
|
||||
sleRippleState->setIFieldAmount(bFlipped ? sfLowLimit : sfHighLimit, STAmount(uCurrencyID, uDstAccountID));
|
||||
sleRippleState->setFieldAmount(sfBalance, STAmount(uCurrencyID, ACCOUNT_ONE)); // Zero balance in currency.
|
||||
sleRippleState->setFieldAmount(bFlipped ? sfHighLimit : sfLowLimit, saLimitAllow);
|
||||
sleRippleState->setFieldAmount(bFlipped ? sfLowLimit : sfHighLimit, STAmount(uCurrencyID, uDstAccountID));
|
||||
|
||||
if (uQualityIn)
|
||||
sleRippleState->setIFieldU32(bFlipped ? sfHighQualityIn : sfLowQualityIn, uQualityIn);
|
||||
sleRippleState->setFieldU32(bFlipped ? sfHighQualityIn : sfLowQualityIn, uQualityIn);
|
||||
if (uQualityOut)
|
||||
sleRippleState->setIFieldU32(bFlipped ? sfHighQualityOut : sfLowQualityOut, uQualityOut);
|
||||
sleRippleState->setFieldU32(bFlipped ? sfHighQualityOut : sfLowQualityOut, uQualityOut);
|
||||
|
||||
uint64 uSrcRef; // Ignored, dirs never delete.
|
||||
|
||||
@@ -380,24 +380,24 @@ TER TransactionEngine::doNicknameSet(const SerializedTransaction& txn)
|
||||
{
|
||||
std::cerr << "doNicknameSet>" << std::endl;
|
||||
|
||||
const uint256 uNickname = txn.getITFieldH256(sfNickname);
|
||||
const bool bMinOffer = txn.getITFieldPresent(sfMinimumOffer);
|
||||
const STAmount saMinOffer = bMinOffer ? txn.getITFieldAmount(sfAmount) : STAmount();
|
||||
const uint256 uNickname = txn.getFieldH256(sfNickname);
|
||||
const bool bMinOffer = txn.isFieldPresent(sfMinimumOffer);
|
||||
const STAmount saMinOffer = bMinOffer ? txn.getFieldAmount(sfAmount) : STAmount();
|
||||
|
||||
SLE::pointer sleNickname = entryCache(ltNICKNAME, uNickname);
|
||||
|
||||
if (sleNickname)
|
||||
{
|
||||
// Edit old entry.
|
||||
sleNickname->setIFieldAccount(sfAccount, mTxnAccountID);
|
||||
sleNickname->setFieldAccount(sfAccount, mTxnAccountID);
|
||||
|
||||
if (bMinOffer && saMinOffer)
|
||||
{
|
||||
sleNickname->setIFieldAmount(sfMinimumOffer, saMinOffer);
|
||||
sleNickname->setFieldAmount(sfMinimumOffer, saMinOffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
sleNickname->makeIFieldAbsent(sfMinimumOffer);
|
||||
sleNickname->makeFieldAbsent(sfMinimumOffer);
|
||||
}
|
||||
|
||||
entryModify(sleNickname);
|
||||
@@ -411,10 +411,10 @@ TER TransactionEngine::doNicknameSet(const SerializedTransaction& txn)
|
||||
|
||||
std::cerr << "doNicknameSet: Creating nickname node: " << sleNickname->getIndex().ToString() << std::endl;
|
||||
|
||||
sleNickname->setIFieldAccount(sfAccount, mTxnAccountID);
|
||||
sleNickname->setFieldAccount(sfAccount, mTxnAccountID);
|
||||
|
||||
if (bMinOffer && saMinOffer)
|
||||
sleNickname->setIFieldAmount(sfMinimumOffer, saMinOffer);
|
||||
sleNickname->setFieldAmount(sfMinimumOffer, saMinOffer);
|
||||
}
|
||||
|
||||
std::cerr << "doNicknameSet<" << std::endl;
|
||||
@@ -426,7 +426,7 @@ TER TransactionEngine::doPasswordFund(const SerializedTransaction& txn)
|
||||
{
|
||||
std::cerr << "doPasswordFund>" << std::endl;
|
||||
|
||||
const uint160 uDstAccountID = txn.getITFieldAccount(sfDestination);
|
||||
const uint160 uDstAccountID = txn.getFieldAccount160(sfDestination);
|
||||
SLE::pointer sleDst = mTxnAccountID == uDstAccountID
|
||||
? mTxnAccount
|
||||
: entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(uDstAccountID));
|
||||
@@ -486,11 +486,11 @@ TER TransactionEngine::doPayment(const SerializedTransaction& txn, const Transac
|
||||
const bool bPartialPayment = isSetBit(uTxFlags, tfPartialPayment);
|
||||
const bool bLimitQuality = isSetBit(uTxFlags, tfLimitQuality);
|
||||
const bool bNoRippleDirect = isSetBit(uTxFlags, tfNoRippleDirect);
|
||||
const bool bPaths = txn.getITFieldPresent(sfPaths);
|
||||
const bool bMax = txn.getITFieldPresent(sfSendMax);
|
||||
const uint160 uDstAccountID = txn.getITFieldAccount(sfDestination);
|
||||
const STAmount saDstAmount = txn.getITFieldAmount(sfAmount);
|
||||
const STAmount saMaxAmount = bMax ? txn.getITFieldAmount(sfSendMax) : saDstAmount;
|
||||
const bool bPaths = txn.isFieldPresent(sfPaths);
|
||||
const bool bMax = txn.isFieldPresent(sfSendMax);
|
||||
const uint160 uDstAccountID = txn.getFieldAccount160(sfDestination);
|
||||
const STAmount saDstAmount = txn.getFieldAmount(sfAmount);
|
||||
const STAmount saMaxAmount = bMax ? txn.getFieldAmount(sfSendMax) : saDstAmount;
|
||||
const uint160 uSrcCurrency = saMaxAmount.getCurrency();
|
||||
const uint160 uDstCurrency = saDstAmount.getCurrency();
|
||||
|
||||
@@ -550,8 +550,8 @@ TER TransactionEngine::doPayment(const SerializedTransaction& txn, const Transac
|
||||
// Create the account.
|
||||
sleDst = entryCreate(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(uDstAccountID));
|
||||
|
||||
sleDst->setIFieldAccount(sfAccount, uDstAccountID);
|
||||
sleDst->setIFieldU32(sfSequence, 1);
|
||||
sleDst->setFieldAccount(sfAccount, uDstAccountID);
|
||||
sleDst->setFieldU32(sfSequence, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -566,7 +566,7 @@ TER TransactionEngine::doPayment(const SerializedTransaction& txn, const Transac
|
||||
{
|
||||
// Ripple payment
|
||||
|
||||
STPathSet spsPaths = txn.getITFieldPathSet(sfPaths);
|
||||
STPathSet spsPaths = txn.getFieldPathSet(sfPaths);
|
||||
STAmount saMaxAmountAct;
|
||||
STAmount saDstAmountAct;
|
||||
|
||||
@@ -589,7 +589,7 @@ TER TransactionEngine::doPayment(const SerializedTransaction& txn, const Transac
|
||||
{
|
||||
// Direct XNS payment.
|
||||
|
||||
STAmount saSrcXNSBalance = mTxnAccount->getIValueFieldAmount(sfBalance);
|
||||
STAmount saSrcXNSBalance = mTxnAccount->getFieldAmount(sfBalance);
|
||||
|
||||
if (saSrcXNSBalance < saDstAmount)
|
||||
{
|
||||
@@ -600,8 +600,8 @@ TER TransactionEngine::doPayment(const SerializedTransaction& txn, const Transac
|
||||
}
|
||||
else
|
||||
{
|
||||
mTxnAccount->setIFieldAmount(sfBalance, saSrcXNSBalance - saDstAmount);
|
||||
sleDst->setIFieldAmount(sfBalance, sleDst->getIValueFieldAmount(sfBalance) + saDstAmount);
|
||||
mTxnAccount->setFieldAmount(sfBalance, saSrcXNSBalance - saDstAmount);
|
||||
sleDst->setFieldAmount(sfBalance, sleDst->getFieldAmount(sfBalance) + saDstAmount);
|
||||
|
||||
terResult = tesSUCCESS;
|
||||
}
|
||||
@@ -626,9 +626,9 @@ TER TransactionEngine::doWalletAdd(const SerializedTransaction& txn)
|
||||
{
|
||||
std::cerr << "WalletAdd>" << std::endl;
|
||||
|
||||
const std::vector<unsigned char> vucPubKey = txn.getITFieldVL(sfPublicKey);
|
||||
const std::vector<unsigned char> vucSignature = txn.getITFieldVL(sfSignature);
|
||||
const uint160 uAuthKeyID = txn.getITFieldAccount(sfAuthorizedKey);
|
||||
const std::vector<unsigned char> vucPubKey = txn.getFieldVL(sfPublicKey);
|
||||
const std::vector<unsigned char> vucSignature = txn.getFieldVL(sfSignature);
|
||||
const uint160 uAuthKeyID = txn.getFieldAccount160(sfAuthorizedKey);
|
||||
const NewcoinAddress naMasterPubKey = NewcoinAddress::createAccountPublic(vucPubKey);
|
||||
const uint160 uDstAccountID = naMasterPubKey.getAccountID();
|
||||
|
||||
@@ -648,8 +648,8 @@ TER TransactionEngine::doWalletAdd(const SerializedTransaction& txn)
|
||||
return tefCREATED;
|
||||
}
|
||||
|
||||
STAmount saAmount = txn.getITFieldAmount(sfAmount);
|
||||
STAmount saSrcBalance = mTxnAccount->getIValueFieldAmount(sfBalance);
|
||||
STAmount saAmount = txn.getFieldAmount(sfAmount);
|
||||
STAmount saSrcBalance = mTxnAccount->getFieldAmount(sfBalance);
|
||||
|
||||
if (saSrcBalance < saAmount)
|
||||
{
|
||||
@@ -663,15 +663,15 @@ TER TransactionEngine::doWalletAdd(const SerializedTransaction& txn)
|
||||
}
|
||||
|
||||
// Deduct initial balance from source account.
|
||||
mTxnAccount->setIFieldAmount(sfBalance, saSrcBalance-saAmount);
|
||||
mTxnAccount->setFieldAmount(sfBalance, saSrcBalance-saAmount);
|
||||
|
||||
// Create the account.
|
||||
sleDst = entryCreate(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(uDstAccountID));
|
||||
|
||||
sleDst->setIFieldAccount(sfAccount, uDstAccountID);
|
||||
sleDst->setIFieldU32(sfSequence, 1);
|
||||
sleDst->setIFieldAmount(sfBalance, saAmount);
|
||||
sleDst->setIFieldAccount(sfAuthorizedKey, uAuthKeyID);
|
||||
sleDst->setFieldAccount(sfAccount, uDstAccountID);
|
||||
sleDst->setFieldU32(sfSequence, 1);
|
||||
sleDst->setFieldAmount(sfBalance, saAmount);
|
||||
sleDst->setFieldAccount(sfAuthorizedKey, uAuthKeyID);
|
||||
|
||||
std::cerr << "WalletAdd<" << std::endl;
|
||||
|
||||
@@ -758,7 +758,7 @@ TER TransactionEngine::takeOffers(
|
||||
else
|
||||
{
|
||||
// Have an offer directory to consider.
|
||||
Log(lsINFO) << "takeOffers: considering dir : " << sleOfferDir->getJson(0);
|
||||
Log(lsINFO) << "takeOffers: considering dir: " << sleOfferDir->getJson(0);
|
||||
|
||||
SLE::pointer sleBookNode;
|
||||
unsigned int uBookEntry;
|
||||
@@ -770,11 +770,11 @@ TER TransactionEngine::takeOffers(
|
||||
|
||||
Log(lsINFO) << "takeOffers: considering offer : " << sleOffer->getJson(0);
|
||||
|
||||
const uint160 uOfferOwnerID = sleOffer->getIValueFieldAccount(sfAccount).getAccountID();
|
||||
STAmount saOfferPays = sleOffer->getIValueFieldAmount(sfTakerGets);
|
||||
STAmount saOfferGets = sleOffer->getIValueFieldAmount(sfTakerPays);
|
||||
const uint160 uOfferOwnerID = sleOffer->getFieldAccount(sfAccount).getAccountID();
|
||||
STAmount saOfferPays = sleOffer->getFieldAmount(sfTakerGets);
|
||||
STAmount saOfferGets = sleOffer->getFieldAmount(sfTakerPays);
|
||||
|
||||
if (sleOffer->getIFieldPresent(sfExpiration) && sleOffer->getIFieldU32(sfExpiration) <= mLedger->getParentCloseTimeNC())
|
||||
if (sleOffer->isFieldPresent(sfExpiration) && sleOffer->getFieldU32(sfExpiration) <= mLedger->getParentCloseTimeNC())
|
||||
{
|
||||
// Offer is expired. Expired offers are considered unfunded. Delete it.
|
||||
Log(lsINFO) << "takeOffers: encountered expired offer";
|
||||
@@ -849,10 +849,10 @@ TER TransactionEngine::takeOffers(
|
||||
// Adjust offer
|
||||
|
||||
// Offer owner will pay less. Subtract what taker just got.
|
||||
sleOffer->setIFieldAmount(sfTakerGets, saOfferPays -= saSubTakerGot);
|
||||
sleOffer->setFieldAmount(sfTakerGets, saOfferPays -= saSubTakerGot);
|
||||
|
||||
// Offer owner will get less. Subtract what owner just paid.
|
||||
sleOffer->setIFieldAmount(sfTakerPays, saOfferGets -= saSubTakerPaid);
|
||||
sleOffer->setFieldAmount(sfTakerPays, saOfferGets -= saSubTakerPaid);
|
||||
|
||||
entryModify(sleOffer);
|
||||
|
||||
@@ -919,8 +919,8 @@ TER TransactionEngine::doOfferCreate(const SerializedTransaction& txn)
|
||||
Log(lsWARNING) << "doOfferCreate> " << txn.getJson(0);
|
||||
const uint32 txFlags = txn.getFlags();
|
||||
const bool bPassive = isSetBit(txFlags, tfPassive);
|
||||
STAmount saTakerPays = txn.getITFieldAmount(sfTakerPays);
|
||||
STAmount saTakerGets = txn.getITFieldAmount(sfTakerGets);
|
||||
STAmount saTakerPays = txn.getFieldAmount(sfTakerPays);
|
||||
STAmount saTakerGets = txn.getFieldAmount(sfTakerGets);
|
||||
|
||||
Log(lsINFO) << boost::str(boost::format("doOfferCreate: saTakerPays=%s saTakerGets=%s")
|
||||
% saTakerPays.getFullText()
|
||||
@@ -928,8 +928,8 @@ Log(lsINFO) << boost::str(boost::format("doOfferCreate: saTakerPays=%s saTakerGe
|
||||
|
||||
const uint160 uPaysIssuerID = saTakerPays.getIssuer();
|
||||
const uint160 uGetsIssuerID = saTakerGets.getIssuer();
|
||||
const uint32 uExpiration = txn.getITFieldU32(sfExpiration);
|
||||
const bool bHaveExpiration = txn.getITFieldPresent(sfExpiration);
|
||||
const uint32 uExpiration = txn.getFieldU32(sfExpiration);
|
||||
const bool bHaveExpiration = txn.isFieldPresent(sfExpiration);
|
||||
const uint32 uSequence = txn.getSequence();
|
||||
|
||||
const uint256 uLedgerIndex = Ledger::getOfferIndex(mTxnAccountID, uSequence);
|
||||
@@ -965,7 +965,7 @@ Log(lsINFO) << boost::str(boost::format("doOfferCreate: saTakerPays=%s saTakerGe
|
||||
|
||||
terResult = temBAD_OFFER;
|
||||
}
|
||||
else if (!saTakerPays || !saTakerGets)
|
||||
else if (!saTakerPays.isPositive() || !saTakerGets.isPositive())
|
||||
{
|
||||
Log(lsWARNING) << "doOfferCreate: Malformed offer: bad amount";
|
||||
|
||||
@@ -1090,16 +1090,16 @@ Log(lsINFO) << boost::str(boost::format("doOfferCreate: saTakerPays=%s saTakerGe
|
||||
Log(lsWARNING) << "doOfferCreate: uPaysCurrency=" << saTakerPays.getHumanCurrency();
|
||||
Log(lsWARNING) << "doOfferCreate: uGetsCurrency=" << saTakerGets.getHumanCurrency();
|
||||
|
||||
sleOffer->setIFieldAccount(sfAccount, mTxnAccountID);
|
||||
sleOffer->setIFieldU32(sfSequence, uSequence);
|
||||
sleOffer->setIFieldH256(sfBookDirectory, uDirectory);
|
||||
sleOffer->setIFieldAmount(sfTakerPays, saTakerPays);
|
||||
sleOffer->setIFieldAmount(sfTakerGets, saTakerGets);
|
||||
sleOffer->setIFieldU64(sfOwnerNode, uOwnerNode);
|
||||
sleOffer->setIFieldU64(sfBookNode, uBookNode);
|
||||
sleOffer->setFieldAccount(sfAccount, mTxnAccountID);
|
||||
sleOffer->setFieldU32(sfSequence, uSequence);
|
||||
sleOffer->setFieldH256(sfBookDirectory, uDirectory);
|
||||
sleOffer->setFieldAmount(sfTakerPays, saTakerPays);
|
||||
sleOffer->setFieldAmount(sfTakerGets, saTakerGets);
|
||||
sleOffer->setFieldU64(sfOwnerNode, uOwnerNode);
|
||||
sleOffer->setFieldU64(sfBookNode, uBookNode);
|
||||
|
||||
if (uExpiration)
|
||||
sleOffer->setIFieldU32(sfExpiration, uExpiration);
|
||||
sleOffer->setFieldU32(sfExpiration, uExpiration);
|
||||
|
||||
if (bPassive)
|
||||
sleOffer->setFlag(lsfPassive);
|
||||
@@ -1114,7 +1114,7 @@ Log(lsINFO) << boost::str(boost::format("doOfferCreate: saTakerPays=%s saTakerGe
|
||||
TER TransactionEngine::doOfferCancel(const SerializedTransaction& txn)
|
||||
{
|
||||
TER terResult;
|
||||
const uint32 uSequence = txn.getITFieldU32(sfOfferSequence);
|
||||
const uint32 uSequence = txn.getFieldU32(sfOfferSequence);
|
||||
const uint256 uOfferIndex = Ledger::getOfferIndex(mTxnAccountID, uSequence);
|
||||
SLE::pointer sleOffer = entryCache(ltOFFER, uOfferIndex);
|
||||
|
||||
@@ -1141,14 +1141,14 @@ TER TransactionEngine::doContractAdd(const SerializedTransaction& txn)
|
||||
{
|
||||
Log(lsWARNING) << "doContractAdd> " << txn.getJson(0);
|
||||
|
||||
const uint32 expiration = txn.getITFieldU32(sfExpiration);
|
||||
// const uint32 bondAmount = txn.getITFieldU32(sfBondAmount);
|
||||
// const uint32 stampEscrow = txn.getITFieldU32(sfStampEscrow);
|
||||
STAmount rippleEscrow = txn.getITFieldAmount(sfRippleEscrow);
|
||||
std::vector<unsigned char> createCode = txn.getITFieldVL(sfCreateCode);
|
||||
std::vector<unsigned char> fundCode = txn.getITFieldVL(sfFundCode);
|
||||
std::vector<unsigned char> removeCode = txn.getITFieldVL(sfRemoveCode);
|
||||
std::vector<unsigned char> expireCode = txn.getITFieldVL(sfExpireCode);
|
||||
const uint32 expiration = txn.getFieldU32(sfExpiration);
|
||||
// const uint32 bondAmount = txn.getFieldU32(sfBondAmount);
|
||||
// const uint32 stampEscrow = txn.getFieldU32(sfStampEscrow);
|
||||
STAmount rippleEscrow = txn.getFieldAmount(sfRippleEscrow);
|
||||
std::vector<unsigned char> createCode = txn.getFieldVL(sfCreateCode);
|
||||
std::vector<unsigned char> fundCode = txn.getFieldVL(sfFundCode);
|
||||
std::vector<unsigned char> removeCode = txn.getFieldVL(sfRemoveCode);
|
||||
std::vector<unsigned char> expireCode = txn.getFieldVL(sfExpireCode);
|
||||
|
||||
// make sure
|
||||
// expiration hasn't passed
|
||||
|
||||
@@ -105,7 +105,7 @@ TER TransactionEngine::applyTransaction(const SerializedTransaction& txn, Transa
|
||||
NewcoinAddress naSigningPubKey;
|
||||
|
||||
if (tesSUCCESS == terResult)
|
||||
naSigningPubKey = NewcoinAddress::createAccountPublic(txn.peekSigningPubKey());
|
||||
naSigningPubKey = NewcoinAddress::createAccountPublic(txn.getSigningPubKey());
|
||||
|
||||
// Consistency: really signed.
|
||||
if ((tesSUCCESS == terResult) && !isSetBit(params, tapNO_CHECK_SIGN) && !txn.checkSign(naSigningPubKey))
|
||||
@@ -136,7 +136,7 @@ TER TransactionEngine::applyTransaction(const SerializedTransaction& txn, Transa
|
||||
|
||||
case ttNICKNAME_SET:
|
||||
{
|
||||
SLE::pointer sleNickname = entryCache(ltNICKNAME, txn.getITFieldH256(sfNickname));
|
||||
SLE::pointer sleNickname = entryCache(ltNICKNAME, txn.getFieldH256(sfNickname));
|
||||
|
||||
if (!sleNickname)
|
||||
saCost = theConfig.FEE_NICKNAME_CREATE;
|
||||
@@ -222,8 +222,8 @@ TER TransactionEngine::applyTransaction(const SerializedTransaction& txn, Transa
|
||||
}
|
||||
else
|
||||
{
|
||||
saSrcBalance = mTxnAccount->getIValueFieldAmount(sfBalance);
|
||||
bHaveAuthKey = mTxnAccount->getIFieldPresent(sfAuthorizedKey);
|
||||
saSrcBalance = mTxnAccount->getFieldAmount(sfBalance);
|
||||
bHaveAuthKey = mTxnAccount->isFieldPresent(sfAuthorizedKey);
|
||||
}
|
||||
|
||||
// Check if account claimed.
|
||||
@@ -279,7 +279,7 @@ TER TransactionEngine::applyTransaction(const SerializedTransaction& txn, Transa
|
||||
|
||||
default:
|
||||
// Verify the transaction's signing public key is the key authorized for signing.
|
||||
if (bHaveAuthKey && naSigningPubKey.getAccountID() == mTxnAccount->getIValueFieldAccount(sfAuthorizedKey).getAccountID())
|
||||
if (bHaveAuthKey && naSigningPubKey.getAccountID() == mTxnAccount->getFieldAccount(sfAuthorizedKey).getAccountID())
|
||||
{
|
||||
// Authorized to continue.
|
||||
nothing();
|
||||
@@ -322,7 +322,7 @@ TER TransactionEngine::applyTransaction(const SerializedTransaction& txn, Transa
|
||||
}
|
||||
else
|
||||
{
|
||||
mTxnAccount->setIFieldAmount(sfBalance, saSrcBalance - saPaid);
|
||||
mTxnAccount->setFieldAmount(sfBalance, saSrcBalance - saPaid);
|
||||
}
|
||||
|
||||
// Validate sequence
|
||||
@@ -332,7 +332,7 @@ TER TransactionEngine::applyTransaction(const SerializedTransaction& txn, Transa
|
||||
}
|
||||
else if (saCost)
|
||||
{
|
||||
uint32 a_seq = mTxnAccount->getIFieldU32(sfSequence);
|
||||
uint32 a_seq = mTxnAccount->getFieldU32(sfSequence);
|
||||
|
||||
Log(lsTRACE) << "Aseq=" << a_seq << ", Tseq=" << t_seq;
|
||||
|
||||
@@ -359,7 +359,7 @@ TER TransactionEngine::applyTransaction(const SerializedTransaction& txn, Transa
|
||||
}
|
||||
else
|
||||
{
|
||||
mTxnAccount->setIFieldU32(sfSequence, t_seq + 1);
|
||||
mTxnAccount->setFieldU32(sfSequence, t_seq + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -111,6 +111,8 @@ enum TER // aka TransactionEngineResult
|
||||
#define isTemMalformed(x) ((x) >= temMALFORMED && (x) < tefFAILURE)
|
||||
#define isTefFailure(x) ((x) >= tefFAILURE && (x) < terRETRY)
|
||||
#define isTepPartial(x) ((x) >= tepPATH_PARTIAL)
|
||||
#define isTepSuccess(x) ((x) >= tesSUCCESS)
|
||||
#define isTerRetry(x) ((x) >= terRETRY && (x) < tesSUCCESS)
|
||||
|
||||
bool transResultInfo(TER terCode, std::string& strToken, std::string& strHuman);
|
||||
std::string transToken(TER terCode);
|
||||
|
||||
@@ -1,133 +1,124 @@
|
||||
|
||||
#include "TransactionFormats.h"
|
||||
|
||||
#define S_FIELD(x) sf##x, #x
|
||||
#define TF_BASE \
|
||||
{ sfTransactionType, SOE_REQUIRED }, \
|
||||
{ sfFlags, SOE_REQUIRED }, \
|
||||
{ sfSourceTag, SOE_OPTIONAL }, \
|
||||
{ sfAccount, SOE_REQUIRED }, \
|
||||
{ sfSequence, SOE_REQUIRED }, \
|
||||
{ sfFee, SOE_REQUIRED }, \
|
||||
{ sfSigningPubKey, SOE_REQUIRED }, \
|
||||
{ sfTxnSignature, SOE_OPTIONAL },
|
||||
|
||||
TransactionFormat InnerTxnFormats[]=
|
||||
TransactionFormat TxnFormats[]=
|
||||
{
|
||||
{ "AccountSet", ttACCOUNT_SET, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ 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(TransferRate), STI_UINT32, SOE_IFFLAG, 32 },
|
||||
{ S_FIELD(PublishHash), STI_HASH256, SOE_IFFLAG, 64 },
|
||||
{ S_FIELD(PublishSize), STI_UINT32, SOE_IFFLAG, 128 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "Claim", ttCLAIM, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Generator), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(PublicKey), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Signature), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "CreditSet", ttCREDIT_SET, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(LimitAmount), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(QualityIn), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(QualityOut), STI_UINT32, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 4 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "AccountSet", ttACCOUNT_SET, { TF_BASE
|
||||
{ sfEmailHash, SOE_OPTIONAL },
|
||||
{ sfWalletLocator, SOE_OPTIONAL },
|
||||
{ sfMessageKey, SOE_OPTIONAL },
|
||||
{ sfDomain, SOE_OPTIONAL },
|
||||
{ sfTransferRate, SOE_OPTIONAL },
|
||||
{ sfPublishHash, SOE_OPTIONAL },
|
||||
{ sfPublishSize, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "Claim", ttCLAIM, { TF_BASE
|
||||
{ sfGenerator, SOE_REQUIRED },
|
||||
{ sfPublicKey, SOE_REQUIRED },
|
||||
{ sfSignature, SOE_REQUIRED },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "CreditSet", ttCREDIT_SET, { TF_BASE
|
||||
{ sfLimitAmount, SOE_OPTIONAL },
|
||||
{ sfQualityIn, SOE_OPTIONAL },
|
||||
{ sfQualityOut, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
/*
|
||||
{ "Invoice", ttINVOICE, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Target), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Amount), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(Destination), STI_ACCOUNT, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(Identifier), STI_VL, SOE_IFFLAG, 4 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "Invoice", ttINVOICE, { TF_BASE
|
||||
{ sfTarget, SOE_REQUIRED },
|
||||
{ sfAmount, SOE_REQUIRED },
|
||||
{ sfDestination, SOE_OPTIONAL },
|
||||
{ sfIdentifier, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
*/
|
||||
{ "NicknameSet", ttNICKNAME_SET, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Nickname), STI_HASH256, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(MinimumOffer), STI_AMOUNT, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(Signature), STI_VL, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 4 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "OfferCreate", ttOFFER_CREATE, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(TakerPays), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(TakerGets), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(Expiration), STI_UINT32, SOE_IFFLAG, 2 },
|
||||
{ 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 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "PasswordFund", ttPASSWORD_FUND, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Destination), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "PasswordSet", ttPASSWORD_SET, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(AuthorizedKey), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Generator), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(PublicKey), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Signature), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "Payment", ttPAYMENT, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Destination), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Amount), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(SendMax), STI_AMOUNT, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(Paths), STI_PATHSET, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 4 },
|
||||
{ S_FIELD(InvoiceID), STI_HASH256, SOE_IFFLAG, 8 },
|
||||
{ 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 },
|
||||
{ S_FIELD(AuthorizedKey), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(PublicKey), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Signature), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "Contract", ttCONTRACT, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Expiration), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(BondAmount), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(StampEscrow), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(RippleEscrow), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(CreateCode), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(FundCode), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(RemoveCode), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(ExpireCode), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "Contract", ttCONTRACT_REMOVE, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Target), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
},
|
||||
{ "NicknameSet", ttNICKNAME_SET, { TF_BASE
|
||||
{ sfNickname, SOE_REQUIRED },
|
||||
{ sfMinimumOffer, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "OfferCreate", ttOFFER_CREATE, { TF_BASE
|
||||
{ sfTakerPays, SOE_REQUIRED },
|
||||
{ sfTakerGets, SOE_REQUIRED },
|
||||
{ sfExpiration, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "OfferCancel", ttOFFER_CANCEL, { TF_BASE
|
||||
{ sfOfferSequence, SOE_REQUIRED },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "PasswordFund", ttPASSWORD_FUND, { TF_BASE
|
||||
{ sfDestination, SOE_REQUIRED },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "PasswordSet", ttPASSWORD_SET, { TF_BASE
|
||||
{ sfAuthorizedKey, SOE_REQUIRED },
|
||||
{ sfGenerator, SOE_REQUIRED },
|
||||
{ sfPublicKey, SOE_REQUIRED },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "Payment", ttPAYMENT, { TF_BASE
|
||||
{ sfDestination, SOE_REQUIRED },
|
||||
{ sfAmount, SOE_REQUIRED },
|
||||
{ sfSendMax, SOE_OPTIONAL },
|
||||
{ sfPaths, SOE_OPTIONAL },
|
||||
{ sfInvoiceID, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "WalletAdd", ttWALLET_ADD, { TF_BASE
|
||||
{ sfAmount, SOE_REQUIRED },
|
||||
{ sfAuthorizedKey, SOE_REQUIRED },
|
||||
{ sfPublicKey, SOE_REQUIRED },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "Contract", ttCONTRACT, { TF_BASE
|
||||
{ sfExpiration, SOE_REQUIRED },
|
||||
{ sfBondAmount, SOE_REQUIRED },
|
||||
{ sfStampEscrow, SOE_REQUIRED },
|
||||
{ sfRippleEscrow, SOE_REQUIRED },
|
||||
{ sfCreateCode, SOE_OPTIONAL },
|
||||
{ sfFundCode, SOE_OPTIONAL },
|
||||
{ sfRemoveCode, SOE_OPTIONAL },
|
||||
{ sfExpireCode, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "RemoveContract", ttCONTRACT_REMOVE, { TF_BASE
|
||||
{ sfTarget, SOE_REQUIRED },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ NULL, ttINVALID }
|
||||
};
|
||||
|
||||
TransactionFormat* getTxnFormat(TransactionType t)
|
||||
TransactionFormat* getTxnFormat(TransactionType t)
|
||||
{
|
||||
TransactionFormat* f = InnerTxnFormats;
|
||||
while (f->t_name != NULL)
|
||||
{
|
||||
if (f->t_type == t) return f;
|
||||
++f;
|
||||
}
|
||||
return getTxnFormat(static_cast<int>(t));
|
||||
}
|
||||
|
||||
TransactionFormat* getTxnFormat(int t)
|
||||
{
|
||||
for (TransactionFormat* f = TxnFormats; f->t_name != NULL; ++f)
|
||||
if (t == f->t_type)
|
||||
return f;
|
||||
return NULL;
|
||||
}
|
||||
// vim:ts=4
|
||||
|
||||
TransactionFormat* getTxnFormat(const std::string& format)
|
||||
{
|
||||
for (TransactionFormat* f = TxnFormats; f->t_name != NULL; ++f)
|
||||
if (format == f->t_name)
|
||||
return f;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -23,17 +23,11 @@ enum TransactionType
|
||||
|
||||
struct TransactionFormat
|
||||
{
|
||||
const char *t_name;
|
||||
TransactionType t_type;
|
||||
SOElement elements[16];
|
||||
const char * t_name;
|
||||
TransactionType t_type;
|
||||
SOElement elements[24];
|
||||
};
|
||||
|
||||
const int TransactionISigningPubKey = 0;
|
||||
const int TransactionISourceID = 1;
|
||||
const int TransactionISequence = 2;
|
||||
const int TransactionIType = 3;
|
||||
const int TransactionIFee = 4;
|
||||
|
||||
const int TransactionMinLen = 32;
|
||||
const int TransactionMaxLen = 1048576;
|
||||
|
||||
@@ -50,7 +44,9 @@ const uint32 tfPartialPayment = 0x00020000;
|
||||
const uint32 tfLimitQuality = 0x00040000;
|
||||
const uint32 tfNoRippleDirect = 0x00080000;
|
||||
|
||||
extern TransactionFormat InnerTxnFormats[];
|
||||
extern TransactionFormat TxnFormats[];
|
||||
extern TransactionFormat* getTxnFormat(TransactionType t);
|
||||
extern TransactionFormat* getTxnFormat(const std::string& t);
|
||||
extern TransactionFormat* getTxnFormat(int t);
|
||||
#endif
|
||||
// vim:ts=4
|
||||
|
||||
@@ -66,7 +66,7 @@ Json::Value TMNEThread::getJson(int) const
|
||||
|
||||
TMNEAmount::TMNEAmount(int type, SerializerIterator& sit) : TransactionMetaNodeEntry(type)
|
||||
{
|
||||
mAmount = *dynamic_cast<STAmount*>(STAmount::deserialize(sit, NULL).get()); // Ouch
|
||||
mAmount = *dynamic_cast<STAmount*>(STAmount::deserialize(sit, sfAmount).get()); // Ouch
|
||||
}
|
||||
|
||||
void TMNEAmount::addRaw(Serializer& s) const
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//
|
||||
|
||||
#define SERVER_VERSION_MAJOR 0
|
||||
#define SERVER_VERSION_MINOR 5
|
||||
#define SERVER_VERSION_MINOR 6
|
||||
#define SERVER_VERSION_SUB "-a"
|
||||
#define SERVER_NAME "NewCoin"
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
(SERVER_NAME "-" SV_STRINGIZE(SERVER_VERSION_MAJOR) "." SV_STRINGIZE(SERVER_VERSION_MINOR) SERVER_VERSION_SUB)
|
||||
|
||||
// Version we prefer to speak:
|
||||
#define PROTO_VERSION_MAJOR 0
|
||||
#define PROTO_VERSION_MINOR 8
|
||||
#define PROTO_VERSION_MAJOR 1
|
||||
#define PROTO_VERSION_MINOR 1
|
||||
|
||||
// Version we will speak to:
|
||||
#define MIN_PROTO_MAJOR 0
|
||||
#define MIN_PROTO_MINOR 8
|
||||
#define MIN_PROTO_MAJOR 1
|
||||
#define MIN_PROTO_MINOR 1
|
||||
|
||||
#define MAKE_VERSION_INT(maj,min) ((maj << 16) | min)
|
||||
#define GET_VERSION_MAJOR(ver) (ver >> 16)
|
||||
|
||||
Reference in New Issue
Block a user