Uh oh!
There was an error while loading. Please reload this page.
Add method to count total fees in a Route #999 - #1063
Conversation
Codecov Report
@@ Coverage Diff @@## main #1063 +/- ##
==========================================
- Coverage 90.82% 90.74% -0.08%
==========================================
Files 65 65 Lines 32890 33948 +1058 ==========================================
+ Hits 29872 30806 +934 - Misses 3018 3142 +124
Continue to review full report at Codecov.
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…devkit#999 * Added `get_total_fees` method to route, to calculate all the fees paid accross each path. * Added `get_total_amount` method to route, to calculate the total of actual amounts paid in each path.
03aaa9d to
03bb808Comparegalderz
commented
Sep 21, 2021
Reworked unit tests and added an extra |
| /// This doesn't include any extra payment made to the recipient, | ||
| /// which can happen in excess of the amount passed to `get_route`'s `final_value_msat`. |
There was a problem hiding this comment.
nit: lines should be 100chars each
| .flat_map(|path| path.split_last().unwrap().1) | ||
| .map(|hop| &hop.fee_msat) | ||
| .sum(); | ||
| } |
| .map(|hop| &hop.fee_msat) | ||
| .sum(); | ||
| } | ||
| /// Returns the total amount paid on this Route, excluding the fees. |
There was a problem hiding this comment.
nit: ticks around Route and above
| .sum(); | ||
| } | ||
| /// Returns the total amount paid on this Route, excluding the fees. | ||
| pub fn get_total_amount(&self) -> u64 { |
There was a problem hiding this comment.
Idk if it's worth noting for these methods that they'll panic for 0-length routes?
| RouteHop { | ||
| pubkey: PublicKey::from_slice(&hex::decode("02eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619").unwrap()[..]).unwrap(), | ||
| channel_features: ChannelFeatures::empty(), node_features: NodeFeatures::empty(), | ||
| short_channel_id: 0, fee_msat: 100, cltv_expiry_delta: 0 // Test vectors are garbage and not generateble from a RouteHop, we fill in payloads manually |
There was a problem hiding this comment.
nit here and below: s/generateble/generatable (i think these comments can all be deleted though 😛)
TheBlueMatt
commented
Sep 21, 2021
Gonna land this, will handle val's comments in a new PR. |
Part of #999. Add a member function for Route that returns the total amount of fees paid across all paths.
Further work will be carried out following @valentinewallace's work in #1053, so that the same can be calculated post payment. This implies taking into account which payments were really confirmed and discard what failed or was retried.