lightninglabs / lightninglabs/faraday

accounting: Add desired units to node report query

Open
#39 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
130
Forks
35
Avg merge
7h 54m
Merged PRs (30d)
5

Description

At present, the node report output query provides BTC values quoted in millisatoshis.
Multiple amount fields can be confusing, so rather than add more fields with our new units, we can deprecate the existing field in `ReportEntry` and replace it with a `oneof`. Since fiat values are subject to rounding (if we round down to BTC, we likely also want to round down our USD amount), we should paid the amount + fiat fields. Calculation in the actual accounting package should **remain in msat**, since it provides us with the best level of precision.

### Steps to completion
1. Add a `unit` enum to `NodeReportRequest` which defaults to `msat` but allows `satoshis` and `bitcoin`, round accordingly in `rpcReportResponse` and make sure the headings in the csv file are updated
1. Deprecate the `amount` and `fiat` fields and replace with a oneof:
```
entryAmount{
amount = 1;
fiat = 2;
}

oneOf{
entryAmount msatAmount =1;
entryAmount satoshiAmount = 2;
entryAmount bitcoinAmount =3;
}
```

~This change should be mindful of the intention to add other fiat currencies, as detailed in #38~

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating NodeReportRequest, ReportEntry, and rpcReportResponse, then review the accounting package to confirm calculations remain in msat. Implement the requested unit selection, paired amount and fiat oneof fields, rounding, and CSV heading updates; done means msat, satoshi, and bitcoin outputs are represented correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.