How to let surplus go to fundraiser in ANYONECANPAY crowdfunding script?

2

ANYONECANPAY can be used for crowdfunding, where pledged donations cannot be spent unless funding goal/soft cap is reached. But since output is committed, when soft cap is exceed, all the surplus will go to transaction fee. Any way to make the exceeded part to go to the fundraiser as ICOs typically do?

ALL|ANYONECANPAY

This construction can be used to make a "crowdfunding”-style transaction. Someone attempting to raise funds can construct a transaction with a single output. The single output pays the "goal" amount to the fundraiser. Such a transaction is obviously not valid, as it has no inputs. However, others can now amend it by adding an input of their own, as a donation. They sign their own input with ALL|ANYONECANPAY. Unless enough inputs are gathered to reach the value of the output, the transaction is invalid. Each donation is a "pledge," which cannot be collected by the fundraiser until the entire goal amount is raised.

sinoTrinity

Posted 2018-09-03T18:17:37.090

Reputation: 147

Answers

0

Not by only using SIGHASH_ALL|SIGHASH_ANYONECANPAY. This is because the outputs cannot be modified.

SIGHASH_ALL|SIGHASH_ANYONECANPAY signs all of the outputs but only this one input, and it also allows anyone to add or remove other inputs, so anyone can contribute additional satoshis but they cannot change how many satoshis are sent nor where they go. - https://bitcoin.org/en/developer-guide#signature-hash-types.

But, the fundraiser does not have to submit the transaction that includes additional funds (because that would not benefit them, only miners). Once the first transaction is complete (minimum has been met), then others can verify that the minimum amount of funds have been raised, and then just create a normal transaction to the fundraiser.

JBaczuk

Posted 2018-09-03T18:17:37.090

Reputation: 6 172

What if when the minimum is first reached, it is exceeded by a large amount? For example, 1st pledge is 50 Bitcoins and 2nd is also 50 while the minimum is 60. Any way to get around this, with or without ANYONECANPAY?sinoTrinity 2018-09-05T07:14:08.023

What do you mean "get around this"?JBaczuk 2018-09-05T11:58:28.533

Getting around this constraint and receive full pledged amount, e.g., 50+50 Bitcoins?sinoTrinity 2018-09-05T20:23:05.933

You can create multiple transactions. If a funder is worried about not meeting a minimum, then they can wait until the first SIGHASH_ANYONECANPAY transaction confirms.JBaczuk 2018-09-05T20:43:12.163

> multiple transactions? What do u mean? > first SIGHASH_ANYONECANPAY transaction confirms? SIGHASH_ANYONECANPAY inputs are merged into a final transaction after minimum is reached and broadcast. What do u mean first tx confirms? There is only 1 tx.sinoTrinity 2018-09-10T20:12:49.777

After the minimum is reached, the transaction is broadcast, mined, and confirmed. Now investors can verify that the minimum was met. There is no need to add surplus to the same transaction, so why not allow investors to just send additional transactions after the first tx is confirmed?JBaczuk 2018-09-10T20:42:23.657

How would it work if 1st pledge is 50 Bitcoins and 2nd is also 50 while the minimum is 60?sinoTrinity 2018-09-10T21:48:54.453

You can warn users if their pledge goes over before they commit. That way, they can create a separate normal transaction for the excess after it's broadcasted.JBaczuk 2018-09-10T22:32:54.887