How to properly start state channels

5 replies 380 views
Posts: 5 · Reputation: 91
#1Apr 28, 2021, 08:07 AM
Hey folks, I could use some clarity on how to kick off a state channel. Let’s break it down: picture this as a one-way channel with Alice on one end, the buyer, and Bob on the other, the seller. I came across some info saying that to start the channel, Alice needs to sign a transaction that sends funds to a 2-of-2 multisig address (her and Bob). This already raises a red flag for me. Why would anyone want to give up complete control of their funds to someone they don’t know? Then I stumbled upon something in Mastering Bitcoin, which mentioned that Alice should first sign a refund transaction before she goes ahead with the funding transaction. She’d get Bob to sign it too and send it back. By having that refund transaction, which she keeps under wraps as long as Bob behaves, she can then feel secure about signing and broadcasting the 2-of-2 multisig funding transaction. That part clicks for me. But here’s what I’m puzzled about: how can you even create (let alone sign) the refund transaction if its input is supposed to be the output of the funding transaction that hasn’t even happened yet?
5 Reply Quote Share
Posts: 5 · Reputation: 91
#2Apr 28, 2021, 12:50 PM
The answer is in LN whitepaper: " 3.1.2 Spending from an Unsigned Transaction The Lightning Network uses a SIGHASH NOINPUT transaction to spend from this 2-of-2 Funding Transaction output, as it is necessary to spend from a transaction for which the signatures are not yet exchanged. SIGHASH NOINPUT, implemented using a soft-fork, ensures transactions can be spent from before it is signed by all parties, as transactions would need to be signed to get a transaction ID without new sighash flags. Without SIGHASH NOINPUT, Bitcoin transactions cannot be spent from before they may be broadcast —it’s as if one could not draft a contract without paying the other party first. SIGHASH NOINPUT resolves this problem. See Appendix A for more information and implementation." Reading in appendix A: "Without SIGHASH NOINPUT, one cannot build outputs before the transaction can be funded. It is as if one cannot make any agreements without committing funds without knowing what one is committing to. SIGHASH NOINPUT allows one to build redemption for transactions which do not yet exist. In other words, one can form agreements before funding the transaction if the output is a 2-of-2 multisignature transaction." OK so SIGHASH NOINPUT is what makes this possible and indeed answer my question. The paper doesn't go into too much details of actual implementation of this. If anyone knows a resource where one can dig to the bottom about these Bitcoin script puzzles it would be much appreciated! Cheers
0 Reply Quote Share
im_lynxHero Member
Posts: 515 · Reputation: 2161
#3Apr 28, 2021, 01:45 PM
How about Mastering the Lightning Network (LN) by Andreas M. Antonopoulos? It's still on my read-this list and I only glimpsed over very few chapters. Therefore I can't say if it suits you or you'll find what you want to know about Lightning Network. If it's similar to Mastering Bitcoin, at least I won't be disappointed.
4 Reply Quote Share
Posts: 5 · Reputation: 91
#4Apr 28, 2021, 03:51 PM
Thanks for the link. Looks like an interesting resource indeed.
0 Reply Quote Share
alt21Senior Member
Posts: 398 · Reputation: 1732
#5Apr 28, 2021, 06:04 PM
It's an incredible book and I highly suggest it. You can find all of his books here: https://aantonop.com/books/ dislaimer: I have only read the ones that refer to bitcoin
4 Reply Quote Share
Posts: 5 · Reputation: 91
#6Apr 28, 2021, 06:40 PM
In fact this is made possible by SegWit softfork. SIGHASH_NOINPUT does not exist. Seems like these BIP aren't well understood by majority of bitcoiners. That's interesting!
2 Reply Quote Share
?Reply
Sign in to reply to this topic

Related topics