<p>A one input/one output tx signed with <code>SIGHASH_SINGLE|SIGHASH_ANYONECANPAY</code> can still be modified to include more inputs and outputs, as long as the original input and output are not modified.</p>

<p>A tx signed with <code>SIGHASH_ALL</code> cannot be modified at all, and no new inputs or outputs can be added.</p>

CC BY-SA 4.0
2018-09-02T04:01:57.687Z
I was asking more about the procedure for generating the signature script. Am I correct that the only difference is the hash type byte appended to the end of the transaction before hashing, assuming the transaction only has 1 input and 1 output?
Roy Tang
CC BY-SA 4.0
2018-09-02T03:03:53.343Z
2018-09-02T03:03:53.343Z
Raghav Sood
<p>I have an signing implementation that already works for SIGHASH_ALL, and I'm trying to also support SIGHASH_SINGLE|SIGHASH_ANYONECANPAY.</p>

<p>I'm referencing <a href="https://en.bitcoin.it/wiki/OP_CHECKSIG" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/OP_CHECKSIG</a> for the behaviors of different SIGHASH types. From my reading, I assumed that there should be no difference between SIGHASH_ALL and SIGHASH_SINGLE|SIGHASH_ANYONECANPAY (aside from the hashtype appended to the end of the transaction being hashed) if the transaction involved only has one input and one output, but from my testing using other tools this does not seem to be the case.</p>

<p>Am I wrong with my interpretation? What modifications would the signing need if it's SIGHASH_SINGLE|SIGHASH_ANYONECANPAY instead of SIGHASH_ALL, assuming there's only a single input and output?</p>

<signature><sighash-flags>
For a transaction with a single input and output, is there a difference between SIGHASH_ALL and SIGHASH_SINGLE|SIGHASH_ANYONECANPAY
Roy Tang
# For a transaction with a single input and output, is there a difference between SIGHASH_ALL and SIGHASH_SINGLE|SIGHASH_ANYONECANPAY

(Asked by: username_0 on 2018-09-01)

I have an signing implementation that already works for SIGHASH\_ALL, and I'm trying to also support SIGHASH\_SINGLE|SIGHASH\_ANYONECANPAY.

I'm referencing <https://en.bitcoin.it/wiki/OP_CHECKSIG> for the behaviors of different SIGHASH types. From my reading, I assumed that there should be no difference between SIGHASH\_ALL and SIGHASH\_SINGLE|SIGHASH\_ANYONECANPAY (aside from the hashtype appended to the end of the transaction being hashed) if the transaction involved only has one input and one output, but from my testing using other tools this does not seem to be the case.

Am I wrong with my interpretation? What modifications would the signing need if it's SIGHASH\_SINGLE|SIGHASH\_ANYONECANPAY instead of SIGHASH\_ALL, assuming there's only a single input and output?

**Tags:** signature, sighash-flags


---

## 1 answers

### Answer by username_1 on 2018-09-02. Score: 2

A one input/one output tx signed with `SIGHASH_SINGLE|SIGHASH_ANYONECANPAY` can still be modified to include more inputs and outputs, as long as the original input and output are not modified.

A tx signed with `SIGHASH_ALL` cannot be modified at all, and no new inputs or outputs can be added.

> **Comments:**
> **username_0**: I was asking more about the procedure for generating the signature script. Am I correct that the only difference is the hash type byte appended to the end of the transaction before hashing, assuming the transaction only has 1 input and 1 output?  

---

