Skip to content

Commit

Permalink
Merge bitcoin#21944: wallet: Fix issues when walletdir is root dire…
Browse files Browse the repository at this point in the history
…ctory

d44a261 Fix issues when `walletdir` is root directory (unknown)

Pull request description:

  + Remove one character less from wallet path

  + After testing lot of random strings with special chars in `wallet_name`, I found that the issue was not related to special characters in the name. Reviewing PR bitcoin#21907 helped me resolve the issue.

  **Real issue**: If the path mentioned in `walletdir` is a root directory, first character of the wallet name or path is removed

  **Solution**: `if` statement to check `walletdir` is a root directory

  Fixes: bitcoin#21510 bitcoin#21501
  Related PR: bitcoin#20080

  Consider the wallet directories `w1` and `w2` saved in `D:\`. Run `bitcoind.exe -walletdir=D:\`, Results for `bitcoin-cli.exe listwalletdir`:

  Before this PR:

  ```

  {
    "wallets": [
      {
        "name": "1"
      },
      {
        "name": "2"
      }
    ]
  }

  ```

  After this PR:
  ```
    "wallets": [
      {
        "name": "w1"
      },
      {
        "name": "w2"
      }
    ]
  }

  ```

ACKs for top commit:
  ryanofsky:
    Code review ACK d44a261
  meshcollider:
    utACK d44a261

Tree-SHA512: b09b00f727407e3771c8694861dae1bfd29d97a0d51ddcb5d9c0111dc618b3fff2f75829cbb4361c54457ee564e94fcefd9e2928262a1c918a2b6bbad724eb55
  • Loading branch information
meshcollider authored and PastaPastaPasta committed Apr 16, 2023
1 parent f95c3f9 commit 0cd4553
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/wallet/db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

std::vector<fs::path> ListDatabases(const fs::path& wallet_dir)
{
const size_t offset = wallet_dir.string().size() + 1;
const size_t offset = wallet_dir.string().size() + (wallet_dir == wallet_dir.root_name() ? 0 : 1);
std::vector<fs::path> paths;
boost::system::error_code ec;

Expand Down

0 comments on commit 0cd4553

Please sign in to comment.