From 6a0b5e5e07901c019f79bda68e8bbfa56cb60498 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Mon, 19 May 2025 09:23:55 +0000 Subject: [PATCH] minor Ethereum file format change This is a backwards-incompatible change. Offline signing devices must be upgraded if you transact ETH or ETC. --- mmgen/proto/eth/tx/new.py | 8 +++----- mmgen/proto/eth/tx/unsigned.py | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/mmgen/proto/eth/tx/new.py b/mmgen/proto/eth/tx/new.py index 7940cf34..6ae4fe72 100755 --- a/mmgen/proto/eth/tx/new.py +++ b/mmgen/proto/eth/tx/new.py @@ -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: diff --git a/mmgen/proto/eth/tx/unsigned.py b/mmgen/proto/eth/tx/unsigned.py index 58ab401b..ccb9a171 100755 --- a/mmgen/proto/eth/tx/unsigned.py +++ b/mmgen/proto/eth/tx/unsigned.py @@ -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