From 12f298d83094b7694246ff0e2bdeadb5af0ab432 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 10 Sep 2021 11:44:16 +0930 Subject: [PATCH] openingd: tell lightningd what channel type we negotiated. Currently we actually insist it's the default, but in future it could be different. We also need to tell openingd what the channel_type was, if we resume via openingd_funder_complete(). Signed-off-by: Rusty Russell --- lightningd/opening_common.h | 3 +++ lightningd/opening_control.c | 35 ++++++++++++++------------ openingd/openingd.c | 49 ++++++++++++++++++++---------------- openingd/openingd_wire.csv | 6 +++++ openingd/openingd_wiregen.c | 26 ++++++++++++------- openingd/openingd_wiregen.h | 19 +++++++------- 6 files changed, 83 insertions(+), 55 deletions(-) diff --git a/lightningd/opening_common.h b/lightningd/opening_common.h index b499407e6..27ad45d5b 100644 --- a/lightningd/opening_common.h +++ b/lightningd/opening_common.h @@ -78,6 +78,9 @@ struct funding_channel { /* Channel, subsequent owner of us */ struct uncommitted_channel *uc; + /* Channel type we ended up negotiating. */ + struct channel_type *channel_type; + /* The scriptpubkey to pay (once started) */ u8 *funding_scriptpubkey; diff --git a/lightningd/opening_control.c b/lightningd/opening_control.c index 339e66672..9a1b98620 100644 --- a/lightningd/opening_control.c +++ b/lightningd/opening_control.c @@ -98,14 +98,14 @@ wallet_commit_channel(struct lightningd *ld, struct channel_info *channel_info, u32 feerate, const u8 *our_upfront_shutdown_script, - const u8 *remote_upfront_shutdown_script) + const u8 *remote_upfront_shutdown_script, + const struct channel_type *type) { struct channel *channel; struct amount_msat our_msat; struct amount_sat local_funding; s64 final_key_idx; u64 static_remotekey_start; - struct channel_type *type; u32 lease_start_blockheight = 0; /* No leases on v1 */ /* We cannot both be the fundee *and* have a `fundchannel_start` @@ -161,8 +161,6 @@ wallet_commit_channel(struct lightningd *ld, * - MUST use that `channel_type` for all commitment transactions. */ /* i.e. We set it now for the channel permanently. */ - type = default_channel_type(NULL, - ld->our_features, uc->peer->their_features); if (channel_type_has(type, OPT_STATIC_REMOTEKEY)) static_remotekey_start = 0; else @@ -305,12 +303,12 @@ static void opening_funder_start_replied(struct subd *openingd, const u8 *resp, const int *fds, struct funding_channel *fc) { - u8 *funding_scriptPubkey; bool supports_shutdown_script; - if (!fromwire_openingd_funder_start_reply(resp, resp, - &funding_scriptPubkey, - &supports_shutdown_script)) { + if (!fromwire_openingd_funder_start_reply(fc, resp, + &fc->funding_scriptpubkey, + &supports_shutdown_script, + &fc->channel_type)) { log_broken(fc->uc->log, "bad OPENING_FUNDER_REPLY %s", tal_hex(resp, resp)); @@ -325,8 +323,6 @@ static void opening_funder_start_replied(struct subd *openingd, const u8 *resp, fc->our_upfront_shutdown_script = tal_free(fc->our_upfront_shutdown_script); - /* Save this so we can indentify output for scriptpubkey */ - fc->funding_scriptpubkey = tal_steal(fc, funding_scriptPubkey); funding_started_success(fc); /* Mark that we're in-flight */ @@ -356,6 +352,7 @@ static void opening_funder_finished(struct subd *openingd, const u8 *resp, u8 *remote_upfront_shutdown_script; struct per_peer_state *pps; struct penalty_base *pbase; + struct channel_type *type; /* This is a new channel_info.their_config so set its ID to 0 */ channel_info.their_config.id = 0; @@ -377,7 +374,8 @@ static void opening_funder_finished(struct subd *openingd, const u8 *resp, &funding_txout, &feerate, &fc->uc->our_config.channel_reserve, - &remote_upfront_shutdown_script)) { + &remote_upfront_shutdown_script, + &type)) { log_broken(fc->uc->log, "bad OPENING_FUNDER_REPLY %s", tal_hex(resp, resp)); @@ -412,7 +410,8 @@ static void opening_funder_finished(struct subd *openingd, const u8 *resp, &channel_info, feerate, fc->our_upfront_shutdown_script, - remote_upfront_shutdown_script); + remote_upfront_shutdown_script, + type); if (!channel) { was_pending(command_fail(fc->cmd, LIGHTNINGD, "Key generation failure")); @@ -456,6 +455,7 @@ static void opening_fundee_finished(struct subd *openingd, u8 *remote_upfront_shutdown_script, *local_upfront_shutdown_script; struct per_peer_state *pps; struct penalty_base *pbase; + struct channel_type *type; log_debug(uc->log, "Got opening_fundee_finish_response"); @@ -483,7 +483,8 @@ static void opening_fundee_finished(struct subd *openingd, cast_const2(u8 **, &fwd_msg), &uc->our_config.channel_reserve, &local_upfront_shutdown_script, - &remote_upfront_shutdown_script)) { + &remote_upfront_shutdown_script, + &type)) { log_broken(uc->log, "bad OPENING_FUNDEE_REPLY %s", tal_hex(reply, reply)); uncommitted_channel_disconnect(uc, LOG_BROKEN, @@ -520,7 +521,8 @@ static void opening_fundee_finished(struct subd *openingd, &channel_info, feerate, local_upfront_shutdown_script, - remote_upfront_shutdown_script); + remote_upfront_shutdown_script, + type); if (!channel) { uncommitted_channel_disconnect(uc, LOG_BROKEN, "Commit channel failed"); @@ -1085,8 +1087,9 @@ static struct command_result *json_fundchannel_complete(struct command *cmd, /* Set the cmd to this new cmd */ peer->uncommitted_channel->fc->cmd = cmd; msg = towire_openingd_funder_complete(NULL, - funding_txid, - *funding_txout_num); + funding_txid, + *funding_txout_num, + peer->uncommitted_channel->fc->channel_type); subd_send_msg(peer->uncommitted_channel->open_daemon, take(msg)); return command_still_pending(cmd); } diff --git a/openingd/openingd.c b/openingd/openingd.c index 437113187..3770bf311 100644 --- a/openingd/openingd.c +++ b/openingd/openingd.c @@ -114,6 +114,9 @@ struct state { * as initial channels never have HTLCs. */ struct channel *channel; + /* Channel type we agreed on (even before channel populated) */ + struct channel_type *channel_type; + struct feature_set *our_features; }; @@ -147,6 +150,8 @@ static void negotiation_aborted(struct state *state, bool am_opener, * failed. */ memset(&state->channel_id, 0, sizeof(state->channel_id)); state->channel = tal_free(state->channel); + + state->channel_type = tal_free(state->channel_type); } /*~ For negotiation failures: we tell them the parameter we didn't like. */ @@ -432,6 +437,10 @@ static u8 *funder_channel_start(struct state *state, u8 channel_flags) } set_remote_upfront_shutdown(state, accept_tlvs->upfront_shutdown_script); + state->channel_type = default_channel_type(state, + state->our_features, + state->their_features); + /* BOLT #2: * * The `temporary_channel_id` MUST be the same as the @@ -483,11 +492,12 @@ static u8 *funder_channel_start(struct state *state, u8 channel_flags) tal_hex(tmpctx, funding_output_script)); return towire_openingd_funder_start_reply(state, - funding_output_script, - feature_negotiated( - state->our_features, - state->their_features, - OPT_UPFRONT_SHUTDOWN_SCRIPT)); + funding_output_script, + feature_negotiated( + state->our_features, + state->their_features, + OPT_UPFRONT_SHUTDOWN_SCRIPT), + state->channel_type); } static bool funder_finalize_channel_setup(struct state *state, @@ -502,7 +512,6 @@ static bool funder_finalize_channel_setup(struct state *state, struct channel_id cid; char *err_reason; struct wally_tx_output *direct_outputs[NUM_SIDES]; - struct channel_type *type; /*~ Now we can initialize the `struct channel`. This represents * the current channel state and is how we can generate the current @@ -515,10 +524,6 @@ static bool funder_finalize_channel_setup(struct state *state, derive_channel_id(&cid, &state->funding_txid, state->funding_txout); - type = default_channel_type(NULL, - state->our_features, - state->their_features); - state->channel = new_initial_channel(state, &cid, &state->funding_txid, @@ -535,7 +540,7 @@ static bool funder_finalize_channel_setup(struct state *state, &state->their_points, &state->our_funding_pubkey, &state->their_funding_pubkey, - take(type), + state->channel_type, feature_offered(state->their_features, OPT_LARGE_CHANNELS), /* Opener is local */ @@ -747,7 +752,8 @@ static u8 *funder_channel_complete(struct state *state) state->funding_txout, state->feerate_per_kw, state->localconf.channel_reserve, - state->upfront_shutdown_script[REMOTE]); + state->upfront_shutdown_script[REMOTE], + state->channel_type); } /*~ The peer sent us an `open_channel`, that means we're the fundee. */ @@ -765,7 +771,6 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg) char* err_reason; struct wally_tx_output *direct_outputs[NUM_SIDES]; struct penalty_base *pbase; - struct channel_type *type; struct tlv_accept_channel_tlvs *accept_tlvs; struct tlv_open_channel_tlvs *open_tlvs = tlv_open_channel_tlvs_new(tmpctx); @@ -984,6 +989,9 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg) sync_crypto_write(state->pps, take(msg)); + state->channel_type = default_channel_type(state, + state->our_features, + state->their_features); peer_billboard(false, "Incoming channel: accepted, now waiting for them to create funding tx"); @@ -1014,9 +1022,6 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg) &state->channel_id), type_to_string(msg, struct channel_id, &id_in)); - type = default_channel_type(NULL, - state->our_features, state->their_features); - /* Now we can create the channel structure. */ state->channel = new_initial_channel(state, &state->channel_id, @@ -1033,7 +1038,7 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg) &state->our_points, &theirs, &state->our_funding_pubkey, &their_funding_pubkey, - take(type), + state->channel_type, feature_offered(state->their_features, OPT_LARGE_CHANNELS), REMOTE); @@ -1164,7 +1169,8 @@ static u8 *fundee_channel(struct state *state, const u8 *open_channel_msg) msg, state->localconf.channel_reserve, state->upfront_shutdown_script[LOCAL], - state->upfront_shutdown_script[REMOTE]); + state->upfront_shutdown_script[REMOTE], + state->channel_type); } /*~ Standard "peer sent a message, handle it" demuxer. Though it really only @@ -1291,9 +1297,10 @@ static u8 *handle_master_in(struct state *state) wire_sync_write(REQ_FD, take(msg)); return NULL; case WIRE_OPENINGD_FUNDER_COMPLETE: - if (!fromwire_openingd_funder_complete(msg, - &funding_txid, - &funding_txout)) + if (!fromwire_openingd_funder_complete(state, msg, + &funding_txid, + &funding_txout, + &state->channel_type)) master_badmsg(WIRE_OPENINGD_FUNDER_COMPLETE, msg); state->funding_txid = funding_txid; state->funding_txout = funding_txout; diff --git a/openingd/openingd_wire.csv b/openingd/openingd_wire.csv index a8a4491fb..26451bf67 100644 --- a/openingd/openingd_wire.csv +++ b/openingd/openingd_wire.csv @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -48,6 +49,7 @@ msgdata,openingd_got_offer,max_accepted_htlcs,u16, msgdata,openingd_got_offer,channel_flags,u8, msgdata,openingd_got_offer,shutdown_len,u16, msgdata,openingd_got_offer,shutdown_scriptpubkey,u8,shutdown_len + # master->openingd: optional rejection message msgtype,openingd_got_offer_reply,6105 msgdata,openingd_got_offer_reply,rejection,?wirestring, @@ -76,6 +78,7 @@ msgdata,openingd_funder_reply,feerate_per_kw,u32, msgdata,openingd_funder_reply,our_channel_reserve_satoshis,amount_sat, msgdata,openingd_funder_reply,shutdown_len,u16, msgdata,openingd_funder_reply,shutdown_scriptpubkey,u8,shutdown_len +msgdata,openingd_funder_reply,channel_type,channel_type, # master->openingd: start channel establishment for a funding tx msgtype,openingd_funder_start,6002 @@ -91,6 +94,7 @@ msgtype,openingd_funder_start_reply,6102 msgdata,openingd_funder_start_reply,script_len,u8, msgdata,openingd_funder_start_reply,scriptpubkey,u8,script_len msgdata,openingd_funder_start_reply,upfront_shutdown_negotiated,bool, +msgdata,openingd_funder_start_reply,channel_type,channel_type, # master->openingd: complete channel establishment for a funding # tx that will be paid for by an external wallet @@ -98,6 +102,7 @@ msgdata,openingd_funder_start_reply,upfront_shutdown_negotiated,bool, msgtype,openingd_funder_complete,6012 msgdata,openingd_funder_complete,funding_txid,bitcoin_txid, msgdata,openingd_funder_complete,funding_txout,u16, +msgdata,openingd_funder_complete,channel_type,channel_type, #master->openingd: cancel channel establishment for a funding msgtype,openingd_funder_cancel,6013 @@ -134,6 +139,7 @@ msgdata,openingd_fundee,local_shutdown_len,u16, msgdata,openingd_fundee,local_shutdown_scriptpubkey,u8,local_shutdown_len msgdata,openingd_fundee,remote_shutdown_len,u16, msgdata,openingd_fundee,remote_shutdown_scriptpubkey,u8,remote_shutdown_len +msgdata,openingd_fundee,channel_type,channel_type, # master -> openingd: do you have a memleak? msgtype,openingd_dev_memleak,6033 diff --git a/openingd/openingd_wiregen.c b/openingd/openingd_wiregen.c index db9ffd243..9a4eafa85 100644 --- a/openingd/openingd_wiregen.c +++ b/openingd/openingd_wiregen.c @@ -261,7 +261,7 @@ bool fromwire_openingd_got_offer_reply(const tal_t *ctx, const void *p, wirestri /* WIRE: OPENINGD_FUNDER_REPLY */ /* Openingd->master: we've successfully offered channel. */ /* This gives their sig */ -u8 *towire_openingd_funder_reply(const tal_t *ctx, const struct channel_config *their_config, const struct bitcoin_tx *first_commit, const struct penalty_base *pbase, const struct bitcoin_signature *first_commit_sig, const struct per_peer_state *pps, const struct pubkey *revocation_basepoint, const struct pubkey *payment_basepoint, const struct pubkey *htlc_basepoint, const struct pubkey *delayed_payment_basepoint, const struct pubkey *their_per_commit_point, u32 minimum_depth, const struct pubkey *remote_fundingkey, const struct bitcoin_txid *funding_txid, u16 funding_txout, u32 feerate_per_kw, struct amount_sat our_channel_reserve_satoshis, const u8 *shutdown_scriptpubkey) +u8 *towire_openingd_funder_reply(const tal_t *ctx, const struct channel_config *their_config, const struct bitcoin_tx *first_commit, const struct penalty_base *pbase, const struct bitcoin_signature *first_commit_sig, const struct per_peer_state *pps, const struct pubkey *revocation_basepoint, const struct pubkey *payment_basepoint, const struct pubkey *htlc_basepoint, const struct pubkey *delayed_payment_basepoint, const struct pubkey *their_per_commit_point, u32 minimum_depth, const struct pubkey *remote_fundingkey, const struct bitcoin_txid *funding_txid, u16 funding_txout, u32 feerate_per_kw, struct amount_sat our_channel_reserve_satoshis, const u8 *shutdown_scriptpubkey, const struct channel_type *channel_type) { u16 shutdown_len = tal_count(shutdown_scriptpubkey); u8 *p = tal_arr(ctx, u8, 0); @@ -290,10 +290,11 @@ u8 *towire_openingd_funder_reply(const tal_t *ctx, const struct channel_config * towire_amount_sat(&p, our_channel_reserve_satoshis); towire_u16(&p, shutdown_len); towire_u8_array(&p, shutdown_scriptpubkey, shutdown_len); + towire_channel_type(&p, channel_type); return memcheck(p, tal_count(p)); } -bool fromwire_openingd_funder_reply(const tal_t *ctx, const void *p, struct channel_config *their_config, struct bitcoin_tx **first_commit, struct penalty_base **pbase, struct bitcoin_signature *first_commit_sig, struct per_peer_state **pps, struct pubkey *revocation_basepoint, struct pubkey *payment_basepoint, struct pubkey *htlc_basepoint, struct pubkey *delayed_payment_basepoint, struct pubkey *their_per_commit_point, u32 *minimum_depth, struct pubkey *remote_fundingkey, struct bitcoin_txid *funding_txid, u16 *funding_txout, u32 *feerate_per_kw, struct amount_sat *our_channel_reserve_satoshis, u8 **shutdown_scriptpubkey) +bool fromwire_openingd_funder_reply(const tal_t *ctx, const void *p, struct channel_config *their_config, struct bitcoin_tx **first_commit, struct penalty_base **pbase, struct bitcoin_signature *first_commit_sig, struct per_peer_state **pps, struct pubkey *revocation_basepoint, struct pubkey *payment_basepoint, struct pubkey *htlc_basepoint, struct pubkey *delayed_payment_basepoint, struct pubkey *their_per_commit_point, u32 *minimum_depth, struct pubkey *remote_fundingkey, struct bitcoin_txid *funding_txid, u16 *funding_txout, u32 *feerate_per_kw, struct amount_sat *our_channel_reserve_satoshis, u8 **shutdown_scriptpubkey, struct channel_type **channel_type) { u16 shutdown_len; @@ -327,6 +328,7 @@ bool fromwire_openingd_funder_reply(const tal_t *ctx, const void *p, struct chan // 2nd case shutdown_scriptpubkey *shutdown_scriptpubkey = shutdown_len ? tal_arr(ctx, u8, shutdown_len) : NULL; fromwire_u8_array(&cursor, &plen, *shutdown_scriptpubkey, shutdown_len); + *channel_type = fromwire_channel_type(ctx, &cursor, &plen); return cursor != NULL; } @@ -369,7 +371,7 @@ bool fromwire_openingd_funder_start(const tal_t *ctx, const void *p, struct amou /* WIRE: OPENINGD_FUNDER_START_REPLY */ /* openingd->master: send back output script for 2-of-2 funding output */ -u8 *towire_openingd_funder_start_reply(const tal_t *ctx, const u8 *scriptpubkey, bool upfront_shutdown_negotiated) +u8 *towire_openingd_funder_start_reply(const tal_t *ctx, const u8 *scriptpubkey, bool upfront_shutdown_negotiated, const struct channel_type *channel_type) { u8 script_len = tal_count(scriptpubkey); u8 *p = tal_arr(ctx, u8, 0); @@ -378,10 +380,11 @@ u8 *towire_openingd_funder_start_reply(const tal_t *ctx, const u8 *scriptpubkey, towire_u8(&p, script_len); towire_u8_array(&p, scriptpubkey, script_len); towire_bool(&p, upfront_shutdown_negotiated); + towire_channel_type(&p, channel_type); return memcheck(p, tal_count(p)); } -bool fromwire_openingd_funder_start_reply(const tal_t *ctx, const void *p, u8 **scriptpubkey, bool *upfront_shutdown_negotiated) +bool fromwire_openingd_funder_start_reply(const tal_t *ctx, const void *p, u8 **scriptpubkey, bool *upfront_shutdown_negotiated, struct channel_type **channel_type) { u8 script_len; @@ -395,6 +398,7 @@ bool fromwire_openingd_funder_start_reply(const tal_t *ctx, const void *p, u8 ** *scriptpubkey = script_len ? tal_arr(ctx, u8, script_len) : NULL; fromwire_u8_array(&cursor, &plen, *scriptpubkey, script_len); *upfront_shutdown_negotiated = fromwire_bool(&cursor, &plen); + *channel_type = fromwire_channel_type(ctx, &cursor, &plen); return cursor != NULL; } @@ -402,17 +406,18 @@ bool fromwire_openingd_funder_start_reply(const tal_t *ctx, const void *p, u8 ** /* master->openingd: complete channel establishment for a funding */ /* tx that will be paid for by an external wallet */ /* response to this is a normal `openingd_funder_reply` ?? */ -u8 *towire_openingd_funder_complete(const tal_t *ctx, const struct bitcoin_txid *funding_txid, u16 funding_txout) +u8 *towire_openingd_funder_complete(const tal_t *ctx, const struct bitcoin_txid *funding_txid, u16 funding_txout, const struct channel_type *channel_type) { u8 *p = tal_arr(ctx, u8, 0); towire_u16(&p, WIRE_OPENINGD_FUNDER_COMPLETE); towire_bitcoin_txid(&p, funding_txid); towire_u16(&p, funding_txout); + towire_channel_type(&p, channel_type); return memcheck(p, tal_count(p)); } -bool fromwire_openingd_funder_complete(const void *p, struct bitcoin_txid *funding_txid, u16 *funding_txout) +bool fromwire_openingd_funder_complete(const tal_t *ctx, const void *p, struct bitcoin_txid *funding_txid, u16 *funding_txout, struct channel_type **channel_type) { const u8 *cursor = p; size_t plen = tal_count(p); @@ -421,6 +426,7 @@ bool fromwire_openingd_funder_complete(const void *p, struct bitcoin_txid *fundi return false; fromwire_bitcoin_txid(&cursor, &plen, funding_txid); *funding_txout = fromwire_u16(&cursor, &plen); + *channel_type = fromwire_channel_type(ctx, &cursor, &plen); return cursor != NULL; } @@ -469,7 +475,7 @@ bool fromwire_openingd_funder_failed(const tal_t *ctx, const void *p, wirestring /* WIRE: OPENINGD_FUNDEE */ /* Openingd->master: they offered channel. */ /* This gives their txid and info */ -u8 *towire_openingd_fundee(const tal_t *ctx, const struct channel_config *their_config, const struct bitcoin_tx *first_commit, const struct penalty_base *pbase, const struct bitcoin_signature *first_commit_sig, const struct per_peer_state *pps, const struct pubkey *revocation_basepoint, const struct pubkey *payment_basepoint, const struct pubkey *htlc_basepoint, const struct pubkey *delayed_payment_basepoint, const struct pubkey *their_per_commit_point, const struct pubkey *remote_fundingkey, const struct bitcoin_txid *funding_txid, u16 funding_txout, struct amount_sat funding_satoshis, struct amount_msat push_msat, u8 channel_flags, u32 feerate_per_kw, const u8 *funding_signed_msg, struct amount_sat our_channel_reserve_satoshis, const u8 *local_shutdown_scriptpubkey, const u8 *remote_shutdown_scriptpubkey) +u8 *towire_openingd_fundee(const tal_t *ctx, const struct channel_config *their_config, const struct bitcoin_tx *first_commit, const struct penalty_base *pbase, const struct bitcoin_signature *first_commit_sig, const struct per_peer_state *pps, const struct pubkey *revocation_basepoint, const struct pubkey *payment_basepoint, const struct pubkey *htlc_basepoint, const struct pubkey *delayed_payment_basepoint, const struct pubkey *their_per_commit_point, const struct pubkey *remote_fundingkey, const struct bitcoin_txid *funding_txid, u16 funding_txout, struct amount_sat funding_satoshis, struct amount_msat push_msat, u8 channel_flags, u32 feerate_per_kw, const u8 *funding_signed_msg, struct amount_sat our_channel_reserve_satoshis, const u8 *local_shutdown_scriptpubkey, const u8 *remote_shutdown_scriptpubkey, const struct channel_type *channel_type) { u16 msglen = tal_count(funding_signed_msg); u16 local_shutdown_len = tal_count(local_shutdown_scriptpubkey); @@ -507,10 +513,11 @@ u8 *towire_openingd_fundee(const tal_t *ctx, const struct channel_config *their_ 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_channel_type(&p, channel_type); return memcheck(p, tal_count(p)); } -bool fromwire_openingd_fundee(const tal_t *ctx, const void *p, struct channel_config *their_config, struct bitcoin_tx **first_commit, struct penalty_base **pbase, struct bitcoin_signature *first_commit_sig, struct per_peer_state **pps, struct pubkey *revocation_basepoint, struct pubkey *payment_basepoint, struct pubkey *htlc_basepoint, struct pubkey *delayed_payment_basepoint, struct pubkey *their_per_commit_point, struct pubkey *remote_fundingkey, struct bitcoin_txid *funding_txid, u16 *funding_txout, struct amount_sat *funding_satoshis, struct amount_msat *push_msat, u8 *channel_flags, u32 *feerate_per_kw, u8 **funding_signed_msg, struct amount_sat *our_channel_reserve_satoshis, u8 **local_shutdown_scriptpubkey, u8 **remote_shutdown_scriptpubkey) +bool fromwire_openingd_fundee(const tal_t *ctx, const void *p, struct channel_config *their_config, struct bitcoin_tx **first_commit, struct penalty_base **pbase, struct bitcoin_signature *first_commit_sig, struct per_peer_state **pps, struct pubkey *revocation_basepoint, struct pubkey *payment_basepoint, struct pubkey *htlc_basepoint, struct pubkey *delayed_payment_basepoint, struct pubkey *their_per_commit_point, struct pubkey *remote_fundingkey, struct bitcoin_txid *funding_txid, u16 *funding_txout, struct amount_sat *funding_satoshis, struct amount_msat *push_msat, u8 *channel_flags, u32 *feerate_per_kw, u8 **funding_signed_msg, struct amount_sat *our_channel_reserve_satoshis, u8 **local_shutdown_scriptpubkey, u8 **remote_shutdown_scriptpubkey, struct channel_type **channel_type) { u16 msglen; u16 local_shutdown_len; @@ -557,6 +564,7 @@ bool fromwire_openingd_fundee(const tal_t *ctx, const void *p, struct channel_co // 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); + *channel_type = fromwire_channel_type(ctx, &cursor, &plen); return cursor != NULL; } @@ -600,4 +608,4 @@ bool fromwire_openingd_dev_memleak_reply(const void *p, bool *leak) *leak = fromwire_bool(&cursor, &plen); return cursor != NULL; } -// SHA256STAMP:d29170ad38f0c5273930ae4c87ab3ce075af9671d16f3977d5db7584f3fde1b9 +// SHA256STAMP:f1728e2b3e5e2001e7620e23b0d1c1d359569684fd7d585b6f4471d1abeb332c diff --git a/openingd/openingd_wiregen.h b/openingd/openingd_wiregen.h index 6f493ba2f..600530001 100644 --- a/openingd/openingd_wiregen.h +++ b/openingd/openingd_wiregen.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -81,8 +82,8 @@ bool fromwire_openingd_got_offer_reply(const tal_t *ctx, const void *p, wirestri /* WIRE: OPENINGD_FUNDER_REPLY */ /* Openingd->master: we've successfully offered channel. */ /* This gives their sig */ -u8 *towire_openingd_funder_reply(const tal_t *ctx, const struct channel_config *their_config, const struct bitcoin_tx *first_commit, const struct penalty_base *pbase, const struct bitcoin_signature *first_commit_sig, const struct per_peer_state *pps, const struct pubkey *revocation_basepoint, const struct pubkey *payment_basepoint, const struct pubkey *htlc_basepoint, const struct pubkey *delayed_payment_basepoint, const struct pubkey *their_per_commit_point, u32 minimum_depth, const struct pubkey *remote_fundingkey, const struct bitcoin_txid *funding_txid, u16 funding_txout, u32 feerate_per_kw, struct amount_sat our_channel_reserve_satoshis, const u8 *shutdown_scriptpubkey); -bool fromwire_openingd_funder_reply(const tal_t *ctx, const void *p, struct channel_config *their_config, struct bitcoin_tx **first_commit, struct penalty_base **pbase, struct bitcoin_signature *first_commit_sig, struct per_peer_state **pps, struct pubkey *revocation_basepoint, struct pubkey *payment_basepoint, struct pubkey *htlc_basepoint, struct pubkey *delayed_payment_basepoint, struct pubkey *their_per_commit_point, u32 *minimum_depth, struct pubkey *remote_fundingkey, struct bitcoin_txid *funding_txid, u16 *funding_txout, u32 *feerate_per_kw, struct amount_sat *our_channel_reserve_satoshis, u8 **shutdown_scriptpubkey); +u8 *towire_openingd_funder_reply(const tal_t *ctx, const struct channel_config *their_config, const struct bitcoin_tx *first_commit, const struct penalty_base *pbase, const struct bitcoin_signature *first_commit_sig, const struct per_peer_state *pps, const struct pubkey *revocation_basepoint, const struct pubkey *payment_basepoint, const struct pubkey *htlc_basepoint, const struct pubkey *delayed_payment_basepoint, const struct pubkey *their_per_commit_point, u32 minimum_depth, const struct pubkey *remote_fundingkey, const struct bitcoin_txid *funding_txid, u16 funding_txout, u32 feerate_per_kw, struct amount_sat our_channel_reserve_satoshis, const u8 *shutdown_scriptpubkey, const struct channel_type *channel_type); +bool fromwire_openingd_funder_reply(const tal_t *ctx, const void *p, struct channel_config *their_config, struct bitcoin_tx **first_commit, struct penalty_base **pbase, struct bitcoin_signature *first_commit_sig, struct per_peer_state **pps, struct pubkey *revocation_basepoint, struct pubkey *payment_basepoint, struct pubkey *htlc_basepoint, struct pubkey *delayed_payment_basepoint, struct pubkey *their_per_commit_point, u32 *minimum_depth, struct pubkey *remote_fundingkey, struct bitcoin_txid *funding_txid, u16 *funding_txout, u32 *feerate_per_kw, struct amount_sat *our_channel_reserve_satoshis, u8 **shutdown_scriptpubkey, struct channel_type **channel_type); /* WIRE: OPENINGD_FUNDER_START */ /* master->openingd: start channel establishment for a funding tx */ @@ -91,15 +92,15 @@ bool fromwire_openingd_funder_start(const tal_t *ctx, const void *p, struct amou /* WIRE: OPENINGD_FUNDER_START_REPLY */ /* openingd->master: send back output script for 2-of-2 funding output */ -u8 *towire_openingd_funder_start_reply(const tal_t *ctx, const u8 *scriptpubkey, bool upfront_shutdown_negotiated); -bool fromwire_openingd_funder_start_reply(const tal_t *ctx, const void *p, u8 **scriptpubkey, bool *upfront_shutdown_negotiated); +u8 *towire_openingd_funder_start_reply(const tal_t *ctx, const u8 *scriptpubkey, bool upfront_shutdown_negotiated, const struct channel_type *channel_type); +bool fromwire_openingd_funder_start_reply(const tal_t *ctx, const void *p, u8 **scriptpubkey, bool *upfront_shutdown_negotiated, struct channel_type **channel_type); /* WIRE: OPENINGD_FUNDER_COMPLETE */ /* master->openingd: complete channel establishment for a funding */ /* tx that will be paid for by an external wallet */ /* response to this is a normal `openingd_funder_reply` ?? */ -u8 *towire_openingd_funder_complete(const tal_t *ctx, const struct bitcoin_txid *funding_txid, u16 funding_txout); -bool fromwire_openingd_funder_complete(const void *p, struct bitcoin_txid *funding_txid, u16 *funding_txout); +u8 *towire_openingd_funder_complete(const tal_t *ctx, const struct bitcoin_txid *funding_txid, u16 funding_txout, const struct channel_type *channel_type); +bool fromwire_openingd_funder_complete(const tal_t *ctx, const void *p, struct bitcoin_txid *funding_txid, u16 *funding_txout, struct channel_type **channel_type); /* WIRE: OPENINGD_FUNDER_CANCEL */ /* master->openingd: cancel channel establishment for a funding */ @@ -114,8 +115,8 @@ bool fromwire_openingd_funder_failed(const tal_t *ctx, const void *p, wirestring /* WIRE: OPENINGD_FUNDEE */ /* Openingd->master: they offered channel. */ /* This gives their txid and info */ -u8 *towire_openingd_fundee(const tal_t *ctx, const struct channel_config *their_config, const struct bitcoin_tx *first_commit, const struct penalty_base *pbase, const struct bitcoin_signature *first_commit_sig, const struct per_peer_state *pps, const struct pubkey *revocation_basepoint, const struct pubkey *payment_basepoint, const struct pubkey *htlc_basepoint, const struct pubkey *delayed_payment_basepoint, const struct pubkey *their_per_commit_point, const struct pubkey *remote_fundingkey, const struct bitcoin_txid *funding_txid, u16 funding_txout, struct amount_sat funding_satoshis, struct amount_msat push_msat, u8 channel_flags, u32 feerate_per_kw, const u8 *funding_signed_msg, struct amount_sat our_channel_reserve_satoshis, const u8 *local_shutdown_scriptpubkey, const u8 *remote_shutdown_scriptpubkey); -bool fromwire_openingd_fundee(const tal_t *ctx, const void *p, struct channel_config *their_config, struct bitcoin_tx **first_commit, struct penalty_base **pbase, struct bitcoin_signature *first_commit_sig, struct per_peer_state **pps, struct pubkey *revocation_basepoint, struct pubkey *payment_basepoint, struct pubkey *htlc_basepoint, struct pubkey *delayed_payment_basepoint, struct pubkey *their_per_commit_point, struct pubkey *remote_fundingkey, struct bitcoin_txid *funding_txid, u16 *funding_txout, struct amount_sat *funding_satoshis, struct amount_msat *push_msat, u8 *channel_flags, u32 *feerate_per_kw, u8 **funding_signed_msg, struct amount_sat *our_channel_reserve_satoshis, u8 **local_shutdown_scriptpubkey, u8 **remote_shutdown_scriptpubkey); +u8 *towire_openingd_fundee(const tal_t *ctx, const struct channel_config *their_config, const struct bitcoin_tx *first_commit, const struct penalty_base *pbase, const struct bitcoin_signature *first_commit_sig, const struct per_peer_state *pps, const struct pubkey *revocation_basepoint, const struct pubkey *payment_basepoint, const struct pubkey *htlc_basepoint, const struct pubkey *delayed_payment_basepoint, const struct pubkey *their_per_commit_point, const struct pubkey *remote_fundingkey, const struct bitcoin_txid *funding_txid, u16 funding_txout, struct amount_sat funding_satoshis, struct amount_msat push_msat, u8 channel_flags, u32 feerate_per_kw, const u8 *funding_signed_msg, struct amount_sat our_channel_reserve_satoshis, const u8 *local_shutdown_scriptpubkey, const u8 *remote_shutdown_scriptpubkey, const struct channel_type *channel_type); +bool fromwire_openingd_fundee(const tal_t *ctx, const void *p, struct channel_config *their_config, struct bitcoin_tx **first_commit, struct penalty_base **pbase, struct bitcoin_signature *first_commit_sig, struct per_peer_state **pps, struct pubkey *revocation_basepoint, struct pubkey *payment_basepoint, struct pubkey *htlc_basepoint, struct pubkey *delayed_payment_basepoint, struct pubkey *their_per_commit_point, struct pubkey *remote_fundingkey, struct bitcoin_txid *funding_txid, u16 *funding_txout, struct amount_sat *funding_satoshis, struct amount_msat *push_msat, u8 *channel_flags, u32 *feerate_per_kw, u8 **funding_signed_msg, struct amount_sat *our_channel_reserve_satoshis, u8 **local_shutdown_scriptpubkey, u8 **remote_shutdown_scriptpubkey, struct channel_type **channel_type); /* WIRE: OPENINGD_DEV_MEMLEAK */ /* master -> openingd: do you have a memleak? */ @@ -128,4 +129,4 @@ bool fromwire_openingd_dev_memleak_reply(const void *p, bool *leak); #endif /* LIGHTNING_OPENINGD_OPENINGD_WIREGEN_H */ -// SHA256STAMP:d29170ad38f0c5273930ae4c87ab3ce075af9671d16f3977d5db7584f3fde1b9 +// SHA256STAMP:f1728e2b3e5e2001e7620e23b0d1c1d359569684fd7d585b6f4471d1abeb332c