Export canonical order method

This commit is contained in:
nolash 2021-04-12 19:09:11 +02:00
parent 86ef9bdb56
commit 23a5e8dcd0
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
2 changed files with 11 additions and 4 deletions

View File

@ -0,0 +1,5 @@
ethereum_recid_modifier = 35
def chain_id_to_v(chain_id, signature):
v = signature[64]
return (chain_id * 2) + ethereum_recid_modifier + v

View File

@ -13,10 +13,12 @@ from hexathon import (
# local imports
from crypto_dev_signer.eth.encoding import chain_id_to_v
from crypto_dev_signer.eth.rlp import rlp_encode
#from crypto_dev_signer.eth.rlp import rlp_encode
import rlp
logg = logging.getLogger().getChild(__name__)
rlp_encode = rlp.encode
class Transaction:
@ -91,7 +93,7 @@ class EIP155Transaction:
self.sender = strip_0x(tx['from'])
def __canonical_order(self):
def canonical_order(self):
s = [
self.nonce,
self.gas_price,
@ -108,7 +110,7 @@ class EIP155Transaction:
def bytes_serialize(self):
s = self.__canonical_order()
s = self.canonical_order()
b = b''
for e in s:
b += e
@ -116,7 +118,7 @@ class EIP155Transaction:
def rlp_serialize(self):
s = self.__canonical_order()
s = self.canonical_order()
return rlp_encode(s)