v1.0.4: Fix bugs in recover input validation and secure mode file handling, clean up _toDelete folder

This commit is contained in:
LC
2026-01-05 16:12:06 +00:00
parent b9ab22c131
commit a4f188af36
4 changed files with 10 additions and 1179 deletions

View File

@@ -406,7 +406,7 @@ def cmd_gen(args):
with tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=True) as temp_file:
temp_file.write(out_text)
temp_file.flush()
print(f"Output written to temp file: {temp_file.name} (auto-deleted on exit)")
print("Output written to temporary file (auto-deleted on exit)")
else:
with open(args.file, 'w') as f:
f.write(out_text)
@@ -449,6 +449,13 @@ def cmd_recover(args):
if args.export_private and not args.pgp_pubkey_file:
raise ValueError("--export-private requires --pgp-pubkey-file")
# Validate input methods
input_methods = [bool(args.mnemonic), bool(args.seed), args.interactive]
if sum(input_methods) > 1:
raise ValueError("Provide only one of --mnemonic, --seed, or --interactive")
if sum(input_methods) == 0:
raise ValueError("Missing input (use --mnemonic/--seed/--interactive)")
mnemonic = None
seed_hex = None
@@ -464,8 +471,6 @@ def cmd_recover(args):
mnemonic = args.mnemonic.strip()
elif args.seed:
seed_hex = args.seed.strip()
else:
raise ValueError("Missing input (use --mnemonic/--seed/--interactive)")
if mnemonic:
if not Bip39MnemonicValidator().IsValid(mnemonic):
@@ -512,7 +517,7 @@ def cmd_recover(args):
with tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=True) as temp_file:
temp_file.write(out_text)
temp_file.flush()
print(f"Output written to temp file: {temp_file.name} (auto-deleted on exit)")
print("Output written to temporary file (auto-deleted on exit)")
else:
with open(args.file, 'w') as f:
f.write(out_text)