To allign with our other projects, move our accounting docs into a base
docs dir. Since we've sent the existing link out, we leave a docs file
pointing to our new docs location so nobody gets lost.
To allow running our accounting report without a backing bitcoin node,
we allow the fee function provided to be nil. In these cases, we log
the entries which we cannot lookup fees for so that users have the
option to manually lookup those fees.
We have a lot of different payment formats in lnd, since the payments
database has been migrated multiple times. We need to account for the
following:
- Legacy payments: settled, no htlcs present
- In flight payments: not settled, no htlcs present
- Keysend payments: no payment request
- Sendpayment + dest: no payment request present
Since we need to list all payments (an invoice settled in our period
could have been send by a payment before the period), we update our
code to not fail in the case where we do not know payment destination.
This will result in legacy circular payments (that were made with no
payment request) not being identified as circular payments (as well as
their corresponding invoices). We log an error for this, and make a
note of it in our docs. This should not be an issue for payments made
by newer versions on lnd, because they have the information we require.
Add payments to off chain report, failing if there are any duplicate
payments in the period being queried. Legacy payments in lnd have
duplicate payments which add significant overhead to dealing with
payments. Rather than carry the tech debt, we do not support these
payments.
Add entry generation for invoices, including the special case where we
made a payment to ourselves. This is common practise for nodes that
manage liquidity with circular rebalancing. We record this as a balance
increase because money has moved; the amount that we gain will be offset
with a circular payment entry of matching amounts when we create payment
records.
Add entries for the close transaction that spends from our funding tx.
Note that this change *does not* account for resolutions that occur
on chain after this close. Since we have to resolve our own balance on
chain for local force closes, these entries may have a zero balance.