Skip to content

Commit 8f8783c

Browse files
rustyrussellcdecker
authored andcommitted
pay: correctly blame the *next* node on BADONION error.
The node which sent the error is doing so because the following one sent WIRE_UPDATE_FAIL_MALFORMED_HTLC. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent f5ced1d commit 8f8783c

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lightningd/pay.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,22 @@ remote_routing_failure(const tal_t *ctx,
351351
report_to_gossipd = true;
352352
else
353353
report_to_gossipd = false;
354-
} else
354+
erring_node = &route_nodes[origin_index];
355+
} else {
355356
/* Report the *next* channel as failing. */
356357
erring_channel = &route_channels[origin_index + 1];
357358

358-
erring_node = &route_nodes[origin_index];
359+
/* If the error is a BADONION, then it's on behalf of the
360+
* following node. */
361+
if (failcode & BADONION) {
362+
log_debug(log, "failcode %u => erring_node %s",
363+
failcode,
364+
type_to_string(tmpctx, struct pubkey,
365+
&route_nodes[origin_index + 1]));
366+
erring_node = &route_nodes[origin_index + 1];
367+
} else
368+
erring_node = &route_nodes[origin_index];
369+
}
359370

360371
routing_failure->erring_index = (unsigned int) (origin_index + 1);
361372
routing_failure->failcode = failcode;

tests/test_misc.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,6 @@ def test_check_command(node_factory):
11371137
sock.close()
11381138

11391139

1140-
@pytest.mark.xfail(strict=True)
11411140
def test_bad_onion(node_factory, bitcoind):
11421141
"""Test that we get a reasonable error from sendpay when an onion is bad"""
11431142
l1, l2, l3, l4 = node_factory.line_graph(4, wait_for_announce=True)

0 commit comments

Comments
 (0)