openingd: Reject zeroconf if the peer is not allowed

We determine whether they are allowed or not based on the hook return
value of `mindepth`. To do so we need to pass that value down to
`openingd` and verify that the `channel_type` and our permissions
match up.
This commit is contained in:
Christian Decker 2023-08-18 10:17:14 +02:00 committed by Rusty Russell
parent 6bc71796c8
commit 71a8e59acd
3 changed files with 13 additions and 2 deletions

View File

@ -725,7 +725,8 @@ openchannel_hook_final(struct openchannel_hook_payload *payload STEALS)
take(towire_openingd_got_offer_reply(NULL, errmsg,
our_upfront_shutdown_script,
upfront_shutdown_script_wallet_index,
payload->uc->reserve)));
payload->uc->reserve,
payload->uc->minimum_depth)));
}
static bool

View File

@ -1126,7 +1126,8 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
if (!fromwire_openingd_got_offer_reply(state, msg, &err_reason,
&state->upfront_shutdown_script[LOCAL],
&state->local_upfront_shutdown_wallet_index,
&reserve))
&reserve,
&state->minimum_depth))
master_badmsg(WIRE_OPENINGD_GOT_OFFER_REPLY, msg);
/* If they give us a reason to reject, do so. */
@ -1136,6 +1137,14 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg)
return NULL;
}
if (channel_type_has(state->channel_type, OPT_ZEROCONF) &&
state->minimum_depth > 0) {
negotiation_failed(
state,
"You required zeroconf, but you're not on our allowlist");
return NULL;
}
if (!state->upfront_shutdown_script[LOCAL])
state->upfront_shutdown_script[LOCAL]
= no_upfront_shutdown_script(state,

View File

@ -51,6 +51,7 @@ msgdata,openingd_got_offer_reply,shutdown_len,u16,
msgdata,openingd_got_offer_reply,our_shutdown_scriptpubkey,?u8,shutdown_len
msgdata,openingd_got_offer_reply,our_shutdown_wallet_index,?u32,
msgdata,openingd_got_offer_reply,reserve,?amount_sat,
msgdata,openingd_got_offer_reply,mindepth,u32,
#include <common/penalty_base.h>
# Openingd->master: we've successfully offered channel.

1 #include <bitcoin/chainparams.h>
51 #include <common/penalty_base.h> msgdata,openingd_got_offer_reply,mindepth,u32,
52 # Openingd->master: we've successfully offered channel. #include <common/penalty_base.h>
53 # This gives their sig, means we can broadcast tx: we're done. # Openingd->master: we've successfully offered channel.
54 # This gives their sig, means we can broadcast tx: we're done.
55 msgtype,openingd_funder_reply,6101
56 msgdata,openingd_funder_reply,their_config,channel_config,
57 msgdata,openingd_funder_reply,first_commit,bitcoin_tx,