diff --git a/lightningd/pay.c b/lightningd/pay.c index bd798453b..11df40669 100644 --- a/lightningd/pay.c +++ b/lightningd/pay.c @@ -351,11 +351,22 @@ remote_routing_failure(const tal_t *ctx, report_to_gossipd = true; else report_to_gossipd = false; - } else + erring_node = &route_nodes[origin_index]; + } else { /* Report the *next* channel as failing. */ erring_channel = &route_channels[origin_index + 1]; - erring_node = &route_nodes[origin_index]; + /* If the error is a BADONION, then it's on behalf of the + * following node. */ + if (failcode & BADONION) { + log_debug(log, "failcode %u => erring_node %s", + failcode, + type_to_string(tmpctx, struct pubkey, + &route_nodes[origin_index + 1])); + erring_node = &route_nodes[origin_index + 1]; + } else + erring_node = &route_nodes[origin_index]; + } routing_failure->erring_index = (unsigned int) (origin_index + 1); routing_failure->failcode = failcode; diff --git a/tests/test_misc.py b/tests/test_misc.py index 69c98b279..3cef21ccd 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -1137,7 +1137,6 @@ def test_check_command(node_factory): sock.close() -@pytest.mark.xfail(strict=True) def test_bad_onion(node_factory, bitcoind): """Test that we get a reasonable error from sendpay when an onion is bad""" l1, l2, l3, l4 = node_factory.line_graph(4, wait_for_announce=True)