LoadWalletInternal logic check #25418

issue guoyl opened this issue on June 20, 2022
  1. guoyl commented at 1:45 AM on June 20, 2022: none

    In the RPC method: https://github.com/bitcoin/bitcoin/blob/master/src/wallet/rpc/wallet.cpp When the RPC method "loadwallet" is called, it will call loadwallet(https://github.com/bitcoin/bitcoin/blob/master/src/wallet/wallet.cpp) and LoadWalletInternal. When the user repeatedly call the loadwallet with same wallet name. In the LoadWalletInternal funcntion, although it does not call Addwallet repeatedly to add to context.wallets and avoid open SQLite database repeatedly. But it will make new SQLiteDatabase unique_ptr and do some series checks.
    Is it better to use GetWallet to determine if the wallet is already loaded before calling LoadWalletInternal?

  2. guoyl added the label Feature on Jun 20, 2022
  3. MarcoFalke removed the label Feature on Jun 20, 2022
  4. MarcoFalke added the label Wallet on Jun 20, 2022
  5. MarcoFalke added the label Questions and Help on Jun 20, 2022
  6. furszy commented at 7:00 PM on August 4, 2022: member

    The "name" parameter in loadwallet isn't just a simple name. Could be a:

    1. Path where a directory can be created.
    2. Path to an existing directory.
    3. Path to a symlink to a directory.
    4. The name of a data file in -walletdir.

    So, depends on how the wallet was initially loaded (from which of those options), the stored "wallet name" inside the wallet class will be different. So, only a GetWallet(name) check before loading the db wouldn't work if you load the same wallet in two different ways. Eg: load a wallet by name first (location inside -walletdir), then load it by its path.

  7. adamjonas commented at 12:21 AM on August 5, 2022: member

    Closing based on furszy response.

  8. adamjonas closed this on Aug 5, 2022

  9. bitcoin locked this on Aug 5, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-21 15:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me