From d786f08d70ef0c353144d19c143bca39b24f6883 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Wed, 9 Sep 2026 18:33:54 +0000 Subject: [PATCH] tx.file: `metadata_only` -> `get_proto_only` --- mmgen/tx/file.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mmgen/tx/file.py b/mmgen/tx/file.py index 14f7e56c..e389aa08 100755 --- a/mmgen/tx/file.py +++ b/mmgen/tx/file.py @@ -82,16 +82,16 @@ class MMGenTxFile(MMGenObject): self.fmt_data = None self.filename = None - def parse(self, infile, *, metadata_only=False, quiet_open=False): + def parse(self, infile, *, get_proto_only=False, quiet_open=False): tx = self.tx from ..fileutil import get_data_from_file data = get_data_from_file(tx.cfg, infile, desc=f'{tx.desc} data', quiet=quiet_open) if len(data) > tx.cfg.max_tx_file_size: die('MaxFileSizeExceeded', f'Transaction file size exceeds limit ({tx.cfg.max_tx_file_size} bytes)') - return (self.parse_data_json if data[0] == '{' else self.parse_data_legacy)(data, metadata_only) + return (self.parse_data_json if data[0] == '{' else self.parse_data_legacy)(data, get_proto_only) - def parse_data_json(self, data, metadata_only): + def parse_data_json(self, data, get_proto_only): tx = self.tx tx.file_format = 'json' outer_data = json.loads(data) @@ -105,13 +105,13 @@ class MMGenTxFile(MMGenObject): tx.proto = get_proto_from_coin_id(tx, data['coin_id'], data['chain']) + if get_proto_only: + return + for k, v in self.attrs.items(): if v != 'skip': setattr(tx, k, v(data[k]) if v else data[k]) - if metadata_only: - return - for k, v in self.extra_attrs.items(): if k in data: setattr(tx, k, v(data[k]) if v else data[k]) @@ -130,7 +130,7 @@ class MMGenTxFile(MMGenObject): assert tx.proto.coin_amt(data['send_amt']) == tx.send_amt, f'{data["send_amt"]} != {tx.send_amt}' - def parse_data_legacy(self, data, metadata_only): + def parse_data_legacy(self, data, get_proto_only): tx = self.tx tx.file_format = 'legacy' @@ -199,6 +199,9 @@ class MMGenTxFile(MMGenObject): desc = 'coin_id or chain' tx.proto = get_proto_from_coin_id(tx, coin_id, tx.chain) + if get_proto_only: + return + desc = 'metadata (4 items)' (txid, send_amt, tx.timestamp, blockcount) = metadata @@ -207,9 +210,6 @@ class MMGenTxFile(MMGenObject): desc = 'block count in metadata' tx.blockcount = int(blockcount) - if metadata_only: - return - desc = 'transaction file hex data' tx.check_txfile_hex_data() desc = 'Ethereum RLP or JSON data' @@ -338,5 +338,5 @@ class MMGenTxFile(MMGenObject): def get_proto(cls, cfg, filename, *, quiet_open=False): from . import BaseTX tmp_tx = BaseTX(cfg=cfg) - cls(tmp_tx).parse(filename, metadata_only=True, quiet_open=quiet_open) + cls(tmp_tx).parse(filename, get_proto_only=True, quiet_open=quiet_open) return tmp_tx.proto