<p>SIGHASH_ALL | SIGHASH_ANYONECANPAY signs the outputs. So the entrepreneur cannot change the output, as it would invalidate the signatures on all the inputs he received.</p>

<p>There is another way he can bypass this though - if he has 500 BTC himself (or can borrow that amount very briefly) - he can contribute that himself, getting away with raising only 500 BTC but still taking the coins. The only way around that is having some form of escrow that verifies the payments. </p>

CC BY-SA 4.0
2020-05-05T21:49:03.763Z
2020-05-05T21:49:03.763Z
Pieter Wuille
<p>I'm having a bit of trouble understanding example 3, the bit coin assurance contract on the bitcoin wiki(<a href="https://en.bitcoin.it/wiki/Contract" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Contract</a>) where senders choose to donate money only if 1000BTC total is raised. Here is the description of the assurance contract example:</p>

<ol>
<li>An entrepreneur creates a new address and announces that the good will be created if at least 1000 BTC is raised. Anyone can contribute.</li>
<li>Each party wishing to pledge creates a new transaction spending some of their coins to the announced address, but they do not broadcast it. The transaction is similar to a regular transaction except for three differences: Firstly, there cannot be any change. If you don’t have any outputs of the right size, you must create one first by spending to one of your own addresses. Secondly, the input script signature is signed with SIGHASH_ALL | SIGHASH_ANYONECANPAY. Finally, the output value is set to 1000 BTC. Note that this is not a valid transaction because the output value is larger than the input value.</li>
<li>The transaction is uploaded to the entrepreneur's server, which saves it to disk and updates its count of how many coins have been pledged.</li>
<li>Once the server has enough coins, it merges the separate transactions together into a new transaction. The new transaction has a single output that simply spends to the announced address - it is the same as the outputs on each contributed transaction. The inputs to the transaction are collected from the contributed pledges.</li>
<li>The finished transaction is broadcast, sending the pledged coins to the announced address.</li>
</ol>

<p>where each transaction is of the following form from bitcoin wiki(<a href="https://en.bitcoin.it/wiki/Transaction" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Transaction</a>):</p>

<pre><code>Input:
Previous tx: f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6
Index: 0
scriptSig: 304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d10
90db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501

Output:
Value: 1000
scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d
OP_EQUALVERIFY OP_CHECKSIG
</code></pre>

<p>I'm having trouble understanding step 4. If the entraprenuer only ends up raising 500BTC and never meets their goal of raising 1000BTC why can't the entraprenuer change the output value to 500BTC, then broadcast the transaction and cash out anyway without each of the the sender's consent?</p>

<transactions><script><signature>
Understanding assurance contract in bitcoin scripts
wade king
# Understanding assurance contract in bitcoin scripts

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

I'm having a bit of trouble understanding example 3, the bit coin assurance contract on the bitcoin wiki(<https://en.bitcoin.it/wiki/Contract>) where senders choose to donate money only if 1000BTC total is raised. Here is the description of the assurance contract example:

1. An entrepreneur creates a new address and announces that the good will be created if at least 1000 BTC is raised. Anyone can contribute.
2. Each party wishing to pledge creates a new transaction spending some of their coins to the announced address, but they do not broadcast it. The transaction is similar to a regular transaction except for three differences: Firstly, there cannot be any change. If you don’t have any outputs of the right size, you must create one first by spending to one of your own addresses. Secondly, the input script signature is signed with SIGHASH\_ALL | SIGHASH\_ANYONECANPAY. Finally, the output value is set to 1000 BTC. Note that this is not a valid transaction because the output value is larger than the input value.
3. The transaction is uploaded to the entrepreneur's server, which saves it to disk and updates its count of how many coins have been pledged.
4. Once the server has enough coins, it merges the separate transactions together into a new transaction. The new transaction has a single output that simply spends to the announced address - it is the same as the outputs on each contributed transaction. The inputs to the transaction are collected from the contributed pledges.
5. The finished transaction is broadcast, sending the pledged coins to the announced address.

where each transaction is of the following form from bitcoin wiki(<https://en.bitcoin.it/wiki/Transaction>):

```
Input:
Previous tx: f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6
Index: 0
scriptSig: 304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d10
90db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501

Output:
Value: 1000
scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549d
OP_EQUALVERIFY OP_CHECKSIG

```

I'm having trouble understanding step 4. If the entraprenuer only ends up raising 500BTC and never meets their goal of raising 1000BTC why can't the entraprenuer change the output value to 500BTC, then broadcast the transaction and cash out anyway without each of the the sender's consent?

**Tags:** transactions, script, signature


---

## 1 answers

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

SIGHASH\_ALL | SIGHASH\_ANYONECANPAY signs the outputs. So the entrepreneur cannot change the output, as it would invalidate the signatures on all the inputs he received.

There is another way he can bypass this though - if he has 500 BTC himself (or can borrow that amount very briefly) - he can contribute that himself, getting away with raising only 500 BTC but still taking the coins. The only way around that is having some form of escrow that verifies the payments.


---

