diff --git a/src/Amount.cpp b/src/Amount.cpp index eb65164ba0..6c19711d3d 100644 --- a/src/Amount.cpp +++ b/src/Amount.cpp @@ -721,9 +721,9 @@ uint64 getRate(const STAmount& offerOut, const STAmount& offerIn) if (offerOut.isZero()) throw std::runtime_error("Worthless offer"); STAmount r = divide(offerIn, offerOut, uint160(1)); - assert((r.getOffset() >= -100) && (r.getOffset() <= 155)); - uint64 ret = r.getOffset() + 100; - return (ret << (64 - 8)) | r.getValue(); + assert((r.getExponent() >= -100) && (r.getExponent() <= 155)); + uint64 ret = r.getExponent() + 100; + return (ret << (64 - 8)) | r.getMantissa(); } STAmount getClaimed(STAmount& offerOut, STAmount& offerIn, STAmount& paid) @@ -786,8 +786,7 @@ static uint64_t muldiv(uint64_t a, uint64_t b, uint64_t c) uint64 convertToDisplayAmount(const STAmount& internalAmount, uint64_t totalNow, uint64_t totalInit) { // Convert an internal ledger/account quantity of native currency to a display amount - if (internalAmount.isNative()) throw std::runtime_error("not native curency"); - return muldiv(internalAmount.getValue(), totalInit, totalNow); + return muldiv(internalAmount.getNValue(), totalInit, totalNow); } STAmount convertToInternalAmount(uint64_t displayAmount, uint64_t totalNow, uint64_t totalInit, diff --git a/src/SerializedTransaction.cpp b/src/SerializedTransaction.cpp index ebdf54d7d4..81f463e343 100644 --- a/src/SerializedTransaction.cpp +++ b/src/SerializedTransaction.cpp @@ -164,14 +164,14 @@ STAmount SerializedTransaction::getTransactionFee() const { const STAmount* v = dynamic_cast(mMiddleTxn.peekAtPIndex(TransactionIFee)); if (!v) throw std::runtime_error("corrupt transaction"); - return v->getValue(); + return v->getNValue(); } void SerializedTransaction::setTransactionFee(STAmount saFee) { STAmount* v = dynamic_cast(mMiddleTxn.getPIndex(TransactionIFee)); if (!v) throw std::runtime_error("corrupt transaction"); - v->setValue(saFee); + v->setNValue(saFee); } uint32 SerializedTransaction::getSequence() const diff --git a/src/SerializedTypes.h b/src/SerializedTypes.h index 59aa59ca1c..317ff0312d 100644 --- a/src/SerializedTypes.h +++ b/src/SerializedTypes.h @@ -253,9 +253,12 @@ public: std::string getRaw() const; void add(Serializer& s) const; - int getOffset() const { return mOffset; } - uint64 getValue() const { return mValue; } - void setValue(const STAmount& v) { mValue=v; } + int getExponent() const { return mOffset; } + uint64 getMantissa() const { return mValue; } + + uint64 getNValue() const { if (!mIsNative) throw std::runtime_error("not native"); return mValue; } + void setNValue(uint64_t v) { if (!mIsNative) throw std::runtime_error("not native"); mValue = v; } + std::string getCurrencyHuman(); bool isNative() const { return mIsNative; }