bitcoin/src/wallet
Samuel Dobson 99ab3a72c5
Merge #15931: Remove GetDepthInMainChain dependency on locked chain interface
36b68de5b2 Remove getBlockDepth method from Chain::interface (Antoine Riard)
b66c429c56 Remove locked_chain from GetDepthInMainChain and its callers (Antoine Riard)
0ff03871ad Use CWallet::m_last_block_processed_height in GetDepthInMainChain (Antoine Riard)
f77b1de16f Only return early from BlockUntilSyncedToCurrentChain if current tip is exact match (Antoine Riard)
769ff05e48 Refactor some importprunedfunds checks with guard clause (Antoine Riard)
5971d3848e Add block_height field in struct Confirmation (Antoine Riard)
9700fcb47f Replace CWalletTx::SetConf by Confirmation initialization list (Antoine Riard)
5aacc3eff1 Add m_last_block_processed_height field in CWallet (Antoine Riard)
10b4729e33 Pass block height in Chain::BlockConnected/Chain::BlockDisconnected (Antoine Riard)

Pull request description:

  Work starter to remove Chain::Lock interface by adding m_last_block_processed_height in CWallet and m_block_height in CMerkleTx to avoid GetDepthInMainChain having to keep a lock . Once this one done, it should ease work to wipe out more cs_main locks from wallet code.

  I think it's ready for a first round of review before to get further.

  - `BlockUntilSyncedToCurrent` : restrain isPotentialTip to isTip because we want to be sure that wallet see BlockDisconnected callbacks if its height differs from the Chain one. It means during a reorg, an RPC could return before the BlockDisconnected callback had been triggered. This could cause a tx that had been included in the disconnected block to be displayed as confirmed, for example.

  ~~- `AbandonTransaction` : in case of conflicted tx (nIndex = -1), we set its m_block_height to the one of conflicting blocks, but if this height is superior to CWallet::m_last_block_processed_height, that means tx isn't conflicted anymore so we return 0 as tx is again unconfirmed~~ After #16624, we instead rely on Confirmation.

  ~~- `AddToWalletIfInvolvingMe`: in case of block disconnected, transactions are added to mempool again, so we need to replace old txn in `mapWallet` with a height set to zero so we remove check on block_hash.IsNull~~ Already done in #16624

ACKs for top commit:
  jnewbery:
    @jkczyz you've ACKed an intermediate commit (github annoyingly orders commits in date order, not commit order). Did you mean to ACK the final commit in this branch (36b68de5b2).
  jkczyz:
    > @jkczyz you've ACKed an intermediate commit (github annoyingly orders commits in date order, not commit order). Did you mean to ACK the final commit in this branch ([36b68de](36b68de5b2)).
  meshcollider:
    utACK 36b68de5b2
  ryanofsky:
    Code review ACK 36b68de5b2. Changes since last review: new jkczyz refactor importprunedfunds commit, changed BlockUntilSyncedToCurrentChainChanges commit title and description, changed Confirmation struct field order and line-wrapped comment
  jnewbery:
    utACK 36b68de5b2
  promag:
    Code review ACK 36b68de5b2.

Tree-SHA512: 08b89a0bcc39f67c82a6cb6aee195e6a11697770c788ba737b90986b4893f44e90d1ab9ef87239ea3766508b7e24ea882b7199df41173ab27a3d000328c14644
2019-11-08 23:23:14 +13:00
..
test Merge #15931: Remove GetDepthInMainChain dependency on locked chain interface 2019-11-08 23:23:14 +13:00
coincontrol.cpp extract min & max depth onto coin control 2019-07-22 15:23:21 -04:00
coincontrol.h refactor: Replace all uses of boost::optional with our own Optional type 2019-10-30 14:27:31 +01:00
coinselection.cpp refactor: Replace all uses of boost::optional with our own Optional type 2019-10-30 14:27:31 +01:00
coinselection.h amount: Move CAmount CENT to unit test header 2018-09-17 14:34:56 -04:00
crypter.cpp Fix occurences of c_str() used with size() to data() 2019-10-28 13:41:45 +01:00
crypter.h Remove unused includes 2019-10-15 22:56:43 +00:00
db.cpp wallet: Avoid showing GUI popups on RPC errors 2019-10-08 13:02:14 -04:00
db.h Merge #17070: wallet: Avoid showing GUI popups on RPC errors 2019-10-21 13:48:27 +02:00
feebumper.cpp Remove locked_chain from GetDepthInMainChain and its callers 2019-11-06 13:36:43 -05:00
feebumper.h change wallet pointers to references in feebumper 2019-10-10 17:46:59 -04:00
fees.cpp Remove unused includes 2019-10-15 22:56:43 +00:00
fees.h Remove uses of fee globals in wallet code 2019-02-22 15:43:02 -04:00
init.cpp Pass NodeContext, ConnMan, BanMan references more places 2019-10-28 10:30:51 -04:00
ismine.h Refactor: Split up CWallet and LegacyScriptPubKeyMan and classes 2019-10-25 19:20:24 -04:00
load.cpp wallet: Avoid showing GUI popups on RPC errors 2019-10-08 13:02:14 -04:00
load.h wallet: Fix documentation around WalletParameterInteraction 2019-09-03 14:10:25 -04:00
psbtwallet.cpp Refactor: Split up CWallet and LegacyScriptPubKeyMan and classes 2019-10-25 19:20:24 -04:00
psbtwallet.h Remove unused includes 2019-10-15 22:56:43 +00:00
rpcdump.cpp Merge #15931: Remove GetDepthInMainChain dependency on locked chain interface 2019-11-08 23:23:14 +13:00
rpcwallet.cpp Merge #15931: Remove GetDepthInMainChain dependency on locked chain interface 2019-11-08 23:23:14 +13:00
rpcwallet.h Add EnsureLegacyScriptPubKeyMan and use in rpcwallet.cpp 2019-11-05 10:13:43 -05:00
scriptpubkeyman.cpp Clean up nested scope in GetReservedDestination 2019-11-05 10:47:07 -05:00
scriptpubkeyman.h Get rid of confusing LegacyScriptPubKeyMan::TopUpKeyPool method 2019-11-05 10:43:36 -05:00
wallet.cpp Merge #15931: Remove GetDepthInMainChain dependency on locked chain interface 2019-11-08 23:23:14 +13:00
wallet.h Remove locked_chain from GetDepthInMainChain and its callers 2019-11-06 13:36:43 -05:00
walletdb.cpp Refactor: Split up CWallet and LegacyScriptPubKeyMan and classes 2019-10-25 19:20:24 -04:00
walletdb.h Merge #17070: wallet: Avoid showing GUI popups on RPC errors 2019-10-21 13:48:27 +02:00
wallettool.cpp Merge #17260: Split some CWallet functions into new LegacyScriptPubKeyMan 2019-10-29 08:19:23 -04:00
wallettool.h Remove unused includes 2019-10-15 22:56:43 +00:00
walletutil.cpp Merge #15870: wallet: Only fail rescan when blocks have actually been pruned 2019-05-16 11:18:27 -04:00
walletutil.h Move wallet enums to walletutil.h 2019-10-25 19:20:24 -04:00