whitespace, variable renames

This commit is contained in:
The MMGen Project 2025-02-06 10:12:50 +00:00
commit 02d736f101
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
3 changed files with 13 additions and 9 deletions

View file

@ -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

View file

@ -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):

View file

@ -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+<first letter of unit name>