Add setup.py, rename server script

This commit is contained in:
nolash 2020-08-08 10:45:37 +02:00
parent 472e2f04fc
commit 51f076ba2a
Signed by: lash
GPG Key ID: 93EC1C676274C889
6 changed files with 43 additions and 24 deletions

1
scripts/crypto-dev-daemon Symbolic link
View File

@ -0,0 +1 @@
scripts/crypto-dev-daemon.py

39
scripts/server.py → scripts/crypto-dev-daemon.py Normal file → Executable file
View File

@ -1,3 +1,5 @@
#!/usr/bin/python3
import socket import socket
import json import json
import logging import logging
@ -19,20 +21,24 @@ chainId = 8995
def personal_new_account(p): def personal_new_account(p):
if p.__class__.__name__ != 'list': password = p
e = JSONRPCInvalidParams() if p.__class__.__name__ != 'str':
e.data = 'parameter must be list containing one string' if p.__class__.__name__ != 'list':
raise ValueError(e) e = JSONRPCInvalidParams()
if len(p) != 1: e.data = 'parameter must be list containing one string'
e = JSONRPCInvalidParams() raise ValueError(e)
e.data = 'parameter must be list containing one string' logg.error('foo {}'.format(p))
raise ValueError(e) if len(p) != 1:
if p[0].__class__.__name__ != 'str': e = JSONRPCInvalidParams()
e = JSONRPCInvalidParams() e.data = 'parameter must be list containing one string'
e.data = 'parameter must be list containing one string' raise ValueError(e)
raise ValueError(e) if p[0].__class__.__name__ != 'str':
e = JSONRPCInvalidParams()
e.data = 'parameter must be list containing one string'
raise ValueError(e)
password = p[0]
r = db.new(p[0]) r = db.new(password)
return r return r
@ -50,10 +56,7 @@ def personal_sign_transaction(p):
# TODO: temporary workaround for platform, since personal_signTransaction is missing from web3.py # TODO: temporary workaround for platform, since personal_signTransaction is missing from web3.py
def eth_signTransaction(tx): def eth_signTransaction(tx):
password = tx['password'] return personal_sign_transaction([tx, ''])
del tx['password']
tx_signed = personal_sign_transaction([tx, password])
return tx_signed
methods = { methods = {
@ -89,9 +92,7 @@ def is_valid_json(j):
def process_input(j): def process_input(j):
rpc_id = j['id'] rpc_id = j['id']
m = j['method'] m = j['method']
p = j['params'] p = j['params']
return (rpc_id, methods[m](p)) return (rpc_id, methods[m](p))

14
setup.py Normal file
View File

@ -0,0 +1,14 @@
from setuptools import setup
setup(
name="crypto-dev-signer",
version="0.1.0",
description="A signer and keystore daemon and library for cryptocurrency software development",
author="Louis Holbrook",
author_email="dev@holbrook.no",
packages=['crypto-dev-signer'],
install_requires=['web3', 'psycopg2', 'cryptography', 'eth-keys', 'pysha3', 'rlp'],
scripts = [
'scripts/crypto-dev-daemon.py',
],
)

View File

@ -1,7 +1,9 @@
# standard imports
import logging import logging
import base64 import base64
import os import os
# third-party imports
from cryptography.fernet import Fernet from cryptography.fernet import Fernet
import psycopg2 import psycopg2
from psycopg2 import sql from psycopg2 import sql
@ -9,6 +11,7 @@ from eth_keys import KeyAPI
from eth_keys.backends import NativeECCBackend from eth_keys.backends import NativeECCBackend
import sha3 import sha3
# local imports
from common import strip_hex_prefix from common import strip_hex_prefix
from keystore.interface import Keystore from keystore.interface import Keystore
@ -18,15 +21,10 @@ logging.basicConfig(level=logging.DEBUG)
logg = logging.getLogger(__file__) logg = logging.getLogger(__file__)
def to_bytes(x): def to_bytes(x):
return x.encode('utf-8') return x.encode('utf-8')
class ReferenceKeystore(Keystore): class ReferenceKeystore(Keystore):
schema = [ schema = [

View File

@ -1,12 +1,16 @@
# standard imports
import logging import logging
import binascii import binascii
# third-party imports
from rlp import encode as rlp_encode from rlp import encode as rlp_encode
# local imports
from common import strip_hex_prefix, add_hex_prefix from common import strip_hex_prefix, add_hex_prefix
logg = logging.getLogger(__name__) logg = logging.getLogger(__name__)
class Transaction: class Transaction:
def rlp_serialize(self): def rlp_serialize(self):

View File

@ -1,3 +1,4 @@
# standard imports
import logging import logging
import re import re
import socket import socket