diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ebb36114..1092dd16c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. to/from peers, instead of `gossipd` doing that itself. - Test: `python-xdist` is now a dependency for tests. - Logging: JSON connections no longer spam debug logs. - +- Routing: We no longer consider channels that are not usable either because of + their capacity or their `htlc_minimum_msat` parameter (#1777) ### Deprecated Note: You should always set `allow-deprecated-apis=false` to test for diff --git a/gossipd/routing.c b/gossipd/routing.c index bcbae8ffd..2bf5a12ad 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -403,6 +403,10 @@ static void bfg_one_edge(struct node *node, /* Skip this edge if the channel has insufficient * capacity to route the required amount */ continue; + } else if (requiredcap < c->htlc_minimum_msat) { + /* Skip a channels if it indicated that it won't route + * the requeuested amount. */ + continue; } else if (requiredcap + risk >= MAX_MSATOSHI) { SUPERVERBOSE("...extreme %"PRIu64 " + fee %"PRIu64 diff --git a/gossipd/test/run-find_route-specific.c b/gossipd/test/run-find_route-specific.c index dea3e4d24..424c29496 100644 --- a/gossipd/test/run-find_route-specific.c +++ b/gossipd/test/run-find_route-specific.c @@ -115,6 +115,7 @@ get_or_make_connection(struct routing_state *rstate, { struct short_channel_id scid; struct chan *chan; + const int idx = pubkey_idx(from_id, to_id); if (!short_channel_id_from_str(shortid, strlen(shortid), &scid)) abort(); @@ -123,8 +124,11 @@ get_or_make_connection(struct routing_state *rstate, chan = new_chan(rstate, &scid, from_id, to_id); /* Make sure it's seen as initialized (update non-NULL). */ - chan->half[pubkey_idx(from_id, to_id)].channel_update = (void *)chan; + chan->half[idx].channel_update = (void *)chan; + chan->half[idx].htlc_minimum_msat = 0; + chan->satoshis = satoshis; + return &chan->half[pubkey_idx(from_id, to_id)]; } @@ -194,6 +198,7 @@ int main(void) nc->delay = 5; nc->flags = 0; nc->last_timestamp = 1504064344; + nc->htlc_minimum_msat = 100; /* {'active': True, 'short_id': '6989:2:1/1', 'fee_per_kw': 10, 'delay': 5, 'flags': 1, 'destination': '0230ad0e74ea03976b28fda587bb75bdd357a1938af4424156a18265167f5e40ae', 'source': '03c173897878996287a8100469f954dd820fcd8941daed91c327f168f3329be0bf', 'last_update': 1504064344}]} */ nc = get_or_make_connection(rstate, &a, &b, "6989:2:1", 1000); @@ -219,6 +224,11 @@ int main(void) route = find_route(tmpctx, rstate, &a, &c, 999999, riskfactor, 0.0, NULL, &fee); assert(!route); + /* This should fail to returns a route because it is smaller than these + * htlc_minimum_msat on the last channel. */ + route = find_route(tmpctx, rstate, &a, &c, 1, riskfactor, 0.0, NULL, &fee); + assert(!route); + tal_free(tmpctx); secp256k1_context_destroy(secp256k1_ctx); return 0; diff --git a/gossipd/test/run-find_route.c b/gossipd/test/run-find_route.c index 612b46aaa..1863f6b7e 100644 --- a/gossipd/test/run-find_route.c +++ b/gossipd/test/run-find_route.c @@ -130,6 +130,7 @@ static void add_connection(struct routing_state *rstate, c->proportional_fee = proportional_fee; c->delay = delay; c->flags = get_channel_direction(from, to); + c->htlc_minimum_msat = 0; } /* Returns chan connecting from and to: *idx set to refer