Skip to content

Commit 203c5b7

Browse files
Merge pull request #734 from lightninglabs/docs-faraday
Update faraday documentation
2 parents dede15c + cec6d2c commit 203c5b7

File tree

1 file changed

+117
-57
lines changed

1 file changed

+117
-57
lines changed

docs/faraday/accounting.md

Lines changed: 117 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
11
# Accounting Reports
22
Faraday produces accounting reports on a node's on chain and off chain activity.
3-
These reports are formatted using the [Harmony Reporting Standard](https://github.com/harmony-csv/harmony).
3+
These reports are formatted using the [Harmony Reporting
4+
Standard](https://github.com/harmony-csv/harmony).
45
This document provides a description of the entries in these reports.
56

67
## Bitcoin Backend
7-
It is strongly recommended that Faraday is run with a connection to a Bitcon node when these reports are generated. This is required to lookup fee entries for channel close transactions and sweep fees. If a connection to a bitcoin node is not provided, warnings will be logged for the transactions that do not have fee entries.
8+
It is strongly recommended that Faraday is run with a connection to a Bitcoin
9+
node when these reports are generated. This is required to lookup fee entries
10+
for channel close transactions and sweep fees. If a connection to a bitcoin node
11+
is not provided, warnings will be logged for the transactions that do not have
12+
fee entries.
813

914
## Common Fields
10-
For brevity, the following fields which have the same meaning for each entry will be omitted:
11-
- Timestamp: The timestamp of the block that the channel open transaction appeared in.
12-
- Fiat: The value of the amount field in specified currency. Note that values less than one satoshi will be rounded down to zero.
15+
For brevity, the following fields which have the same meaning for each entry
16+
will be omitted:
17+
- Timestamp: The timestamp of the block that the channel open transaction
18+
appeared in.
19+
- Fiat: The value of the amount field in specified currency. Note that values
20+
less than one satoshi will be rounded down to zero.
1321
- OnChain: Whether the transaction occurred off chain, or on chain.
14-
- Credit: True when an entry increased our balances, false when an entry decreased our balances.
22+
- Credit: True when an entry increased our balances, false when an entry
23+
decreased our balances.
1524

16-
Note that fee entries reference the entry they are associated with by appending a fee marker (:-1) to the original reference. The fee entry will have a reference formatted as follows: `original reference:-1`.
25+
Note that fee entries reference the entry they are associated with by appending
26+
a fee marker (:-1) to the original reference. The fee entry will have a
27+
reference formatted as follows: `original reference:-1`.
1728

1829
## On Chain Reports
1930

@@ -22,8 +33,9 @@ Local channel open entry types represent channel opens that were initiated by
2233
our node. These entries are accompanied by a separate Channel Open Fees entry,
2334
because the opening party pays on chain fees.
2435

25-
- Amount: The amount in millisatoshis that we added to the channel, excluding on chain fees.
26-
- TxID: The on chain transaction ID for the channel open.
36+
- Amount: The amount in millisatoshis that we added to the channel, excluding on
37+
chain fees.
38+
- TXID: The on chain transaction ID for the channel open.
2739
- Reference: The unique channel ID assigned to the channel.
2840
- Note: A note with details of who opened the channel.
2941

@@ -42,82 +54,113 @@ The fees paid to open a channel that we initiated.
4254
Remote channel open entry types represent channels that were opened by remote
4355
peers.
4456

45-
- Amount: Zero, our balance is unaffected by remote channel creation, with the exception of a push amount listed below.
46-
- TxID: The on chain transaction ID for the channel open.
57+
- Amount: Zero, our balance is unaffected by remote channel creation, except for
58+
a push amount listed below.
59+
- TXID: The on chain transaction ID for the channel open.
4760
- Reference: The unique channel ID assigned to the channel.
4861
- Note: A note containing the pubkey of the peer that opened a channel to us.
4962

5063
Known Omissions:
51-
- Remote peers may push balance to our node as part of the funding flow. This amount is not currently included in these reports.
64+
- Remote peers may push balance to our node as part of the funding flow. This
65+
amount is not currently included in these reports.
5266

5367
### Channel Close
5468
Channel close entries represent the on chain close of a channel.
5569

56-
- Amount: The amount in millisatoshis that was paid out to us immediately on channel close.
57-
- TxID: The on chain transaction ID for the channel close.
70+
- Amount: The amount in millisatoshis that was paid out to us immediately on
71+
channel close.
72+
- TXID: The on chain transaction ID for the channel close.
5873
- Reference: The channel close transaction ID.
5974
- Note: A note indicating the type of channel close, and who initiated it.
6075

6176
Known Omissions:
62-
- If our balance is encumbered behind a timelock, or in an unresolved htlc, it will not be paid out as part of this transaction and must be resolved by follow up on chain transactions.
77+
- If our balance is encumbered behind a timelock, or in an unresolved HTLC, it
78+
will not be paid out as part of this transaction and must be resolved by
79+
follow up on chain transactions.
6380

6481
### Channel Close Fee
65-
Channel close fee entries represent the fees we paid on chain to close channels that we initiated. Note that this includes the case where we opened the channel but the remote party closed the channel.
82+
Channel close fee entries represent the fees we paid on chain to close channels
83+
that we initiated. Note that this includes the case where we opened the channel
84+
but the remote party closed the channel.
6685

67-
- Amount: The amount in millisatoshis that we paid in on chain fees to close the channel.
68-
- TxID: The on chain transaction ID for the channel close.
86+
- Amount: The amount in millisatoshis that we paid in on chain fees to close the
87+
channel.
88+
- TXID: The on chain transaction ID for the channel close.
6989
- Reference: The channel close transaction ID:-1.
7090
- Note: Not set for close fees.
7191

7292
Known Omissions:
73-
- If a channel was closed before we started saving our channel information for use after close (<lnd 0.9), we will not know which party opened the channel, so fees may be omitted.
93+
- If a channel was closed before we started saving our channel information for
94+
use after close (<lnd 0.9), we will not know which party opened the channel,
95+
so fees may be omitted.
7496

7597
### Receipt
76-
A receipt is an on chain transaction which paid to our wallet which was not related to the opening/closing of channels.
98+
A receipt is an on chain transaction which paid to our wallet which was not
99+
related to the opening/closing of channels.
77100

78-
- Amount: The amount in millisatoshis that was paid to an address controlled by our wallet.
79-
- TxID: The on chain transaction ID.
101+
- Amount: The amount in millisatoshis that was paid to an address controlled by
102+
our wallet.
103+
- TXID: The on chain transaction ID.
80104
- Reference: The on chain transaction ID.
81-
- Note: An optional label set on transaction publish (see [lnd transaction labels](https://github.com/lightningnetwork/lnd/blob/master/lnrpc/walletrpc/walletkit.proto#L136)).
105+
- Note: An optional label set on transaction publish (see
106+
[lnd transaction labels][1]).
82107

83108
Known Omissions:
84-
- This entry type will include on chain resolutions for channel closes that sweep balances back to our node.
109+
- This entry type will include on chain resolutions for channel closes that
110+
sweep balances back to our node.
85111

86112
### Payment
87-
A payment is an on chain transaction which was paid from our wallet and was not related to the opening/closing of channels.
88-
- Amount: The amount in millisatoshis that was paid from an address controlled by our wallet.
89-
- TxID: The on chain transaction ID.
113+
A payment is an on chain transaction which was paid from our wallet and was not
114+
related to the opening/closing of channels.
115+
- Amount: The amount in millisatoshis that was paid from an address controlled
116+
by our wallet.
117+
- TXID: The on chain transaction ID.
90118
- Reference: The on chain transaction ID.
91-
- Note: An optional label set on transaction publish (see [lnd transaction labels](https://github.com/lightningnetwork/lnd/blob/master/lnrpc/walletrpc/walletkit.proto#L136)).
119+
- Note: An optional label set on transaction publish (see
120+
[lnd transaction labels][1]).
92121

93122
Known Omissions:
94-
- This entry type will include the on chain resolution of htlcs when we force close on our peers and have to settle or fail them on chain.
95-
- The current accounting package does not support accounting for payments with duplicate payment hashes, which were allowed in previous versions of lnd. Duplicate payments should be deleted or a time range that does not include them should be specified.
96-
- Legacy payments that were made in older versions of lnd that were created without a payment request will not have any information stored about their destination. We therefore cannot identify whether these are circular payments (they will be identified as regular payments). A warning will be logged when we encounter this type of payment.
123+
- This entry type will include the on chain resolution of HTLCs when we force
124+
close on our peers and have to settle or fail them on chain.
125+
- The current accounting package does not support accounting for payments with
126+
duplicate payment hashes, which were allowed in previous versions of lnd.
127+
Duplicate payments should be deleted or a time range that does not include
128+
them should be specified.
129+
- Legacy payments that were made in older versions of lnd that were created
130+
without a payment request will not have any information stored about their
131+
destination. We therefore cannot identify whether these are circular payments
132+
(they will be identified as regular payments). A warning will be logged when
133+
we encounter this type of payment.
97134

98135
### Fee
99136
A fee entry represents the on chain fees we paid for a transaction.
100137

101138
- Amount: The amount in millisatoshis that was paid in fees from our wallet.
102-
- TxID: The on chain transaction ID.
139+
- TXID: The on chain transaction ID.
103140
- Reference: TransactionID:-1.
104141
- Note: Note set for fees.
105142

106143
### Sweep
107-
A sweep is an on chain transaction which is used to sweep our own funds back to our wallet. This is required when a channel is force closed and need to sweep time locked commitment outputs, htlcs or both.
144+
A sweep is an on chain transaction which is used to sweep our own funds back to
145+
our wallet. This is required when a channel is force closed and need to sweep
146+
time locked commitment outputs, HTLCs or both.
108147

109-
- TxID: The on chain transaction ID.
148+
- TXID: The on chain transaction ID.
110149
- Reference: The on chain transaction ID.
111-
- Note: An optional label set on transaction publish (see [lnd transaction labels](https://github.com/lightningnetwork/lnd/blob/master/lnrpc/walletrpc/walletkit.proto#L136)).
150+
- Note: An optional label set on transaction publish (see
151+
[lnd transaction labels][1]).
112152

113153
Known Omissions:
114-
- Note that this entry type does not include the first stage success/timeout transactions that are required to resolve htlcs when we force close on our peer. We currently do not have the information required to identify these transactions available, so they are included in payments, see known omissions.
154+
- Note that this entry type does not include the first stage success/timeout
155+
transactions that are required to resolve HTLCs when we force close on our
156+
peer. We currently do not have the information required to identify these
157+
transactions available, so they are included in payments, see known omissions.
115158

116159
### Sweep Fee
117160
A fee entry represents the on chain fees we paid for a sweep.
118161

119162
- Amount: The amount in millisatoshis that was paid in fees from our wallet.
120-
- TxID: The on chain transaction ID.
163+
- TXID: The on chain transaction ID.
121164
- Reference: TransactionID:-1.
122165
- Note: Not set for fees.
123166

@@ -126,68 +169,85 @@ A fee entry represents the on chain fees we paid for a sweep.
126169
### Receipt
127170
Receipts off chain represent invoices that are paid via the Lightning Network.
128171

129-
- Amount: The amount in millisatoshis that we were paid, note that this may be greater than the original invoice value.
130-
- TxID: The payment hash of the invoice.
172+
- Amount: The amount in millisatoshis that we were paid, note that this may be
173+
greater than the original invoice value.
174+
- TXID: The payment hash of the invoice.
131175
- Reference: The preimage of the invoice.
132-
- Note: Optionally set if the invoice had a memo attached, was overpaid, or was a keysend.
176+
- Note: Optionally set if the invoice had a memo attached, was overpaid, or was
177+
a keysend.
133178

134179
### Circular Receipt
135180
Circular receipts record instances where we have paid one of our own invoices.
136181

137-
- Amount: The amount in millisatoshis that we were paid, note that this may be greater than the original invoice value.
138-
- TxID: The payment hash of the invoice.
182+
- Amount: The amount in millisatoshis that we were paid, note that this may be
183+
greater than the original invoice value.
184+
- TXID: The payment hash of the invoice.
139185
- Reference: The preimage of the invoice.
140-
- Note: Optionally set if the invoice had a memo attached, was overpaid, or was a keysend.
186+
- Note: Optionally set if the invoice had a memo attached, was overpaid, or was
187+
a keysend.
141188

142189
### Payment
143190
Payments off chain represent payments made via the Lightning Network.
144191

145-
- Amount: The amount in millisatoshis that we paid, excluding the off chain fees paid.
146-
- TxID: The payment hash.
192+
- Amount: The amount in millisatoshis that we paid, excluding the off chain fees
193+
paid.
194+
- TXID: The payment hash.
147195
- Reference: Unique payment ID: Payment Preimage.
148196
- Note: The node pubkey that the payment was made to.
149197

150198
### Fee
151199
- Amount: The amount in millisatoshis that was paid in off chain fees.
152-
- TxID: The payment hash.
200+
- TXID: The payment hash.
153201
- Reference: Unique payment ID: Payment Preimage: -1.
154202
- Note: The node pubkey that the payment was made to.
155203

156204
### Circular Payment
157-
Circular payments represent payments made to our own node to rebalance channels. These payments are paid from our node to one of our own invoices.
205+
Circular payments represent payments made to our own node to re-balance
206+
channels. These payments are paid from our node to one of our own invoices.
158207

159208
- Amount: The amount that was rebalanced.
160-
- TxID: The payment hash.
209+
- TXID: The payment hash.
161210
- Reference: Unique payment ID: Payment Preimage.
162211
- Note: The node pubkey that the payment was made to.
163212

164213
### Circular Payment Fee
165-
Circular payment fees represent the fees we paid to loop a circular payment to ourselves.
214+
Circular payment fees represent the fees we paid to loop a circular payment to
215+
ourselves.
166216

167217
- Amount: The amount that was paid in off chain fees.
168-
- TxID: The payment hash.
218+
- TXID: The payment hash.
169219
- Reference: Unique payment ID: Payment Preimage: -1.
170220
- Note: The node pubkey that the payment was made to.
171221

172222
### Forwards
173-
A forward represents a payment that arrives at our node on an incoming channel and is forwarded out on an outgoing channel in exchange for fees. The forward itself does not changes our balance, since it just shifts funds over our channels. We include forwarding entries with zero balances for completeness. Forwarding fee entries reflect the increase in our holdings from the fee we are paid.
174-
175-
- Amount: Zero, forwards do not change our balance except for fees, which are separated out.
176-
- TxID: Timestamp: Incoming Channel ID: Outgoing Channel ID.
223+
A forward represents a payment that arrives at our node on an incoming channel
224+
and is forwarded out on an outgoing channel in exchange for fees. The forward
225+
itself does not changes our balance, since it just shifts funds over our
226+
channels. We include forwarding entries with zero balances for completeness.
227+
Forwarding fee entries reflect the increase in our holdings from the fee we are
228+
paid.
229+
230+
- Amount: Zero, forwards do not change our balance except for fees, which are
231+
separated out.
232+
- TXID: Timestamp: Incoming Channel ID: Outgoing Channel ID.
177233
- Reference: Not set for forwards.
178234
- Note: The amounts that were forwarded in and out of our node.
179235

180236
Known Omissions:
181-
- We use incoming and outgoing channel ID paired with timestamp as a best-effort version of a txid. Note that this is not strictly unique for a single htlc, it is theoretically possible for two htlcs to pass through the same channel with the same timestamp.
237+
- We use incoming and outgoing channel ID paired with timestamp as a best-effort
238+
version of a TXID. Note that this is not strictly unique for a single HTLC, it
239+
is theoretically possible for two HTLCs to pass through the same channel with
240+
the same timestamp.
182241

183242
### Forward Fee
184243
Forward fee entries represent the fees we earned from forwarding payments.
185244

186245
- Amount: The amount in millisatoshis of fees we earned from the forward.
187-
- TxID: Timestamp: Incoming Channel ID: Outgoing Channel ID.
246+
- TXID: Timestamp: Incoming Channel ID: Outgoing Channel ID.
188247
- Reference: Not set for forwards.
189248
- Note: Not set for forwards.
190249

191250
Known Omissions:
192-
- See the note on txids in the Forwards section.
251+
- See the note on TXIDs in the Forwards section.
193252

253+
[1]: https://github.com/lightningnetwork/lnd/blob/master/lnrpc/walletrpc/walletkit.proto#L136

0 commit comments

Comments
 (0)