diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-08-07 14:38:39 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-08-07 17:01:21 +0200 |
commit | 46347add438d49a69f34a3f2ab755feda7daff10 (patch) | |
tree | 24025b570a23124335f6ce839a797bfc291102f7 /src/core_write.cpp | |
parent | dac37823d4799477b19434d4d53c74c4af455c76 (diff) |
rpc: Move ValueFromAmount to core_write
This is necessary because core_write has to write amounts in
TxToUniv, and mistakingly uses FormatMoney for that
(which is only for debugging).
We don't move AmountFromValue at the same time, as
this is more challenging due to the RPCError depencency
there.
Diffstat (limited to 'src/core_write.cpp')
-rw-r--r-- | src/core_write.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/core_write.cpp b/src/core_write.cpp index a366ef933c..2bf28a1506 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -16,6 +16,16 @@ #include "utilmoneystr.h" #include "utilstrencodings.h" +UniValue ValueFromAmount(const CAmount& amount) +{ + bool sign = amount < 0; + int64_t n_abs = (sign ? -amount : amount); + int64_t quotient = n_abs / COIN; + int64_t remainder = n_abs % COIN; + return UniValue(UniValue::VNUM, + strprintf("%s%d.%08d", sign ? "-" : "", quotient, remainder)); +} + std::string FormatScript(const CScript& script) { std::string ret; |