ScriptSig field during P2PKH transaction signature In P2PKH transactions, the content after signing the transaction contains: &lt;signature(with hash_flag)&gt;&lt;public_key&gt;. However, since the signature can't sign itself, during the signature process the ScripSig field is temporarily set to a certain value.

According to the accepted answer from How to redeem a basic Tx?, the field is temporarily set with the ScriptPubKey field from the UTXO we want to redeem (in this case a P2PKH ScriptPubKey with the RIPEMD160 of the previous address). However, according to VButerin's pybitcointools, the field is set with a P2PKH ScriptPubKey with the RIPEMD160 of your own address (the one you are using as a source, and which private key will be used to sign the transaction).

I used pybitcointools signing function several times, and the generated transactions are valid, but the answer from the aforementioned question has been well received, so at this point I'm quite confused about what the field should contain.
According to the accepted answer from How to redeem a basic Tx?, the field is temporarily set with the ScriptPubKey field from the UTXO we want to redeem (in this case a P2PKH ScriptPubKey with the RIPEMD160 of the previous address). However, according to VButerin's pybitcointools, the field is set with a P2PKH ScriptPubKey with the RIPEMD160 of your own address (the one you are using as a source, and which private key will be used to sign the transaction).


You're saying the same thing twice here.

A transaction T1 existed with an output T1:0 which has a scriptPubKey P2PKH(K1). This is the transaction that credited you. It resulted in the creation of a UTXO with script P2PKH(K1), and your own key is K1.

You're trying to create a transaction T2 with as input T1:0 and an output T2:0 with scriptPubKey P2PKH(K2). This is the spending transaction, which you're signing for with K1. It sends money to K2, but consumes the UTXO T1:0 which has script P2PKH(K1).