funga

Signer and keystore daemon and library for cryptocurrency software development
Log | Files | Refs | README | LICENSE

commit 2caa0ba755dfe1f83eac64491ab84bc10b6deee3
parent b3d2ab4703c735454332618471dcf0c48f90621e
Author: nolash <dev@holbrook.no>
Date:   Wed, 31 Mar 2021 12:13:04 +0200

Return address from import key in same format as get

Diffstat:
Mcrypto_dev_signer/keystore/dict.py | 2+-
Mcrypto_dev_signer/runnable/signer.py | 10++++++----
Mrequirements.txt | 2+-
Msetup.py | 2+-
Mtest/test_keystore_dict.py | 15+++++++++++----
Mtest/test_keystore_reference.py | 3++-
6 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/crypto_dev_signer/keystore/dict.py b/crypto_dev_signer/keystore/dict.py @@ -37,4 +37,4 @@ class DictKeystore(Keystore): address_hex_clean = strip_0x(address_hex) self.keys[address_hex_clean] = pk.secret logg.debug('added key {}'.format(address_hex)) - return address_hex + return address_hex_clean diff --git a/crypto_dev_signer/runnable/signer.py b/crypto_dev_signer/runnable/signer.py @@ -9,9 +9,10 @@ import logging import argparse from urllib.parse import urlparse -# third-party imports +# external imports import confini from jsonrpc.exceptions import * +from hexathon import add_0x # local imports from crypto_dev_signer.eth.signer import ReferenceSigner @@ -99,9 +100,10 @@ def personal_new_account(p): r = db.new(password) - return r + return add_0x(r) +# TODO: move to translation module ("personal" rpc namespace is node-specific) def personal_signTransaction(p): logg.debug('got {} to sign'.format(p[0])) #t = EIP155Transaction(p[0], p[0]['nonce'], 8995) @@ -117,9 +119,9 @@ def personal_signTransaction(p): return o -# TODO: temporary workaround for platform, since personal_signTransaction is missing from web3.py def eth_signTransaction(tx): - return personal_signTransaction([tx[0], '']) + o = personal_signTransaction([tx[0], '']) + return o['raw'] def eth_sign(p): diff --git a/requirements.txt b/requirements.txt @@ -9,4 +9,4 @@ confini~=0.3.6a3 sqlalchemy==1.3.20 coincurve==15.0.0 pycrypto==2.6.1 -hexathon~=0.0.1a6 +hexathon~=0.0.1a7 diff --git a/setup.py b/setup.py @@ -24,7 +24,7 @@ f.close() setup( name="crypto-dev-signer", - version="0.4.14a14", + version="0.4.14a17", description="A signer and keystore daemon and library for cryptocurrency software development", author="Louis Holbrook", author_email="dev@holbrook.no", diff --git a/test/test_keystore_dict.py b/test/test_keystore_dict.py @@ -6,6 +6,12 @@ import logging import base64 import os +# external imports +from hexathon import ( + strip_0x, + add_0x, + ) + # local imports from crypto_dev_signer.keystore.dict import DictKeystore from crypto_dev_signer.error import UnknownAccountError @@ -28,7 +34,8 @@ class TestDict(unittest.TestCase): keystore_filepath = os.path.join(script_dir, 'testdata', 'UTC--2021-01-08T18-37-01.187235289Z--00a329c0648769a73afac7f9381e08fb43dbea72') - self.address_hex = self.db.import_keystore_file(keystore_filepath, '') + address_hex = self.db.import_keystore_file(keystore_filepath, '') + self.address_hex = add_0x(address_hex) def tearDown(self): @@ -36,8 +43,8 @@ class TestDict(unittest.TestCase): def test_get_key(self): - logg.debug('getting {}'.format(self.address_hex[2:])) - pk = self.db.get(self.address_hex[2:], '') + logg.debug('getting {}'.format(strip_0x(self.address_hex))) + pk = self.db.get(strip_0x(self.address_hex), '') self.assertEqual(self.address_hex.lower(), '0x00a329c0648769a73afac7f9381e08fb43dbea72') @@ -48,7 +55,7 @@ class TestDict(unittest.TestCase): def test_sign_message(self): s = ReferenceSigner(self.db) - z = s.sign_ethereum_message(self.address_hex[2:], b'foo') + z = s.sign_ethereum_message(strip_0x(self.address_hex), b'foo') logg.debug('zzz {}'.format(str(z))) diff --git a/test/test_keystore_reference.py b/test/test_keystore_reference.py @@ -6,7 +6,7 @@ import logging import base64 import os -# third-party imports +# external imports import psycopg2 from psycopg2 import sql from cryptography.fernet import Fernet, InvalidToken @@ -39,6 +39,7 @@ class TestDatabase(unittest.TestCase): } self.db = ReferenceKeystore('postgres+psycopg2://postgres@localhost:5432/signer_test', **kw) self.address_hex = self.db.new('foo') + #self.address_hex = add_0x(address_hex) def tearDown(self):