diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -715,8 +715,14 @@ } else if (command == "outaddr") { MutateTxAddOutAddr(tx, commandVal, chainParams); } else if (command == "outpubkey") { + if (!ecc) { + ecc.reset(new Secp256k1Init()); + } MutateTxAddOutPubKey(tx, commandVal); } else if (command == "outmultisig") { + if (!ecc) { + ecc.reset(new Secp256k1Init()); + } MutateTxAddOutMultiSig(tx, commandVal); } else if (command == "outscript") { MutateTxAddOutScript(tx, commandVal); diff --git a/src/utiltime.cpp b/src/utiltime.cpp --- a/src/utiltime.cpp +++ b/src/utiltime.cpp @@ -9,14 +9,19 @@ #include "utiltime.h" +#include + #include #include //!< For unit testing -static int64_t nMockTime = 0; +static std::atomic nMockTime(0); int64_t GetTime() { - if (nMockTime) return nMockTime; + int64_t mocktime = nMockTime.load(std::memory_order_relaxed); + if (mocktime) { + return mocktime; + } time_t now = time(nullptr); assert(now > 0); @@ -24,7 +29,7 @@ } void SetMockTime(int64_t nMockTimeIn) { - nMockTime = nMockTimeIn; + nMockTime.store(nMockTimeIn, std::memory_order_relaxed); } int64_t GetTimeMillis() { @@ -49,7 +54,10 @@ /** Return a time useful for the debug log */ int64_t GetLogTimeMicros() { - if (nMockTime) return nMockTime * 1000000; + int64_t mocktime = nMockTime.load(std::memory_order_relaxed); + if (mocktime) { + return mocktime * 1000000; + } return GetTimeMicros(); }