Browse Source

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.
fee-tracking2
Christian Decker 6 years ago
committed by Rusty Russell
parent
commit
81f5b89fe3
  1. 1
      CHANGELOG.md
  2. 1
      tests/test_pay.py
  3. 7
      wallet/wallet.c

1
CHANGELOG.md

@ -40,6 +40,7 @@ changes.
- JSON RPC: `ping` now works even after one peer fails to respond. - 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: `getroute` `fuzzpercent` and `pay` `maxfeepercent` can now be > 100.
- JSON RPC: `riskfactor` in `pay` and `getroute` no longer always treated as 1. - 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 deadlock when both peers flood with gossip.
- Protocol: fix occasional long delay on sending `reply_short_channel_ids_end`. - Protocol: fix occasional long delay on sending `reply_short_channel_ids_end`.
- Protocol: re-send `node_announcement` when address/alias/color etc change. - Protocol: re-send `node_announcement` when address/alias/color etc change.

1
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' 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): def test_forward_stats(node_factory):
l1, l2, l3 = node_factory.line_graph(3, announce=True) l1, l2, l3 = node_factory.line_graph(3, announce=True)

7
wallet/wallet.c

@ -798,6 +798,7 @@ void wallet_channel_stats_load(struct wallet *w,
struct channel_stats *stats) struct channel_stats *stats)
{ {
sqlite3_stmt *stmt; sqlite3_stmt *stmt;
int res;
stmt = db_prepare(w->db, stmt = db_prepare(w->db,
"SELECT in_payments_offered, in_payments_fulfilled" "SELECT in_payments_offered, in_payments_fulfilled"
" , in_msatoshi_offered, in_msatoshi_fulfilled" " , in_msatoshi_offered, in_msatoshi_fulfilled"
@ -806,6 +807,12 @@ void wallet_channel_stats_load(struct wallet *w,
" FROM channels" " FROM channels"
" WHERE id = ?"); " WHERE id = ?");
sqlite3_bind_int64(stmt, 1, 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_offered = sqlite3_column_int64(stmt, 0);
stats->in_payments_fulfilled = sqlite3_column_int64(stmt, 1); stats->in_payments_fulfilled = sqlite3_column_int64(stmt, 1);
stats->in_msatoshi_offered = sqlite3_column_int64(stmt, 2); stats->in_msatoshi_offered = sqlite3_column_int64(stmt, 2);

Loading…
Cancel
Save