Skip to content

Commit

Permalink
BOLT 3: define closing transaction.
Browse files Browse the repository at this point in the history
The only surprise here (maybe?) is that we use the commitment number encoding.
I think that makes sense, but it was unspecified before.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Jul 4, 2017
1 parent f55adff commit 5d27a11
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions 03-transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This details the exact format of on-chain transactions, which both sides need to
* [Received HTLC Outputs](#received-htlc-outputs)
* [Trimmed Outputs](#trimmed-outputs)
* [HTLC-Timeout and HTLC-Success Transactions](#htlc-timeout-and-htlc-success-transactions)
* [Closing Transaction](#closing-transaction)
* [Fees](#fees)
* [Fee Calculation](#fee-calculation)
* [Fee Payment](#fee-payment)
Expand Down Expand Up @@ -234,6 +235,45 @@ The witness script for the output is:

To spend this via penalty, the remote node uses a witness stack `<revocationsig> 1` and to collect the output the local node uses an input with nSequence `to_self_delay` and a witness stack `<local_delayedsig> 0`

## Closing Transaction

Note that there are two possible variants for each node.

* version: 2
* locktime: 0
* txin count: 1
* `txin[0]` outpoint: `txid` and `output_index` from `funding_created` message
* `txin[0]` sequence: 0xFFFFFFFF
* `txin[0]` script bytes: 0
* `txin[0]` witness: `0 <signature_for_key1> <signature_for_key2>`
* txout count: 0, 1 or 2
* `txout` amount: final balance to be paid to one node (minus `fee_satoshis` from `closing_signed` if this peer funded the channel)
* `txout` script: as specified in that node's `scriptpubkey` in its `shutdown` message.

### Requirements

Each node offering MUST subtract the fee given by `fee_satoshis` from
the output to the funder. Each node MUST then remove any output below
the `dust_limit_satoshis` of the node offering `closing_signed`, and
MAY also eliminate its own output.

### Rationale

There is a possibility of irreparable differences on closing if one
node considers the other's output too small to allow propagation on
the bitcoin network (aka "dust"), and that other node instead
considers that output to be too valuable to discard. This is why each
side uses its own `dust_limit_satoshis`, and the result can be a
signature validation failure, if they disagree on what the closing
transaction should look like.

However, if one side chooses to eliminate its own output, there's no
reason for the other side to fail the closing protocol, so this is
explicitly allowed. The signature will indicate which variant
has been used.

It is assumed that `dust_limit_satoshis` is greater than the funding

## Fees

### Fee Calculation
Expand Down

0 comments on commit 5d27a11

Please sign in to comment.