diff --git a/src/Amount.cpp b/src/Amount.cpp index 4c35c46a06..9fc46089e3 100644 --- a/src/Amount.cpp +++ b/src/Amount.cpp @@ -359,19 +359,16 @@ 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, value, offset, isNegative); + 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); + sapResult = new STAmount(name, uCurrencyID, uIssuerID); } - if (sapResult) - sapResult->setIssuer(uIssuerID); - return sapResult; } @@ -522,7 +519,22 @@ STAmount& STAmount::operator-=(const STAmount& a) STAmount STAmount::operator-(void) const { if (mValue == 0) return *this; - return STAmount(name, mCurrency, mValue, mOffset, mIsNative, !mIsNegative); + return STAmount(name, mCurrency, mIssuer, mValue, mOffset, mIsNative, !mIsNegative); +} + +STAmount& STAmount::operator=(const STAmount &a) +{ + if (name == NULL) + name = a.name; + + mCurrency = a.mCurrency; + mIssuer = a.mIssuer; + mValue = a.mValue; + mOffset = a.mOffset; + mIsNative = a.mIsNative; + mIsNegative = a.mIsNegative; + + return *this; } STAmount& STAmount::operator=(uint64 v) diff --git a/src/SerializedTypes.h b/src/SerializedTypes.h index e7735bfc8e..fef6664123 100644 --- a/src/SerializedTypes.h +++ b/src/SerializedTypes.h @@ -250,9 +250,9 @@ protected: 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, uint64 val, int off, bool isNative, bool isNegative) - : SerializedType(n), mCurrency(cur), mValue(val), mOffset(off), mIsNative(isNative), 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), + mIsNative(isNat), mIsNegative(isNeg) { ; } uint64 toUInt64() const; static uint64 muldiv(uint64, uint64, uint64); @@ -272,8 +272,9 @@ public: { canonicalize(); } // YYY This should probably require issuer too. - STAmount(const char* n, const uint160& currency, uint64 v = 0, int off = 0, bool isNeg = false) : - SerializedType(n), mCurrency(currency), mValue(v), mOffset(off), mIsNegative(isNeg) + STAmount(const char* 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); @@ -347,6 +348,7 @@ public: STAmount operator-(uint64) const; STAmount operator-(void) const; + STAmount& operator=(const STAmount&); STAmount& operator+=(const STAmount&); STAmount& operator-=(const STAmount&); STAmount& operator+=(uint64);