-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closing tx detailed specification #201
Changes from all commits
f7d151d
ff17597
04d318a
e3d9051
45eacb5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
|
@@ -234,6 +235,44 @@ 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: 1 | ||
* 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In what case would having no transaction outputs be warranted or valid? |
||
* `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. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BIP 69 should be used here as well. I'm assuming y'all already do so? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes |
||
### Requirements | ||
|
||
Each node offering a signature MUST subtract the fee given by `fee_satoshis` from | ||
the output to the funder; it MUST then remove any output below its own `dust_limit_satoshis`, 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. | ||
|
||
There will be at least one output if `dust_limit_satoshis` is greater | ||
than twice the funding amount. | ||
|
||
## Fees | ||
|
||
### Fee Calculation | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't that version 2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Roasbeef said version 1, since version 2 only needed for CLTV, which we don't need here. I don't really mind...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using version 1 here allow us to blend in a bit more with regular (non contract) traffic (assuming an eventual saturation of transactions spending segwit inputs).