Return address from import key in same format as get

This commit is contained in:
nolash 2021-03-31 12:13:04 +02:00
parent b3d2ab4703
commit 2caa0ba755
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
6 changed files with 22 additions and 12 deletions

View File

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

View File

@ -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):

View File

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

View File

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

View File

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

View File

@ -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):