23 lines
936 B
Python
23 lines
936 B
Python
from pathlib import Path
|
|
|
|
from django.conf import settings
|
|
from django.core.management.base import BaseCommand, CommandError
|
|
|
|
from apps.lottery.keys import generate_keys
|
|
|
|
|
|
class Command(BaseCommand):
|
|
help = "One-off: create the master key and its encryption key (0600) and print the account's public key (ARC-78)."
|
|
|
|
def add_arguments(self, parser):
|
|
parser.add_argument("directory", help="where to write master.key and master.encryption.key")
|
|
|
|
def handle(self, *args, **options):
|
|
try:
|
|
xpub = generate_keys(Path(options["directory"]), settings.PLM_PROFILE)
|
|
except FileExistsError as error:
|
|
raise CommandError(str(error)) from error
|
|
self.stdout.write(f"Keys written to {options['directory']} for {settings.PLM_NETWORK}.")
|
|
self.stdout.write("Put this public key in .env (the web process needs nothing else):")
|
|
self.stdout.write(f"PLM_ACCOUNT_XPUB={xpub}")
|