Make wallet creation and load fail with a clear error when the db directory isn’t writable.
1) For Wallet Creation
Before: creating a wallet would return a generic error: “SQLiteDatabase: Failed to open database: unable to open database file”
After: creating a wallet returns: “SQLiteDatabase: Failed to open database in directory <dir_path>: directory is not writable”
2) For Wallet Loading
We currently allow the load of wallets located on non-writable directories. This is problematic because the node crashes on any subsequent write; generating a block is enough to trigger it. Can be verified just by running the following test on master: https://github.com/furszy/bitcoin-core/commit/85fa4e2910f0a8f43d4ee5a1322cbb69656d85e9
Also, to check directory writability, this creates a tmp file rather than relying on the
permissions() functions, since perms bits alone may not reliably reflect actual writability
in some systems.
Testing Note: Pushed the tests in separate commits so they can be cherry-picked on master for comparison.