diff --git a/Boss/Mod/EarningsTracker.cpp b/Boss/Mod/EarningsTracker.cpp index 87a7148b5..a141e0094 100644 --- a/Boss/Mod/EarningsTracker.cpp +++ b/Boss/Mod/EarningsTracker.cpp @@ -235,18 +235,41 @@ class EarningsTracker::Impl { ; )QRY").execute(); + uint64_t total_in_earnings = 0; + uint64_t total_in_expenditures = 0; + uint64_t total_out_earnings = 0; + uint64_t total_out_expenditures = 0; + auto out = Json::Out(); auto obj = out.start_object(); for (auto& r : fetch) { + auto in_earnings = r.get(1); + auto in_expenditures = r.get(2); + auto out_earnings = r.get(3); + auto out_expenditures = r.get(4); auto sub = obj.start_object(r.get(0)); sub - .field("in_earnings", r.get(1)) - .field("in_expenditures", r.get(2)) - .field("out_earnings", r.get(3)) - .field("out_expenditures", r.get(4)) + .field("in_earnings", in_earnings) + .field("in_expenditures", in_expenditures) + .field("out_earnings", out_earnings) + .field("out_expenditures", out_expenditures) ; sub.end_object(); + total_in_earnings += in_earnings; + total_in_expenditures += in_expenditures; + total_out_earnings += out_earnings; + total_out_expenditures += out_expenditures; } + + auto sub = obj.start_object("total"); + sub + .field("in_earnings", total_in_earnings) + .field("in_expenditures", total_in_expenditures) + .field("out_earnings", total_out_earnings) + .field("out_expenditures", total_out_expenditures) + ; + sub.end_object(); + obj.end_object(); tx.commit(); diff --git a/Boss/Mod/ForwardFeeMonitor.cpp b/Boss/Mod/ForwardFeeMonitor.cpp index 6b6df4333..ddc815711 100644 --- a/Boss/Mod/ForwardFeeMonitor.cpp +++ b/Boss/Mod/ForwardFeeMonitor.cpp @@ -29,7 +29,7 @@ void ForwardFeeMonitor::start() { try { auto payload = n.params["forward_event"]; if ( !payload.has("out_channel") - || !payload.has("fee") + || !payload.has("fee_msat") || !payload.has("resolved_time") || !payload.has("received_time") ) diff --git a/docs/earnings_tracker.md b/docs/earnings_tracker.md new file mode 100644 index 000000000..e44974cfa --- /dev/null +++ b/docs/earnings_tracker.md @@ -0,0 +1,21 @@ +# CLBOSS Earnings Tracker + +```mermaid + %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% + + flowchart TB + + style EarningsTracker fill:#9fb,stroke:#333,stroke-width:4px + Initiator-->|DbResource|EarningsTracker + ForwardFeeMonitor-->|ForwardFee|EarningsTracker + EarningsRebalancer-->|RequestMoveFunds|EarningsTracker + FundsMover_Runner-->|ResponseMoveFunds|EarningsTracker + EarningsRebalancer-->|RequestEarningsInfo|EarningsTracker + InitialRebalancer-->|RequestEarningsInfo|EarningsTracker + JitRebalancer-->|RequestEarningsInfo|EarningsTracker + StatusCommand-->|SolicitStatus|EarningsTracker + EarningsTracker-->|ResponseEarningsInfo|EarningsRebalancer + EarningsTracker-->|ResponseEarningsInfo|InitialRebalancer + EarningsTracker-->|ResponseEarningsInfo|JitRebalancer + EarningsTracker-->|ProvideStatus|StatusCommand +``` diff --git a/tests/boss/test_forwardfeemonitor.cpp b/tests/boss/test_forwardfeemonitor.cpp index fefa16526..85a3427cb 100644 --- a/tests/boss/test_forwardfeemonitor.cpp +++ b/tests/boss/test_forwardfeemonitor.cpp @@ -131,7 +131,6 @@ int main() { "in_msat": "100001001msat", "out_msatoshi": 100000000, "out_msat": "100000000msat", - "fee": 1001, "fee_msat": "1001msat", "status": "settled", "received_time": 1560696342.368,