programmingbitcoin icon indicating copy to clipboard operation
programmingbitcoin copied to clipboard

code-ch13 TxIn class

Open norisg opened this issue 6 years ago • 2 comments

In the parse_segwit method the code line:

tx_in.witness = items

which means the TxIn class should have this "witness" parameter also in its init procedure. How can this be possible ?

norisg avatar Sep 01 '19 08:09 norisg

It's been a while since I looked at it, but are you sure the code doesn't work? In Python you can add an attribute to an object like that. For a clean coding style, yes it probably should be initialized in the __init__ but that's not a requirement of the language.

chanhosuh avatar Sep 01 '19 19:09 chanhosuh

Yes the code does work, but I had problems understanding how this could be possible. But as you mentioned before, for clean coding style definitely worth to correct it.

norisg avatar Sep 02 '19 05:09 norisg