Merge #10574: Remove includes in .cpp files for things the corresponding .h file...
[bitcoinplatinum.git] / doc / developer-notes.md
blob7f34b07d151a009574a2d3cc1e170069cfa03366
1 Developer Notes
2 ===============
4 Various coding styles have been used during the history of the codebase,
5 and the result is not very consistent. However, we're now trying to converge to
6 a single style, which is specified below. When writing patches, favor the new
7 style over attempting to mimic the surrounding style, except for move-only
8 commits.
10 Do not submit patches solely to modify the style of existing code.
12 - **Indentation and whitespace rules** as specified in
13 [src/.clang-format](/src/.clang-format). You can use the provided
14 [clang-format-diff script](/contrib/devtools/README.md#clang-format-diffpy)
15 tool to clean up patches automatically before submission.
16   - Braces on new lines for namespaces, classes, functions, methods.
17   - Braces on the same line for everything else.
18   - 4 space indentation (no tabs) for every block except namespaces.
19   - No indentation for `public`/`protected`/`private` or for `namespace`.
20   - No extra spaces inside parenthesis; don't do ( this )
21   - No space after function names; one space after `if`, `for` and `while`.
22   - If an `if` only has a single-statement `then`-clause, it can appear
23     on the same line as the `if`, without braces. In every other case,
24     braces are required, and the `then` and `else` clauses must appear
25     correctly indented on a new line.
27 - **Symbol naming conventions**. These are preferred in new code, but are not
28 required when doing so would need changes to significant pieces of existing
29 code.
30   - Variable and namespace names are all lowercase, and may use `_` to
31     separate words (snake_case).
32     - Class member variables have a `m_` prefix.
33     - Global variables have a `g_` prefix.
34   - Constant names are all uppercase, and use `_` to separate words.
35   - Class names, function names and method names are UpperCamelCase
36     (PascalCase). Do not prefix class names with `C`.
38 - **Miscellaneous**
39   - `++i` is preferred over `i++`.
40   - `nullptr` is preferred over `NULL` or `(void*)0`.
41   - `static_assert` is preferred over `assert` where possible. Generally; compile-time checking is preferred over run-time checking.
43 Block style example:
44 ```c++
45 int g_count = 0;
47 namespace foo
49 class Class
51     std::string m_name;
53 public:
54     bool Function(const std::string& s, int n)
55     {
56         // Comment summarising what this section of code does
57         for (int i = 0; i < n; ++i) {
58             int total_sum = 0;
59             // When something fails, return early
60             if (!Something()) return false;
61             ...
62             if (SomethingElse(i)) {
63                 total_sum += ComputeSomething(g_count);
64             } else {
65                 DoSomething(m_name, total_sum);
66             }
67         }
69         // Success return is usually at the end
70         return true;
71     }
73 } // namespace foo
74 ```
76 Doxygen comments
77 -----------------
79 To facilitate the generation of documentation, use doxygen-compatible comment blocks for functions, methods and fields.
81 For example, to describe a function use:
82 ```c++
83 /**
84  * ... text ...
85  * @param[in] arg1    A description
86  * @param[in] arg2    Another argument description
87  * @pre Precondition for function...
88  */
89 bool function(int arg1, const char *arg2)
90 ```
91 A complete list of `@xxx` commands can be found at http://www.stack.nl/~dimitri/doxygen/manual/commands.html.
92 As Doxygen recognizes the comments by the delimiters (`/**` and `*/` in this case), you don't
93 *need* to provide any commands for a comment to be valid; just a description text is fine.
95 To describe a class use the same construct above the class definition:
96 ```c++
97 /**
98  * Alerts are for notifying old versions if they become too obsolete and
99  * need to upgrade. The message is displayed in the status bar.
100  * @see GetWarnings()
101  */
102 class CAlert
106 To describe a member or variable use:
107 ```c++
108 int var; //!< Detailed description after the member
112 ```cpp
113 //! Description before the member
114 int var;
117 Also OK:
118 ```c++
120 /// ... text ...
122 bool function2(int arg1, const char *arg2)
125 Not OK (used plenty in the current source, but not picked up):
126 ```c++
128 // ... text ...
132 A full list of comment syntaxes picked up by doxygen can be found at http://www.stack.nl/~dimitri/doxygen/manual/docblocks.html,
133 but if possible use one of the above styles.
135 Development tips and tricks
136 ---------------------------
138 **compiling for debugging**
140 Run configure with the --enable-debug option, then make. Or run configure with
141 CXXFLAGS="-g -ggdb -O0" or whatever debug flags you need.
143 **debug.log**
145 If the code is behaving strangely, take a look in the debug.log file in the data directory;
146 error and debugging messages are written there.
148 The -debug=... command-line option controls debugging; running with just -debug or -debug=1 will turn
149 on all categories (and give you a very large debug.log file).
151 The Qt code routes qDebug() output to debug.log under category "qt": run with -debug=qt
152 to see it.
154 **testnet and regtest modes**
156 Run with the -testnet option to run with "play bitcoins" on the test network, if you
157 are testing multi-machine code that needs to operate across the internet.
159 If you are testing something that can run on one machine, run with the -regtest option.
160 In regression test mode, blocks can be created on-demand; see test/functional/ for tests
161 that run in -regtest mode.
163 **DEBUG_LOCKORDER**
165 Bitcoin Core is a multithreaded application, and deadlocks or other multithreading bugs
166 can be very difficult to track down. Compiling with -DDEBUG_LOCKORDER (configure
167 CXXFLAGS="-DDEBUG_LOCKORDER -g") inserts run-time checks to keep track of which locks
168 are held, and adds warnings to the debug.log file if inconsistencies are detected.
170 **Valgrind suppressions file**
172 Valgrind is a programming tool for memory debugging, memory leak detection, and
173 profiling. The repo contains a Valgrind suppressions file
174 ([`valgrind.supp`](https://github.com/bitcoin/bitcoin/blob/master/contrib/valgrind.supp))
175 which includes known Valgrind warnings in our dependencies that cannot be fixed
176 in-tree. Example use:
178 ```shell
179 $ valgrind --suppressions=contrib/valgrind.supp src/test/test_bitcoin
180 $ valgrind --suppressions=contrib/valgrind.supp --leak-check=full \
181       --show-leak-kinds=all src/test/test_bitcoin --log_level=test_suite
182 $ valgrind -v --leak-check=full src/bitcoind -printtoconsole
185 **compiling for test coverage**
187 LCOV can be used to generate a test coverage report based upon `make check`
188 execution. LCOV must be installed on your system (e.g. the `lcov` package
189 on Debian/Ubuntu).
191 To enable LCOV report generation during test runs:
193 ```shell
194 ./configure --enable-lcov
195 make
196 make cov
198 # A coverage report will now be accessible at `./test_bitcoin.coverage/index.html`.
201 Locking/mutex usage notes
202 -------------------------
204 The code is multi-threaded, and uses mutexes and the
205 LOCK/TRY_LOCK macros to protect data structures.
207 Deadlocks due to inconsistent lock ordering (thread 1 locks cs_main
208 and then cs_wallet, while thread 2 locks them in the opposite order:
209 result, deadlock as each waits for the other to release its lock) are
210 a problem. Compile with -DDEBUG_LOCKORDER to get lock order
211 inconsistencies reported in the debug.log file.
213 Re-architecting the core code so there are better-defined interfaces
214 between the various components is a goal, with any necessary locking
215 done by the components (e.g. see the self-contained CKeyStore class
216 and its cs_KeyStore lock for example).
218 Threads
219 -------
221 - ThreadScriptCheck : Verifies block scripts.
223 - ThreadImport : Loads blocks from blk*.dat files or bootstrap.dat.
225 - StartNode : Starts other threads.
227 - ThreadDNSAddressSeed : Loads addresses of peers from the DNS.
229 - ThreadMapPort : Universal plug-and-play startup/shutdown
231 - ThreadSocketHandler : Sends/Receives data from peers on port 8333.
233 - ThreadOpenAddedConnections : Opens network connections to added nodes.
235 - ThreadOpenConnections : Initiates new connections to peers.
237 - ThreadMessageHandler : Higher-level message handling (sending and receiving).
239 - DumpAddresses : Dumps IP addresses of nodes to peers.dat.
241 - ThreadFlushWalletDB : Close the wallet.dat file if it hasn't been used in 500ms.
243 - ThreadRPCServer : Remote procedure call handler, listens on port 8332 for connections and services them.
245 - BitcoinMiner : Generates bitcoins (if wallet is enabled).
247 - Shutdown : Does an orderly shutdown of everything.
249 Ignoring IDE/editor files
250 --------------------------
252 In closed-source environments in which everyone uses the same IDE it is common
253 to add temporary files it produces to the project-wide `.gitignore` file.
255 However, in open source software such as Bitcoin Core, where everyone uses
256 their own editors/IDE/tools, it is less common. Only you know what files your
257 editor produces and this may change from version to version. The canonical way
258 to do this is thus to create your local gitignore. Add this to `~/.gitconfig`:
261 [core]
262         excludesfile = /home/.../.gitignore_global
265 (alternatively, type the command `git config --global core.excludesfile ~/.gitignore_global`
266 on a terminal)
268 Then put your favourite tool's temporary filenames in that file, e.g.
270 # NetBeans
271 nbproject/
274 Another option is to create a per-repository excludes file `.git/info/exclude`.
275 These are not committed but apply only to one repository.
277 If a set of tools is used by the build system or scripts the repository (for
278 example, lcov) it is perfectly acceptable to add its files to `.gitignore`
279 and commit them.
281 Development guidelines
282 ============================
284 A few non-style-related recommendations for developers, as well as points to
285 pay attention to for reviewers of Bitcoin Core code.
287 General Bitcoin Core
288 ----------------------
290 - New features should be exposed on RPC first, then can be made available in the GUI
292   - *Rationale*: RPC allows for better automatic testing. The test suite for
293     the GUI is very limited
295 - Make sure pull requests pass Travis CI before merging
297   - *Rationale*: Makes sure that they pass thorough testing, and that the tester will keep passing
298      on the master branch. Otherwise all new pull requests will start failing the tests, resulting in
299      confusion and mayhem
301   - *Explanation*: If the test suite is to be updated for a change, this has to
302     be done first
304 Wallet
305 -------
307 - Make sure that no crashes happen with run-time option `-disablewallet`.
309   - *Rationale*: In RPC code that conditionally uses the wallet (such as
310     `validateaddress`) it is easy to forget that global pointer `pwalletMain`
311     can be nullptr. See `test/functional/disablewallet.py` for functional tests
312     exercising the API with `-disablewallet`
314 - Include `db_cxx.h` (BerkeleyDB header) only when `ENABLE_WALLET` is set
316   - *Rationale*: Otherwise compilation of the disable-wallet build will fail in environments without BerkeleyDB
318 General C++
319 -------------
321 - Assertions should not have side-effects
323   - *Rationale*: Even though the source code is set to refuse to compile
324     with assertions disabled, having side-effects in assertions is unexpected and
325     makes the code harder to understand
327 - If you use the `.h`, you must link the `.cpp`
329   - *Rationale*: Include files define the interface for the code in implementation files. Including one but
330       not linking the other is confusing. Please avoid that. Moving functions from
331       the `.h` to the `.cpp` should not result in build errors
333 - Use the RAII (Resource Acquisition Is Initialization) paradigm where possible. For example by using
334   `unique_ptr` for allocations in a function.
336   - *Rationale*: This avoids memory and resource leaks, and ensures exception safety
338 C++ data structures
339 --------------------
341 - Never use the `std::map []` syntax when reading from a map, but instead use `.find()`
343   - *Rationale*: `[]` does an insert (of the default element) if the item doesn't
344     exist in the map yet. This has resulted in memory leaks in the past, as well as
345     race conditions (expecting read-read behavior). Using `[]` is fine for *writing* to a map
347 - Do not compare an iterator from one data structure with an iterator of
348   another data structure (even if of the same type)
350   - *Rationale*: Behavior is undefined. In C++ parlor this means "may reformat
351     the universe", in practice this has resulted in at least one hard-to-debug crash bug
353 - Watch out for out-of-bounds vector access. `&vch[vch.size()]` is illegal,
354   including `&vch[0]` for an empty vector. Use `vch.data()` and `vch.data() +
355   vch.size()` instead.
357 - Vector bounds checking is only enabled in debug mode. Do not rely on it
359 - Make sure that constructors initialize all fields. If this is skipped for a
360   good reason (i.e., optimization on the critical path), add an explicit
361   comment about this
363   - *Rationale*: Ensure determinism by avoiding accidental use of uninitialized
364     values. Also, static analyzers balk about this.
366 - By default, declare single-argument constructors `explicit`.
368   - *Rationale*: This is a precaution to avoid unintended conversions that might
369     arise when single-argument constructors are used as implicit conversion
370     functions.
372 - Use explicitly signed or unsigned `char`s, or even better `uint8_t` and
373   `int8_t`. Do not use bare `char` unless it is to pass to a third-party API.
374   This type can be signed or unsigned depending on the architecture, which can
375   lead to interoperability problems or dangerous conditions such as
376   out-of-bounds array accesses
378 - Prefer explicit constructions over implicit ones that rely on 'magical' C++ behavior
380   - *Rationale*: Easier to understand what is happening, thus easier to spot mistakes, even for those
381   that are not language lawyers
383 Strings and formatting
384 ------------------------
386 - Be careful of `LogPrint` versus `LogPrintf`. `LogPrint` takes a `category` argument, `LogPrintf` does not.
388   - *Rationale*: Confusion of these can result in runtime exceptions due to
389     formatting mismatch, and it is easy to get wrong because of subtly similar naming
391 - Use `std::string`, avoid C string manipulation functions
393   - *Rationale*: C++ string handling is marginally safer, less scope for
394     buffer overflows and surprises with `\0` characters. Also some C string manipulations
395     tend to act differently depending on platform, or even the user locale
397 - Use `ParseInt32`, `ParseInt64`, `ParseUInt32`, `ParseUInt64`, `ParseDouble` from `utilstrencodings.h` for number parsing
399   - *Rationale*: These functions do overflow checking, and avoid pesky locale issues
401 - For `strprintf`, `LogPrint`, `LogPrintf` formatting characters don't need size specifiers
403   - *Rationale*: Bitcoin Core uses tinyformat, which is type safe. Leave them out to avoid confusion
405 Variable names
406 --------------
408 Although the shadowing warning (`-Wshadow`) is not enabled by default (it prevents issues rising
409 from using a different variable with the same name),
410 please name variables so that their names do not shadow variables defined in the source code.
412 E.g. in member initializers, prepend `_` to the argument name shadowing the
413 member name:
415 ```c++
416 class AddressBookPage
418     Mode mode;
421 AddressBookPage::AddressBookPage(Mode _mode) :
422       mode(_mode)
426 When using nested cycles, do not name the inner cycle variable the same as in
427 upper cycle etc.
430 Threads and synchronization
431 ----------------------------
433 - Build and run tests with `-DDEBUG_LOCKORDER` to verify that no potential
434   deadlocks are introduced. As of 0.12, this is defined by default when
435   configuring with `--enable-debug`
437 - When using `LOCK`/`TRY_LOCK` be aware that the lock exists in the context of
438   the current scope, so surround the statement and the code that needs the lock
439   with braces
441   OK:
443 ```c++
445     TRY_LOCK(cs_vNodes, lockNodes);
446     ...
450   Wrong:
452 ```c++
453 TRY_LOCK(cs_vNodes, lockNodes);
455     ...
459 Source code organization
460 --------------------------
462 - Implementation code should go into the `.cpp` file and not the `.h`, unless necessary due to template usage or
463   when performance due to inlining is critical
465   - *Rationale*: Shorter and simpler header files are easier to read, and reduce compile time
467 - Every `.cpp` and `.h` file should `#include` every header file it directly uses classes, functions or other
468   definitions from, even if those headers are already included indirectly through other headers. One exception
469   is that a `.cpp` file does not need to re-include the includes already included in its corresponding `.h` file.
471   - *Rationale*: Excluding headers because they are already indirectly included results in compilation
472     failures when those indirect dependencies change. Furthermore, it obscures what the real code
473     dependencies are.
475 - Don't import anything into the global namespace (`using namespace ...`). Use
476   fully specified types such as `std::string`.
478   - *Rationale*: Avoids symbol conflicts
480 - Terminate namespaces with a comment (`// namespace mynamespace`). The comment
481   should be placed on the same line as the brace closing the namespace, e.g.
483 ```c++
484 namespace mynamespace {
485     ...
486 } // namespace mynamespace
488 namespace {
489     ...
490 } // namespace
493   - *Rationale*: Avoids confusion about the namespace context
495 - Prefer `#include <primitives/transaction.h>` bracket syntax instead of
496   `#include "primitives/transactions.h"`` quote syntax when possible.
498   - *Rationale*: Bracket syntax is less ambiguous because the preprocessor
499     searches a fixed list of include directories without taking location of the
500     source file into account. This allows quoted includes to stand out more when
501     the location of the source file actually is relevant.
504 -----
506 - Do not display or manipulate dialogs in model code (classes `*Model`)
508   - *Rationale*: Model classes pass through events and data from the core, they
509     should not interact with the user. That's where View classes come in. The converse also
510     holds: try to not directly access core data structures from Views.
512 Subtrees
513 ----------
515 Several parts of the repository are subtrees of software maintained elsewhere.
517 Some of these are maintained by active developers of Bitcoin Core, in which case changes should probably go
518 directly upstream without being PRed directly against the project.  They will be merged back in the next
519 subtree merge.
521 Others are external projects without a tight relationship with our project.  Changes to these should also
522 be sent upstream but bugfixes may also be prudent to PR against Bitcoin Core so that they can be integrated
523 quickly.  Cosmetic changes should be purely taken upstream.
525 There is a tool in contrib/devtools/git-subtree-check.sh to check a subtree directory for consistency with
526 its upstream repository.
528 Current subtrees include:
530 - src/leveldb
531   - Upstream at https://github.com/google/leveldb ; Maintained by Google, but open important PRs to Core to avoid delay
533 - src/libsecp256k1
534   - Upstream at https://github.com/bitcoin-core/secp256k1/ ; actively maintaned by Core contributors.
536 - src/crypto/ctaes
537   - Upstream at https://github.com/bitcoin-core/ctaes ; actively maintained by Core contributors.
539 - src/univalue
540   - Upstream at https://github.com/jgarzik/univalue ; report important PRs to Core to avoid delay.
543 Git and GitHub tips
544 ---------------------
546 - For resolving merge/rebase conflicts, it can be useful to enable diff3 style using
547   `git config merge.conflictstyle diff3`. Instead of
549         <<<
550         yours
551         ===
552         theirs
553         >>>
555   you will see
557         <<<
558         yours
559         |||
560         original
561         ===
562         theirs
563         >>>
565   This may make it much clearer what caused the conflict. In this style, you can often just look
566   at what changed between *original* and *theirs*, and mechanically apply that to *yours* (or the other way around).
568 - When reviewing patches which change indentation in C++ files, use `git diff -w` and `git show -w`. This makes
569   the diff algorithm ignore whitespace changes. This feature is also available on github.com, by adding `?w=1`
570   at the end of any URL which shows a diff.
572 - When reviewing patches that change symbol names in many places, use `git diff --word-diff`. This will instead
573   of showing the patch as deleted/added *lines*, show deleted/added *words*.
575 - When reviewing patches that move code around, try using
576   `git diff --patience commit~:old/file.cpp commit:new/file/name.cpp`, and ignoring everything except the
577   moved body of code which should show up as neither `+` or `-` lines. In case it was not a pure move, this may
578   even work when combined with the `-w` or `--word-diff` options described above.
580 - When looking at other's pull requests, it may make sense to add the following section to your `.git/config`
581   file:
583         [remote "upstream-pull"]
584                 fetch = +refs/pull/*:refs/remotes/upstream-pull/*
585                 url = git@github.com:bitcoin/bitcoin.git
587   This will add an `upstream-pull` remote to your git repository, which can be fetched using `git fetch --all`
588   or `git fetch upstream-pull`. Afterwards, you can use `upstream-pull/NUMBER/head` in arguments to `git show`,
589   `git checkout` and anywhere a commit id would be acceptable to see the changes from pull request NUMBER.
591 Scripted diffs
592 --------------
594 For reformatting and refactoring commits where the changes can be easily automated using a bash script, we use
595 scripted-diff commits. The bash script is included in the commit message and our Travis CI job checks that
596 the result of the script is identical to the commit. This aids reviewers since they can verify that the script
597 does exactly what it's supposed to do. It is also helpful for rebasing (since the same script can just be re-run
598 on the new master commit).
600 To create a scripted-diff:
602 - start the commit message with `scripted-diff:` (and then a description of the diff on the same line)
603 - in the commit message include the bash script between lines containing just the following text:
604     - `-BEGIN VERIFY SCRIPT-`
605     - `-END VERIFY SCRIPT-`
607 The scripted-diff is verified by the tool `contrib/devtools/commit-script-check.sh`
609 Commit `bb81e173` is an example of a scripted-diff.
611 RPC interface guidelines
612 --------------------------
614 A few guidelines for introducing and reviewing new RPC interfaces:
616 - Method naming: use consecutive lower-case names such as `getrawtransaction` and `submitblock`
618   - *Rationale*: Consistency with existing interface.
620 - Argument naming: use snake case `fee_delta` (and not, e.g. camel case `feeDelta`)
622   - *Rationale*: Consistency with existing interface.
624 - Use the JSON parser for parsing, don't manually parse integers or strings from
625   arguments unless absolutely necessary.
627   - *Rationale*: Introduces hand-rolled string manipulation code at both the caller and callee sites,
628     which is error prone, and it is easy to get things such as escaping wrong.
629     JSON already supports nested data structures, no need to re-invent the wheel.
631   - *Exception*: AmountFromValue can parse amounts as string. This was introduced because many JSON
632     parsers and formatters hard-code handling decimal numbers as floating point
633     values, resulting in potential loss of precision. This is unacceptable for
634     monetary values. **Always** use `AmountFromValue` and `ValueFromAmount` when
635     inputting or outputting monetary values. The only exceptions to this are
636     `prioritisetransaction` and `getblocktemplate` because their interface
637     is specified as-is in BIP22.
639 - Missing arguments and 'null' should be treated the same: as default values. If there is no
640   default value, both cases should fail in the same way. The easiest way to follow this
641   guideline is detect unspecified arguments with `params[x].isNull()` instead of
642   `params.size() <= x`. The former returns true if the argument is either null or missing,
643   while the latter returns true if is missing, and false if it is null.
645   - *Rationale*: Avoids surprises when switching to name-based arguments. Missing name-based arguments
646   are passed as 'null'.
648 - Try not to overload methods on argument type. E.g. don't make `getblock(true)` and `getblock("hash")`
649   do different things.
651   - *Rationale*: This is impossible to use with `bitcoin-cli`, and can be surprising to users.
653   - *Exception*: Some RPC calls can take both an `int` and `bool`, most notably when a bool was switched
654     to a multi-value, or due to other historical reasons. **Always** have false map to 0 and
655     true to 1 in this case.
657 - Don't forget to fill in the argument names correctly in the RPC command table.
659   - *Rationale*: If not, the call can not be used with name-based arguments.
661 - Set okSafeMode in the RPC command table to a sensible value: safe mode is when the
662   blockchain is regarded to be in a confused state, and the client deems it unsafe to
663   do anything irreversible such as send. Anything that just queries should be permitted.
665   - *Rationale*: Troubleshooting a node in safe mode is difficult if half the
666     RPCs don't work.
668 - Add every non-string RPC argument `(method, idx, name)` to the table `vRPCConvertParams` in `rpc/client.cpp`.
670   - *Rationale*: `bitcoin-cli` and the GUI debug console use this table to determine how to
671     convert a plaintext command line to JSON. If the types don't match, the method can be unusable
672     from there.
674 - A RPC method must either be a wallet method or a non-wallet method. Do not
675   introduce new methods such as `signrawtransaction` that differ in behavior
676   based on presence of a wallet.
678   - *Rationale*: as well as complicating the implementation and interfering
679     with the introduction of multi-wallet, wallet and non-wallet code should be
680     separated to avoid introducing circular dependencies between code units.
682 - Try to make the RPC response a JSON object.
684   - *Rationale*: If a RPC response is not a JSON object then it is harder to avoid API breakage if
685     new data in the response is needed.
687 - Wallet RPCs call BlockUntilSyncedToCurrentChain to maintain consistency with
688   `getblockchaininfo`'s state immediately prior to the call's execution. Wallet
689   RPCs whose behavior does *not* depend on the current chainstate may omit this
690   call.
692   - *Rationale*: In previous versions of Bitcoin Core, the wallet was always
693     in-sync with the chainstate (by virtue of them all being updated in the
694     same cs_main lock). In order to maintain the behavior that wallet RPCs
695     return results as of at least the highest best-known block an RPC
696     client may be aware of prior to entering a wallet RPC call, we must block
697     until the wallet is caught up to the chainstate as of the RPC call's entry.
698     This also makes the API much easier for RPC clients to reason about.