{"action":"created","issue":{"url":"https://api.github.com/repos/bitcoin/bitcoin/issues/6582","labels_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/6582/labels{/name}","comments_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/6582/comments","events_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/6582/events","html_url":"https://github.com/bitcoin/bitcoin/issues/6582","id":102635148,"number":6582,"title":"Wallet salvage searches for `wallet.dat` in the current directory rather than .bitcoin","user":{"login":"apoelstra","id":1351933,"avatar_url":"https://avatars.githubusercontent.com/u/1351933?v=3","gravatar_id":"","url":"https://api.github.com/users/apoelstra","html_url":"https://github.com/apoelstra","followers_url":"https://api.github.com/users/apoelstra/followers","following_url":"https://api.github.com/users/apoelstra/following{/other_user}","gists_url":"https://api.github.com/users/apoelstra/gists{/gist_id}","starred_url":"https://api.github.com/users/apoelstra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apoelstra/subscriptions","organizations_url":"https://api.github.com/users/apoelstra/orgs","repos_url":"https://api.github.com/users/apoelstra/repos","events_url":"https://api.github.com/users/apoelstra/events{/privacy}","received_events_url":"https://api.github.com/users/apoelstra/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/bitcoin/bitcoin/labels/Bug","name":"Bug","color":"FBBAAB"},{"url":"https://api.github.com/repos/bitcoin/bitcoin/labels/Wallet","name":"Wallet","color":"02d7e1"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-08-23T16:18:21Z","updated_at":"2015-11-24T09:21:28Z","closed_at":"2015-11-24T09:21:28Z","body":"If you try to start bitcoind with a corrupted wallet, it will attempt to run `CWalletDB::Recover`, which moves `wallet.dat` to some other name, reads all the records, and writes them to a fresh `wallet.dat`.\r\n\r\nHowever, when moving `wallet.dat`, it searches the current directory rather than `.bitcoin`, so if you start `bitcoind` from anywhere else, it'll fail. To see this, run\r\n```\r\necho \"I'm not a real wallet!\" > ~/.bitcoin/wallet.dat  ## MOVE YOUR REAL WALLET OUT OF THE WAY\r\nbitcoind\r\n```\r\nThe output on stdout is simply \"Error:\" with no additional information. In debug.log you will see something like\r\n```\r\n2015-08-23 16:13:17 CDBEnv::Open: LogDir=/home/apoelstra/.bitcoin/database ErrorFile=/home/apoelstra/.bitcoin/db.log\r\n2015-08-23 16:13:17 Failed to rename wallet.dat to wallet.1440346397.bak (err -1)\r\n2015-08-23 16:13:17 errno 2: No such file or directory\r\n```\r\n(The errno line won't appear; I added that while investigating the bug.)\r\n\r\nOn the other hand, if you run bitcoind from `~/.bitcoin` itself, it will rename the wallet successfully (and instead fail trying to read records from \"I'm not a wallet!\" :))."},"comment":{"url":"https://api.github.com/repos/bitcoin/bitcoin/issues/comments/159205048","html_url":"https://github.com/bitcoin/bitcoin/issues/6582#issuecomment-159205048","issue_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/6582","id":159205048,"user":{"login":"laanwj","id":126646,"avatar_url":"https://avatars.githubusercontent.com/u/126646?v=3","gravatar_id":"","url":"https://api.github.com/users/laanwj","html_url":"https://github.com/laanwj","followers_url":"https://api.github.com/users/laanwj/followers","following_url":"https://api.github.com/users/laanwj/following{/other_user}","gists_url":"https://api.github.com/users/laanwj/gists{/gist_id}","starred_url":"https://api.github.com/users/laanwj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laanwj/subscriptions","organizations_url":"https://api.github.com/users/laanwj/orgs","repos_url":"https://api.github.com/users/laanwj/repos","events_url":"https://api.github.com/users/laanwj/events{/privacy}","received_events_url":"https://api.github.com/users/laanwj/received_events","type":"User","site_admin":false},"created_at":"2015-11-24T09:21:28Z","updated_at":"2015-11-24T09:21:28Z","body":"Looks like the user changed code which may have resulted in this problem, the issue is inactive, so closing.\r\n"}}