command-line handler for trezor
This commit is contained in:
parent
557286ff79
commit
2863d19579
5
electrum
5
electrum
|
@ -73,7 +73,7 @@ from electrum import util
|
||||||
from electrum import SimpleConfig, Network, Wallet, WalletStorage, NetworkProxy
|
from electrum import SimpleConfig, Network, Wallet, WalletStorage, NetworkProxy
|
||||||
from electrum.util import print_msg, print_error, print_stderr, print_json, set_verbosity, InvalidPassword
|
from electrum.util import print_msg, print_error, print_stderr, print_json, set_verbosity, InvalidPassword
|
||||||
from electrum.daemon import get_daemon
|
from electrum.daemon import get_daemon
|
||||||
from electrum.plugins import init_plugins
|
from electrum.plugins import init_plugins, run_hook, always_hook
|
||||||
from electrum.commands import get_parser, known_commands, Commands, config_variables
|
from electrum.commands import get_parser, known_commands, Commands, config_variables
|
||||||
|
|
||||||
|
|
||||||
|
@ -263,6 +263,9 @@ def run_cmdline(config):
|
||||||
# create wallet instance
|
# create wallet instance
|
||||||
wallet = Wallet(storage) if cmd.requires_wallet else None
|
wallet = Wallet(storage) if cmd.requires_wallet else None
|
||||||
|
|
||||||
|
# notify plugins
|
||||||
|
always_hook('cmdline_load_wallet', wallet)
|
||||||
|
|
||||||
# important warning
|
# important warning
|
||||||
if cmd.name in ['dumpprivkey', 'dumpprivkeys']:
|
if cmd.name in ['dumpprivkey', 'dumpprivkeys']:
|
||||||
print_stderr("WARNING: ALL your private keys are secret.")
|
print_stderr("WARNING: ALL your private keys are secret.")
|
||||||
|
|
|
@ -93,7 +93,10 @@ class Plugin(BasePlugin):
|
||||||
self.wallet = None
|
self.wallet = None
|
||||||
|
|
||||||
@hook
|
@hook
|
||||||
def init_cmdline(self):
|
def cmdline_load_wallet(self, wallet):
|
||||||
|
self.wallet = wallet
|
||||||
|
self.wallet.plugin = self
|
||||||
|
if self.handler is None:
|
||||||
self.handler = TrezorCmdLineHandler()
|
self.handler = TrezorCmdLineHandler()
|
||||||
|
|
||||||
@hook
|
@hook
|
||||||
|
@ -493,12 +496,22 @@ class TrezorGuiMixin(object):
|
||||||
class TrezorCmdLineHandler:
|
class TrezorCmdLineHandler:
|
||||||
|
|
||||||
def get_passphrase(self, msg):
|
def get_passphrase(self, msg):
|
||||||
|
import getpass
|
||||||
print_msg(msg)
|
print_msg(msg)
|
||||||
return raw_input()
|
return getpass.getpass('')
|
||||||
|
|
||||||
def get_pin(self, msg):
|
def get_pin(self, msg):
|
||||||
|
t = { 'a':'7', 'b':'8', 'c':'9', 'd':'4', 'e':'5', 'f':'6', 'g':'1', 'h':'2', 'i':'3'}
|
||||||
|
print_msg(msg)
|
||||||
|
print_msg("a b c\nd e f\ng h i\n-----")
|
||||||
|
o = raw_input()
|
||||||
|
return ''.join(map(lambda x: t[x], o))
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def show_message(self, msg):
|
||||||
print_msg(msg)
|
print_msg(msg)
|
||||||
return raw_input()
|
|
||||||
|
|
||||||
|
|
||||||
class TrezorQtHandler:
|
class TrezorQtHandler:
|
||||||
|
|
Loading…
Reference in New Issue