Skip to content

Commit

Permalink
MOVEONLY: CWallet transaction code out of wallet.cpp/.h
Browse files Browse the repository at this point in the history
This commit just moves code without making any changes. It can be
reviewed with `git log -p -n1 --color-moved=dimmed_zebra`

Motivation for this change is to make wallet.cpp/h less monolithic and
start to make wallet transaction state tracking comprehensible so bugs
in
https://github.com/bitcoin-core/bitcoin-devwiki/wiki/Wallet-Transaction-Conflict-Tracking
can be fixed safely without introducing new problems.

This commit moves wallet classes and methods that deal with transactions
out of wallet.cpp/.h into better organized files:

- transaction.cpp/.h - CWalletTx and CMerkleTX class definitions
- receive.cpp/.h - functions checking received transactions and computing balances
- spend.cpp/.h - functions creating transactions and finding spendable coins

After bitcoin#20773, when loading is separated from syncing it will also be
possible to move more wallet.cpp/.h functions to:

- sync.cpp/.h - functions handling chain notifications and rescanning

This commit arranges receive.cpp and spend.cpp functions in dependency
order so it's possible to skim receive.cpp and get an idea of how
computing balances works, and skim spend.cpp and get an idea of how
transactions are created, without having to jump all over wallet.cpp
where functions are not in order and there is a lot of unrelated
uncode.

Followup commit "refactor: Detach wallet transaction methods" in
bitcoin#21206 follows up this PR and
tweaks function names and arguments to reflect new locations. The two
commits are split into separate PRs because this commit is more work to
maintain and less work to review, while the other commit is less work to
maintain and more work to review, so hopefully this commit can be merged
earlier.
  • Loading branch information
ryanofsky committed Feb 10, 2021
1 parent 47b99ab commit 11dd250
Show file tree
Hide file tree
Showing 10 changed files with 2,006 additions and 1,909 deletions.
10 changes: 10 additions & 0 deletions src/Makefile.am
Expand Up @@ -274,11 +274,18 @@ BITCOIN_CORE_H = \
wallet/fees.h \
wallet/ismine.h \
wallet/load.h \
<<<<<<< HEAD
wallet/rpcsigner.h \
||||||| merged common ancestors
=======
wallet/receive.h \
>>>>>>> MOVEONLY: CWallet transaction code out of wallet.cpp/.h
wallet/rpcwallet.h \
wallet/salvage.h \
wallet/scriptpubkeyman.h \
wallet/spend.h \
wallet/sqlite.h \
wallet/transaction.h \
wallet/wallet.h \
wallet/walletdb.h \
wallet/wallettool.h \
Expand Down Expand Up @@ -392,10 +399,13 @@ libbitcoin_wallet_a_SOURCES = \
wallet/fees.cpp \
wallet/interfaces.cpp \
wallet/load.cpp \
wallet/receive.cpp \
wallet/rpcdump.cpp \
wallet/rpcsigner.cpp \
wallet/rpcwallet.cpp \
wallet/scriptpubkeyman.cpp \
wallet/spend.cpp \
wallet/transaction.cpp \
wallet/wallet.cpp \
wallet/walletdb.cpp \
wallet/walletutil.cpp \
Expand Down

0 comments on commit 11dd250

Please sign in to comment.