Skip to content

Commit

Permalink
bkp: debug invalid peer_id
Browse files Browse the repository at this point in the history
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
  • Loading branch information
vincenzopalazzo committed Sep 25, 2022
1 parent d0daef1 commit fcfccb4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
3 changes: 2 additions & 1 deletion doc/lightning-listpeers.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,5 @@ If **connected** is *true*:
- **features** (hex): bitmap of BOLT #9 features from peer's INIT message
- **remote\_addr** (string, optional): The public IPv4/6 address the peer sees us from, e.g. 1.2.3.4:1234

[comment]: # ( SHA256STAMP:4029720c7824ee1d6d029bbf0df18702ada64527f7df987438f55dea1ca6797d)
=======
[comment]: # ( SHA256STAMP:8ea63ab95c5ca859442a6b0e8e4e112bb51710da6001dcfac23a7def949bbd7e)
1 change: 1 addition & 0 deletions lightningd/dual_open_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ void json_add_unsaved_channel(struct json_stream *response,

oa = channel->open_attempt;

assert(peer);
json_object_start(response, NULL);
json_add_node_id(response, "peer_id", &peer->id);
json_add_bool(response, "peer_connected", peer->connected);
Expand Down
1 change: 1 addition & 0 deletions lightningd/peer_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ static void json_add_channel(struct lightningd *ld,
struct state_change_entry *state_changes;
u32 feerate;

assert(peer);
json_object_start(response, key);
json_add_node_id(response, "peer_id", &peer->id);
json_add_bool(response, "peer_connected", peer->connected);
Expand Down
11 changes: 5 additions & 6 deletions plugins/bkpr/bookkeeper.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#include "common/status_levels.h"
#include "config.h"
#include "lightningd/log.h"
#include <ccan/array_size/array_size.h>
#include <ccan/cast/cast.h>
#include <ccan/json_escape/json_escape.h>
Expand Down Expand Up @@ -618,7 +616,6 @@ static bool new_missed_channel_account(struct command *cmd,
size_t i;
const jsmntok_t *curr_chan, *chan_arr_tok;

plugin_log(cmd->plugin, LOG_DBG, "new_missed_channel_account JSON payload: %s", buf);
chan_arr_tok = json_get_member(buf, result, "channels");
assert(chan_arr_tok && chan_arr_tok->type == JSMN_ARRAY);

Expand All @@ -632,12 +629,14 @@ static bool new_missed_channel_account(struct command *cmd,
bool ok, is_opener, is_leased;

err = json_scan(tmpctx, buf, curr_chan,
"{channel_id:%,"
"{peer_id:%,"
"channel_id:%,"
"funding_txid:%,"
"funding_outnum:%,"
"funding:{local_funds_msat:%,"
"remote_funds_msat:%},"
"opener:%}",
JSON_SCAN(json_to_node_id, &peer_id),
JSON_SCAN_TAL(tmpctx, json_strdup, &chan_id),
JSON_SCAN(json_to_txid, &opt.txid),
JSON_SCAN(json_to_number, &opt.n),
Expand Down Expand Up @@ -850,7 +849,7 @@ static struct command_result *log_error(struct command *cmd,
return notification_handled(cmd);
}

static struct command_result * listpeerchannels_multi_done(struct command *cmd,
static struct command_result *listpeerchannels_multi_done(struct command *cmd,
const char *buf,
const jsmntok_t *result,
struct new_account_info **new_accts)
Expand Down Expand Up @@ -901,14 +900,14 @@ static struct command_result * listpeerchannels_multi_done(struct command *cmd,
info->timestamp - 1,
credit_diff, debit_diff);
}

plugin_log(cmd->plugin, LOG_DBG, "Snapshot balances updated");
return notification_handled(cmd);
}

static char *do_account_close_checks(const tal_t *ctx,
struct chain_event *e,
struct account *acct)

{
struct account *closed_acct;

Expand Down
14 changes: 7 additions & 7 deletions tests/test_opening.py
Original file line number Diff line number Diff line change
Expand Up @@ -1772,12 +1772,12 @@ def test_zeroreserve(node_factory, bitcoind):
wait_for(lambda: l3.channel_state(l1) == 'CHANNELD_NORMAL')

# Now make sure we all agree on each others reserves
l1c1 = l1.rpc.listpeers(l2.info['id'])['peers'][0]['channels'][0]
l2c1 = l2.rpc.listpeers(l1.info['id'])['peers'][0]['channels'][0]
l2c2 = l2.rpc.listpeers(l3.info['id'])['peers'][0]['channels'][0]
l3c2 = l3.rpc.listpeers(l2.info['id'])['peers'][0]['channels'][0]
l3c3 = l3.rpc.listpeers(l1.info['id'])['peers'][0]['channels'][0]
l1c3 = l1.rpc.listpeers(l3.info['id'])['peers'][0]['channels'][0]
l1c1 = l1.rpc.listpeerchannels(l2.info['id'])['channels'][0]
l2c1 = l2.rpc.listpeerchannels(l1.info['id'])['channels'][0]
l2c2 = l2.rpc.listpeerchannels(l3.info['id'])['channels'][0]
l3c2 = l3.rpc.listpeerchannels(l2.info['id'])['channels'][0]
l3c3 = l3.rpc.listpeerchannels(l1.info['id'])['channels'][0]
l1c3 = l1.rpc.listpeerchannels(l3.info['id'])['channels'][0]

# l1 imposed a 0sat reserve on l2, while l2 imposed the default 1% reserve on l1
assert l1c1['their_reserve_msat'] == l2c1['our_reserve_msat'] == Millisatoshi('0sat')
Expand All @@ -1797,7 +1797,7 @@ def test_zeroreserve(node_factory, bitcoind):
l2.drain(l1)

# Remember that this is the reserve l1 imposed on l2, so l2 can drain completely
l2c1 = l2.rpc.listpeers(l1.info['id'])['peers'][0]['channels'][0]
l2c1 = l2.rpc.listpeerchannels(l1.info['id'])['channels'][0]

# And despite us briefly being above dust (with a to_us output),
# closing should result in the output being trimmed again since we
Expand Down

0 comments on commit fcfccb4

Please sign in to comment.