So you would put them in the "sighash" area.
Assuming "signature" is just a function for doing DER signing, it doesn't explicitly make use of the inputs themselves, but deals with an entire transaction.
And then you have the witness step where the inputs are definitely required.
I'm not familiar with your code or the "bitcoin" PyPI library so I can't give you a code example, but like I said you can just round them up for the sighash calculation.
The last code is:
txins= []
txin1 = CTxIn(COutPoint(lx(txid1), vout1))
txin2 = CTxIn(COutPoint(lx(txid2), vout2))
txins=[txin1,txin2]
txout = CTxOut(amount_less_fee, target_scriptPubKey)
tx = CMutableTransaction(txins, [txout])
txin_index = 0
redeem_script1 = address1.to_redeemScript()
redeem_script2 = address2.to_redeemScript()
sighash1 = SignatureHash(redeem_script1, tx, txin_index, SIGHASH_SINGLE, amount=amount1, sigversion=SIGVERSION_WITNESS_V0)
sighash2 = SignatureHash(redeem_script2, tx, txin_index, SIGHASH_SINGLE, amount=amount2, sigversion=SIGVERSION_WITNESS_V0)
signature1 = seckey1.sign(sighash1) + bytes([SIGHASH_SINGLE])
signature2 = seckey2.sign(sighash2) + bytes([SIGHASH_SINGLE])
witness1 = [signature1, public_key1]
witness2 = [signature2, public_key2]
witness1next = CScript(witness1)
witness2next = CScript(witness2)
ctxinwitnesses1 = [CTxInWitness(CScriptWitness(witness1))]
ctxinwitnesses2 = [CTxInWitness(CScriptWitness(witness2))]
tx.wit = CTxWitness(ctxinwitnesses1)
VerifyScript(witness1next, scriptPubKey1, tx, 0, (SCRIPT_VERIFY_P2SH,))
print(b2x(tx.serialize()))
At which line should be the inputs moved into one variable to fulfill the tx requirements?