Post
Topic
Board Development & Technical Discussion
Re: What happens when you unlock the wallet?
by
calchuchesta
on 26/09/2021, 15:36:22 UTC
This has everything you need to know about wallet encryption: github.com/bitcoin/bitcoin/blob/6b8a5ab622e5c9386c872036646bf94da983b190/doc/README

Unfortunately it doesn't answer about what GUI do when you unlock the wallet.

I use the walletpassphrase to see if I still can remember my password and I don't want to transact, so im curious about what goes on when the GUI unlocks it when making a transaction.
If you need to do that, you can set a timeout of '1' second so your passphrase wont stay in your RAM for too long.

You also could use command walletlock if you accidentally use default unlock duration and being extremely careful.

It should be somewhere on the code. Im trying to find things related to transactions on the qt folder source where it it's related to the passphrase being used:

https://github.com/bitcoin/bitcoin/blob/master/src/qt/askpassphrasedialog.h
https://github.com/bitcoin/bitcoin/blob/master/src/qt/askpassphrasedialog.cpp

I think this only relates to the actual window but not what happens with the passphrase. There's also this:

https://github.com/bitcoin/bitcoin/blob/master/src/interfaces/wallet.h

Code:
    //! Encrypt wallet.
    virtual bool encryptWallet(const SecureString& wallet_passphrase) = 0;

    //! Return whether wallet is encrypted.
    virtual bool isCrypted() = 0;

    //! Lock wallet.
    virtual bool lock() = 0;

    //! Unlock wallet.
    virtual bool unlock(const SecureString& wallet_passphrase) = 0;

    //! Return whether wallet is locked.
    virtual bool isLocked() = 0;

    //! Change wallet passphrase.
    virtual bool changeWalletPassphrase(const SecureString& old_wallet_passphrase,
        const SecureString& new_wallet_passphrase) = 0;

I can't find what the "default timeout" would be.