Implement personal_signTransaction in socket server

This commit is contained in:
nolash
2020-08-05 22:00:23 +02:00
parent acaff79ad2
commit 7c3208de4c
4 changed files with 31 additions and 7 deletions

View File

@@ -28,7 +28,7 @@ class ReferenceSigner(Signer):
def signTransaction(self, tx, password=None):
s = tx.serialize()
s = tx.rlp_serialize()
h = sha3.keccak_256()
h.update(s)
g = h.digest()

View File

@@ -23,10 +23,10 @@ class Transaction:
self.v = chainId
self.r = 0
self.s = 0
self.sender = tx['from']
self.sender = strip_hex_prefix(tx['from'])
def serialize(self):
def rlp_serialize(self):
b = self.nonce.to_bytes(8, byteorder='little')
s = [
self.nonce,
@@ -40,3 +40,16 @@ class Transaction:
self.s,
]
return rlp_encode(s)
def serialize(self):
return {
'nonce': '0x' + hex(self.nonce),
'gasPrice': '0x' + hex(self.gas_price),
'gas': '0x' + hex(self.start_gas),
'to': '0x' + self.to.hex(),
'value': '0x' + hex(self.value),
'data': '0x' + self.data.hex(),
'v': '0x' + hex(self.v),
'r': '0x' + self.r.hex(),
's': '0x' + self.s.hex(),
}