Author

Topic: SIGHASH_ANYONECANPAY. (Read 1729 times)

hero member
Activity: 560
Merit: 509
I prefer Zakir over Muhammed when mentioning me!
February 17, 2015, 05:12:14 AM
#5
You can add dummy inputs before you sign. The pre-sig tx removes them but it makes the tx well formed. Using SIGHASH_SINGLE locks one txout. It kinda assumes that you are responsible for the txout that has the same index as the txin that you are signing. Therefore you don't have room for a change txout. I find them less useful than SIGHASH_ANYONECANPAY|SIGHASH_ALL.

Okay! Understood except - none of the inputs are dummies

As the inputs will be larger than outputs, where would change go?

   -MZ
sr. member
Activity: 467
Merit: 267
February 17, 2015, 03:35:41 AM
#4
You can add dummy inputs before you sign. The pre-sig tx removes them but it makes the tx well formed. Using SIGHASH_SINGLE locks one txout. It kinda assumes that you are responsible for the txout that has the same index as the txin that you are signing. Therefore you don't have room for a change txout. I find them less useful than SIGHASH_ANYONECANPAY|SIGHASH_ALL.
hero member
Activity: 560
Merit: 509
I prefer Zakir over Muhammed when mentioning me!
February 15, 2015, 12:03:42 PM
#3

In `SIGHASH_ANYONECANPAY` all the other inputs are removed before signing. For instance, if the tx has 3 inputs and you are signing the 2nd one, the 1st one and the 3rd one are removed and can be modified later *before* being published. The outputs are not modified so you are still paying the same people.

Let's say that you and your roommates are paying your rent in a single tx. You sign your share of the rent as `SIGHASH_ANYONECANPAY` so that your roommates can add their share later. Once everyone is done, you can publish the completed transaction.

Note that in this case, you may need a special wallet because the total output value is greater than the total input values while you build the tx.

In other words, you locked the destination but you don't care if others want to add more coins.

Thanks, hhanh00! As the inputs will be larger than outputs, where would change go?

Is SIGHASH_SINGLE|SIGHASH_ANYONECANPAY better? As I could sign a single input & output and others can add/change other inputs and outputs, so the change can be managed.

   -MZ
sr. member
Activity: 467
Merit: 267
February 15, 2015, 09:25:06 AM
#2
When you sign a transaction, the wallet prepares a 'before-sign' transaction then calculates its hash. The hash is signed and put back into the raw transaction. The result is the final transaction to publish[1].
Normally signatures are SIGHASH_ALL (1). It's a byte appended to the signature. [Ex][2]: 3045022100d9e4dbe1d5cb4404e6d06c1f8ada2cee913f6fe192129a38d75834739f2d5a4202202 6d4354d769179cb9775d4ef5b4b4862f8bf1827a57fa8e1b42a18b3202cacff**01**

However, you can have other types of signatures. `SIGHASH_ANYONECANPAY` is one of them. It modifies how the Bitcoin forms the 'before-sign' transaction to sign/verify. This tx determines what is being signed. In other words, if something is omitted from it, it can be modified later without making the signature invalid.

In `SIGHASH_ANYONECANPAY` all the other inputs are removed before signing. For instance, if the tx has 3 inputs and you are signing the 2nd one, the 1st one and the 3rd one are removed and can be modified later *before* being published. The outputs are not modified so you are still paying the same people.

Let's say that you and your roommates are paying your rent in a single tx. You sign your share of the rent as `SIGHASH_ANYONECANPAY` so that your roommates can add their share later. Once everyone is done, you can publish the completed transaction.

Note that in this case, you may need a special wallet because the total output value is greater than the total input values while you build the tx.

In other words, you locked the destination but you don't care if others want to add more coins.

[1]: http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html
[2]: https://blockchain.info/tx/0b5477156878eb16b6220e68f06e6a1685b8ab13545f792b833444fe7a85c9be
hero member
Activity: 560
Merit: 509
I prefer Zakir over Muhammed when mentioning me!
February 15, 2015, 05:01:40 AM
#1
https://bitcoin.org/en/developer-guide#term-sighash-anyonecanpay

Can anybody please give a brief explanation with example? Thanks!

Kindly,
Muhammed Zakir
Jump to: