diff --git a/plugins/keysend.c b/plugins/keysend.c index f4b682a52..e3dd2d37a 100644 --- a/plugins/keysend.c +++ b/plugins/keysend.c @@ -65,6 +65,22 @@ static void keysend_cb(struct keysend_data *d, struct payment *p) { "Recipient %s does not support keysend payments " "(no TLV support)", node_id_to_hexstr(tmpctx, p->destination)); + } else if (p->step == PAYMENT_STEP_FAILED) { + /* Now we can look at the error, and the failing node, + and determine whether they didn't like our + attempt. This is required since most nodes don't + explicitly signal support for keysend through the + featurebit method.*/ + + if (p->result != NULL && + node_id_eq(p->destination, p->result->erring_node) && + p->result->failcode == WIRE_INVALID_ONION_PAYLOAD) { + return payment_abort( + p, + "Recipient %s reported an invalid payload, this " + "usually means they don't support keysend.", + node_id_to_hexstr(tmpctx, p->destination)); + } } if (p->step != PAYMENT_STEP_ONION_PAYLOAD) diff --git a/tests/test_pay.py b/tests/test_pay.py index 3eb7bca31..d21b7e80d 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -3049,7 +3049,7 @@ def test_keysend(node_factory): # And finally try to send a keysend payment to l4, which doesn't # support it. It MUST fail. - with pytest.raises(RpcError, match=r"Recipient [0-9a-f]{66} does not support keysend payments"): + with pytest.raises(RpcError, match=r"Recipient [0-9a-f]{66} reported an invalid payload"): l3.rpc.keysend(l4.info['id'], amt)