1
0
Fork 0
mirror of https://github.com/lightning/bolts.git synced 2025-02-22 14:22:46 +01:00

BOLT 3: Fix fee calculation.

I forgot to add in the amount+scriptsize overhead for each HTLC.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2016-11-24 10:56:13 +10:30
parent 4dde8e6a26
commit 1e7e21b5c6

View file

@ -158,13 +158,13 @@ The *expected weight* of a commitment transaction is calculated as follows:
transaction input: 32 + 4 + 1 + 4
transaction input witness: 1 + 74 + 74 + 1 + 1 + 34 + 34 + 1 + 1
transaction output: 8 + 1
transaction htlc output: 34
transaction to-local output: 34
transaction to-remote output: 25
transaction htlc output script: 34
transaction to-local output script: 34
transaction to-remote output script: 25
Multiplying non-witness data by 4, this gives a weight of:
597 + 136*num-htlc-outputs + 100*to-remote
597 + 172*num-htlc-outputs + 136*to-remote
Where `to-remote` is 0 if the amount is below the local node's
`dust-limit-satoshis`, or 1 otherwise. `num-htlc-outputs` is the
@ -202,12 +202,12 @@ The fee for a commitment transaction MUST BE calculated to match:
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 136 to `weight`, otherwise add
`dust-limit-satoshis`, then add 172 to `weight`, otherwise add
the HTLC amount to `fee`.
4. For every accepted HTLC, if the HTLC amount plus the HTLC-success
transaction fee is greater or equal to the local node's
`dust-limit-satoshis`, then add 136 to `weight`, otherwise add
`dust-limit-satoshis`, then add 172 to `weight`, otherwise add
the HTLC amount to `fee`.
5. Multiply `feerate-per-kw` by `weight`, divide by 1024 (rounding down),