diff --git a/src/wallet/test/coinselector_tests.cpp b/src/wallet/test/coinselector_tests.cpp index e880e138458..8606924bb30 100644 --- a/src/wallet/test/coinselector_tests.cpp +++ b/src/wallet/test/coinselector_tests.cpp @@ -71,13 +71,18 @@ static void add_coin(std::vector& coins, CWallet& wallet, const CAmount // so stop vin being empty, and cache a non-zero Debit to fake out IsFromMe() tx.vin.resize(1); } - CWalletTx* wtx = wallet.AddToWallet(MakeTransactionRef(std::move(tx)), /* confirm= */ {}); + uint256 txid = tx.GetHash(); + + LOCK(wallet.cs_wallet); + auto ret = wallet.mapWallet.emplace(std::piecewise_construct, std::forward_as_tuple(txid), std::forward_as_tuple(MakeTransactionRef(std::move(tx)))); + assert(ret.second); + CWalletTx& wtx = (*ret.first).second; if (fIsFromMe) { - wtx->m_amounts[CWalletTx::DEBIT].Set(ISMINE_SPENDABLE, 1); - wtx->m_is_cache_empty = false; + wtx.m_amounts[CWalletTx::DEBIT].Set(ISMINE_SPENDABLE, 1); + wtx.m_is_cache_empty = false; } - COutput output(wallet, *wtx, nInput, nAge, true /* spendable */, true /* solvable */, true /* safe */); + COutput output(wallet, wtx, nInput, nAge, true /* spendable */, true /* solvable */, true /* safe */); coins.push_back(output); } diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index a6839f1f784..c920d4af51e 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -1188,9 +1188,9 @@ std::unique_ptr CreateDummyWalletDatabase() /** Return object for accessing temporary in-memory database. */ std::unique_ptr CreateMockWalletDatabase() { -#ifdef USE_BDB - return std::make_unique(std::make_shared(), ""); -#elif USE_SQLITE +#ifdef USE_SQLITE return std::make_unique("", "", true); +#elif USE_BDB + return std::make_unique(std::make_shared(), ""); #endif }