Documentation ¶
Index ¶
Constants ¶
const Subsystem = "ACNT"
Subsystem defines the logging code for this subsystem.
Variables ¶
var ErrReceiveWithFee = errors.New("on chain receive with non-zero fee")
ErrReceiveWithFee is returned if we get an on chain receive with a fee, which we do not expect.
Functions ¶
func FeeReference ¶
FeeReference returns a special unique reference for the fee paid on a transaction. We use the reference of the original entry with :-1 to denote that this entry is associated with the original entry.
Types ¶
type CommonConfig ¶
type CommonConfig struct { // StartTime is the time from which the report should be created, // inclusive. StartTime time.Time // EndTime is the time until which the report should be created, // exclusive. EndTime time.Time // DisableFiat is set if we want to produce a report without fiat // conversions. This is useful for testing, and for cases where our fiat // data api may be down. DisableFiat bool // PriceSourceCfg is the config to be used for initialising the // PriceSource used for fiat related queries. PriceSourceCfg *fiat.PriceSourceConfig // Categories is a set of custom categories which should be added to the // report. Categories []CustomCategory }
CommonConfig contains the items that are common to both types of requests.
type CustomCategory ¶
type CustomCategory struct { // Name is the custom name for the category. Name string // Regexes is a slice of regexes which we will use to match labels. If // a label matches any one expression in this set, it is considered // part of the category. Regexes []*regexp.Regexp }
CustomCategory describes a custom category which can be used to identify special case groups of transactions.
func NewCustomCategory ¶
func NewCustomCategory(name string, regexes []string) (*CustomCategory, error)
NewCustomCategory creates compiles the set of regexes provided and returning a new category. This function assumes that each regex is unique.
type EntryType ¶
type EntryType int
EntryType indicates the lightning specific type of an entry.
const ( // EntryTypeLocalChannelOpen represents the funding transaction we // created to open a channel to a remote peer. EntryTypeLocalChannelOpen EntryType // EntryTypeRemoteChannelOpen represents the funding transaction that // our peer created to open a channel to us. EntryTypeRemoteChannelOpen // EntryTypeChannelOpenFee records the fees we paid on chain when // opening a channel to a remote peer. EntryTypeChannelOpenFee // EntryTypeChannelClose represents a channel closing transaction. If // we were paid out a balance by this transaction, the entry will // contain that amount. Note that the on chain resolutions required to // resolve a force close are not contained in this category. If we // force closed, our own balance will also require further on chain // resolution, so it will not be included. EntryTypeChannelClose // EntryTypeReceipt indicates that we have received a payment. Off // chain, this receipt is an invoice that we were paid via lightning. // On chain, this receipt is an on chain transaction paying into our // wallet. EntryTypeReceipt // EntryTypePayment indicates that we have made a payment. Off chain, // this payment is a lightning payment to an invoice. On chain, this // receipt is an on chain transaction paying from our wallet. EntryTypePayment // EntryTypeFee represent fees paid for on chain transactions or off // chain routing. Note that this entry type excludes fees for channel // opens and closes. EntryTypeFee // EntryTypeCircularReceipt represents an invoice that we paid to // ourselves. This occurs when circular payments are used to rebalance // channels. EntryTypeCircularReceipt // EntryTypeForward represents a forward through our node. EntryTypeForward // EntryTypeForwardFee represents the fees we earned forwarding a // payment. EntryTypeForwardFee // EntryTypeCircularPayment represents an operational payment which // we pay to ourselves to rebalance channels. EntryTypeCircularPayment // EntryTypeCircularPaymentFee represents a the fees paid on an // operational payment paid to ourselves to rebalance channels. EntryTypeCircularPaymentFee // EntryTypeSweep represents an on chain payment which swept funds // back to our own wallet. EntryTypeSweep // EntryTypeSweepFee represents the fees that were paid to sweep funds // back to our own wallet. EntryTypeSweepFee // EntryTypeChannelCloseFee represents fees our node paid to close a // channel. EntryTypeChannelCloseFee )
type HarmonyEntry ¶
type HarmonyEntry struct { // Timestamp is the time at which the event occurred. // On chain events: timestamp will be obtained from the block timestamp. // Off chain events: timestamp will be obtained from lnd's records. Timestamp time.Time // Amount is the balance change incurred by this entry, expressed in // msat. Amount lnwire.MilliSatoshi // FiatValue is the fiat value of this entry's amount. This value is // expressed as a decimal so that we do not lose precision. FiatValue decimal.Decimal // TxID is the transaction ID of this entry. TxID string // Reference is a unique identifier for this entry, if available. Reference string // Note is an optional note field. Note string // Type describes the type of entry. Type EntryType // Category indicates whether the entry is part of a custom category. Category string // OnChain indicates whether the transaction occurred on or off chain. OnChain bool // Credit is true if the amount listed is a credit, and false if it is // a debit. Credit bool // BTCPrice is the timestamped bitcoin price we used to get our fiat // value. BTCPrice *fiat.Price }
HarmonyEntry represents a single action on our balance.
type OffChainConfig ¶
type OffChainConfig struct { CommonConfig // ListInvoices lists all our invoices. ListInvoices func() ([]lndclient.Invoice, error) // ListPayments lists all our payments. ListPayments func() ([]lndclient.Payment, error) // ListForwards lists all our forwards over out relevant period. ListForwards func() ([]lndclient.ForwardingEvent, error) // DecodePayReq decodes a payment request. DecodePayReq decodePaymentRequest // OwnPubKey is our node's public key. We use this value to identify // payments that are made to our own node. OwnPubKey route.Vertex }
OffChainConfig contains all the functionality required to produce an off chain report.
func NewOffChainConfig ¶
func NewOffChainConfig(ctx context.Context, lnd lndclient.LndServices, maxInvoices, maxPayments, maxForwards uint64, ownPubkey route.Vertex, startTime, endTime time.Time, disableFiat bool, priceCfg *fiat.PriceSourceConfig, categories []CustomCategory) *OffChainConfig
NewOffChainConfig creates a config for creating off chain reports. It takes max parameters which allow control over the pagination size for queries to lnd.
type OnChainConfig ¶
type OnChainConfig struct { CommonConfig // OpenChannels provides a list of all currently open channels. OpenChannels func() ([]lndclient.ChannelInfo, error) // ClosedChannels provides a list of all closed channels. ClosedChannels func() ([]lndclient.ClosedChannel, error) // PendingChannels provides a list of our pending channels. PendingChannels func() (*lndclient.PendingChannels, error) // OnChainTransactions provides a list of all on chain transactions // relevant to our wallet over a block range. OnChainTransactions func() ([]lndclient.Transaction, error) // ListSweeps returns the transaction ids of the list of sweeps known // to lnd. ListSweeps func() ([]string, error) // GetFee gets the total fees for a transaction. This function may be // nil if we do not have access to a bitcoin backend to lookup fees. GetFee getFeeFunc }
OnChainConfig contains all the functionality required to produce an on chain report.
func NewOnChainConfig ¶
func NewOnChainConfig(ctx context.Context, lnd lndclient.LndServices, startTime, endTime time.Time, disableFiat bool, txLookup fees.GetDetailsFunc, priceCfg *fiat.PriceSourceConfig, categories []CustomCategory) *OnChainConfig
NewOnChainConfig returns an on chain config from the lnd services provided. The txLookup function may be nil if a connection to a bitcoin backend is not available. If this is the case, the fee report will log warnings indicating that fee lookups are not possible in certain cases.
type Report ¶
type Report []*HarmonyEntry
Report contains a set of entries.
func OffChainReport ¶
func OffChainReport(ctx context.Context, cfg *OffChainConfig) (Report, error)
OffChainReport gets a report of off chain activity using live price data.
func OnChainReport ¶
func OnChainReport(ctx context.Context, cfg *OnChainConfig) (Report, error)
OnChainReport produces a report of our on chain activity for a period using live price data. Note that this report relies on transactions returned by GetTransactions in lnd. If a transaction is not included in this response (eg, a remote party opening a channel to us), it will not be included.