<blockquote>
  <p>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).</p>
</blockquote>

<p>You're saying the same thing twice here.</p>

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

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

CC BY-SA 3.0
2017-05-05T18:04:49.990Z
Yes, right, long hours working on the same I guess. Thanks Pieter.
sr_gi
CC BY-SA 3.0
2017-05-05T17:55:40.917Z
2017-05-05T17:55:40.917Z
Pieter Wuille
<p>In <code>P2PKH</code> transactions, the content after signing the transaction contains: <code>&lt;signature(with hash_flag)&gt;&lt;public_key&gt;</code>. However, since the signature can't sign itself, during the signature process the <code>ScripSig</code> field is temporarily set to a certain value.</p>

<p>According to the accepted answer from <a href="https://bitcoin.stackexchange.com/questions/3374/how-to-redeem-a-basic-tx">How to redeem a basic Tx?</a>, the field is temporarily set with the <code>ScriptPubKey</code> field from the <code>UTXO</code> we want to redeem (in this case a <code>P2PKH ScriptPubKey</code> with the <code>RIPEMD160</code> of the previous address). However, according to <a href="https://github.com/vbuterin/pybitcointools/blob/6db88d846d3dd0414f9064febd98d2553e14f953/bitcoin/transaction.py#L369" rel="nofollow noreferrer">VButerin's pybitcointools</a>, the field is set with a <code>P2PKH ScriptPubKey</code> with the <code>RIPEMD160</code> of your own address (the one you are using as a source, and which private key will be used to sign the transaction).</p>

<p>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.</p>

<script><signature><raw-transaction><python>
ScriptSig field during P2PKH transaction signature
sr_gi
# ScriptSig field during P2PKH transaction signature

(Asked by: username_0 on 2017-05-05)

In `P2PKH` transactions, the content after signing the transaction contains: `<signature(with hash_flag)><public_key>`. 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?](https://bitcoin.stackexchange.com/questions/3374/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](https://github.com/vbuterin/pybitcointools/blob/6db88d846d3dd0414f9064febd98d2553e14f953/bitcoin/transaction.py#L369), 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.

**Tags:** script, signature, raw-transaction, python


---

## 1 answers

### Answer by username_1 on 2017-05-05. Score: 2 | Accepted answer

> 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)*.

> **Comments:**
> **username_0**: Yes, right, long hours working on the same I guess. Thanks username_1.  

---

