Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qa: Add TestNode::assert_debug_log #14024

merged 1 commit into from Aug 24, 2018


Copy link

commented Aug 22, 2018

Closes #13006

@MarcoFalke MarcoFalke force-pushed the MarcoFalke:Mf1808-rpcDebugLog branch Aug 22, 2018
@fanquake fanquake added the Tests label Aug 22, 2018
@MarcoFalke MarcoFalke force-pushed the MarcoFalke:Mf1808-rpcDebugLog branch Aug 22, 2018

This comment has been minimized.

Copy link

commented Aug 22, 2018

No more conflicts as of last run.

This comment has been minimized.

Copy link

commented Aug 23, 2018

Concept ACK


This comment has been minimized.

Copy link

commented Aug 23, 2018

Concept ACK asserting on the contents of the debug log, but I don't understand why a new RPC method is needed. Why not read the debug log file directly?


This comment has been minimized.

Copy link
Member Author

commented Aug 23, 2018

@jnewbery I don't think it is possible to read from a file that is opened for writing on windows with python.


This comment has been minimized.

Copy link

commented Aug 23, 2018

I don't think it is possible to read from a file that is opened for writing on windows with python.

I'm NACKish on this. I don't think we should be adding code to the product to work around a limitation in the test framework on a specific platform.

@MarcoFalke MarcoFalke force-pushed the MarcoFalke:Mf1808-rpcDebugLog branch Aug 23, 2018

This comment has been minimized.

Copy link
Member Author

commented Aug 23, 2018

Removed rpc


This comment has been minimized.

Copy link

commented Aug 24, 2018

Concept ACK.
Seems like you've solve the problem on Windows, I'm able to pass p2p_invalid_tx test on Windows

Copy link

left a comment

This is great. Tested ACK fa5a71a1498f6934e3d30499c1e17e01903f5659 (tested by asserting for a missing log).

I have a few nits inline.

test/functional/ Outdated
node.p2p.send_txs_and_test([tx1], node, success=False, expect_disconnect=True)
with node.assert_debug_log(expected_msgs=[
re.escape("{} from peer=0 was not accepted: mandatory-script-verify-flag-failed (Invalid OP_IF construction) (code 16)".format(tx1.hash)),
re.escape("disconnecting peer=0"),

This comment has been minimized.

Copy link

jnewbery Aug 24, 2018


Passing in an escaped string means that the printed assert when this fails looks a bit weird, but no big deal:

    raise AssertionError(self._node_msg(msg))
AssertionError: [node 0] Expected message "8d7190866370e089916899a483a8df5ce7b495b04ffefc841ecd0d5779e9a0ca\ asdf\ from\ peer\=0\ was\ not\ accepted\:\ mandatory\-script\-verify\-flag\-failed\ \(Invalid\ OP_IF\ construction\)\ \(code\ 16\)" does not partially match log:
test/functional/test_framework/ Outdated
log =
for expected_msg in expected_msgs:
if, log, flags=re.MULTILINE) is None:
self._raise_assertion_error('Expected message "{}" does not partially match log:\n"{}"\n'.format(expected_msg, log))

This comment has been minimized.

Copy link

jnewbery Aug 24, 2018


Printing the log excerpt out in the assert is a bit confusing for anything that's parsing the test_framework log (since the timestamps at the start of the line will be interpreted as new log lines. Can I convince you to make the following change:

@@ -242,9 +242,10 @@ class TestNode():
             with open(debug_log, encoding='utf-8') as dl:
                 log =
+                print_log = " - " + "\n - ".join(log.splitlines())
             for expected_msg in expected_msgs:
                 if, log, flags=re.MULTILINE) is None:
-                    self._raise_assertion_error('Expected message "{}" does not partially match log:\n"{}"\n'.format(expected_msg, log))
+                    self._raise_assertion_error('Expected message "{}" does not partially match log:\n\n{}\n\n'.format(expected_msg, print_log))

so that the printed log lines are prefixed with -.

