Add message signer cli
This commit is contained in:
parent
903f65936e
commit
30c82b9cd1
@ -1,3 +1,5 @@
|
||||
* 0.5.4
|
||||
- Add message signer cli
|
||||
* 0.5.3
|
||||
- Upgrade RLP to 3.0.0 (eliminates really annoying cytoolz warning on stdout)
|
||||
---
|
||||
|
49
funga/eth/runnable/msg.py
Normal file
49
funga/eth/runnable/msg.py
Normal file
@ -0,0 +1,49 @@
|
||||
# standard imports
|
||||
import os
|
||||
import logging
|
||||
import sys
|
||||
import json
|
||||
import argparse
|
||||
import getpass
|
||||
|
||||
# external impors
|
||||
import coincurve
|
||||
from hexathon import strip_0x
|
||||
|
||||
# local imports
|
||||
from funga.error import DecryptError
|
||||
from funga.eth.keystore.dict import DictKeystore
|
||||
from funga.eth.signer import EIP155Signer
|
||||
|
||||
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
logg = logging.getLogger()
|
||||
|
||||
argparser = argparse.ArgumentParser()
|
||||
argparser.add_argument('-f', type=str, help='Keyfile to use for signing')
|
||||
argparser.add_argument('-z', action='store_true', help='zero-length password')
|
||||
argparser.add_argument('-v', action='store_true', help='be verbose')
|
||||
argparser.add_argument('msg', type=str, help='Message to sign')
|
||||
args = argparser.parse_args()
|
||||
|
||||
if args.v:
|
||||
logg.setLevel(logging.DEBUG)
|
||||
|
||||
|
||||
def main():
|
||||
passphrase = os.environ.get('WALLET_PASSPHRASE', os.environ.get('PASSPHRASE'))
|
||||
if args.z:
|
||||
passphrase = ''
|
||||
if passphrase == None:
|
||||
passphrase = getpass.getpass('decryption phrase: ')
|
||||
|
||||
keystore = DictKeystore()
|
||||
address = keystore.import_keystore_file(args.f, password=passphrase)
|
||||
|
||||
signer = EIP155Signer(keystore)
|
||||
sig = signer.sign_ethereum_message(address, args.msg.encode('utf-8').hex(), password=passphrase)
|
||||
sys.stdout.write(sig.hex())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
3
setup.py
3
setup.py
@ -33,7 +33,7 @@ f.close()
|
||||
|
||||
setup(
|
||||
name="funga-eth",
|
||||
version="0.5.3",
|
||||
version="0.5.4b1",
|
||||
description="Ethereum implementation of the funga keystore and signer",
|
||||
author="Louis Holbrook",
|
||||
author_email="dev@holbrook.no",
|
||||
@ -55,6 +55,7 @@ setup(
|
||||
'console_scripts': [
|
||||
'funga-ethd=funga.eth.runnable.signer:main',
|
||||
'eth-keyfile=funga.eth.runnable.keyfile:main',
|
||||
'eth-sign-msg=funga.eth.runnable.msg:main',
|
||||
],
|
||||
},
|
||||
url='https://gitlab.com/chaintool/funga-eth',
|
||||
|
Loading…
Reference in New Issue
Block a user