813 | @@ -814,7 +814,7 @@ def BIP341_sha_sequences(txTo):
814 | def BIP341_sha_outputs(txTo):
815 | return sha256(b"".join(o.serialize() for o in txTo.vout))
816 |
817 | -def TaprootSignatureMsg(txTo, spent_utxos, hash_type, input_index=0, *, scriptpath=False, leaf_script=None, codeseparator_pos=-1, annex=None, leaf_ver=LEAF_VERSION_TAPSCRIPT):
818 | +def TaprootSignatureMsg(txTo, spent_utxos, hash_type, input_index=0, *, scriptpath=False, leaf_script=None, codeseparator_pos=0xFFFFFFFF, annex=None, leaf_ver=LEAF_VERSION_TAPSCRIPT):
Could be set to None, like leaf_script?
0xFFFFFFFF isn't a sentinel here, it's the BIP342 value for "no codeseparator executed", so it's the correct default as-is. None would need a branch back to 0xFFFFFFFF before the to_bytes call, which doesn't buy anything.
What I was trying to say is that there is no need to pass this value, if it isn't used. And if it is used, it seems better to write test code that is obvious and explicit.
-1 or None achieve that by throwing a Python exception. Your suggestion of 0xFFFFFFFF does not.
Maybe I am blind, but I don't see the point of this pull request. My recommendation would be to use:
- -1 (i.e. close this pull), or
- use None.
If you think that 0xFFFFFFFF makes sense, it would be good to explain what real-world test scenario or dev experience you are trying to improve.
It is used: it is the last 4 bytes of every scriptpath sighash (script.py:856), the field BIP342 calls codesep_pos. The question is only what it should default to when no OP_CODESEPARATOR executed.
-1 can no longer be that default. It worked while the line was signed=True; 81e5c8385b changed it to signed=False and left the signature alone, so the default now raises OverflowError. Going back is not available either: feature_taproot passes 0xffffffff and 0xfffffffe, which overflow as signed.
So the choice is None or 0xFFFFFFFF, and the repo has already made it three times: interpreter.cpp:444, feature_taproot.py:436 and :1296.
I have put the full walkthrough, including the concrete case you asked about, in a comment below. If it does not convince you, say so and I will close.