I'd also be tempted to add a hint like:

        self.log.error("Expected Log not raised. Check that bitcoind log format output has not changed!")

Changes to logging that cause tests to fail can be really annoying, so adding a hint is a friendly thing to do here.


This comment has been minimized.

Copy link

commented Aug 24, 2018

ping @ryanofsky for review

@MarcoFalke MarcoFalke force-pushed the MarcoFalke:Mf1808-rpcDebugLog branch 2 times, most recently Aug 24, 2018
@MarcoFalke MarcoFalke force-pushed the MarcoFalke:Mf1808-rpcDebugLog branch to fa3e9f7 Aug 24, 2018
Copy link

left a comment

utACK fad48e85d7a3f52d7df433e895689b19d117d157

Though I actually do think the previous code adding the tail log RPC ( was nice because the tail command seems handy, and it would let us turn on log buffering in the future.

with open(debug_log, encoding='utf-8') as dl:
log =
print_log = " - " + "\n - ".join(log.splitlines())

This comment has been minimized.

Copy link

ryanofsky Aug 24, 2018


Might be more efficient to move this line before the _raise_assertion_error call in case the variable is unused.

This comment has been minimized.

Copy link

MarcoFalke Aug 24, 2018

Author Member

I think we don't optimize for performance in the test framework, so this should be fine.

@@ -229,6 +230,23 @@ def is_node_stopped(self):
def wait_until_stopped(self, timeout=BITCOIND_PROC_WAIT_TIMEOUT):
wait_until(self.is_node_stopped, timeout=timeout)

def assert_debug_log(self, expected_msgs):

This comment has been minimized.

Copy link

ryanofsky Aug 24, 2018


I was surprised to see that this code actually works without adding RPCs before and after the yield to flush the log. But apparently there is a setbuf call in the logging code which disables buffering. Might be worth noting in a comment.


This comment has been minimized.

Copy link

commented Aug 24, 2018

utACK fa3e9f7

MarcoFalke added a commit to MarcoFalke/bitcoin-core that referenced this pull request Aug 24, 2018
fa3e9f7 qa: Add TestNode::assert_debug_log (MarcoFalke)

Pull request description:

  Closes bitcoin#13006

Tree-SHA512: 8e2d2331039d70525a425aad65a4eaf9b83fb1f85a4260d69453176f04dbede6dd9b7bb4d5f089b46cf8f8c98571aa6ba7fac8fa6847bb3bdf6a6ad21a27b1a7
@MarcoFalke MarcoFalke merged commit fa3e9f7 into bitcoin:master Aug 24, 2018
1 of 2 checks passed
1 of 2 checks passed
continuous-integration/travis-ci/pr The Travis CI build failed
continuous-integration/appveyor/pr AppVeyor build succeeded
@MarcoFalke MarcoFalke deleted the MarcoFalke:Mf1808-rpcDebugLog branch Aug 24, 2018
MarcoFalke added a commit to MarcoFalke/bitcoin-core that referenced this pull request Oct 25, 2018
toxeus pushed a commit to toxeus/bitcoin that referenced this pull request Nov 28, 2018
GChuf added a commit to GChuf/bitcoin that referenced this pull request Aug 29, 2019
* Drop the unnecessary UTXO based on the UTXOs present, not on earlier wallet things

Instead of dropping the unnecessary UTXO based on whether the wallet did something,
do it based on whether two UTXOs are there.

* Convert non-witness UTXOs to witness if witness sig created

If a witness signature was created when a non-witness UTXO is used,
convert the non-witness UTXO to a witness one.

* doc: Clean out release notes after release 0.17.0

Tree-SHA512: 0b641fdf4cf4ac6a6f9f5c1b45d65c4449b0d7bb777ba57498e389840ba7a37bfc0569ce5e70f0ac998785fc4eea600ecf6f7c7d83d86513997f4033bcc14a5d

* [wallet] Restore ability to list incoming transactions by label

Backport of PR 14411 to v0.17.

This change partially reverts bitcoin#13075 and bitcoin#14023.

Fixes bitcoin#14382

* [doc] getblocktemplate: use SegWit in example

* qa: Add TestNode::assert_debug_log

Github-Pull: bitcoin#14024
Rebased-From: fa3e9f7

* [qa] Use correct python index slices in example test

Github-Pull: bitcoin#14215
Rebased-From: 9dcb676

* qa: Add some actual witness in rpc_rawtransaction

Github-Pull: bitcoin#14052
Rebased-From: fae0400

* scripted-diff: Pass node into p2p_segwit acceptance tests

sed -i --regexp-extended -e 's/(test_witness_block|test_transaction_acceptance)\((self\.nodes\[.\])\.rpc/\1(\2/g' test/functional/

Github-Pull: bitcoin#14101
Rebased-From: 749ba35

* scripted-diff: Use named arguments in feature_block

sed -i --regexp-extended -e "s/sync_blocks\((.*?), (True|False), (1.?), /sync_blocks(\1, success=\2, reject_code=\3, reject_reason=/g" ./test/functional/

Github-Pull: bitcoin#14101
Rebased-From: b4d3309

* qa: Use named args in some tests

Github-Pull: bitcoin#14101
Rebased-From: fa782a3

* test: Add tests for RPC help

Github-Pull: bitcoin#14020
Rebased-From: 6af6d9b

* Test failed: Check whether ZMQ is enabled or not.

Github-Pull: bitcoin#14122
Rebased-From: 8dfc2f3

* qa: Premine to deterministic address with -disablewallet

Github-Pull: bitcoin#14180
Rebased-From: faa669c

* qa: Run all tests even if wallet is not compiled

Github-Pull: bitcoin#14180
Rebased-From: fac9539

* Import CInv from correct module

Github-Pull: bitcoin#13965
Rebased-From: a9cf5c9

* doc/ tweaks

Add some implementation details, and tweak phrasing in examples section to be
more explicit about how script expressions are used for matching.

Github-Pull: bitcoin#14161
Rebased-From: eb49412

* Refer to descriptors as describing instead of matching

Github-Pull: bitcoin#14161
Rebased-From: eeeaa29

* Disable wallet and address book Qt tests on macOS minimal platform

macOS Qt minimal platform is frequently broken, and these are currently failing
with Qt 5.11.1.

The tests do pass when run on the full cocoa platform
(with `test_bitcoin-qt -platform cocoa`).

Github-Pull: bitcoin#14011
Rebased-From: a3197c5

* [macOS] Remove DS_Store WindowBounds bytes object

Github-Pull: bitcoin#14416
Rebased-From: 43719e0
Tree-SHA512: 0b5987abf34a8c62c3f704c4ca3c9837a23fbce11954740461833099157db94418886001993f9f1a0b3252c923bd049bc1e1d0f99d04205c889270755a8cd245

* doc: Update release notes for

* build: Bump version for

* travis: Pin flake8 version to 3.5.0

* Docs/Release notes: is a minor release

* qt: Revert "Force TLS1.0+ for SSL connections"

This reverts commit 15e26a6, whose
purpose was to tweak the Qt configuration to force TLS, i.e., to
disable SSLv3, in Qt versions >= 5.5. However, the default behavior
of Qt >= 5.4 is to disable SSLv3 anyway [1], so the configuration
tweak is redundant.

With Qt 5.11.2, the configuration tweak is not only redundant but in
fact provokes a deadlock (bitcoin#14359) due to Qt 5.11.2 being incompatible
with OpenSSL 1.1.1 [2]. Since the deadlock occurs at the early startup
stage of bitcoin-qt, it renders bitcoin-qt entirely non-functional
when compiled against OpenSSL 1.1.1 and Qt 5.11.2 (and possible future
combinations of OpenSSL and Qt versions).

This commit fixes bitcoin#14359 by removing the redundant code.


Github-Pull: bitcoin#14403
Rebased-From: 7d173c4
Tree-SHA512: 71a34b13202c834c5ca73bcb9b70efff26c34e1aac3b954f098620b62c2be53a8e319929c4764a5b5cc5d0dd163ff70f4eb3a4f1f608363b7d23d1b16b25ddc7

* doc: Clean out release notes after

Tree-SHA512: c04192e3b93537f4b37f5ea55fd455b26dd7d902da3b5f8b59ef6fa4590cf413b72fc11bba330a8fd7fa3938b09e6c1d35171806ab5ce85d6b99681953c291a5

* wallet: Avoid potential use of unitialized value bnb_used in CWallet::CreateTransaction(...)

Github-Pull: bitcoin#13546
Rebased-From: a23a7f6

* Add in ARM Cross-compilation

autogen for the config files was missing.

Github-Pull: bitcoin#14276
Rebased-From: 52beb9e

* [wallet] Ensure wallet is unlocked before signing

Github-Pull: bitcoin#14310
Rebased-From: db15805

* Fix listreceivedbyaddress not taking address as a string

Fixes bitcoin#14173. Add the patch in bitcoin#14173 and include a regression test.

Github-Pull: bitcoin#14417
Rebased-From: d4d70ed

* qa: Add test to ensure node can generate all help texts at runtime

Github-Pull: bitcoin#14658
Rebased-From: bbbbb3f

* Tests: Fix a comment

Github-Pull: bitcoin#14632
Rebased-From: 086fc83

* build: Remove illegal spacing in

Github-Pull: bitcoin#14647
Rebased-From: 63c74d2

* add a test demonstrating an overflow in a deserialization edge case

Also add a test that the highest legal index is accepted.

Github-Pull: bitcoin#14685
Rebased-From: 051faf7

* fix a deserialization overflow edge case

A specially-constructed BlockTransactionsRequest can overflow in
deserialization in a way that is currently harmless.

Github-Pull: bitcoin#14685
Rebased-From: 6bed4b3

* build: Add bitcoin-tx.exe into Windows installer

Github-Pull: bitcoin#14698
Rebased-From: 5c5902a

* disallow oversized CBlockHeaderAndShortTxIDs

Otherwise we'd reply with a bogus BlockTransactionsRequest trying to
request indexes with overflowed deltas.

Github-Pull: bitcoin#14685
Rebased-From: b08af10

* travis: Remove deprecated sudo

* gui: explicitly disable "Dark Mode" appearance on macOS

Github-Pull: bitcoin#14593
Rebased-From: cf2f430

* Bugfix: RPC: Add address_type named param for createmultisig

Github-Pull: bitcoin#14596
Rebased-From: d8bf107

* Throw error if CPubKey is invalid during PSBT keypath serialization

Github-Pull: bitcoin#14690
Rebased-From: 4e4de10

* fix uninitialized read when stringifying an addrLocal

Reachable from either place where SetIP is used when our best-guess
addrLocal for a peer is IPv4, but the peer tells us it's reaching us at
an IPv6 address.

In that case, SetIP turns an IPv4 address into an IPv6 address without
setting the scopeId, which is subsequently read in GetSockAddr during
CNetAddr::ToStringIP and passed to getnameinfo. Fix by ensuring every
constructor initializes the scopeId field with something.

Github-Pull: bitcoin#14728
Rebased-From: b7b36de

* add test demonstrating addrLocal UB

Github-Pull: bitcoin#14728
Rebased-From: 8ebbef0

* rpc: Make HTTP RPC debug logging more informative

Github-Pull: bitcoin#14618
Rebased-From: 9912486

* Add SAFE_CHARS[SAFE_CHARS_URI]: Chars allowed in URIs (RFC 3986)

Github-Pull: bitcoin#14618
Rebased-From: ab8c6f2

* qa: Avoid race in p2p_invalid_block by waiting for the block request

Github-Pull: bitcoin#14700
Rebased-From: fa21568

* Remove stale comment in CalculateMaximumSignedInputSize

* CreateTransaction: Assume minimum p2sh-p2wpkh spend size for unknown change

* [tests] Add

Adds a test specifically to test the wallet's getbalance and
getunconfirmedbalance RPCs.

Github-Pull: bitcoin#14845
Rebased-From: c1825b9

* check that a separator is found for psbt inputs, outputs, and global map

Github-Pull: bitcoin#14377
Rebased-From: 4fb3388

* More concise conversion of CDataStream to string

Use .str() instead of .data() and .size() when converting CDataStream to
a string. Uses std::string, avoiding conversion to a C string.

Github-Pull: bitcoin#14588
Rebased-From: fe5d22b

* Remove redundant txConst parameter to FillPSBT

Github-Pull: bitcoin#14588
Rebased-From: 4f3f5cb

* New PartiallySignedTransaction constructor from CTransction

New constructor that creates a PartiallySignedTransaction from a
CTransaction, automatically sizing the inputs and outputs vectors for

Github-Pull: bitcoin#14588
Rebased-From: 65166d4

* Add bool PSBTInputSigned

Refactor out a "PSBTInputSigned" function to check if a PSBT is signed,
for use in subsequent commits.

Also improve a related comment.

GitHub-Pull: bitcoin#14588
Rebased-From: 53e6fff

* Simplify arguments to SignPSBTInput

Remove redundant arguments to SignPSBTInput -- since it needs several
bits of the PartiallySignedTransaction, pass in a reference instead of
doing it piecemeal. This saves us having to pass in both a PSBTInput and
its index, as well as having to pass in the CTransaction. Also avoid
redundantly passing the sighash_type, which is contained in the
PSBTInput already.

Github-Pull: bitcoin#14588
Rebased-From: 0f5bda2

* Refactor PSBTInput signing to enforce invariant

Refactor the process of PSBTInput signing to enforce the invariant that
a PSBTInput always has _either_ a witness_utxo or a non_witness_utxo,
never both.

This simplifies the logic of SignPSBTInput slightly, since it no longer
has to deal with the "both" case. When calling it, we now give it, in
order of preference: (1) whichever of the utxo fields was already
present in the PSBT we received, or (2) if neither, the
non_witness_utxo field, which is just a copy of the input transaction,
which we get from the wallet.

SignPSBTInput no longer has to remove one of the two fields; instead, it
will check if we have a witness signature, and if so, it will replace
the non_witness_utxo with the witness_utxo (which is smaller, as it is
just a copy of the output being spent.)

Add PSBTInput::IsSane checks in two more places, which checks for
both utxo fields being present; we will now give an RPC error early on
if we are supplied such a malformed PSBT to fill in.

Also add a check to FillPSBT, to avoid touching any input that is
already signed. (This is now redundant, since we should no longer
potentially harm an already-signed input, but it's harmless.)

fixes bitcoin#14473

Github-Pull: bitcoin#14588

* Add regression test for PSBT signing bug bitcoin#14473

Github-Pull: bitcoin#14588
Rebased-From: e13fea9

* Add test for conversion from non-witness to witness UTXO

Github-Pull: bitcoin#14197
Rebased-From: 862d159

* fix converttopsbt permitsigdata arg, add basic test

Github-Pull: bitcoin#14356
Rebased-From: 88a79cb

* rpc: Fix wallet unload during walletpassphrase timeout

Github-Pull: bitcoin#14453
Rebased-From: 321decf

* build: bump version to 0.17.1

Also update man pages.

Tree-SHA512: 826f3c9ad1e49902ee2f1710a4329388c0a9298a359971f21130bf8f390d4a7b744d010f04eb109666ceb28d0053b9fa7ec088caaa4e4cc38509526457086d40

* qa: Ensure wallet unload during walletpassphrase timeout

0.17 branch doesn't include bitcoin#12493 which changed encryptwallet behavior. For that
reason the test is adjusted.

Github-Pull: bitcoin#14453
Rebased-From: 8907df9

* Stop requiring imported pubkey to sign non-PKH schemes

Github-Pull: bitcoin#14424
Rebased-From: 2f6b466

* doc: Fill in authors and changelog for 0.17.1 release notes

Tree-SHA512: dc23ae43e81ad379b48bb8dc6da21cde647a7edc778563b8b8266dfe84d9baa70bf4565915e276ea0e14aa96ce677547494da0aadeebfcc961f53430c7bb84ea

* rpc: Avoid creating non-standard raw transactions

Github-Pull: bitcoin#14890
Rebased-From: fa4c867

* importmulti: Don't add internal addresses to address book

Github-Pull: bitcoin#14679
Rebased-From: 7afddfa

* doc: Clean out release notes post-0.17.1

Tree-SHA512: 0cd6e97156da2dea9a9b557083d8140c17f85f6e718d5fcb73aa67460480b6437b665fad147bf4eacd13570aeb25a29f28c35b7fb0365ae630b2edf05901a431

* Add PSBT documentation

Github-Pull: bitcoin#13941
Rebased-From: 19efc01

* doc: Fix PSBT howto and example parameters

* Remove outdated reference to replaceable parameter
* Fix address reference
* Unify quotation and italicization of parameters
* Fix PSBT reference

Github-Pull: bitcoin#14319
Rebased-From: 78542a3

* Fix minor grammar error in doc

Github-Pull: bitcoin#15012
Rebased-From: 72b63bc

* fix testmempoolaccept CLI syntax

`testmempoolaccept "hexstring"` will give a "JSON parse error". The correct syntax is `testmempoolaccept \[\"hexstring\"\]` (but seems escaping is not displayed in other areas so leaving backspaces out).

Github-Pull: bitcoin#14966
Rebased-From: b74a521

* doc: update NetBSD build instructions for 8.0

Github-Pull: bitcoin#14944
Rebased-From: be5ca82

* gui: Favor macOS show / hide action in dock menu

Github-Pull: bitcoin#14133
Rebased-From: ee3a494

* Clean systray icon menu for -disablewallet mode

Ref bitcoin#3392

Github-Pull: bitcoin#14383
Rebased-From: 36323e2

* Remove obj_c for macOS Dock icon setting

Qt `setWindowIcon()` does this work.

Github-Pull: bitcoin#14597
Rebased-From: 53bb6be

* Use Qt signal for macOS Dock icon click event

This moves the Dock icon click reaction code to the common place and
allows some cleanup in obj_c code.

According to the Apple's docs `class_replaceMethod` behaves as
`class_addMethod`, if the method identified by name does not yet exist;
or as `method_setImplementation`, if it does exist.

Github-Pull: bitcoin#14597
Rebased-From: 2464925

* Remove obj_c for macOS Dock icon menu

Qt `setAsDockMenu()` does this work.

Github-Pull: bitcoin#14597
Rebased-From: 6b1d297

* qt: Add GUIUtil::bringToFront

Github-Pull: bitcoin#14123
Rebased-From: 5796671

* qt: Use GUIUtil::bringToFront where possible

Github-Pull: bitcoin#14123
Rebased-From: 6fc21ac

* qt: All tray menu actions call showNormalIfMinimized

Github-Pull: bitcoin#14123
Rebased-From: 0a656f8

* gui: Fix for Incorrect application name when passing -regtest

Github-Pull: bitcoin#15085
Rebased-From: cc341ad

* rpc: Make unloadwallet wait for complete wallet unload

Github-Pull: bitcoin#14941
Rebased-From: c37851d

* Remove errant past from walletcreatefundedpsbt for nLocktime replaceability

Github-Pull: bitcoin#15213
Rebased-From: 85f0ca9

* Update zmq to 4.3.1


Github-Pull: bitcoin#15188
Rebased-From: 3046e5f

* [0.17] [Doc] Backport release note about PSBT doc

* Add function to close all Db's and reload the databae environment

Adds a ReloadDbEnv function to BerkeleyEnvironment in order to close all Db
instances, closes the environment, resets it, and then reopens
the BerkeleyEnvironment.

Also adds a ReloadDbEnv function to BerkeleyDatabase that calls
BerkeleyEnvironment's ReloadDbEnv.

Github-Pull: bitcoin#12493
Rebased-From: 5d296ac

* After encrypting the wallet, reload the database environment

Calls ReloadDbEnv after encrypting the wallet so that the database
environment is flushed, closed, and reopened to prevent unencrypted
keys from being saved on disk.

Github-Pull: bitcoin#12493
Rebased-From: d7637c5

* Move BerkeleyEnvironment deletion from internal method to callsite

Instead of having the object destroy itself, having the caller
destroy it.

Github-Pull: bitcoin#12493
Rebased-From: a769461

* No longer shutdown after encrypting the wallet

Since the database environment is flushed, closed, and reopened during
EncryptWallet, there is no need to shut down the software anymore.

Github-Pull: bitcoin#12493
Rebased-From: c1dde3a

* wallet: Fix duplicate fileid

Github-Pull: bitcoin#14320
Rebased-From: 2d796fa

* wallet: Add WalletLocation utility class

Github-Pull: bitcoin#14350
Rebased-From: 01a4c09

* wallet: Refactor to use WalletLocation

Github-Pull: bitcoin#14350
Rebased-From: 65f3672

* wallet: Add trailing wallet.dat when detecting duplicate wallet if it's a directory.

Github-Pull: bitcoin#14552
Rebased-From: 15c93f0

* tests: add test case for loading copied wallet twice

Github-Pull: bitcoin#14320
Rebased-From: 4ea7732

* Refactor: Move m_db pointers into BerkeleyDatabase

This is a refactoring change that doesn't affect behavior. The motivation
behind the change is give BerkeleyEnvironment objects access to
BerkeleyDatabase objects so it will be possible to simplify the duplicate
wallet check and more reliably avoid opening the same databases twice.

Github-Pull: bitcoin#14552
Rebased-From: c456fbd

* wallet: Create IsDatabaseLoaded function

Github-Pull: bitcoin#14552
Rebased-From: 5912031

* Free BerkeleyEnvironment instances when not in use

Instead of adding BerkeleyEnvironment objects permanently to the g_dbenvs map,
use reference counted shared pointers and remove map entries when the last
BerkeleyEnvironment reference goes out of scope.

This change was requested by Matt Corallo <> and makes code that
sets up mock databases cleaner. The mock database environment will now go out
of scope and be reset on destruction so there is no need to call
BerkeleyEnvironment::Reset() during wallet construction to clear out prior

This change does affect bitcoin behavior slightly. On startup, instead of same
wallet environments staying open throughout VerifyWallets() and OpenWallets()
calls, VerifyWallets() will open and close an environment once for each wallet,
and OpenWallets() will create its own environment(s) later.

Github-Pull: bitcoin#11911
Rebased-From: f1f4bb7

* wallet: Close dbenv error file db.log

The error file db.log is opened by BerkeleyEnvironment instance and
should be closed after dbenv is closed.

Github-Pull: bitcoin#15297
Rebased-From: 8602a1e

* wallet: Close wallet env lock file

Close .walletlock file when a BerkeleyEnvironment is deleted.

Github-Pull: bitcoin#15297
Rebased-From: 2f8b8f4

* qa: Test .walletlock file is closed

Github-Pull: bitcoin#15297
Rebased-From: d3bf3b9

* Trivial: add doxygen-compatible comments relating to BerkeleyEnvironment

Github-Pull: bitcoin#11911
Rebased-From: 14bc2a1

* Tests: add unit tests for GetWalletEnv

Github-Pull: bitcoin#11911
Rebased-From: 88b1d95

* build with -fstack-reuse=none

Github-Pull: bitcoin#15983
Rebased-From: faf38bc

* Add test for GCC bug 90348

Github-Pull: bitcoin#15985
Rebased-From: 58e291c

* build: bump version to 0.17.2

* doc: update manpages for 0.17.2

* qt: 0.17.2 translation update

* doc: update release notes for 0.17.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
7 participants
You can’t perform that action at this time.