Add message signer cli

This commit is contained in:
lash 2022-01-24 12:04:21 +00:00
parent 903f65936e
commit 30c82b9cd1
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
3 changed files with 53 additions and 1 deletions

View File

@ -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
View 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()

View File

@ -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',