gpg: allow setting passphrase from environment variable

as done by TREZOR's client library
master
Roman Zeyde 6 years ago
parent 34ce1005fd
commit 7803026f61
No known key found for this signature in database
GPG Key ID: 87CAE5FA46917CBB

@ -6,6 +6,7 @@ import os
import subprocess
import sys
import mnemonic
import semver
from . import interface
@ -81,6 +82,13 @@ class Trezor(interface.Device):
if _is_open_tty(sys.stdin):
return cli_handler(msg) # CLI-based PIN handler
# Reusing environment variable from trezorlib/client.py
passphrase = os.getenv("PASSPHRASE")
if passphrase is not None:
log.info("Using PASSPHRASE environment variable.")
return self._defs.PassphraseAck(
passphrase=mnemonic.Mnemonic.normalize_string(passphrase))
passphrase = _message_box('Please enter passphrase:')
return self._defs.PassphraseAck(passphrase=passphrase)

@ -20,6 +20,7 @@ setup(
'python-daemon>=2.1.2',
'ecdsa>=0.13',
'ed25519>=1.4',
'mnemonic>=0.18',
'pymsgbox>=1.0.6',
'semver>=2.2',
'unidecode>=0.4.20',

Loading…
Cancel
Save