How do Bitcoin payment channels work?

I would like to know how payment channel mechanic works in practice. What do the involved parties need to do, which information they exchange and how is the security ensured.

Bonus question: What different types of payment channels exist?

Only answers that actually explain channels will qualify for the bounty. While linking to 3rd party sources is encouraged and desired, answers that solely do that won’t count.

Submit an answer See answers Share on Twitter Share on Facebook
Answers
Accepted Answer

Accepted: Leverage nSequence and nLockTime while passing raw transactions around

https://wiki.bitcoinsv.io/index.php/Payment_Channels

Above link for reference.

First party would create a transaction that is malleable in some way (ex. sighash_single) , sign yet keep nSequence below the max value and nlocktime at some point in the future so the tx cannot be mined.

Parties would pass the raw tx back, forth and around changing inputs and outputs as needed, with SIGHASH_Single they could even add or modify OP_RETURN outputs or modify with metadata about the transaction. This can be done with simple HTTP API POST requests of the raw transaction.

The security is ensured by setting nlocktime in the future (to prevent premature broadcast) and incrementing the nSequence with signatures so that inputs cannot be arbitrarily invalidated.

The possibilities are quite endless, but this is the mechanism in which 2 or more parties would negotiate and/or modify data within a payment channel.

Once completed, the last party to update will finalize the nSequence for all inputs, or allow the nlocktime to expire so the tx becomes valid and broadcasts it to the network.

Below for reference as well: https://wiki.bitcoinsv.io/index.php/NLocktime_and_nSequence

This is the way we did it on Zixo wallet(will be out soon)

Let’s say we have two parties here, you(user) and a merchant(service provider)

  1. You create a transaction(tx1) to the multisig address with the requirement of two signature for spending(which you and the service provider have the keys but you don’t hand it over to the service provider or broadcast it to the network, you just give the txid(with enough info for using it as UTXO) to the service provider and tell him to use this txid as a UTXO and creates a new tx(tx2) to your address with a nlocktime of one day(for example) and a non-final sequence number, and signs his part and gives it to you.
  2. When you receive the tx2, you broadcast tx1 and tx2(the second one is optional and is better to be broadcasted later).
  3. So, now you have paid some money to a channel and will get the money back in one day if you don’t sign any other version of the tx2
  4. Now you request a chunk of the data(here the service is data streaming), and the provider tells you: to receive that, you need to pay 1000 satoshis to XXXXXXXXXXXXXXX address. You update the tx2 with no nlocktime and final sequence number, then partially sign it and send it to the service provider. The service provider DOESN’T broadcast this transaction because if he does, the channel will be closed.
  5. After receiving the confirmation of the payment, the service provider sends the data to you with the price of the next chunk of data
  6. This process can continue until the channel is empty(no money on the multisig address)
  7. Finally one of the parties decides to close the channel(for example user closes his application). In this case, the provider broadcasts the latest version of tx2 and receives his money, if the provider doesn’t broadcast any of tx2 transactions, the money will go back to the user after one day.

You are creating this answer as an anonymous user. If you log in we will be able to store the draft as you write it.

Submit an Answer

By swiping I acknowledge that the answer will be immutably stored on the Bitcoin SV blockchain forever and that I take full responsibility for any legal or other consequences that might be related to that.
Made with in Slovenia.