update handler
This commit is contained in:
parent
a043f33242
commit
5061aace41
15
parse.py
15
parse.py
@ -321,8 +321,8 @@ def noop_handler(cmd):
|
||||
def generate_private_key():
|
||||
"""Generate a new private key."""
|
||||
web3 = Web3()
|
||||
account = web3.eth.account.create()
|
||||
return account.address
|
||||
account = web3.eth.account.create()
|
||||
return account.address,w3.to_hex(account.key)
|
||||
|
||||
def store_key_in_keystore(private_key, key_name, store_name):
|
||||
keystore = {
|
||||
@ -342,8 +342,13 @@ def store_key_in_keystore(private_key, key_name, store_name):
|
||||
def key_create_handler(cmd):
|
||||
store_name = cmd.t
|
||||
key_name = str(cmd.f).split(":")[1]
|
||||
private_key = cmd.k
|
||||
address = generate_private_key()
|
||||
|
||||
if cmd.k is None:
|
||||
address,private_key = generate_private_key()
|
||||
else:
|
||||
if private_key.startswith("0x"):
|
||||
private_key = private_key[2:]
|
||||
address = w3.eth.account.from_key(privatekey)
|
||||
store_key_in_keystore(private_key, key_name, store_name)
|
||||
return address
|
||||
|
||||
@ -483,7 +488,7 @@ if __name__ == '__main__':
|
||||
o = Router()
|
||||
o.register(CmdId.KEY_CREATE,key_create_handler)
|
||||
o.register(CmdId.VOUCHER_CREATE,voucher_create_handler)
|
||||
o.register(CmdId.VOUCHER_MINT, voucher_mint_handler)
|
||||
o.register(CmdId.VOUCHER_MINT, voucher_create_handler)
|
||||
o.register(CmdId.VOUCHER_TRANSFER,voucher_transfer_handler)
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
|
Loading…
Reference in New Issue
Block a user