From 02d736f101cd4708ba6c5551a1f31a25cd3dc531 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Thu, 6 Feb 2025 10:12:50 +0000 Subject: [PATCH] whitespace, variable renames --- mmgen/proto/btc/tx/base.py | 10 +++++++--- mmgen/tx/base.py | 4 ++-- mmgen/tx/new.py | 8 ++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/mmgen/proto/btc/tx/base.py b/mmgen/proto/btc/tx/base.py index 4e872dfd..7582d023 100755 --- a/mmgen/proto/btc/tx/base.py +++ b/mmgen/proto/btc/tx/base.py @@ -222,9 +222,13 @@ class Base(TxBase.Base): return ret + sum(input_size['C'] for i in self.inputs if not i.mmtype) def get_outputs_size(): - # output bytes = amt: 8, byte_count: 1+, pk_script - # pk_script bytes: p2pkh: 25, p2sh: 23, bech32: 22 - return sum({'p2pkh':34, 'p2sh':32, 'bech32':31}[o.addr.addr_fmt] for o in self.outputs) + # output bytes: + # 8 (amt) + scriptlen_byte + script_bytes + # script_bytes: + # ADDR: p2pkh: 25, p2sh: 23, bech32: 22 + return sum( + {'p2pkh':34, 'p2sh':32, 'bech32':31}[o.addr.addr_fmt] + for o in self.outputs) # https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki # The witness is a serialization of all witness data of the transaction. Each txin is diff --git a/mmgen/tx/base.py b/mmgen/tx/base.py index bf33bee7..6bc14ca3 100755 --- a/mmgen/tx/base.py +++ b/mmgen/tx/base.py @@ -91,8 +91,8 @@ class Base(MMGenObject): file_format = 'json' class Input(MMGenTxIO): - scriptPubKey = ListItemAttr(HexStr) - sequence = ListItemAttr(int, typeconv=False) + scriptPubKey = ListItemAttr(HexStr) + sequence = ListItemAttr(int, typeconv=False) tw_copy_attrs = {'scriptPubKey', 'vout', 'amt', 'comment', 'mmid', 'addr', 'confs', 'txid'} class Output(MMGenTxIO): diff --git a/mmgen/tx/new.py b/mmgen/tx/new.py index aaa77e56..f215158b 100755 --- a/mmgen/tx/new.py +++ b/mmgen/tx/new.py @@ -101,11 +101,11 @@ class New(Base): if f: e.comment = f - def check_dup_addrs(self, io_str): - assert io_str in ('inputs', 'outputs') - addrs = [e.addr for e in getattr(self, io_str)] + def check_dup_addrs(self, io_desc): + assert io_desc in ('inputs', 'outputs') + addrs = [e.addr for e in getattr(self, io_desc)] if len(addrs) != len(set(addrs)): - die(2, f'{addrs}: duplicate address in transaction {io_str}') + die(2, f'{addrs}: duplicate address in transaction {io_desc}') # given tx size and absolute fee or fee spec, return absolute fee # relative fee is N+