Skip to content

forwarding ability: change forwarding volume to msat in RPC - #251

Merged
bitromortac merged 3 commits into
lightninglabs:masterfrom
bitromortac:2608-forwarding-volume-msat
Aug 26, 2026
Merged

bitromortac merged 3 commits into
lightninglabs:masterfrom
bitromortac:2608-forwarding-volume-msat

Conversation

@bitromortac

Copy link
Copy Markdown
Contributor

Changes the ForwardingAbility endpoint to report the volume in msat to prevent precision loss. The effective uptime is changed to a uint64 in order to be consistent in the handling of durations in the proto.

@bitromortac
bitromortac requested a review from ViktorT-11 August 26, 2026 08:56

@ViktorT-11 ViktorT-11 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🔥! Just leaving 2 nits leaving some consistency feedback.

Comment thread frdrpcserver/forwarding_ability_test.go Resolved
Comment thread frdrpc/forwarding_ability_codec_test.go Resolved
The forwarding ability endpoint reported per-pair volume in satoshis while
lnd hands us every forward amount in millisatoshis, so the analyzer floored
each forward to a whole satoshi before summing it. A pair carrying only
sub-satoshi forwards reported zero volume and had to be recognised by its
forward count alone, and the CLI's fee rate needed a factor of 1000 to
divide millisatoshi fees by satoshi volume.

Summing at the granularity lnd reports means no forward is floored away and
the fee rate falls out as a plain unitless fraction. The field is renamed
forwarded_sat to forwarded_msat rather than kept, so a REST consumer that
misses the change reads a missing field instead of a value that is silently
1000 times too small.

int64 millisatoshis reaches 92.2 million BTC, over four times the supply, so
the narrower unit costs nothing in range.
Effective uptime is a duration, and the two second-valued fields already in
the schema, ChannelInsight's monitored_seconds and uptime_seconds, are both
unsigned. Aligning effective_uptime_s with them puts the non-negativity in
the type, and it costs nothing at the boundary: the analyzer measures uptime
as a time.Duration and the server derives whole seconds from it.

The msat quantities beside it stay signed. They are the operands of
arithmetic a consumer actually performs, deltas between windows and volume
divided by forward count, where a signed result surfaces a mistake as a
negative rather than as a number near 2^64. That reasoning does not reach a
duration nobody subtracts, and it matches the seven signed msat fields the
schema already carries.

MinQualifyingUptime returns the same unsigned count, so the comparison it
feeds needs no conversion. Its "admits nothing" sentinel becomes MaxUint64.
Decoding an up-but-idle pair now clamps the window before adopting it as an
uptime, since a response whose end precedes its start would otherwise
reconstruct a near-infinite one instead of a negative one.
@bitromortac
bitromortac force-pushed the 2608-forwarding-volume-msat branch from d02540c to cb91843 Compare August 26, 2026 10:12
@bitromortac
bitromortac merged commit 12cc0db into lightninglabs:master Aug 26, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants