There are several instances in functional tests and the framework (MiniWallet, feature_block.py, p2p_segwit.py) where we create a legacy ECDSA signature for a certain transaction's input by doing the following steps:
- calculate the
LegacySignatureHashwith the desired sighash type - create the actual digital signature by calling
ECKey.sign_ecdsaon the signature message hash calculated above - put the DER-encoded result as CScript data push into tx input's scriptSig
Create a new helper sign_input_legacy which hides those details and takes only the necessary parameters (tx, input index, relevant scriptPubKey, private key, sighash type [SIGHASH_ALL by default]). For further convenience, the signature is prepended to already existing data-pushes in scriptSig, in order to avoid rehashing the transaction after calling the new signing function.