Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion common/gossmods_listpeerchannels.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ gossmods_from_listpeerchannels_(const tal_t *ctx,
if (scidd.scid.u64 == 0)
continue;

/* Recovery stubs all use the placeholder 1x1x1 SCID. They are
* deliberately not unique and cannot be used for routing. */
if (is_stub_scid(scidd.scid))
continue;

/* Disable if in bad state (it's already false if not connected) */
if (!streq(state, "CHANNELD_NORMAL")
&& !streq(state, "CHANNELD_AWAITING_SPLICE"))
Expand Down Expand Up @@ -178,4 +183,3 @@ gossmods_from_listpeerchannels_(const tal_t *ctx,

return mods;
}

35 changes: 35 additions & 0 deletions tests/test_askrene.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,41 @@ def test_getroutes_auto_localchans(node_factory):
{'short_channel_id_dir': f'2x2x1/{dir12}', 'amount_in_msat': 101000, 'cltv_in': 99 + 6}]])


@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3',
"deletes database, which is assumed sqlite3")
def test_getroutes_ignores_recovery_stubs(node_factory):
l1, l2, l3, l4 = node_factory.get_nodes(4)

# Three stubs guarantee that at least two have the same direction. Since
# every recovery stub has SCID 1x1x1, askrene used to abort while adding
# the second such channel to its no-duplicates additional-cost table.
l1.fundchannel(l2, 100000)
l1.fundchannel(l3, 100000)
l1.fundchannel(l4, 100000)
scb = l1.rpc.staticbackup()['scb']

l2.stop()
l3.stop()
l4.stop()
l1.stop()
os.unlink(os.path.join(l1.daemon.lightning_dir,
TEST_NETWORK,
'lightningd.sqlite3'))
l1.start()
assert len(l1.rpc.recoverchannel(scb)['stubs']) == 3

with pytest.raises(RpcError):
l1.rpc.getroutes(source=l1.info['id'],
destination=l2.info['id'],
amount_msat=1000,
layers=['auto.localchans'],
maxfee_msat=1000,
final_cltv=9)

# A route cannot be found, but the recovery stubs must not crash askrene.
assert l1.rpc.getinfo()['id'] == l1.info['id']


def test_fees_dont_exceed_constraints(node_factory):
msat = 100000000
max_msat = int(msat * 0.45)
Expand Down
Loading