mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
df: reinitialize dual-funding
Prior to this, all reconnect logic lived in channeld. If you disconnected before we finished building a funding transaction, that was no big deal. Now, however, we're waiting for the funding to lock in in dualopend, instead of handing straight to channeld to wait. So we need a way to restart dualopend.
This commit is contained in:
committed by
Christian Decker
parent
1b6deaffc8
commit
9fdf1ea32a
@@ -1803,6 +1803,7 @@ static unsigned int dual_opend_msg(struct subd *dualopend,
|
||||
|
||||
/* Messages we send */
|
||||
case WIRE_DUALOPEND_INIT:
|
||||
case WIRE_DUALOPEND_REINIT:
|
||||
case WIRE_DUALOPEND_OPENER_INIT:
|
||||
case WIRE_DUALOPEND_GOT_OFFER_REPLY:
|
||||
case WIRE_DUALOPEND_FAIL:
|
||||
@@ -1863,6 +1864,85 @@ AUTODATA(json_command, &openchannel_update_command);
|
||||
AUTODATA(json_command, &openchannel_signed_command);
|
||||
#endif /* EXPERIMENTAL_FEATURES */
|
||||
|
||||
void peer_restart_dualopend(struct peer *peer,
|
||||
struct per_peer_state *pps,
|
||||
struct channel *channel,
|
||||
const u8 *send_msg)
|
||||
{
|
||||
u32 max_to_self_delay;
|
||||
struct amount_msat min_effective_htlc_capacity;
|
||||
struct channel_config unused_config;
|
||||
int hsmfd;
|
||||
u8 *msg;
|
||||
|
||||
hsmfd = hsm_get_client_fd(peer->ld, &peer->id, channel->dbid,
|
||||
HSM_CAP_COMMITMENT_POINT
|
||||
| HSM_CAP_SIGN_REMOTE_TX);
|
||||
|
||||
channel_set_owner(channel,
|
||||
new_channel_subd(peer->ld, "lightning_dualopend",
|
||||
channel, CHANNEL,
|
||||
&peer->id,
|
||||
channel->log, true,
|
||||
dualopend_wire_name,
|
||||
dual_opend_msg,
|
||||
channel_errmsg,
|
||||
channel_set_billboard,
|
||||
take(&pps->peer_fd),
|
||||
take(&pps->gossip_fd),
|
||||
take(&pps->gossip_store_fd),
|
||||
take(&hsmfd), NULL));
|
||||
if (!channel->owner) {
|
||||
log_broken(channel->log, "Could not subdaemon channel: %s",
|
||||
strerror(errno));
|
||||
channel_fail_reconnect_later(channel,
|
||||
"Failed to subdaemon channel");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Find the max self delay and min htlc capacity */
|
||||
channel_config(peer->ld, &unused_config,
|
||||
&max_to_self_delay,
|
||||
&min_effective_htlc_capacity);
|
||||
|
||||
msg = towire_dualopend_reinit(NULL,
|
||||
chainparams,
|
||||
peer->ld->our_features,
|
||||
peer->their_features,
|
||||
&channel->our_config,
|
||||
&channel->channel_info.their_config,
|
||||
&channel->cid,
|
||||
max_to_self_delay,
|
||||
min_effective_htlc_capacity,
|
||||
pps,
|
||||
&channel->local_basepoints,
|
||||
&channel->local_funding_pubkey,
|
||||
&channel->channel_info.remote_fundingkey,
|
||||
channel->minimum_depth,
|
||||
feerate_min(peer->ld, NULL),
|
||||
feerate_max(peer->ld, NULL),
|
||||
&channel->funding_txid,
|
||||
channel->funding_outnum,
|
||||
channel->funding,
|
||||
channel->our_msat,
|
||||
&channel->channel_info.theirbase,
|
||||
&channel->channel_info.remote_per_commit,
|
||||
channel->psbt,
|
||||
channel->opener,
|
||||
channel->scid != NULL,
|
||||
channel->remote_funding_locked,
|
||||
channel->state == CHANNELD_SHUTTING_DOWN,
|
||||
channel->shutdown_scriptpubkey[REMOTE] != NULL,
|
||||
channel->shutdown_scriptpubkey[LOCAL],
|
||||
channel->remote_upfront_shutdown_script,
|
||||
channel->remote_tx_sigs,
|
||||
channel->fee_states,
|
||||
send_msg);
|
||||
|
||||
|
||||
subd_send_msg(channel->owner, take(msg));
|
||||
}
|
||||
|
||||
void peer_start_dualopend(struct peer *peer,
|
||||
struct per_peer_state *pps,
|
||||
const u8 *send_msg)
|
||||
|
||||
@@ -10,6 +10,11 @@ void peer_start_dualopend(struct peer *peer,
|
||||
struct per_peer_state *pps,
|
||||
const u8 *send_msg);
|
||||
|
||||
void peer_restart_dualopend(struct peer *peer,
|
||||
struct per_peer_state *pps,
|
||||
struct channel *channel,
|
||||
const u8 *send_msg);
|
||||
|
||||
void dualopen_tell_depth(struct subd *dualopend,
|
||||
struct channel *channel,
|
||||
u32 depth);
|
||||
|
||||
@@ -1024,9 +1024,18 @@ peer_connected_hook_cb(struct peer_connected_hook_payload *payload STEALS,
|
||||
}
|
||||
case DUALOPEND_OPEN_INIT:
|
||||
case DUALOPEND_AWAITING_LOCKIN:
|
||||
/* FIXME: open dualopend */
|
||||
abort();
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
assert(!channel->owner);
|
||||
|
||||
channel->peer->addr = addr;
|
||||
peer_restart_dualopend(peer, payload->pps,
|
||||
channel, NULL);
|
||||
|
||||
tal_free(payload);
|
||||
return;
|
||||
#else
|
||||
abort();
|
||||
#endif /* EXPERIMENTAL_FEATURES */
|
||||
case CHANNELD_AWAITING_LOCKIN:
|
||||
case CHANNELD_NORMAL:
|
||||
case CHANNELD_SHUTTING_DOWN:
|
||||
@@ -1060,7 +1069,18 @@ send_error:
|
||||
if (feature_negotiated(ld->our_features,
|
||||
peer->their_features,
|
||||
OPT_DUAL_FUND)) {
|
||||
peer_start_dualopend(peer, payload->pps, error);
|
||||
/* if we have a channel, we're actually restarting
|
||||
* dualopend. we only get here if there's an error */
|
||||
if (channel) {
|
||||
assert(!channel->owner);
|
||||
|
||||
assert(channel->state == DUALOPEND_OPEN_INIT
|
||||
|| channel->state == DUALOPEND_AWAITING_LOCKIN);
|
||||
channel->peer->addr = addr;
|
||||
peer_restart_dualopend(peer, payload->pps,
|
||||
channel, error);
|
||||
} else
|
||||
peer_start_dualopend(peer, payload->pps, error);
|
||||
} else
|
||||
#endif /* EXPERIMENTAL_FEATURES */
|
||||
peer_start_openingd(peer, payload->pps, error);
|
||||
|
||||
@@ -501,6 +501,12 @@ void peer_memleak_done(struct command *cmd UNNEEDED, struct subd *leaker UNNEEDE
|
||||
/* Generated stub for peer_normal_channel */
|
||||
struct channel *peer_normal_channel(struct peer *peer UNNEEDED)
|
||||
{ fprintf(stderr, "peer_normal_channel called!\n"); abort(); }
|
||||
/* Generated stub for peer_restart_dualopend */
|
||||
void peer_restart_dualopend(struct peer *peer UNNEEDED,
|
||||
struct per_peer_state *pps UNNEEDED,
|
||||
struct channel *channel UNNEEDED,
|
||||
const u8 *send_msg UNNEEDED)
|
||||
{ fprintf(stderr, "peer_restart_dualopend called!\n"); abort(); }
|
||||
/* Generated stub for peer_start_channeld */
|
||||
void peer_start_channeld(struct channel *channel UNNEEDED,
|
||||
struct per_peer_state *pps UNNEEDED,
|
||||
|
||||
@@ -148,6 +148,9 @@ struct state {
|
||||
/* Tally of which sides are locked, or not */
|
||||
bool funding_locked[NUM_SIDES];
|
||||
|
||||
/* Have we gotten the peer's tx-sigs yet? */
|
||||
bool remote_funding_sigs_rcvd;
|
||||
|
||||
/* PSBT of the funding tx */
|
||||
struct wally_psbt *psbt;
|
||||
|
||||
@@ -156,6 +159,9 @@ struct state {
|
||||
|
||||
/* Are we shutting down? */
|
||||
bool shutdown_sent[NUM_SIDES];
|
||||
|
||||
/* Were we reconnected at start ? */
|
||||
bool reconnected;
|
||||
};
|
||||
|
||||
/* psbt_changeset_get_next - Get next message to send
|
||||
@@ -766,7 +772,7 @@ static void handle_tx_sigs(struct state *state, const u8 *msg)
|
||||
tal_hex(msg, msg));
|
||||
|
||||
/* Maybe they didn't get our funding_locked message ? */
|
||||
if (state->funding_locked[LOCAL]) {
|
||||
if (state->funding_locked[LOCAL] && !state->reconnected) {
|
||||
status_broken("Got WIRE_TX_SIGNATURES after funding locked "
|
||||
"for channel %s, ignoring: %s",
|
||||
type_to_string(tmpctx, struct channel_id,
|
||||
@@ -2381,6 +2387,7 @@ static u8 *handle_master_in(struct state *state)
|
||||
|
||||
/* Handled inline */
|
||||
case WIRE_DUALOPEND_INIT:
|
||||
case WIRE_DUALOPEND_REINIT:
|
||||
case WIRE_DUALOPEND_DEV_MEMLEAK_REPLY:
|
||||
case WIRE_DUALOPEND_FAIL:
|
||||
case WIRE_DUALOPEND_PSBT_UPDATED:
|
||||
@@ -2427,6 +2434,11 @@ static u8 *handle_peer_in(struct state *state)
|
||||
struct channel_id channel_id;
|
||||
|
||||
if (t == WIRE_OPEN_CHANNEL2) {
|
||||
if (state->channel) {
|
||||
status_broken("Unexpected message %s",
|
||||
peer_wire_name(t));
|
||||
peer_failed_connection_lost();
|
||||
}
|
||||
accepter_start(state, msg);
|
||||
return NULL;
|
||||
} else if (t == WIRE_TX_SIGNATURES) {
|
||||
@@ -2485,7 +2497,11 @@ int main(int argc, char *argv[])
|
||||
struct pollfd pollfd[3];
|
||||
struct state *state = tal(NULL, struct state);
|
||||
struct secret *none;
|
||||
struct fee_states *fee_states;
|
||||
enum side opener;
|
||||
u8 *msg, *inner;
|
||||
struct amount_sat total_funding;
|
||||
struct amount_msat our_msat;
|
||||
|
||||
subdaemon_setup(argc, argv);
|
||||
|
||||
@@ -2495,20 +2511,99 @@ int main(int argc, char *argv[])
|
||||
|
||||
/*~ The very first thing we read from lightningd is our init msg */
|
||||
msg = wire_sync_read(tmpctx, REQ_FD);
|
||||
if (!fromwire_dualopend_init(state, msg,
|
||||
&chainparams,
|
||||
&state->our_features,
|
||||
&state->their_features,
|
||||
&state->localconf,
|
||||
&state->max_to_self_delay,
|
||||
&state->min_effective_htlc_capacity,
|
||||
&state->pps,
|
||||
&state->our_points,
|
||||
&state->our_funding_pubkey,
|
||||
&state->minimum_depth,
|
||||
&state->min_feerate, &state->max_feerate,
|
||||
&inner))
|
||||
master_badmsg(WIRE_DUALOPEND_INIT, msg);
|
||||
if (fromwire_dualopend_init(state, msg,
|
||||
&chainparams,
|
||||
&state->our_features,
|
||||
&state->their_features,
|
||||
&state->localconf,
|
||||
&state->max_to_self_delay,
|
||||
&state->min_effective_htlc_capacity,
|
||||
&state->pps,
|
||||
&state->our_points,
|
||||
&state->our_funding_pubkey,
|
||||
&state->minimum_depth,
|
||||
&state->min_feerate,
|
||||
&state->max_feerate,
|
||||
&inner)) {
|
||||
/*~ Initially we're not associated with a channel, but
|
||||
* handle_peer_gossip_or_error compares this. */
|
||||
memset(&state->channel_id, 0, sizeof(state->channel_id));
|
||||
state->channel = NULL;
|
||||
state->remote_funding_sigs_rcvd = false;
|
||||
|
||||
/*~ We set these to NULL, meaning no requirements on shutdown */
|
||||
state->upfront_shutdown_script[LOCAL]
|
||||
= state->upfront_shutdown_script[REMOTE]
|
||||
= NULL;
|
||||
|
||||
/*~ We're not locked or shutting down quite yet */
|
||||
state->funding_locked[LOCAL]
|
||||
= state->funding_locked[REMOTE]
|
||||
= false;
|
||||
state->shutdown_sent[LOCAL]
|
||||
= state->shutdown_sent[REMOTE]
|
||||
= false;
|
||||
|
||||
} else if (fromwire_dualopend_reinit(state, msg,
|
||||
&chainparams,
|
||||
&state->our_features,
|
||||
&state->their_features,
|
||||
&state->localconf,
|
||||
&state->remoteconf,
|
||||
&state->channel_id,
|
||||
&state->max_to_self_delay,
|
||||
&state->min_effective_htlc_capacity,
|
||||
&state->pps,
|
||||
&state->our_points,
|
||||
&state->our_funding_pubkey,
|
||||
&state->their_funding_pubkey,
|
||||
&state->minimum_depth,
|
||||
&state->min_feerate,
|
||||
&state->max_feerate,
|
||||
&state->funding_txid,
|
||||
&state->funding_txout,
|
||||
&total_funding,
|
||||
&our_msat,
|
||||
&state->their_points,
|
||||
&state->first_per_commitment_point[REMOTE],
|
||||
&state->psbt,
|
||||
&opener,
|
||||
&state->funding_locked[LOCAL],
|
||||
&state->funding_locked[REMOTE],
|
||||
&state->shutdown_sent[LOCAL],
|
||||
&state->shutdown_sent[REMOTE],
|
||||
&state->upfront_shutdown_script[LOCAL],
|
||||
&state->upfront_shutdown_script[REMOTE],
|
||||
&state->remote_funding_sigs_rcvd,
|
||||
&fee_states,
|
||||
&inner)) {
|
||||
|
||||
/*~ We only reconnect on channels that the
|
||||
* saved the the database (exchanged commitment sigs) */
|
||||
state->channel = new_initial_channel(state,
|
||||
&state->channel_id,
|
||||
&state->funding_txid,
|
||||
state->funding_txout,
|
||||
state->minimum_depth,
|
||||
total_funding,
|
||||
our_msat,
|
||||
fee_states,
|
||||
&state->localconf,
|
||||
&state->remoteconf,
|
||||
&state->our_points,
|
||||
&state->their_points,
|
||||
&state->our_funding_pubkey,
|
||||
&state->their_funding_pubkey,
|
||||
true, true, opener);
|
||||
|
||||
if (opener == LOCAL)
|
||||
state->our_role = TX_INITIATOR;
|
||||
else
|
||||
state->our_role = TX_ACCEPTER;
|
||||
} else
|
||||
master_badmsg(fromwire_peektype(msg), msg);
|
||||
|
||||
|
||||
|
||||
/* 3 == peer, 4 == gossipd, 5 = gossip_store, 6 = hsmd */
|
||||
per_peer_state_set_fds(state->pps, 3, 4, 5);
|
||||
@@ -2521,21 +2616,9 @@ int main(int argc, char *argv[])
|
||||
tal_free(inner);
|
||||
}
|
||||
|
||||
/*~ Initially we're not associated with a channel, but
|
||||
* handle_peer_gossip_or_error compares this. */
|
||||
memset(&state->channel_id, 0, sizeof(state->channel_id));
|
||||
state->channel = NULL;
|
||||
state->funding_locked[LOCAL] = state->funding_locked[REMOTE] = false;
|
||||
state->shutdown_sent[LOCAL]= state->shutdown_sent[REMOTE] = false;
|
||||
|
||||
for (size_t i = 0; i < NUM_TX_MSGS; i++)
|
||||
state->tx_msg_count[i] = 0;
|
||||
|
||||
/*~ We set these to NULL, meaning no requirements on shutdown */
|
||||
state->upfront_shutdown_script[LOCAL]
|
||||
= state->upfront_shutdown_script[REMOTE]
|
||||
= NULL;
|
||||
|
||||
/*~ We need an initial per-commitment point whether we're funding or
|
||||
* they are, and lightningd has reserved a unique dbid for us already,
|
||||
* so we might as well get the hsm daemon to generate it now. */
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include <common/channel_id.h>
|
||||
#include <common/derive_basepoints.h>
|
||||
#include <common/features.h>
|
||||
#include <common/fee_states.h>
|
||||
#include <common/htlc_wire.h>
|
||||
#include <common/penalty_base.h>
|
||||
#include <common/per_peer_state.h>
|
||||
|
||||
@@ -30,6 +32,46 @@ msgdata,dualopend_init,max_feerate,u32,
|
||||
msgdata,dualopend_init,len,u16,
|
||||
msgdata,dualopend_init,msg,u8,len
|
||||
|
||||
# master-dualopend: peer has reconnected
|
||||
msgtype,dualopend_reinit,7001
|
||||
msgdata,dualopend_reinit,chainparams,chainparams,
|
||||
msgdata,dualopend_reinit,our_feature_set,feature_set,
|
||||
msgdata,dualopend_reinit,their_init_features_len,u16,
|
||||
msgdata,dualopend_reinit,their_init_features,u8,their_init_features_len
|
||||
msgdata,dualopend_reinit,our_config,channel_config,
|
||||
msgdata,dualopend_reinit,their_config,channel_config,
|
||||
msgdata,dualopend_reinit,channel_id,channel_id,
|
||||
msgdata,dualopend_reinit,max_to_self_delay,u32,
|
||||
msgdata,dualopend_reinit,min_effective_htlc_capacity_msat,amount_msat,
|
||||
msgdata,dualopend_reinit,pps,per_peer_state,
|
||||
msgdata,dualopend_reinit,our_basepoints,basepoints,
|
||||
msgdata,dualopend_reinit,our_funding_pubkey,pubkey,
|
||||
msgdata,dualopend_reinit,their_funding_pubkey,pubkey,
|
||||
msgdata,dualopend_reinit,minimum_depth,u32,
|
||||
msgdata,dualopend_reinit,min_feerate,u32,
|
||||
msgdata,dualopend_reinit,max_feerate,u32,
|
||||
msgdata,dualopend_reinit,funding_txid,bitcoin_txid,
|
||||
msgdata,dualopend_reinit,funding_txout,u16,
|
||||
msgdata,dualopend_reinit,funding_satoshi,amount_sat,
|
||||
msgdata,dualopend_reinit,our_funding,amount_msat,
|
||||
msgdata,dualopend_reinit,their_basepoints,basepoints,
|
||||
msgdata,dualopend_reinit,remote_per_commit,pubkey,
|
||||
msgdata,dualopend_reinit,funding_psbt,wally_psbt,
|
||||
msgdata,dualopend_reinit,opener,enum side,
|
||||
msgdata,dualopend_reinit,local_funding_locked,bool,
|
||||
msgdata,dualopend_reinit,remote_funding_locked,bool,
|
||||
msgdata,dualopend_reinit,send_shutdown,bool,
|
||||
msgdata,dualopend_reinit,remote_shutdown_received,bool,
|
||||
msgdata,dualopend_reinit,local_shutdown_len,u16,
|
||||
msgdata,dualopend_reinit,local_shutdown_scriptpubkey,u8,local_shutdown_len
|
||||
msgdata,dualopend_reinit,remote_shutdown_len,u16,
|
||||
msgdata,dualopend_reinit,remote_shutdown_scriptpubkey,u8,remote_shutdown_len
|
||||
msgdata,dualopend_reinit,remote_funding_sigs_received,bool,
|
||||
msgdata,dualopend_reinit,fee_states,fee_states,
|
||||
# Optional msg to send.
|
||||
msgdata,dualopend_reinit,len,u16,
|
||||
msgdata,dualopend_reinit,msg,u8,len
|
||||
|
||||
# dualopend->master: they offered channel, should we continue?
|
||||
msgtype,dualopend_got_offer,7005
|
||||
msgdata,dualopend_got_offer,opener_funding,amount_sat,
|
||||
|
||||
|
Can't render this file because it has a wrong number of fields in line 11.
|
115
openingd/dualopend_wiregen.c
generated
115
openingd/dualopend_wiregen.c
generated
@@ -21,6 +21,7 @@ const char *dualopend_wire_name(int e)
|
||||
|
||||
switch ((enum dualopend_wire)e) {
|
||||
case WIRE_DUALOPEND_INIT: return "WIRE_DUALOPEND_INIT";
|
||||
case WIRE_DUALOPEND_REINIT: return "WIRE_DUALOPEND_REINIT";
|
||||
case WIRE_DUALOPEND_GOT_OFFER: return "WIRE_DUALOPEND_GOT_OFFER";
|
||||
case WIRE_DUALOPEND_GOT_OFFER_REPLY: return "WIRE_DUALOPEND_GOT_OFFER_REPLY";
|
||||
case WIRE_DUALOPEND_COMMIT_RCVD: return "WIRE_DUALOPEND_COMMIT_RCVD";
|
||||
@@ -49,6 +50,7 @@ bool dualopend_wire_is_defined(u16 type)
|
||||
{
|
||||
switch ((enum dualopend_wire)type) {
|
||||
case WIRE_DUALOPEND_INIT:;
|
||||
case WIRE_DUALOPEND_REINIT:;
|
||||
case WIRE_DUALOPEND_GOT_OFFER:;
|
||||
case WIRE_DUALOPEND_GOT_OFFER_REPLY:;
|
||||
case WIRE_DUALOPEND_COMMIT_RCVD:;
|
||||
@@ -144,6 +146,117 @@ bool fromwire_dualopend_init(const tal_t *ctx, const void *p, const struct chain
|
||||
return cursor != NULL;
|
||||
}
|
||||
|
||||
/* WIRE: DUALOPEND_REINIT */
|
||||
/* master-dualopend: peer has reconnected */
|
||||
u8 *towire_dualopend_reinit(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_feature_set, const u8 *their_init_features, const struct channel_config *our_config, const struct channel_config *their_config, const struct channel_id *channel_id, u32 max_to_self_delay, struct amount_msat min_effective_htlc_capacity_msat, const struct per_peer_state *pps, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, const struct pubkey *their_funding_pubkey, u32 minimum_depth, u32 min_feerate, u32 max_feerate, const struct bitcoin_txid *funding_txid, u16 funding_txout, struct amount_sat funding_satoshi, struct amount_msat our_funding, const struct basepoints *their_basepoints, const struct pubkey *remote_per_commit, const struct wally_psbt *funding_psbt, enum side opener, bool local_funding_locked, bool remote_funding_locked, bool send_shutdown, bool remote_shutdown_received, const u8 *local_shutdown_scriptpubkey, const u8 *remote_shutdown_scriptpubkey, bool remote_funding_sigs_received, const struct fee_states *fee_states, const u8 *msg)
|
||||
{
|
||||
u16 their_init_features_len = tal_count(their_init_features);
|
||||
u16 local_shutdown_len = tal_count(local_shutdown_scriptpubkey);
|
||||
u16 remote_shutdown_len = tal_count(remote_shutdown_scriptpubkey);
|
||||
u16 len = tal_count(msg);
|
||||
u8 *p = tal_arr(ctx, u8, 0);
|
||||
|
||||
towire_u16(&p, WIRE_DUALOPEND_REINIT);
|
||||
towire_chainparams(&p, chainparams);
|
||||
towire_feature_set(&p, our_feature_set);
|
||||
towire_u16(&p, their_init_features_len);
|
||||
towire_u8_array(&p, their_init_features, their_init_features_len);
|
||||
towire_channel_config(&p, our_config);
|
||||
towire_channel_config(&p, their_config);
|
||||
towire_channel_id(&p, channel_id);
|
||||
towire_u32(&p, max_to_self_delay);
|
||||
towire_amount_msat(&p, min_effective_htlc_capacity_msat);
|
||||
towire_per_peer_state(&p, pps);
|
||||
towire_basepoints(&p, our_basepoints);
|
||||
towire_pubkey(&p, our_funding_pubkey);
|
||||
towire_pubkey(&p, their_funding_pubkey);
|
||||
towire_u32(&p, minimum_depth);
|
||||
towire_u32(&p, min_feerate);
|
||||
towire_u32(&p, max_feerate);
|
||||
towire_bitcoin_txid(&p, funding_txid);
|
||||
towire_u16(&p, funding_txout);
|
||||
towire_amount_sat(&p, funding_satoshi);
|
||||
towire_amount_msat(&p, our_funding);
|
||||
towire_basepoints(&p, their_basepoints);
|
||||
towire_pubkey(&p, remote_per_commit);
|
||||
towire_wally_psbt(&p, funding_psbt);
|
||||
towire_side(&p, opener);
|
||||
towire_bool(&p, local_funding_locked);
|
||||
towire_bool(&p, remote_funding_locked);
|
||||
towire_bool(&p, send_shutdown);
|
||||
towire_bool(&p, remote_shutdown_received);
|
||||
towire_u16(&p, local_shutdown_len);
|
||||
towire_u8_array(&p, local_shutdown_scriptpubkey, local_shutdown_len);
|
||||
towire_u16(&p, remote_shutdown_len);
|
||||
towire_u8_array(&p, remote_shutdown_scriptpubkey, remote_shutdown_len);
|
||||
towire_bool(&p, remote_funding_sigs_received);
|
||||
towire_fee_states(&p, fee_states);
|
||||
/* Optional msg to send. */
|
||||
towire_u16(&p, len);
|
||||
towire_u8_array(&p, msg, len);
|
||||
|
||||
return memcheck(p, tal_count(p));
|
||||
}
|
||||
bool fromwire_dualopend_reinit(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_feature_set, u8 **their_init_features, struct channel_config *our_config, struct channel_config *their_config, struct channel_id *channel_id, u32 *max_to_self_delay, struct amount_msat *min_effective_htlc_capacity_msat, struct per_peer_state **pps, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, struct pubkey *their_funding_pubkey, u32 *minimum_depth, u32 *min_feerate, u32 *max_feerate, struct bitcoin_txid *funding_txid, u16 *funding_txout, struct amount_sat *funding_satoshi, struct amount_msat *our_funding, struct basepoints *their_basepoints, struct pubkey *remote_per_commit, struct wally_psbt **funding_psbt, enum side *opener, bool *local_funding_locked, bool *remote_funding_locked, bool *send_shutdown, bool *remote_shutdown_received, u8 **local_shutdown_scriptpubkey, u8 **remote_shutdown_scriptpubkey, bool *remote_funding_sigs_received, struct fee_states **fee_states, u8 **msg)
|
||||
{
|
||||
u16 their_init_features_len;
|
||||
u16 local_shutdown_len;
|
||||
u16 remote_shutdown_len;
|
||||
u16 len;
|
||||
|
||||
const u8 *cursor = p;
|
||||
size_t plen = tal_count(p);
|
||||
|
||||
if (fromwire_u16(&cursor, &plen) != WIRE_DUALOPEND_REINIT)
|
||||
return false;
|
||||
fromwire_chainparams(&cursor, &plen, chainparams);
|
||||
*our_feature_set = fromwire_feature_set(ctx, &cursor, &plen);
|
||||
their_init_features_len = fromwire_u16(&cursor, &plen);
|
||||
// 2nd case their_init_features
|
||||
*their_init_features = their_init_features_len ? tal_arr(ctx, u8, their_init_features_len) : NULL;
|
||||
fromwire_u8_array(&cursor, &plen, *their_init_features, their_init_features_len);
|
||||
fromwire_channel_config(&cursor, &plen, our_config);
|
||||
fromwire_channel_config(&cursor, &plen, their_config);
|
||||
fromwire_channel_id(&cursor, &plen, channel_id);
|
||||
*max_to_self_delay = fromwire_u32(&cursor, &plen);
|
||||
*min_effective_htlc_capacity_msat = fromwire_amount_msat(&cursor, &plen);
|
||||
*pps = fromwire_per_peer_state(ctx, &cursor, &plen);
|
||||
fromwire_basepoints(&cursor, &plen, our_basepoints);
|
||||
fromwire_pubkey(&cursor, &plen, our_funding_pubkey);
|
||||
fromwire_pubkey(&cursor, &plen, their_funding_pubkey);
|
||||
*minimum_depth = fromwire_u32(&cursor, &plen);
|
||||
*min_feerate = fromwire_u32(&cursor, &plen);
|
||||
*max_feerate = fromwire_u32(&cursor, &plen);
|
||||
fromwire_bitcoin_txid(&cursor, &plen, funding_txid);
|
||||
*funding_txout = fromwire_u16(&cursor, &plen);
|
||||
*funding_satoshi = fromwire_amount_sat(&cursor, &plen);
|
||||
*our_funding = fromwire_amount_msat(&cursor, &plen);
|
||||
fromwire_basepoints(&cursor, &plen, their_basepoints);
|
||||
fromwire_pubkey(&cursor, &plen, remote_per_commit);
|
||||
*funding_psbt = fromwire_wally_psbt(ctx, &cursor, &plen);
|
||||
*opener = fromwire_side(&cursor, &plen);
|
||||
*local_funding_locked = fromwire_bool(&cursor, &plen);
|
||||
*remote_funding_locked = fromwire_bool(&cursor, &plen);
|
||||
*send_shutdown = fromwire_bool(&cursor, &plen);
|
||||
*remote_shutdown_received = fromwire_bool(&cursor, &plen);
|
||||
local_shutdown_len = fromwire_u16(&cursor, &plen);
|
||||
// 2nd case local_shutdown_scriptpubkey
|
||||
*local_shutdown_scriptpubkey = local_shutdown_len ? tal_arr(ctx, u8, local_shutdown_len) : NULL;
|
||||
fromwire_u8_array(&cursor, &plen, *local_shutdown_scriptpubkey, local_shutdown_len);
|
||||
remote_shutdown_len = fromwire_u16(&cursor, &plen);
|
||||
// 2nd case remote_shutdown_scriptpubkey
|
||||
*remote_shutdown_scriptpubkey = remote_shutdown_len ? tal_arr(ctx, u8, remote_shutdown_len) : NULL;
|
||||
fromwire_u8_array(&cursor, &plen, *remote_shutdown_scriptpubkey, remote_shutdown_len);
|
||||
*remote_funding_sigs_received = fromwire_bool(&cursor, &plen);
|
||||
*fee_states = fromwire_fee_states(ctx, &cursor, &plen);
|
||||
/* Optional msg to send. */
|
||||
len = fromwire_u16(&cursor, &plen);
|
||||
// 2nd case msg
|
||||
*msg = len ? tal_arr(ctx, u8, len) : NULL;
|
||||
fromwire_u8_array(&cursor, &plen, *msg, len);
|
||||
return cursor != NULL;
|
||||
}
|
||||
|
||||
/* WIRE: DUALOPEND_GOT_OFFER */
|
||||
/* dualopend->master: they offered channel */
|
||||
u8 *towire_dualopend_got_offer(const tal_t *ctx, struct amount_sat opener_funding, struct amount_sat dust_limit_satoshis, struct amount_msat max_htlc_value_in_flight_msat, struct amount_msat htlc_minimum_msat, u32 feerate_funding_max, u32 feerate_funding_min, u32 feerate_funding_best, u32 feerate_per_kw, u16 to_self_delay, u16 max_accepted_htlcs, u8 channel_flags, u32 locktime, const u8 *shutdown_scriptpubkey)
|
||||
@@ -679,4 +792,4 @@ bool fromwire_dualopend_dev_memleak_reply(const void *p, bool *leak)
|
||||
*leak = fromwire_bool(&cursor, &plen);
|
||||
return cursor != NULL;
|
||||
}
|
||||
// SHA256STAMP:5b6ccfff2f6cc43eee53e4aed8767fc7ae539d548277bda1c628c51f3191dfe4
|
||||
// SHA256STAMP:02f28abef3ab5503d52f776543a85f6d5682637a8e9f8494beae16ff44896442
|
||||
|
||||
11
openingd/dualopend_wiregen.h
generated
11
openingd/dualopend_wiregen.h
generated
@@ -14,11 +14,15 @@
|
||||
#include <common/channel_id.h>
|
||||
#include <common/derive_basepoints.h>
|
||||
#include <common/features.h>
|
||||
#include <common/fee_states.h>
|
||||
#include <common/htlc_wire.h>
|
||||
#include <common/penalty_base.h>
|
||||
#include <common/per_peer_state.h>
|
||||
|
||||
enum dualopend_wire {
|
||||
WIRE_DUALOPEND_INIT = 7000,
|
||||
/* master-dualopend: peer has reconnected */
|
||||
WIRE_DUALOPEND_REINIT = 7001,
|
||||
/* dualopend->master: they offered channel */
|
||||
WIRE_DUALOPEND_GOT_OFFER = 7005,
|
||||
/* master->dualopend: reply back with our first funding info/contribs */
|
||||
@@ -73,6 +77,11 @@ bool dualopend_wire_is_defined(u16 type);
|
||||
u8 *towire_dualopend_init(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_feature_set, const u8 *their_init_features, const struct channel_config *our_config, u32 max_to_self_delay, struct amount_msat min_effective_htlc_capacity_msat, const struct per_peer_state *pps, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, u32 minimum_depth, u32 min_feerate, u32 max_feerate, const u8 *msg);
|
||||
bool fromwire_dualopend_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_feature_set, u8 **their_init_features, struct channel_config *our_config, u32 *max_to_self_delay, struct amount_msat *min_effective_htlc_capacity_msat, struct per_peer_state **pps, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, u32 *minimum_depth, u32 *min_feerate, u32 *max_feerate, u8 **msg);
|
||||
|
||||
/* WIRE: DUALOPEND_REINIT */
|
||||
/* master-dualopend: peer has reconnected */
|
||||
u8 *towire_dualopend_reinit(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_feature_set, const u8 *their_init_features, const struct channel_config *our_config, const struct channel_config *their_config, const struct channel_id *channel_id, u32 max_to_self_delay, struct amount_msat min_effective_htlc_capacity_msat, const struct per_peer_state *pps, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, const struct pubkey *their_funding_pubkey, u32 minimum_depth, u32 min_feerate, u32 max_feerate, const struct bitcoin_txid *funding_txid, u16 funding_txout, struct amount_sat funding_satoshi, struct amount_msat our_funding, const struct basepoints *their_basepoints, const struct pubkey *remote_per_commit, const struct wally_psbt *funding_psbt, enum side opener, bool local_funding_locked, bool remote_funding_locked, bool send_shutdown, bool remote_shutdown_received, const u8 *local_shutdown_scriptpubkey, const u8 *remote_shutdown_scriptpubkey, bool remote_funding_sigs_received, const struct fee_states *fee_states, const u8 *msg);
|
||||
bool fromwire_dualopend_reinit(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_feature_set, u8 **their_init_features, struct channel_config *our_config, struct channel_config *their_config, struct channel_id *channel_id, u32 *max_to_self_delay, struct amount_msat *min_effective_htlc_capacity_msat, struct per_peer_state **pps, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, struct pubkey *their_funding_pubkey, u32 *minimum_depth, u32 *min_feerate, u32 *max_feerate, struct bitcoin_txid *funding_txid, u16 *funding_txout, struct amount_sat *funding_satoshi, struct amount_msat *our_funding, struct basepoints *their_basepoints, struct pubkey *remote_per_commit, struct wally_psbt **funding_psbt, enum side *opener, bool *local_funding_locked, bool *remote_funding_locked, bool *send_shutdown, bool *remote_shutdown_received, u8 **local_shutdown_scriptpubkey, u8 **remote_shutdown_scriptpubkey, bool *remote_funding_sigs_received, struct fee_states **fee_states, u8 **msg);
|
||||
|
||||
/* WIRE: DUALOPEND_GOT_OFFER */
|
||||
/* dualopend->master: they offered channel */
|
||||
u8 *towire_dualopend_got_offer(const tal_t *ctx, struct amount_sat opener_funding, struct amount_sat dust_limit_satoshis, struct amount_msat max_htlc_value_in_flight_msat, struct amount_msat htlc_minimum_msat, u32 feerate_funding_max, u32 feerate_funding_min, u32 feerate_funding_best, u32 feerate_per_kw, u16 to_self_delay, u16 max_accepted_htlcs, u8 channel_flags, u32 locktime, const u8 *shutdown_scriptpubkey);
|
||||
@@ -165,4 +174,4 @@ bool fromwire_dualopend_dev_memleak_reply(const void *p, bool *leak);
|
||||
|
||||
|
||||
#endif /* LIGHTNING_OPENINGD_DUALOPEND_WIREGEN_H */
|
||||
// SHA256STAMP:5b6ccfff2f6cc43eee53e4aed8767fc7ae539d548277bda1c628c51f3191dfe4
|
||||
// SHA256STAMP:02f28abef3ab5503d52f776543a85f6d5682637a8e9f8494beae16ff44896442
|
||||
|
||||
2
wallet/db_postgres_sqlgen.c
generated
2
wallet/db_postgres_sqlgen.c
generated
@@ -1780,4 +1780,4 @@ struct db_query db_postgres_queries[] = {
|
||||
|
||||
#endif /* LIGHTNINGD_WALLET_GEN_DB_POSTGRES */
|
||||
|
||||
// SHA256STAMP:6ab0acf78761f626e452b9d6b83206d2546872001c93779eeb2f15ff8accd62f
|
||||
// SHA256STAMP:ca47a99b5c64139f4556f3bf77a6d984cb9ab6b38bcd2851bc551c75c5cc240a
|
||||
|
||||
2
wallet/db_sqlite3_sqlgen.c
generated
2
wallet/db_sqlite3_sqlgen.c
generated
@@ -1780,4 +1780,4 @@ struct db_query db_sqlite3_queries[] = {
|
||||
|
||||
#endif /* LIGHTNINGD_WALLET_GEN_DB_SQLITE3 */
|
||||
|
||||
// SHA256STAMP:6ab0acf78761f626e452b9d6b83206d2546872001c93779eeb2f15ff8accd62f
|
||||
// SHA256STAMP:ca47a99b5c64139f4556f3bf77a6d984cb9ab6b38bcd2851bc551c75c5cc240a
|
||||
|
||||
4
wallet/statements_gettextgen.po
generated
4
wallet/statements_gettextgen.po
generated
@@ -1170,7 +1170,7 @@ msgstr ""
|
||||
msgid "not a valid SQL statement"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/test/run-wallet.c:1384
|
||||
#: wallet/test/run-wallet.c:1390
|
||||
msgid "INSERT INTO channels (id) VALUES (1);"
|
||||
msgstr ""
|
||||
# SHA256STAMP:21482a898c9a9a83ab6cd873e120306701f76f8559a2e8cb93f062a532aec3b6
|
||||
# SHA256STAMP:e9a62e2d71753f9067c6853326ba6d9e486cd85947d46a228dfcc58b8de5004a
|
||||
|
||||
@@ -596,6 +596,12 @@ struct subd *peer_get_owning_subd(struct peer *peer UNNEEDED)
|
||||
/* Generated stub for peer_memleak_done */
|
||||
void peer_memleak_done(struct command *cmd UNNEEDED, struct subd *leaker UNNEEDED)
|
||||
{ fprintf(stderr, "peer_memleak_done called!\n"); abort(); }
|
||||
/* Generated stub for peer_restart_dualopend */
|
||||
void peer_restart_dualopend(struct peer *peer UNNEEDED,
|
||||
struct per_peer_state *pps UNNEEDED,
|
||||
struct channel *channel UNNEEDED,
|
||||
const u8 *send_msg UNNEEDED)
|
||||
{ fprintf(stderr, "peer_restart_dualopend called!\n"); abort(); }
|
||||
/* Generated stub for peer_start_channeld */
|
||||
void peer_start_channeld(struct channel *channel UNNEEDED,
|
||||
struct per_peer_state *pps UNNEEDED,
|
||||
|
||||
Reference in New Issue
Block a user