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 json
import logging
@ -19,20 +21,24 @@ chainId = 8995
def personal_new_account(p):
if p.__class__.__name__ != 'list':
e = JSONRPCInvalidParams()
e.data = 'parameter must be list containing one string'
raise ValueError(e)
if len(p) != 1:
e = JSONRPCInvalidParams()
e.data = 'parameter must be list containing one string'
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
if p.__class__.__name__ != 'str':
if p.__class__.__name__ != 'list':
e = JSONRPCInvalidParams()
e.data = 'parameter must be list containing one string'
raise ValueError(e)
logg.error('foo {}'.format(p))
if len(p) != 1:
e = JSONRPCInvalidParams()
e.data = 'parameter must be list containing one string'
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
@ -50,10 +56,7 @@ def personal_sign_transaction(p):
# TODO: temporary workaround for platform, since personal_signTransaction is missing from web3.py
def eth_signTransaction(tx):
password = tx['password']
del tx['password']
tx_signed = personal_sign_transaction([tx, password])
return tx_signed
return personal_sign_transaction([tx, ''])
methods = {
@ -89,9 +92,7 @@ def is_valid_json(j):
def process_input(j):
rpc_id = j['id']
m = j['method']
p = j['params']
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 base64
import os
# third-party imports
from cryptography.fernet import Fernet
import psycopg2
from psycopg2 import sql
@ -9,6 +11,7 @@ from eth_keys import KeyAPI
from eth_keys.backends import NativeECCBackend
import sha3
# local imports
from common import strip_hex_prefix
from keystore.interface import Keystore
@ -18,15 +21,10 @@ logging.basicConfig(level=logging.DEBUG)
logg = logging.getLogger(__file__)
def to_bytes(x):
return x.encode('utf-8')
class ReferenceKeystore(Keystore):
schema = [

View File

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

View File

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