diff --git a/src/Amount.cpp b/src/Amount.cpp index 793e71c250..11711917ea 100644 --- a/src/Amount.cpp +++ b/src/Amount.cpp @@ -274,7 +274,7 @@ void STAmount::canonicalize() assert((mValue != 0) || (mOffset != -100) ); } -void STAmount::add(Serializer& s) const +void STAmount::addData(Serializer& s) const { if (mIsNative) { diff --git a/src/SerializeProto.h b/src/SerializeProto.h index 225cb85dac..2c9115fd85 100644 --- a/src/SerializeProto.h +++ b/src/SerializeProto.h @@ -64,7 +64,7 @@ FIELD(BaseFee, UINT64, 6) // 128-bit - FIELD(EmailHash, HASH128, 2) + FIELD(EmailHash, HASH128, 1) // 256-bit (common) FIELD(LedgerHash, HASH256, 1) @@ -98,7 +98,7 @@ // variable length FIELD(PublicKey, VL, 1) FIELD(MessageKey, VL, 2) - FIELD(SigningKey, VL, 3) + FIELD(SigningPubKey, VL, 3) FIELD(Signature, VL, 4) FIELD(Generator, VL, 5) FIELD(Domain, VL, 6) @@ -125,8 +125,7 @@ // inner object // OBJECT/1 is reserved for end of object - FIELD(MiddleTransaction, OBJECT, 2) - FIELD(InnerTransaction, OBJECT, 3) + FIELD(InnerTransaction, OBJECT, 1) // array of objects // ARRAY/1 is reserved for end of array diff --git a/src/SerializedLedger.h b/src/SerializedLedger.h index 7468da4d02..b7f35a34f4 100644 --- a/src/SerializedLedger.h +++ b/src/SerializedLedger.h @@ -28,8 +28,8 @@ public: std::string getText() const; Json::Value getJson(int options) const; - const uint256& getIndex() const; - void setIndex(const uint256& i); + const uint256& getIndex() const { return mIndex; } + void setIndex(const uint256& i) { mIndex = i; } LedgerEntryType getType() const { return mType; } uint16 getVersion() const { return getValueFieldU16(sfLedgerEntryType); } diff --git a/src/SerializedObject.cpp b/src/SerializedObject.cpp index ef700db52e..18f20388b7 100644 --- a/src/SerializedObject.cpp +++ b/src/SerializedObject.cpp @@ -212,11 +212,11 @@ std::string STObject::getFullText() const void STObject::add(Serializer& s) const { addFieldID(s); - addRaw(s); + addData(s); s.addFieldID(STI_OBJECT, 1); } -void STObject::addRaw(Serializer& s) const +void STObject::addData(Serializer& s) const { // FIXME: need to add in sorted order BOOST_FOREACH(const SerializedType& it, mData) it.add(s); diff --git a/src/SerializedObject.h b/src/SerializedObject.h index fdc9030e92..f037f0446d 100644 --- a/src/SerializedObject.h +++ b/src/SerializedObject.h @@ -57,7 +57,7 @@ public: virtual bool isEquivalent(const SerializedType& t) const; void add(Serializer& s) const; // with start/end of object - virtual void addRaw(Serializer& s) const; // just inner elements + virtual void addData(Serializer& s) const; // just inner elements Serializer getSerializer() const { Serializer s; add(s); return s; } std::string getFullText() const; std::string getText() const; diff --git a/src/SerializedTransaction.cpp b/src/SerializedTransaction.cpp index f77937cce4..b8a5f96c9a 100644 --- a/src/SerializedTransaction.cpp +++ b/src/SerializedTransaction.cpp @@ -12,7 +12,7 @@ SerializedTransaction::SerializedTransaction(TransactionType type) : mType(type) mFormat = getTxnFormat(type); if (mFormat == NULL) throw std::runtime_error("invalid transaction type"); - mMiddleTxn.giveObject(new STVariableLength(sfSigningKey)); + mMiddleTxn.giveObject(new STVariableLength(sfSigningPubKey)); mMiddleTxn.giveObject(new STAccount(sfAccount)); mMiddleTxn.giveObject(new STUInt32(sfSequence)); mMiddleTxn.giveObject(new STUInt16(sfTransactionType, static_cast(type))); @@ -32,25 +32,25 @@ SerializedTransaction::SerializedTransaction(SerializerIterator& sit) mSignature.setValue(sit.getVL()); - mMiddleTxn.giveObject(new STVariableLength("SigningPubKey", sit.getVL())); + mMiddleTxn.giveObject(new STVariableLength(sfSigningPubKey, sit.getVL())); - STAccount sa("SourceAccount", sit.getVL()); + STAccount sa(sfAccount, sit.getVL()); mSourceAccount = sa.getValueNCA(); mMiddleTxn.giveObject(new STAccount(sa)); - mMiddleTxn.giveObject(new STUInt32("Sequence", sit.get32())); + mMiddleTxn.giveObject(new STUInt32(sfSequence, sit.get32())); mType = static_cast(sit.get16()); - mMiddleTxn.giveObject(new STUInt16("Type", static_cast(mType))); + mMiddleTxn.giveObject(new STUInt16(sfTransactionType, static_cast(mType))); mFormat = getTxnFormat(mType); if (!mFormat) { Log(lsERROR) << "Transaction has invalid type"; throw std::runtime_error("Transaction has invalid type"); } - mMiddleTxn.giveObject(STAmount::deserialize(sit, "Fee")); + mMiddleTxn.giveObject(STAmount::deserialize(sit, sfFee)); - mInnerTxn = STObject(mFormat->elements, sit, "InnerTransaction"); + mInnerTxn = STObject(mFormat->elements, sit, sfInnerTransaction); } std::string SerializedTransaction::getFullText() const diff --git a/src/SerializedTypes.cpp b/src/SerializedTypes.cpp index 6eeb0c9120..4e7ed6ec56 100644 --- a/src/SerializedTypes.cpp +++ b/src/SerializedTypes.cpp @@ -202,7 +202,7 @@ STVector256* STVector256::construct(SerializerIterator& u, SField::ref name) return new STVector256(name, value); } -void STVector256::add(Serializer& s) const +void STVector256::addData(Serializer& s) const { s.addVL(mValue.empty() ? NULL : mValue[0].begin(), mValue.size() * (256 / 8)); } @@ -427,7 +427,7 @@ std::string STPathSet::getText() const } #endif -void STPathSet::add(Serializer& s) const +void STPathSet::addData(Serializer& s) const { bool bFirst = true; diff --git a/src/SerializedTypes.h b/src/SerializedTypes.h index 5df8b6fada..e30a2f783c 100644 --- a/src/SerializedTypes.h +++ b/src/SerializedTypes.h @@ -61,7 +61,8 @@ public: virtual Json::Value getJson(int) const { return getText(); } - virtual void add(Serializer& s) const { return; } + virtual void add(Serializer& s) const { addFieldID(s); addData(s); } + virtual void addData(Serializer& s) const { ; } virtual bool isEquivalent(const SerializedType& t) const { assert(getSType() == STI_NOTPRESENT); return t.getSType() == STI_NOTPRESENT; } @@ -97,7 +98,7 @@ public: SerializedTypeID getSType() const { return STI_UINT8; } std::string getText() const; - void add(Serializer& s) const { s.add8(value); } + void addData(Serializer& s) const { s.add8(value); } unsigned char getValue() const { return value; } void setValue(unsigned char v) { value = v; } @@ -123,7 +124,7 @@ public: SerializedTypeID getSType() const { return STI_UINT16; } std::string getText() const; - void add(Serializer& s) const { s.add16(value); } + void addData(Serializer& s) const { s.add16(value); } uint16 getValue() const { return value; } void setValue(uint16 v) { value=v; } @@ -149,7 +150,7 @@ public: SerializedTypeID getSType() const { return STI_UINT32; } std::string getText() const; - void add(Serializer& s) const { s.add32(value); } + void addData(Serializer& s) const { s.add32(value); } uint32 getValue() const { return value; } void setValue(uint32 v) { value=v; } @@ -175,7 +176,7 @@ public: SerializedTypeID getSType() const { return STI_UINT64; } std::string getText() const; - void add(Serializer& s) const { s.add64(value); } + void addData(Serializer& s) const { s.add64(value); } uint64 getValue() const { return value; } void setValue(uint64 v) { value=v; } @@ -267,7 +268,7 @@ public: std::string getText() const; std::string getRaw() const; std::string getFullText() const; - void add(Serializer& s) const; + void addData(Serializer& s) const; int getExponent() const { return mOffset; } uint64 getMantissa() const { return mValue; } @@ -391,7 +392,7 @@ public: SerializedTypeID getSType() const { return STI_HASH128; } virtual std::string getText() const; - void add(Serializer& s) const { s.add128(value); } + void addData(Serializer& s) const { s.add128(value); } const uint128& getValue() const { return value; } void setValue(const uint128& v) { value=v; } @@ -419,7 +420,7 @@ public: SerializedTypeID getSType() const { return STI_HASH160; } virtual std::string getText() const; - void add(Serializer& s) const { s.add160(value); } + void addData(Serializer& s) const { s.add160(value); } const uint160& getValue() const { return value; } void setValue(const uint160& v) { value=v; } @@ -447,7 +448,7 @@ public: SerializedTypeID getSType() const { return STI_HASH256; } std::string getText() const; - void add(Serializer& s) const { s.add256(value); } + void addData(Serializer& s) const { s.add256(value); } const uint256& getValue() const { return value; } void setValue(const uint256& v) { value=v; } @@ -476,7 +477,7 @@ public: virtual SerializedTypeID getSType() const { return STI_VL; } virtual std::string getText() const; - void add(Serializer& s) const { s.addVL(value); } + void addData(Serializer& s) const { s.addVL(value); } const std::vector& peekValue() const { return value; } std::vector& peekValue() { return value; } @@ -641,7 +642,7 @@ public: { return std::auto_ptr(construct(sit, name)); } // std::string getText() const; - void add(Serializer& s) const; + void addData(Serializer& s) const; virtual Json::Value getJson(int) const; SerializedTypeID getSType() const { return STI_PATHSET; } @@ -710,7 +711,7 @@ public: STVector256(const std::vector& vector) : mValue(vector) { ; } SerializedTypeID getSType() const { return STI_VECTOR256; } - void add(Serializer& s) const; + void addData(Serializer& s) const; static std::auto_ptr deserialize(SerializerIterator& sit, SField::ref name) { return std::auto_ptr(construct(sit, name)); } diff --git a/src/SerializedValidation.cpp b/src/SerializedValidation.cpp index 6eedadb94b..edd4fe721b 100644 --- a/src/SerializedValidation.cpp +++ b/src/SerializedValidation.cpp @@ -11,7 +11,7 @@ SOElement SerializedValidation::sValidationFormat[] = { { sfLoadFee, SOE_OPTIONAL }, { sfBaseFee, SOE_OPTIONAL }, { sfSigningTime, SOE_REQUIRED }, - { sfSigningKey, SOE_REQUIRED }, + { sfSigningPubKey, SOE_REQUIRED }, { sfInvalid, SOE_END } }; @@ -30,7 +30,7 @@ SerializedValidation::SerializedValidation(const uint256& ledgerHash, uint32 sig setValueFieldH256(sfLedgerHash, ledgerHash); setValueFieldU32(sfSigningTime, signTime); if (naSeed.isValid()) - setValueFieldVL(sfSigningKey, NewcoinAddress::createNodePublic(naSeed).getNodePublic()); + setValueFieldVL(sfSigningPubKey, NewcoinAddress::createNodePublic(naSeed).getNodePublic()); if (!isFull) setFlag(sFullFlag); NewcoinAddress::createNodePrivate(naSeed).signNodePrivate(getSigningHash(), mSignature.peekValue()); @@ -73,7 +73,7 @@ bool SerializedValidation::isValid(const uint256& signingHash) const { try { - NewcoinAddress naPublicKey = NewcoinAddress::createNodePublic(getValueFieldVL(sfSigningKey)); + NewcoinAddress naPublicKey = NewcoinAddress::createNodePublic(getValueFieldVL(sfSigningPubKey)); return naPublicKey.isValid() && naPublicKey.verifyNodePublic(signingHash, mSignature.peekValue()); } catch (...) @@ -85,7 +85,7 @@ bool SerializedValidation::isValid(const uint256& signingHash) const NewcoinAddress SerializedValidation::getSignerPublic() const { NewcoinAddress a; - a.setNodePublic(getValueFieldVL(sfSigningKey)); + a.setNodePublic(getValueFieldVL(sfSigningPubKey)); return a; }