Research/Bitcoin Dev Archive / lightning-dev list
crowdfunding with SIGHASH_ANYONE_CAN_PAY
3 messages, Nov 23 to 24, 2015. Started by Ryan Grant.
Ryan Grant (2), Rusty Russell
Alice intends to pledge to Bob's crowdfunded project, and will create a one-input, one-output, anyone-can-pay transaction, valid for one month. Bob publicized his address, anchored to an open channel on the Lightning Network. Alice has already received Bob's hashed preimage R. They plan to use an intermediary node run by Hubab.
/ the problem /
Alice needs some special Lightning protocol option to indicate that only the final hop should be rewritten and signed as anyone-can-pay.
All other anyone-can-pay donors need to pay to the same output. However, Lightning does not normally reuse public keys for fresh Commitment Transactions.
Bob's Lightning software needs to leave all anyone-can-pay fragments alone until they are valid together.
Crowdsourcing initiatives usually deal in larger amounts of money than the initiators can raise beforehand, which would preclude matching the amount in an initial Funding Transaction.
/ routed option /
Alice sends Hubab a normal channel transaction, using the HTLC, to cover the cost plus fees. Alice can then send Hubab special instructions on how to create a SIGHASH_ANYONE_CAN_PAY for Bob, using the HTLC. Hubab does so.
Bob can receive transactions of arbitrary complexity. Once Bob receives the pledge transaction from Alice, it should not be revoked, as in normal bidirectional use of Lightning channels. It should lie out-of-band until the anyone-can-pay output is claimed. Bob does not update any related Commitment Transactions, until the anyone-can-pay is fulfilled.
Hubab will be able to spend her normal channel transaction when Bob reaches his goal. Bob's crowdfunding software will concatenate scriptPubKeys of the pledges delivered by Hubab, with their HTLCs, to claim the anyone-can-pay output, releasing R.
/ other issues /
Crowdfunding events could lock up money for a long time, since execution is not handed over to the network when the HTLC commitment is initiated. Lightning Network nodes will price their fees accordingly. When fee discovery comes about, it should be aware of the different transaction types.
Pledges have longer lives than payments, and it's not an error to change one's mind about them. The protocol needs an update_revoke_pledge_htlc, to revoke accepted pledges that have not yet expired or caused other errors.
Hubab may need to route further, to Carol. Hubab needs to be aware of more in the route than her handoff address, such as whether the next destination is final.
Hubab (or Carol), when signing the SIGHASH_ANYONE_CAN_PAY transaction, needs to select an input matching the exact amount.
Did I get this right?
Is there a simpler way to do crowdfunding with the Lightning Network?
This was an interesting thought experiment for me, but upon reflection there's no point in trying to do this in Lightning.
Everyone considering a pledge can sign their part of the transaction, for free, if they hold any coins on the Bitcoin blockchain. Only the initiator needs to pay any transaction fee.
Ryan Grant <bitcoin-dev at rgrant.org> writes:
Quoted text (6 lines)
> This was an interesting thought experiment for me, but upon reflection > there's no point in trying to do this in Lightning. > > Everyone considering a pledge can sign their part of the transaction, > for free, if they hold any coins on the Bitcoin blockchain. Only the > initiator needs to pay any transaction fee.
Sure, but maybe you've got lightning funds already?
Let's continue your analysis. We already know the protocol can be extended to pay to anything (what I have been calling "Atomic swap to X").
The general problem with swapping onto the blockchain is that it needs to be able to time out, since the basic deal is of form "I will pay you $5 iff you give me R in the next 24 hours". That can't be done natively in script, but it can be done as follows:
First create a tx with a small output with scriptPubkey of form "pay to me, or after <timeout> pay to anyone". Use that as one input to your crowdfunding tx.
After the timeout, anyone can double-spend and thus invalidate the crowdfunding tx (make the amount cover a the expected txfee, and it's free money).
Cheers, Rusty.