Skip to content

Commit 888ed85

Browse files
committed
Support encrypted mnemonics
Allow setting mnemonic to a 27 word mnemonic and where set as such prompt for the mnemonic password as necessary.
1 parent 5a6373f commit 888ed85

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

green_cli/authenticators/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ def mnemonic(self):
9191

9292
@property
9393
def password(self):
94+
if len(self._mnemonic.split()) == 27:
95+
return getpass('Mnemonic password: ')
9496
return ''
9597

9698
def create(self, session_obj, words):
@@ -106,10 +108,14 @@ def create(self, session_obj, words):
106108
return self.register(session_obj)
107109

108110
def set_mnemonic(self, mnemonic):
109-
mnemonic = ' '.join(mnemonic.split())
111+
words = mnemonic.split()
112+
is_encrypted = len(words) == 27
113+
mnemonic = ' '.join(words)
110114
logging.debug("mnemonic: '{}'".format(mnemonic))
111-
if not gdk.validate_mnemonic(mnemonic):
112-
raise click.ClickException("Invalid mnemonic")
115+
# For now no validation of encrypted mnemonic
116+
if not is_encrypted:
117+
if not gdk.validate_mnemonic(mnemonic):
118+
raise click.ClickException("Invalid mnemonic")
113119
self._mnemonic = mnemonic
114120

115121

0 commit comments

Comments
 (0)