<blockquote>
<p>Do I understand correctly that both inputs are to be signed
separately?</p>
</blockquote>
<p>yes</p>
<blockquote>
<p>So first, we sign the first one, then the second one. To sign an input
we replace scriptSig for this input with the scriptPubKey, that locks
this input. ScriptSig for the other one remains blank. It this
correct?</p>
</blockquote>
<p>yes</p>
<blockquote>
<p>But in both threads in step 13 something is appended at the end of
transaction. It is called hash code type. What is this? Is this has
anything to do with sighash type byte the one that is appended to the
signature?</p>
</blockquote>
<p>yes</p>
<blockquote>
<p>What is the correct sighash type for the scenario I described above
(signing inputs separately)? Is this: 0x81 (SIGHASH_ALL |
SIGHASH_ANYONECANPAY)? Or should this be 0x01 (SIGHASH_ALL)?</p>
</blockquote>
<p>Use 0x01 (SIGHASH_ALL)</p>

CC BY-SA 4.0
2020-11-24T00:28:28.673Z
2020-11-24T00:28:28.673Z
amaclin
<p>I have an unsigned raw transaction:</p>
<pre><code>01000000020dcc23ccdb3665779a7657577cd33c5c0660e969ea2ffaf5438c58306ebc9dd20100000000ffffffff49508924c21b25ee2ff6aed61ccc202793aa992d3e033f12f2bf4a94d6346d010000000000ffffffff0240420f00000000001976a9140d7ca1e17524d6c96209cf503fb053613cecf8f688aca0f703000000000017a91452636ce984783dac880e139fa3b69b4d9be39ab68700000000
</code></pre>
<p>I have read these threads:<br />
<a href="https://bitcoin.stackexchange.com/questions/3374/how-to-redeem-a-basic-tx">How to redeem a basic Tx?</a><br />
<a href="https://bitcoin.stackexchange.com/questions/32628/redeeming-a-raw-transaction-step-by-step-example-required">Redeeming a raw transaction step by step example required</a></p>
<p>These threads explain signing a raw transaction with 1 input.</p>
<p><strong>Questions</strong></p>
<p>Do I understand correctly that both inputs are to be signed separately?<br />
So first, we sign the first one, then the second one. To sign an input we replace <em>scriptSig</em> for this input with the <em>scriptPubKey</em>, that locks this input. <em>ScriptSig</em> for the other one remains blank.</p>
<p>It this correct?</p>
<p>But in both threads in step 13 something is appended at the end of transaction. It is called <strong>hash code type</strong></p>
<p>What is this? Is this has anything to do with <strong>sighash type byte</strong> the one that is appended to the signature? If not how to determine this value?</p>
<p>What is the correct sighash type for the scenario I described above (signing inputs separately)?
Is this: 0x81 (SIGHASH_ALL | SIGHASH_ANYONECANPAY)?
Or should this be 0x01 (SIGHASH_ALL)?</p>
<p>I don't know which one is correct as transaction to be signed contains the other input (without scriptSig set but still, it contains it).</p>

<signature><raw-transaction><input-script><sighash>
signing multiple input raw transaction - algorithm and sighash types
Jubert
# signing multiple input raw transaction - algorithm and sighash types

(Asked by: username_0 on 2020-11-23)

I have an unsigned raw transaction:

```
01000000020dcc23ccdb3665779a7657577cd33c5c0660e969ea2ffaf5438c58306ebc9dd20100000000ffffffff49508924c21b25ee2ff6aed61ccc202793aa992d3e033f12f2bf4a94d6346d010000000000ffffffff0240420f00000000001976a9140d7ca1e17524d6c96209cf503fb053613cecf8f688aca0f703000000000017a91452636ce984783dac880e139fa3b69b4d9be39ab68700000000

```

I have read these threads:  
[How to redeem a basic Tx?](https://bitcoin.stackexchange.com/questions/3374/how-to-redeem-a-basic-tx)  
[Redeeming a raw transaction step by step example required](https://bitcoin.stackexchange.com/questions/32628/redeeming-a-raw-transaction-step-by-step-example-required)

These threads explain signing a raw transaction with 1 input.

**Questions**

Do I understand correctly that both inputs are to be signed separately?  
So first, we sign the first one, then the second one. To sign an input we replace *scriptSig* for this input with the *scriptPubKey*, that locks this input. *ScriptSig* for the other one remains blank.

It this correct?

But in both threads in step 13 something is appended at the end of transaction. It is called **hash code type**

What is this? Is this has anything to do with **sighash type byte** the one that is appended to the signature? If not how to determine this value?

What is the correct sighash type for the scenario I described above (signing inputs separately)?
Is this: 0x81 (SIGHASH\_ALL | SIGHASH\_ANYONECANPAY)?
Or should this be 0x01 (SIGHASH\_ALL)?

I don't know which one is correct as transaction to be signed contains the other input (without scriptSig set but still, it contains it).

**Tags:** signature, raw-transaction, input-script, sighash


---

## 1 answers

### Answer by username_1 on 2020-11-24. Score: 1 | Accepted answer

> Do I understand correctly that both inputs are to be signed
> separately?

yes

> So first, we sign the first one, then the second one. To sign an input
> we replace scriptSig for this input with the scriptPubKey, that locks
> this input. ScriptSig for the other one remains blank. It this
> correct?

yes

> But in both threads in step 13 something is appended at the end of
> transaction. It is called hash code type. What is this? Is this has
> anything to do with sighash type byte the one that is appended to the
> signature?

yes

> What is the correct sighash type for the scenario I described above
> (signing inputs separately)? Is this: 0x81 (SIGHASH\_ALL |
> SIGHASH\_ANYONECANPAY)? Or should this be 0x01 (SIGHASH\_ALL)?

Use 0x01 (SIGHASH\_ALL)


---

