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