Skip to content

Commit

Permalink
pay: ignore uncommited channels in listpeerchannels output
Browse files Browse the repository at this point in the history
Uncommited channels are missing several fields which would normally be
populated by an active channel.  This simply skips them for the purposes
of finding a route.  The particular culprit was:
{
  "peer_id": "038cd9f3679d5b39bb2105978467918d549572de472f07dd729e37c7a6377d41d5",
  "peer_connected": true,
  "state": "OPENINGD",
  "owner": "lightning_openingd",
  "opener": "local",
  "to_us_msat": 8317559000,
  "total_msat": 8317559000,
  "features": [
    "option_static_remotekey",
    "option_anchors_zero_fee_htlc_tx"
  ]
}

Fixes #7197 - SEGV in direct_pay_listpeerchannels when field private missing

Changelog-Fixed: Fixed crash in pay plugin caused by parsing uncommitted dual open channels
  • Loading branch information
endothermicdev committed Apr 20, 2024
1 parent 688408c commit 2dae71d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
11 changes: 6 additions & 5 deletions plugins/libplugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -2113,11 +2113,6 @@ static struct listpeers_channel *json_to_listpeers_channel(const tal_t *ctx,

chan = tal(ctx, struct listpeers_channel);

json_to_node_id(buffer, idtok, &chan->id);
json_to_bool(buffer, conntok, &chan->connected);
json_to_bool(buffer, privtok, &chan->private);
chan->state = json_strdup(chan, buffer, statetok);
json_to_txid(buffer, ftxidtok, &chan->funding_txid);
if (scidtok != NULL) {
assert(dirtok != NULL);
chan->scid = tal(chan, struct short_channel_id);
Expand Down Expand Up @@ -2154,6 +2149,12 @@ static struct listpeers_channel *json_to_listpeers_channel(const tal_t *ctx,
if (!chan->scid && !chan->alias[LOCAL])
return tal_free(chan);

json_to_node_id(buffer, idtok, &chan->id);
json_to_bool(buffer, conntok, &chan->connected);
json_to_bool(buffer, privtok, &chan->private);
chan->state = json_strdup(chan, buffer, statetok);
json_to_txid(buffer, ftxidtok, &chan->funding_txid);

json_to_int(buffer, dirtok, &chan->direction);
json_to_msat(buffer, tmsattok, &chan->total_msat);
json_to_msat(buffer, smsattok, &chan->spendable_msat);
Expand Down
1 change: 0 additions & 1 deletion tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -5590,7 +5590,6 @@ def test_pay_partial_msat(node_factory, executor):
l3pay.result(TIMEOUT)


@pytest.mark.xfail(strict=True)
def test_pay_while_opening_channel(node_factory, bitcoind, executor):
delay_plugin = {'plugin': os.path.join(os.getcwd(),
'tests/plugins/openchannel_hook_delay.py'),
Expand Down

0 comments on commit 2dae71d

Please sign in to comment.