12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- """
- bitcoind-walletunlock.py: Unlock a Bitcoin wallet securely
- """
- import sys
- from mmgen.Opts import *
- from mmgen.tx import *
- from mmgen.util import msg, my_getpass, my_raw_input
- prog_name = sys.argv[0].split("/")[-1]
- help_data = {
- 'prog_name': prog_name,
- 'desc': "Unlock a Bitcoin wallet securely",
- 'usage': "[opts]",
- 'options': """
- -h, --help Print this help message
- -e, --echo-passphrase Print passphrase to screen when typing it
- """
- }
- short_opts = "he"
- long_opts = "help","echo_passphrase"
- opts,cmd_args = process_opts(sys.argv,help_data,short_opts,long_opts)
- c = connect_to_bitcoind()
- prompt = "Enter passphrase: "
- if 'echo_passphrase' in opts:
- password = my_raw_input(prompt)
- else:
- password = my_getpass(prompt)
- from bitcoinrpc import exceptions
- try:
- c.walletpassphrase(password, 9999)
- except exceptions.WalletWrongEncState:
- msg("Wallet is unencrypted")
- except exceptions.WalletPassphraseIncorrect:
- msg("Passphrase incorrect")
- except exceptions.WalletAlreadyUnlocked:
- msg("WARNING: Wallet already unlocked!")
|