From d76e4e71497b9b10ceed3de8979c77a07d283d57 Mon Sep 17 00:00:00 2001 From: 21M4TW <21m4tw@proton.me> Date: Wed, 28 Jan 2026 15:23:11 +1030 Subject: [PATCH] lightningd: don't allow enableoffer on single-use offer. Changelog-Fixed: enableoffer: Adding an error when trying to activate an used single use offer (don't crash!) --- common/jsonrpc_errors.h | 1 + lightningd/offer.c | 4 ++++ tests/test_pay.py | 1 - 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/common/jsonrpc_errors.h b/common/jsonrpc_errors.h index d3fe80d53..a2ea1bf1b 100644 --- a/common/jsonrpc_errors.h +++ b/common/jsonrpc_errors.h @@ -116,6 +116,7 @@ enum jsonrpc_errcode { OFFER_BAD_INVREQ_REPLY = 1004, OFFER_TIMEOUT = 1005, OFFER_ALREADY_ENABLED = 1006, + OFFER_USED_SINGLE_USE = 1007, /* Errors from datastore command */ DATASTORE_DEL_DOES_NOT_EXIST = 1200, diff --git a/lightningd/offer.c b/lightningd/offer.c index bd4357eb3..50edd4d4f 100644 --- a/lightningd/offer.c +++ b/lightningd/offer.c @@ -282,6 +282,10 @@ static struct command_result *json_enableoffer(struct command *cmd, return command_fail(cmd, OFFER_ALREADY_ENABLED, "offer already active"); + if (offer_status_single(status) && offer_status_used(status)) + return command_fail(cmd, OFFER_USED_SINGLE_USE, + "cannot activate an used single use offer"); + if (command_check_only(cmd)) return command_check_done(cmd); diff --git a/tests/test_pay.py b/tests/test_pay.py index 980f39355..de53bb3c4 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -4509,7 +4509,6 @@ def test_fetchinvoice_3hop(node_factory, bitcoind): l1.rpc.call('fetchinvoice', {'offer': offer1['bolt12']}) -@pytest.mark.xfail(strict=True) def test_fetchinvoice(node_factory, bitcoind): # We remove the conversion plugin on l3, causing it to get upset. l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True,