mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 06:41:44 +01:00
openingd: Set minimum_depth=0 if peer is allowed to do zeroconf
Creates a copy of `our_features` for the uncommitted channel so we can customize it per peer.
This commit is contained in:
parent
936507eb08
commit
9574c0d89c
3 changed files with 34 additions and 0 deletions
|
@ -48,6 +48,10 @@ new_uncommitted_channel(struct peer *peer)
|
|||
uc->transient_billboard = NULL;
|
||||
uc->dbid = wallet_get_channel_dbid(ld->wallet);
|
||||
|
||||
/* Need to have a copy since these might end up being
|
||||
* peer-specific. */
|
||||
uc->our_features = feature_set_dup(uc, ld->our_features);
|
||||
|
||||
uc->log = new_log(uc, ld->log_book, &uc->peer->id,
|
||||
"chan#%"PRIu64, uc->dbid);
|
||||
|
||||
|
@ -163,3 +167,10 @@ void channel_config(struct lightningd *ld,
|
|||
/* This is filled in by lightning_openingd, for consistency. */
|
||||
ours->channel_reserve = AMOUNT_SAT(UINT64_MAX);
|
||||
}
|
||||
|
||||
bool opening_zeroconf_allow(struct lightningd *ld, struct node_id *peer)
|
||||
{
|
||||
/* FIXME: Actually read the options from `ld` and return
|
||||
* `true` if we were configured to do so. */
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -58,6 +58,10 @@ struct uncommitted_channel {
|
|||
|
||||
/* Our channel config. */
|
||||
struct channel_config our_config;
|
||||
|
||||
/* Features we propose to this peer. This is a copy of
|
||||
* ld->our_features, but customized for this specific peer. */
|
||||
struct feature_set *our_features;
|
||||
};
|
||||
|
||||
struct funding_channel {
|
||||
|
@ -123,4 +127,18 @@ void channel_config(struct lightningd *ld,
|
|||
u32 *max_to_self_delay,
|
||||
struct amount_msat *min_effective_htlc_capacity);
|
||||
|
||||
/**
|
||||
* Are we ok with this peer opening a zeroconf channel?
|
||||
*
|
||||
* Determines whether we'd be happy to open or accept a zeroconf
|
||||
* channel with this peers. It is used to selectively apply the
|
||||
* `option_zeroconf` to the `init` message we'll send to the peer when
|
||||
* a connection is established. This is sticky, as in it applies to
|
||||
* all channels we'll open or accept on this connection. Notice that
|
||||
* this does not differentiate between opening of accepting a channel,
|
||||
* and that's because the accepter doesn't get a say in the channel
|
||||
* negotiation.
|
||||
*/
|
||||
bool opening_zeroconf_allow(struct lightningd *ld, struct node_id *peer);
|
||||
|
||||
#endif /* LIGHTNING_LIGHTNINGD_OPENING_COMMON_H */
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <common/addr.h>
|
||||
#include <common/blockheight_states.h>
|
||||
#include <common/configdir.h>
|
||||
#include <common/features.h>
|
||||
#include <common/fee_states.h>
|
||||
#include <common/json_command.h>
|
||||
#include <common/json_helpers.h>
|
||||
|
@ -896,6 +897,10 @@ bool peer_start_openingd(struct peer *peer, struct peer_fd *peer_fd)
|
|||
* reasonable to avoid double-spending of the funding transaction.
|
||||
*/
|
||||
uc->minimum_depth = peer->ld->config.anchor_confirms;
|
||||
#ifdef EXPERIMENTAL_FEATURES /* zeroconf */
|
||||
if (opening_zeroconf_allow(peer->ld, &peer->id)) {
|
||||
uc->minimum_depth = 0;
|
||||
}
|
||||
|
||||
msg = towire_openingd_init(NULL,
|
||||
chainparams,
|
||||
|
|
Loading…
Add table
Reference in a new issue