From 89f382cf399e2dbe9a5457a9aff1207d59e159ac Mon Sep 17 00:00:00 2001 From: niftynei Date: Wed, 19 Oct 2022 14:59:21 -0500 Subject: [PATCH] dual-fund: only allow for liquidity ads if both nodes support anchors Otherwise we'd have to update the liquidity ads spec to get this shipped. --- openingd/dualopend.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/openingd/dualopend.c b/openingd/dualopend.c index 295fa0487..111437923 100644 --- a/openingd/dualopend.c +++ b/openingd/dualopend.c @@ -2070,15 +2070,6 @@ static void accepter_start(struct state *state, const u8 *oc2_msg) else state->upfront_shutdown_script[REMOTE] = NULL; - /* This is an `option_will_fund` request */ - if (open_tlv->request_funds) { - state->requested_lease = tal(state, struct amount_sat); - state->requested_lease->satoshis /* Raw: u64 -> sat conversion */ - = open_tlv->request_funds->requested_sats; - tx_state->blockheight - = open_tlv->request_funds->blockheight; - } - /* BOLT-* #2 * If the peer's revocation basepoint is unknown (e.g. * `open_channel2`), a temporary `channel_id` should be found @@ -2094,6 +2085,23 @@ static void accepter_start(struct state *state, const u8 *oc2_msg) type_to_string(tmpctx, struct channel_id, &cid)); + /* Since anchor outputs are optional, we + * only support liquidity ads if those are enabled. */ + if (open_tlv->request_funds && + !anchors_negotiated(state->our_features, + state->their_features)) + negotiation_failed(state, "liquidity ads not supported," + " no anchors."); + + /* This is an `option_will_fund` request */ + if (open_tlv->request_funds) { + state->requested_lease = tal(state, struct amount_sat); + state->requested_lease->satoshis /* Raw: u64 -> sat conversion */ + = open_tlv->request_funds->requested_sats; + tx_state->blockheight + = open_tlv->request_funds->blockheight; + } + /* BOLT #2: * * The receiving node MUST fail the channel if: