Updating the balance of a Payment Channel

Commitment Transactions

After the payment channel has been open, Alice wants to pay Bob 0.02 BTC. The payments between the two parties are executed using a special type of transaction called a Commitment Transaction.
These transactions are special because they:

  • can be revoked (canceled) if both parties agree to do so
  • always spend from the 2-of-2 multisig Output of the Funding Transaction
Multiple Commitment Transactions inside a Payment Channel

Pay-Me-First Transaction

In the Pay-Me-First transaction Alice can spend her output immediately, while Bob has to comply with the RSM Contract. A Revocable Sequence Maturity Contract puts several restrictions on spending the Output:

  • the beneficiary of the funds can only spend them after a “maturation” period has passed (is delayed)
  • the contract can be revoked (by the beneficiary)
  • if the contract was revoked and the beneficiary still tries to spend the funds then it risks penalty (loosing all the funds)
The Pay-Me-First transaction created by Alice

Pay-Other-First Transaction

In the Pay-Other-First transaction Bob can spend his output immediately, while Alice has to comply with the RSM Contract. This transaction is more advantageous for Bob. You can view a sample of this transaction here.

The Pay-Other-First transaction created by Alice
The Pay-Other-First transaction created by Alice

Channel State Update — Step By Step

Next we will take a look in detail at what happens when Alice pays Bob 0.02 BTC using a Lightning Network payment channel.

Alice Builds and Signs

Alice builds and signs her Pay-Me-First transaction
Alice builds and signs her Pay-Me-First transaction
  1. BuildPayMeFirstTx( alice) — Alice builds the transaction that pays her 0.08 BTC with no restrictions and 0.02 BTC to Bob under the RSM Contract. We name this transaction payAliceFirstTx.
  2. Sign(payAliceFirstTx) — Alice signs payAliceFirstTx transaction and creates a signature named payAliceFirstSignature.
  3. Send(payAliceFirstSignature) — Alice sends the payAliceFirstSignature to Bob. There is no risk for her sending this signature. The worst case scenario is that Bob will close the channel and will broadcast payAliceFirstTx, which is fine for Alice since she can spend her output right away, while Bob has to wait.
    By broadcasting payAliceFirstTx, Bob also discloses that he received the 0.02 BTC from Alice. If instead of closing the channel Bob becomes unresponsive then Alice can safely broadcast the previous transaction where she has a larger amount (State01) since she has not revoked the current commitment transaction yet.

Bob checks and revokes

Bob checks the signature from Alice and revokes the previous state
Bob checks the signature from Alice and revokes the previous state
Alice receives the revocation message for State01
Alice receives the revocation message for State01

Bob builds and signs

Bob builds and signs the Pay-Me-First transaction
Bob builds and signs the Pay-Me-First transaction

Alice checks and revokes

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store