you can not get the stake if your wallet is encrypted, i did not modify this mechanism
You can if you unlock your wallet by going to
Command Line Banking and typing:
walletpassphrase Your_password_here Time_to_unlock_wallet_in_seconds_here
For example if my password was
mypassword and I wanted to unlock my wallet for 24 hours (
86400 seconds):
walletpassphrase mypassword 86400
Your encrypted wallet will then remain unlocked for 24 hours and be able to stake for 24 hours before locking itself again.