Merge 47b99ab1a9 into merged_master (Bitcoin PR #20406)

This commit is contained in:
Andrew Poelstra 2021-06-25 23:14:56 +00:00
commit bf95eb15d9
8 changed files with 45 additions and 29 deletions

View file

@ -16,8 +16,8 @@
#include <undo.h>
#include <univalue.h>
#include <util/check.h>
#include <util/system.h>
#include <util/strencodings.h>
#include <util/system.h>
#include <secp256k1_rangeproof.h>
@ -45,14 +45,17 @@ public:
};
static RPCRawTransaction_ECC_Init ecc_init_on_load;
UniValue ValueFromAmount(const CAmount& amount)
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;
static_assert(COIN > 1);
int64_t quotient = amount / COIN;
int64_t remainder = amount % COIN;
if (amount < 0) {
quotient = -quotient;
remainder = -remainder;
}
return UniValue(UniValue::VNUM,
strprintf("%s%d.%08d", sign ? "-" : "", quotient, remainder));
strprintf("%s%d.%08d", amount < 0 ? "-" : "", quotient, remainder));
}
std::string FormatScript(const CScript& script)