minor Ethereum file format change

This is a backwards-incompatible change.  Offline signing devices must be
upgraded if you transact ETH or ETC.
This commit is contained in:
The MMGen Project 2025-05-19 09:23:55 +00:00
commit 6a0b5e5e07
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
2 changed files with 4 additions and 6 deletions

View file

@ -12,8 +12,6 @@
proto.eth.tx.new: Ethereum new transaction class
"""
import json
from ....tx import new as TxBase
from ....obj import Int, ETHNonce, MMGenTxID
from ....util import msg, ymsg, is_int, is_hex_str, make_chksum_6, suf, die
@ -81,14 +79,14 @@ class New(Base, TxBase.New):
o_ok = 0 if self.usr_contract_data else 1
assert o_num == o_ok, f'Transaction has {o_num} output{suf(o_num)} (should have {o_ok})'
await self.make_txobj()
odict = {k:v if v is None else str(v) for k, v in self.txobj.items() if k != 'token_to'}
self.serialized = json.dumps(odict)
self.serialized = {k:v if v is None else str(v) for k, v in self.txobj.items() if k != 'token_to'}
self.update_txid()
def update_txid(self):
import json
assert not is_hex_str(self.serialized), (
'update_txid() must be called only when self.serialized is not hex data')
self.txid = MMGenTxID(make_chksum_6(self.serialized).upper())
self.txid = MMGenTxID(make_chksum_6(json.dumps(self.serialized)).upper())
def set_gas_with_data(self, data):
if not self.is_token:

View file

@ -25,7 +25,7 @@ class Unsigned(Completed, TxBase.Unsigned):
desc = 'unsigned transaction'
def parse_txfile_serialized_data(self):
d = json.loads(self.serialized)
d = self.serialized if isinstance(self.serialized, dict) else json.loads(self.serialized)
o = {
'from': CoinAddr(self.proto, d['from']),
# NB: for token, 'to' is sendto address