mmgen-wallet/scripts/bitcoind-walletunlock.py
philemon a3c4bd8731 New feature: export wallet to incognito format
Incognito wallet is 48, 56 or 64 bytes of apparently random data.

  Allows user to hide wallet data in a pre-existing file or on a disk
  partition (preferably filled in advance with random data).

  Can be used to hide wallet securely in unencrypted cloud storage or
  on paper, without revealing the nature of the data.

  Data may be written at a user-specified offset into the file or
  partition, in which case user must remember the offset.

  Each export operation uses a new random init vector to create different
  data each time.  This allows the user to hide wallets at different
  locations on the Net without detection.

  User must remember hash preset in addition to passphrase (though trial
  and error can be used if it's forgotten).

  Fully integrated with address generation and tx signing operations.
2014-07-14 18:31:00 +04:00

61 lines
1.8 KiB
Python
Executable file

#!/usr/bin/env python
#
# mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
# Copyright (C) 2013 by philemon <mmgen-py@yandex.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
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!")