From 81f5b89fe3ffdf93f2fd07d5aae43b1d328a00eb Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Fri, 12 Oct 2018 14:58:36 +0200 Subject: [PATCH] wallet: Actually load wallet stats when asked to The call to `sqlite3_step` is actually needed, otherwise we'll always get the default values for all types. --- CHANGELOG.md | 1 + tests/test_pay.py | 1 - wallet/wallet.c | 7 +++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd1427da0..295a2e96c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ changes. - JSON RPC: `ping` now works even after one peer fails to respond. - JSON RPC: `getroute` `fuzzpercent` and `pay` `maxfeepercent` can now be > 100. - JSON RPC: `riskfactor` in `pay` and `getroute` no longer always treated as 1. +- JSON-RPC: `listpeers` was always reporting 0 for all stats. - Protocol: fix occasional deadlock when both peers flood with gossip. - Protocol: fix occasional long delay on sending `reply_short_channel_ids_end`. - Protocol: re-send `node_announcement` when address/alias/color etc change. diff --git a/tests/test_pay.py b/tests/test_pay.py index 07843c436..fa39512e0 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -976,7 +976,6 @@ def test_forward_pad_fees_and_cltv(node_factory, bitcoind): assert only_one(l3.rpc.listinvoices('test_forward_pad_fees_and_cltv')['invoices'])['status'] == 'paid' -@pytest.mark.xfail(strict=True) def test_forward_stats(node_factory): l1, l2, l3 = node_factory.line_graph(3, announce=True) diff --git a/wallet/wallet.c b/wallet/wallet.c index aeae341c3..947fbe0d6 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -798,6 +798,7 @@ void wallet_channel_stats_load(struct wallet *w, struct channel_stats *stats) { sqlite3_stmt *stmt; + int res; stmt = db_prepare(w->db, "SELECT in_payments_offered, in_payments_fulfilled" " , in_msatoshi_offered, in_msatoshi_fulfilled" @@ -806,6 +807,12 @@ void wallet_channel_stats_load(struct wallet *w, " FROM channels" " WHERE id = ?"); sqlite3_bind_int64(stmt, 1, id); + + res = sqlite3_step(stmt); + + /* This must succeed, since we know the channel exists */ + assert(res == SQLITE_ROW); + stats->in_payments_offered = sqlite3_column_int64(stmt, 0); stats->in_payments_fulfilled = sqlite3_column_int64(stmt, 1); stats->in_msatoshi_offered = sqlite3_column_int64(stmt, 2);