1
0
mirror of https://github.com/lightning/bolts.git synced 2024-11-19 10:00:04 +01:00

BOLT 3: Note assumption about to-remote output existing.

Commit a0c4f7cfd1 "BOLT 3: add more detailed commitment transaction
estimation (#26)" simplified the weight formula to assume there was a
to-remote output.

This worst-case 18% error, but it's simple.  Document it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2016-11-30 06:55:30 +10:30
parent a0c4f7cfd1
commit 970b39a40d

View File

@ -149,12 +149,13 @@ transactions is based on the current `feerate-per-kw` and the
The actual and expected weight vary for several reasons:
* Bitcoin uses DER-encoded signatures which vary in size.
* Bitcoin also uses variable-length integers, so a large number of outputs will take 3 bytes to encode rather than 1.
* The `to-remote` output may be below the dust limit.
* The `to-local` output may be below the dust limit once fees are extracted.
Thus we use a simplified formula for *expected weight*, which assumes:
* Signatures are 73 bytes long (the maximum length)
* There is a small number of outputs (thus 1 byte to count them)
* There is always a to-local output.
* There is always both a to-local output and a to-remote output.
The *expected weight* of a commitment transaction is calculated as follows:
@ -268,9 +269,6 @@ The fee for a commitment transaction MUST BE calculated to match:
1. Start with `weight` = 724, and `fee` = 0.
2. If the amount to the remote node is greater or equal to the local
node's `dust-limit-satoshis`, add 136 to `weight`.
3. For every offered HTLC, if the HTLC amount plus the HTLC-timeout
transaction fee is greater or equal to the local node's
`dust-limit-satoshis`, then add 172 to `weight`, otherwise add