fix cmdline trezor
This commit is contained in:
parent
d5f43610ed
commit
c7b1721f58
10
electrum
10
electrum
|
@ -231,7 +231,7 @@ def init_cmdline(config):
|
||||||
wallet.update_password(password, new_password)
|
wallet.update_password(password, new_password)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
return cmd, password
|
return cmd, password, wallet
|
||||||
|
|
||||||
|
|
||||||
def run_offline_command(config, cmd, wallet, password):
|
def run_offline_command(config, cmd, wallet, password):
|
||||||
|
@ -316,14 +316,8 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
# run command offline
|
# run command offline
|
||||||
if cmd_name not in ['gui', 'daemon']:
|
if cmd_name not in ['gui', 'daemon']:
|
||||||
cmd, password = init_cmdline(config)
|
cmd, password, wallet = init_cmdline(config)
|
||||||
if not cmd.requires_network or config.get('offline'):
|
if not cmd.requires_network or config.get('offline'):
|
||||||
if cmd.requires_wallet:
|
|
||||||
path = config.get_wallet_path()
|
|
||||||
storage = WalletStorage(path)
|
|
||||||
wallet = Wallet(storage)
|
|
||||||
else:
|
|
||||||
wallet = None
|
|
||||||
result = run_offline_command(config, cmd, wallet, password)
|
result = run_offline_command(config, cmd, wallet, password)
|
||||||
print_msg(json_encode(result))
|
print_msg(json_encode(result))
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
from trezor import TrezorPlugin
|
||||||
|
from electrum.util import print_msg
|
||||||
|
from electrum.plugins import hook
|
||||||
|
|
||||||
|
class TrezorCmdLineHandler:
|
||||||
|
|
||||||
|
def get_passphrase(self, msg):
|
||||||
|
import getpass
|
||||||
|
print_msg(msg)
|
||||||
|
return getpass.getpass('')
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
class Plugin(TrezorPlugin):
|
||||||
|
|
||||||
|
@hook
|
||||||
|
def cmdline_load_wallet(self, wallet):
|
||||||
|
print "cmdline load wallet"
|
||||||
|
self.wallet = wallet
|
||||||
|
self.wallet.plugin = self
|
||||||
|
if self.handler is None:
|
||||||
|
self.handler = TrezorCmdLineHandler()
|
||||||
|
print self.wallet
|
||||||
|
|
|
@ -273,13 +273,6 @@ class TrezorPlugin(BasePlugin):
|
||||||
self.client = None
|
self.client = None
|
||||||
self.wallet = None
|
self.wallet = None
|
||||||
|
|
||||||
@hook
|
|
||||||
def cmdline_load_wallet(self, wallet):
|
|
||||||
self.wallet = wallet
|
|
||||||
self.wallet.plugin = self
|
|
||||||
if self.handler is None:
|
|
||||||
self.handler = TrezorCmdLineHandler()
|
|
||||||
|
|
||||||
def sign_transaction(self, tx, prev_tx, xpub_path):
|
def sign_transaction(self, tx, prev_tx, xpub_path):
|
||||||
self.prev_tx = prev_tx
|
self.prev_tx = prev_tx
|
||||||
self.xpub_path = xpub_path
|
self.xpub_path = xpub_path
|
||||||
|
@ -451,27 +444,6 @@ class TrezorGuiMixin(object):
|
||||||
return proto.WordAck(word=word)
|
return proto.WordAck(word=word)
|
||||||
|
|
||||||
|
|
||||||
class TrezorCmdLineHandler:
|
|
||||||
|
|
||||||
def get_passphrase(self, msg):
|
|
||||||
import getpass
|
|
||||||
print_msg(msg)
|
|
||||||
return getpass.getpass('')
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if TREZOR:
|
if TREZOR:
|
||||||
|
|
Loading…
Reference in New Issue