Skip to content
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

accounting: round to nearest whole satoshi for balances, not down #958

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions 03-transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ To allow an opportunity for penalty transactions, in case of a revoked commitmen
The reason for the separate transaction stage for HTLC outputs is so that HTLCs can timeout or be fulfilled even though they are within the `to_self_delay` delay.
Otherwise, the required minimum timeout on HTLCs is lengthened by this delay, causing longer timeouts for HTLCs traversing the network.

The amounts for each output MUST be rounded down to whole satoshis. If this amount, minus the fees for the HTLC transaction, is less than the `dust_limit_satoshis` set by the owner of the commitment transaction, the output MUST NOT be produced (thus the funds add to fees).
The amounts for the `to_local` and `to_remote` outputs MUST be rounded
to the nearest satoshi. Any amount less than 500msat is rounded down;
any amount greater than 499msat is rounded up. This minimizes loss to fees
over the lifetime of a node.

The amounts for each HTLC output MUST be rounded *down* to whole satoshis. If this amount, minus the fees for the HTLC transaction, is less than the `dust_limit_satoshis` set by the owner of the commitment transaction, the output MUST NOT be produced (thus the funds add to fees).

#### `to_local` Output

Expand Down Expand Up @@ -363,7 +368,7 @@ Note that there are two possible variants for each node.
### Requirements

Each node offering a signature:
- MUST round each output down to whole satoshis.
- MUST round each output to the nearest whole satoshi.
- MUST subtract the fee given by `fee_satoshis` from the output to the funder.
- MUST remove any output below its own `dust_limit_satoshis`.
- MAY eliminate its own output.
Expand All @@ -386,6 +391,12 @@ has been used.
There will be at least one output, if the funding amount is greater
than twice `dust_limit_satoshis`.

Output amounts are rounded to the nearest whole satoshi. Any amount less
than 500msat is rounded down; any amount greater than 499msat is rounded up.

This ensures that over the lifetime of a node, the number of satoshis
a node earns/spends will be approximately accurate.

## Fees

### Fee Calculation
Expand Down