Use master seed to create new site from cli
This commit is contained in:
parent
8d88cfcd68
commit
1e1e560795
2 changed files with 22 additions and 6 deletions
|
@ -113,6 +113,8 @@ class Config(object):
|
||||||
|
|
||||||
# SiteCreate
|
# SiteCreate
|
||||||
action = self.subparsers.add_parser("siteCreate", help='Create a new site')
|
action = self.subparsers.add_parser("siteCreate", help='Create a new site')
|
||||||
|
action.register('type', 'bool', self.strToBool)
|
||||||
|
action.add_argument('--use_master_seed', help="Allow created site's private key to be recovered using the master seed in users.json (default: True)", type="bool", choices=[True, False], default=True)
|
||||||
|
|
||||||
# SiteNeedFile
|
# SiteNeedFile
|
||||||
action = self.subparsers.add_parser("siteNeedFile", help='Get a file from site')
|
action = self.subparsers.add_parser("siteNeedFile", help='Get a file from site')
|
||||||
|
|
26
src/main.py
26
src/main.py
|
@ -143,18 +143,28 @@ class Actions(object):
|
||||||
|
|
||||||
# Site commands
|
# Site commands
|
||||||
|
|
||||||
def siteCreate(self):
|
def siteCreate(self, use_master_seed=False):
|
||||||
logging.info("Generating new privatekey...")
|
logging.info("Generating new privatekey (use_master_seed: %s)..." % config.use_master_seed)
|
||||||
|
return
|
||||||
from Crypt import CryptBitcoin
|
from Crypt import CryptBitcoin
|
||||||
privatekey = CryptBitcoin.newPrivatekey()
|
if use_master_seed:
|
||||||
|
from User import UserManager
|
||||||
|
user = UserManager.user_manager.get()
|
||||||
|
if not user:
|
||||||
|
user = UserManager.user_manager.create()
|
||||||
|
address, address_index, site_data = user.getNewSiteData()
|
||||||
|
privatekey = site_data["privatekey"]
|
||||||
|
logging.info("Generated using master seed from users.json, site index: %s" % address_index)
|
||||||
|
else:
|
||||||
|
privatekey = CryptBitcoin.newPrivatekey()
|
||||||
|
address = CryptBitcoin.privatekeyToAddress(privatekey)
|
||||||
logging.info("----------------------------------------------------------------------")
|
logging.info("----------------------------------------------------------------------")
|
||||||
logging.info("Site private key: %s" % privatekey)
|
logging.info("Site private key: %s" % privatekey)
|
||||||
logging.info(" !!! ^ Save it now, required to modify the site ^ !!!")
|
logging.info(" !!! ^ Save it now, required to modify the site ^ !!!")
|
||||||
address = CryptBitcoin.privatekeyToAddress(privatekey)
|
|
||||||
logging.info("Site address: %s" % address)
|
logging.info("Site address: %s" % address)
|
||||||
logging.info("----------------------------------------------------------------------")
|
logging.info("----------------------------------------------------------------------")
|
||||||
|
|
||||||
while True and not config.batch:
|
while True and not config.batch and not use_master_seed:
|
||||||
if input("? Have you secured your private key? (yes, no) > ").lower() == "yes":
|
if input("? Have you secured your private key? (yes, no) > ").lower() == "yes":
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
@ -170,7 +180,11 @@ class Actions(object):
|
||||||
|
|
||||||
logging.info("Creating content.json...")
|
logging.info("Creating content.json...")
|
||||||
site = Site(address)
|
site = Site(address)
|
||||||
site.content_manager.sign(privatekey=privatekey, extend={"postmessage_nonce_security": True})
|
extend = {"postmessage_nonce_security": True}
|
||||||
|
if use_master_seed:
|
||||||
|
extend["address_index"] = address_index
|
||||||
|
|
||||||
|
site.content_manager.sign(privatekey=privatekey, extend=extend)
|
||||||
site.settings["own"] = True
|
site.settings["own"] = True
|
||||||
site.saveSettings()
|
site.saveSettings()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue