Browse Source

dualopend: new `dualopend` daemon, containing most of accepter side

oof. needs validation.
bump-pyln-proto
niftynei 4 years ago
committed by Rusty Russell
parent
commit
cafdbbcd2d
  1. 3
      Makefile
  2. 5
      lightningd/.gitignore
  3. 25
      openingd/Makefile
  4. 10
      openingd/dual_fund_roles.h
  5. 1609
      openingd/dualopend.c
  6. 105
      openingd/dualopend_wire.csv
  7. 418
      openingd/dualopend_wiregen.c
  8. 100
      openingd/dualopend_wiregen.h

3
Makefile

@ -580,7 +580,8 @@ PKGLIBEXEC_PROGRAMS = \
lightningd/lightning_gossipd \
lightningd/lightning_hsmd \
lightningd/lightning_onchaind \
lightningd/lightning_openingd
lightningd/lightning_openingd \
lightningd/lightning_dualopend
# $(PLUGINS) is defined in plugins/Makefile.

5
lightningd/.gitignore

@ -1,8 +1,9 @@
lightningd
lightning_channeld
lightning_closingd
lightning_connectd
lightning_dualopend
lightning_gossipd
lightning_hsmd
lightning_openingd
lightning_closingd
lightning_onchaind
lightning_openingd

25
openingd/Makefile

@ -4,20 +4,30 @@ OPENINGD_HEADERS := \
openingd/common.h \
openingd/openingd_wiregen.h
OPENINGD_SRC := openingd/openingd.c \
DUALOPEND_HEADERS := \
openingd/common.h \
openingd/dualopend_wiregen.h
OPENINGD_SRC := openingd/openingd.c \
$(OPENINGD_HEADERS:.h=.c)
DUALOPEND_SRC := openingd/dualopend.c \
$(DUALOPEND_HEADERS:.h=.c)
OPENINGD_OBJS := $(OPENINGD_SRC:.c=.o)
$(OPENINGD_OBJS): $(OPENINGD_HEADERS)
DUALOPEND_OBJS := $(DUALOPEND_SRC:.c=.o)
$(DUALOPEND_OBJS): $(DUALOPEND_HEADERS)
# Make sure these depend on everything.
ALL_C_SOURCES += $(OPENINGD_SRC)
ALL_C_HEADERS += $(OPENINGD_HEADERS)
ALL_PROGRAMS += lightningd/lightning_openingd
ALL_C_SOURCES += $(OPENINGD_SRC) $(DUALOPEND_SRC)
ALL_C_HEADERS += $(OPENINGD_HEADERS) $(DUALOPEND_HEADERS)
ALL_PROGRAMS += lightningd/lightning_openingd lightningd/lightning_dualopend
# Here's what lightningd depends on
LIGHTNINGD_CONTROL_HEADERS += openingd/openingd_wiregen.h
LIGHTNINGD_CONTROL_OBJS += openingd/openingd_wiregen.o
LIGHTNINGD_CONTROL_HEADERS += openingd/openingd_wiregen.h openingd/dualopend_wiregen.h
LIGHTNINGD_CONTROL_OBJS += openingd/openingd_wiregen.o openingd/dualopend_wiregen.o
# Common source we use.
OPENINGD_COMMON_OBJS := \
@ -55,6 +65,7 @@ OPENINGD_COMMON_OBJS := \
common/peer_billboard.o \
common/peer_failed.o \
common/permute_tx.o \
common/psbt_open.o \
common/pseudorand.o \
common/read_peer_msg.o \
common/setup.o \
@ -72,4 +83,6 @@ OPENINGD_COMMON_OBJS := \
lightningd/lightning_openingd: $(OPENINGD_OBJS) $(OPENINGD_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) $(HSMD_CLIENT_OBJS)
lightningd/lightning_dualopend: $(DUALOPEND_OBJS) $(OPENINGD_COMMON_OBJS) $(WIRE_OBJS) $(BITCOIN_OBJS) $(HSMD_CLIENT_OBJS)
-include openingd/test/Makefile

10
openingd/dual_fund_roles.h

@ -0,0 +1,10 @@
#ifndef LIGHTNING_OPENINGD_DUAL_FUND_ROLES_H
#define LIGHTNING_OPENINGD_DUAL_FUND_ROLES_H
#define NUM_DF_RULES (OPENER + 1)
enum dual_fund_roles {
ACCEPTER,
OPENER,
};
#endif /* LIGHTNING_OPENINGD_DUAL_FUND_ROLES_H */

1609
openingd/dualopend.c

File diff suppressed because it is too large

105
openingd/dualopend_wire.csv

@ -0,0 +1,105 @@
#include <bitcoin/chainparams.h>
#include <bitcoin/psbt.h>
#include <common/cryptomsg.h>
#include <common/channel_config.h>
#include <common/channel_id.h>
#include <common/derive_basepoints.h>
#include <common/features.h>
#include <common/penalty_base.h>
#include <common/per_peer_state.h>
msgtype,dual_open_init,7000
# Which network are we configured for?
msgdata,dual_open_init,chainparams,chainparams,
msgdata,dual_open_init,our_feature_set,feature_set,
msgdata,dual_open_init,their_init_features_len,u16,
msgdata,dual_open_init,their_init_features,u8,their_init_features_len
# Base configuration we'll offer
msgdata,dual_open_init,our_config,channel_config,
# Minimum/maximum configuration values we'll accept
msgdata,dual_open_init,max_to_self_delay,u32,
msgdata,dual_open_init,min_effective_htlc_capacity_msat,amount_msat,
msgdata,dual_open_init,pps,per_peer_state,
msgdata,dual_open_init,our_basepoints,basepoints,
msgdata,dual_open_init,our_funding_pubkey,pubkey,
# Constraints in case the other end tries to open a channel.
msgdata,dual_open_init,minimum_depth,u32,
msgdata,dual_open_init,min_feerate,u32,
msgdata,dual_open_init,max_feerate,u32,
msgdata,dual_open_init,option_anchor_outputs,bool,
# Optional msg to send.
msgdata,dual_open_init,len,u16,
msgdata,dual_open_init,msg,u8,len
# dualopend->master: they offered channel, should we continue?
msgtype,dual_open_got_offer,7005
msgdata,dual_open_got_offer,opener_funding,amount_sat,
msgdata,dual_open_got_offer,dust_limit_satoshis,amount_sat,
msgdata,dual_open_got_offer,max_htlc_value_in_flight_msat,amount_msat,
msgdata,dual_open_got_offer,htlc_minimum_msat,amount_msat,
msgdata,dual_open_got_offer,feerate_per_kw_funding,u32,
msgdata,dual_open_got_offer,feerate_per_kw,u32,
msgdata,dual_open_got_offer,to_self_delay,u16,
msgdata,dual_open_got_offer,max_accepted_htlcs,u16,
msgdata,dual_open_got_offer,channel_flags,u8,
msgdata,dual_open_got_offer,locktime,u32,
msgdata,dual_open_got_offer,shutdown_len,u16,
msgdata,dual_open_got_offer,shutdown_scriptpubkey,u8,shutdown_len
# master->dualopend: reply back with our first funding info/contribs
msgtype,dual_open_got_offer_reply,7105
msgdata,dual_open_got_offer_reply,accepter_funding,amount_sat,
msgdata,dual_open_got_offer_reply,psbt,wally_psbt,
msgdata,dual_open_got_offer_reply,shutdown_len,u16,
msgdata,dual_open_got_offer_reply,our_shutdown_scriptpubkey,?u8,shutdown_len
# dualopend->master: ready to commit channel open to database and
# get some signatures for the funding_tx.
msgtype,dual_open_commit_rcvd,7007
msgdata,dual_open_commit_rcvd,their_config,channel_config,
msgdata,dual_open_commit_rcvd,remote_first_commit,bitcoin_tx,
msgdata,dual_open_commit_rcvd,pbase,?penalty_base,
msgdata,dual_open_commit_rcvd,first_commit_sig,bitcoin_signature,
msgdata,dual_open_commit_rcvd,psbt,wally_psbt,
msgdata,dual_open_commit_rcvd,channel_id,channel_id,
msgdata,dual_open_commit_rcvd,pps,per_peer_state,
msgdata,dual_open_commit_rcvd,revocation_basepoint,pubkey,
msgdata,dual_open_commit_rcvd,payment_basepoint,pubkey,
msgdata,dual_open_commit_rcvd,htlc_basepoint,pubkey,
msgdata,dual_open_commit_rcvd,delayed_payment_basepoint,pubkey,
msgdata,dual_open_commit_rcvd,their_per_commit_point,pubkey,
msgdata,dual_open_commit_rcvd,remote_fundingkey,pubkey,
msgdata,dual_open_commit_rcvd,funding_txid,bitcoin_txid,
msgdata,dual_open_commit_rcvd,funding_txout,u16,
msgdata,dual_open_commit_rcvd,funding_satoshis,amount_sat,
msgdata,dual_open_commit_rcvd,our_funding_sats,amount_sat,
msgdata,dual_open_commit_rcvd,channel_flags,u8,
msgdata,dual_open_commit_rcvd,feerate_per_kw,u32,
# our commitment signatures, for the peer
msgdata,dual_open_commit_rcvd,msglen,u16,
msgdata,dual_open_commit_rcvd,commitment_msg,u8,msglen
msgdata,dual_open_commit_rcvd,our_channel_reserve_satoshis,amount_sat,
msgdata,dual_open_commit_rcvd,local_shutdown_len,u16,
msgdata,dual_open_commit_rcvd,local_shutdown_scriptpubkey,u8,local_shutdown_len
msgdata,dual_open_commit_rcvd,remote_shutdown_len,u16,
msgdata,dual_open_commit_rcvd,remote_shutdown_scriptpubkey,u8,remote_shutdown_len
# dualopend->master: peer updated the psbt
# master->dualopend: response from hook when asking for next moves
msgtype,dual_open_psbt_changed,7107
msgdata,dual_open_psbt_changed,channel_id,channel_id,
msgdata,dual_open_psbt_changed,psbt,wally_psbt,
# master->dualopend: fail this channel open
msgtype,dual_open_fail,7003
msgdata,dual_open_fail,reason,wirestring,
# dualopend->master: we failed to negotiation channel
msgtype,dual_open_failed,7004
msgdata,dual_open_failed,reason,wirestring,
# master -> dualopend: do you have a memleak?
msgtype,dual_open_dev_memleak,7033
msgtype,dual_open_dev_memleak_reply,7133
msgdata,dual_open_dev_memleak_reply,leak,bool,
Can't render this file because it has a wrong number of fields in line 11.

418
openingd/dualopend_wiregen.c

@ -0,0 +1,418 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the .csv file it was generated from. */
/* Original template can be found at tools/gen/impl_template */
#include <openingd/dualopend_wiregen.h>
#include <assert.h>
#include <ccan/array_size/array_size.h>
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <common/utils.h>
#include <stdio.h>
#ifndef SUPERVERBOSE
#define SUPERVERBOSE(...)
#endif
const char *dualopend_wire_name(int e)
{
static char invalidbuf[sizeof("INVALID ") + STR_MAX_CHARS(e)];
switch ((enum dualopend_wire)e) {
case WIRE_DUAL_OPEN_INIT: return "WIRE_DUAL_OPEN_INIT";
case WIRE_DUAL_OPEN_GOT_OFFER: return "WIRE_DUAL_OPEN_GOT_OFFER";
case WIRE_DUAL_OPEN_GOT_OFFER_REPLY: return "WIRE_DUAL_OPEN_GOT_OFFER_REPLY";
case WIRE_DUAL_OPEN_COMMIT_RCVD: return "WIRE_DUAL_OPEN_COMMIT_RCVD";
case WIRE_DUAL_OPEN_PSBT_CHANGED: return "WIRE_DUAL_OPEN_PSBT_CHANGED";
case WIRE_DUAL_OPEN_FAIL: return "WIRE_DUAL_OPEN_FAIL";
case WIRE_DUAL_OPEN_FAILED: return "WIRE_DUAL_OPEN_FAILED";
case WIRE_DUAL_OPEN_DEV_MEMLEAK: return "WIRE_DUAL_OPEN_DEV_MEMLEAK";
case WIRE_DUAL_OPEN_DEV_MEMLEAK_REPLY: return "WIRE_DUAL_OPEN_DEV_MEMLEAK_REPLY";
}
snprintf(invalidbuf, sizeof(invalidbuf), "INVALID %i", e);
return invalidbuf;
}
bool dualopend_wire_is_defined(u16 type)
{
switch ((enum dualopend_wire)type) {
case WIRE_DUAL_OPEN_INIT:;
case WIRE_DUAL_OPEN_GOT_OFFER:;
case WIRE_DUAL_OPEN_GOT_OFFER_REPLY:;
case WIRE_DUAL_OPEN_COMMIT_RCVD:;
case WIRE_DUAL_OPEN_PSBT_CHANGED:;
case WIRE_DUAL_OPEN_FAIL:;
case WIRE_DUAL_OPEN_FAILED:;
case WIRE_DUAL_OPEN_DEV_MEMLEAK:;
case WIRE_DUAL_OPEN_DEV_MEMLEAK_REPLY:;
return true;
}
return false;
}
/* WIRE: DUAL_OPEN_INIT */
u8 *towire_dual_open_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, bool option_anchor_outputs, const u8 *msg)
{
u16 their_init_features_len = tal_count(their_init_features);
u16 len = tal_count(msg);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_DUAL_OPEN_INIT);
/* Which network are we configured for? */
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);
/* Base configuration we'll offer */
towire_channel_config(&p, our_config);
/* Minimum/maximum configuration values we'll accept */
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);
/* Constraints in case the other end tries to open a channel. */
towire_u32(&p, minimum_depth);
towire_u32(&p, min_feerate);
towire_u32(&p, max_feerate);
towire_bool(&p, option_anchor_outputs);
/* Optional msg to send. */
towire_u16(&p, len);
towire_u8_array(&p, msg, len);
return memcheck(p, tal_count(p));
}
bool fromwire_dual_open_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, bool *option_anchor_outputs, u8 **msg)
{
u16 their_init_features_len;
u16 len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_DUAL_OPEN_INIT)
return false;
/* Which network are we configured for? */
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);
/* Base configuration we'll offer */
fromwire_channel_config(&cursor, &plen, our_config);
/* Minimum/maximum configuration values we'll accept */
*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);
/* Constraints in case the other end tries to open a channel. */
*minimum_depth = fromwire_u32(&cursor, &plen);
*min_feerate = fromwire_u32(&cursor, &plen);
*max_feerate = fromwire_u32(&cursor, &plen);
*option_anchor_outputs = fromwire_bool(&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: DUAL_OPEN_GOT_OFFER */
/* dualopend->master: they offered channel */
u8 *towire_dual_open_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_per_kw_funding, u32 feerate_per_kw, u16 to_self_delay, u16 max_accepted_htlcs, u8 channel_flags, u32 locktime, const u8 *shutdown_scriptpubkey)
{
u16 shutdown_len = tal_count(shutdown_scriptpubkey);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_DUAL_OPEN_GOT_OFFER);
towire_amount_sat(&p, opener_funding);
towire_amount_sat(&p, dust_limit_satoshis);
towire_amount_msat(&p, max_htlc_value_in_flight_msat);
towire_amount_msat(&p, htlc_minimum_msat);
towire_u32(&p, feerate_per_kw_funding);
towire_u32(&p, feerate_per_kw);
towire_u16(&p, to_self_delay);
towire_u16(&p, max_accepted_htlcs);
towire_u8(&p, channel_flags);
towire_u32(&p, locktime);
towire_u16(&p, shutdown_len);
towire_u8_array(&p, shutdown_scriptpubkey, shutdown_len);
return memcheck(p, tal_count(p));
}
bool fromwire_dual_open_got_offer(const tal_t *ctx, const void *p, 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_per_kw_funding, u32 *feerate_per_kw, u16 *to_self_delay, u16 *max_accepted_htlcs, u8 *channel_flags, u32 *locktime, u8 **shutdown_scriptpubkey)
{
u16 shutdown_len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_DUAL_OPEN_GOT_OFFER)
return false;
*opener_funding = fromwire_amount_sat(&cursor, &plen);
*dust_limit_satoshis = fromwire_amount_sat(&cursor, &plen);
*max_htlc_value_in_flight_msat = fromwire_amount_msat(&cursor, &plen);
*htlc_minimum_msat = fromwire_amount_msat(&cursor, &plen);
*feerate_per_kw_funding = fromwire_u32(&cursor, &plen);
*feerate_per_kw = fromwire_u32(&cursor, &plen);
*to_self_delay = fromwire_u16(&cursor, &plen);
*max_accepted_htlcs = fromwire_u16(&cursor, &plen);
*channel_flags = fromwire_u8(&cursor, &plen);
*locktime = fromwire_u32(&cursor, &plen);
shutdown_len = fromwire_u16(&cursor, &plen);
// 2nd case shutdown_scriptpubkey
*shutdown_scriptpubkey = shutdown_len ? tal_arr(ctx, u8, shutdown_len) : NULL;
fromwire_u8_array(&cursor, &plen, *shutdown_scriptpubkey, shutdown_len);
return cursor != NULL;
}
/* WIRE: DUAL_OPEN_GOT_OFFER_REPLY */
/* master->dualopend: reply back with our first funding info/contribs */
u8 *towire_dual_open_got_offer_reply(const tal_t *ctx, struct amount_sat accepter_funding, const struct wally_psbt *psbt, const u8 *our_shutdown_scriptpubkey)
{
u16 shutdown_len = tal_count(our_shutdown_scriptpubkey);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_DUAL_OPEN_GOT_OFFER_REPLY);
towire_amount_sat(&p, accepter_funding);
towire_wally_psbt(&p, psbt);
towire_u16(&p, shutdown_len);
towire_u8_array(&p, our_shutdown_scriptpubkey, shutdown_len);
return memcheck(p, tal_count(p));
}
bool fromwire_dual_open_got_offer_reply(const tal_t *ctx, const void *p, struct amount_sat *accepter_funding, struct wally_psbt **psbt, u8 **our_shutdown_scriptpubkey)
{
u16 shutdown_len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_DUAL_OPEN_GOT_OFFER_REPLY)
return false;
*accepter_funding = fromwire_amount_sat(&cursor, &plen);
*psbt = fromwire_wally_psbt(ctx, &cursor, &plen);
shutdown_len = fromwire_u16(&cursor, &plen);
// 2nd case our_shutdown_scriptpubkey
*our_shutdown_scriptpubkey = shutdown_len ? tal_arr(ctx, u8, shutdown_len) : NULL;
fromwire_u8_array(&cursor, &plen, *our_shutdown_scriptpubkey, shutdown_len);
return cursor != NULL;
}
/* WIRE: DUAL_OPEN_COMMIT_RCVD */
/* dualopend->master: ready to commit channel open to database and */
/* get some signatures for the funding_tx. */
u8 *towire_dual_open_commit_rcvd(const tal_t *ctx, const struct channel_config *their_config, const struct bitcoin_tx *remote_first_commit, const struct penalty_base *pbase, const struct bitcoin_signature *first_commit_sig, const struct wally_psbt *psbt, const struct channel_id *channel_id, 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_sat our_funding_sats, u8 channel_flags, u32 feerate_per_kw, const u8 *commitment_msg, struct amount_sat our_channel_reserve_satoshis, const u8 *local_shutdown_scriptpubkey, const u8 *remote_shutdown_scriptpubkey)
{
u16 msglen = tal_count(commitment_msg);
u16 local_shutdown_len = tal_count(local_shutdown_scriptpubkey);
u16 remote_shutdown_len = tal_count(remote_shutdown_scriptpubkey);
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_DUAL_OPEN_COMMIT_RCVD);
towire_channel_config(&p, their_config);
towire_bitcoin_tx(&p, remote_first_commit);
if (!pbase)
towire_bool(&p, false);
else {
towire_bool(&p, true);
towire_penalty_base(&p, pbase);
}
towire_bitcoin_signature(&p, first_commit_sig);
towire_wally_psbt(&p, psbt);
towire_channel_id(&p, channel_id);
towire_per_peer_state(&p, pps);
towire_pubkey(&p, revocation_basepoint);
towire_pubkey(&p, payment_basepoint);
towire_pubkey(&p, htlc_basepoint);
towire_pubkey(&p, delayed_payment_basepoint);
towire_pubkey(&p, their_per_commit_point);
towire_pubkey(&p, remote_fundingkey);
towire_bitcoin_txid(&p, funding_txid);
towire_u16(&p, funding_txout);
towire_amount_sat(&p, funding_satoshis);
towire_amount_sat(&p, our_funding_sats);
towire_u8(&p, channel_flags);
towire_u32(&p, feerate_per_kw);
/* our commitment signatures */
towire_u16(&p, msglen);
towire_u8_array(&p, commitment_msg, msglen);
towire_amount_sat(&p, our_channel_reserve_satoshis);
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);
return memcheck(p, tal_count(p));
}
bool fromwire_dual_open_commit_rcvd(const tal_t *ctx, const void *p, struct channel_config *their_config, struct bitcoin_tx **remote_first_commit, struct penalty_base **pbase, struct bitcoin_signature *first_commit_sig, struct wally_psbt **psbt, struct channel_id *channel_id, 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_sat *our_funding_sats, u8 *channel_flags, u32 *feerate_per_kw, u8 **commitment_msg, struct amount_sat *our_channel_reserve_satoshis, u8 **local_shutdown_scriptpubkey, u8 **remote_shutdown_scriptpubkey)
{
u16 msglen;
u16 local_shutdown_len;
u16 remote_shutdown_len;
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_DUAL_OPEN_COMMIT_RCVD)
return false;
fromwire_channel_config(&cursor, &plen, their_config);
*remote_first_commit = fromwire_bitcoin_tx(ctx, &cursor, &plen);
if (!fromwire_bool(&cursor, &plen))
*pbase = NULL;
else {
*pbase = tal(ctx, struct penalty_base);
fromwire_penalty_base(&cursor, &plen, *pbase);
}
fromwire_bitcoin_signature(&cursor, &plen, first_commit_sig);
*psbt = fromwire_wally_psbt(ctx, &cursor, &plen);
fromwire_channel_id(&cursor, &plen, channel_id);
*pps = fromwire_per_peer_state(ctx, &cursor, &plen);
fromwire_pubkey(&cursor, &plen, revocation_basepoint);
fromwire_pubkey(&cursor, &plen, payment_basepoint);
fromwire_pubkey(&cursor, &plen, htlc_basepoint);
fromwire_pubkey(&cursor, &plen, delayed_payment_basepoint);
fromwire_pubkey(&cursor, &plen, their_per_commit_point);
fromwire_pubkey(&cursor, &plen, remote_fundingkey);
fromwire_bitcoin_txid(&cursor, &plen, funding_txid);
*funding_txout = fromwire_u16(&cursor, &plen);
*funding_satoshis = fromwire_amount_sat(&cursor, &plen);
*our_funding_sats = fromwire_amount_sat(&cursor, &plen);
*channel_flags = fromwire_u8(&cursor, &plen);
*feerate_per_kw = fromwire_u32(&cursor, &plen);
/* our commitment signatures */
msglen = fromwire_u16(&cursor, &plen);
// 2nd case commitment_msg
*commitment_msg = msglen ? tal_arr(ctx, u8, msglen) : NULL;
fromwire_u8_array(&cursor, &plen, *commitment_msg, msglen);
*our_channel_reserve_satoshis = fromwire_amount_sat(&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);
return cursor != NULL;
}
/* WIRE: DUAL_OPEN_PSBT_CHANGED */
/* dualopend->master: peer updated the psbt */
/* master->dualopend: response from hook when asking for next moves */
u8 *towire_dual_open_psbt_changed(const tal_t *ctx, const struct channel_id *channel_id, const struct wally_psbt *psbt)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_DUAL_OPEN_PSBT_CHANGED);
towire_channel_id(&p, channel_id);
towire_wally_psbt(&p, psbt);
return memcheck(p, tal_count(p));
}
bool fromwire_dual_open_psbt_changed(const tal_t *ctx, const void *p, struct channel_id *channel_id, struct wally_psbt **psbt)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_DUAL_OPEN_PSBT_CHANGED)
return false;
fromwire_channel_id(&cursor, &plen, channel_id);
*psbt = fromwire_wally_psbt(ctx, &cursor, &plen);
return cursor != NULL;
}
/* WIRE: DUAL_OPEN_FAIL */
/* master->dualopend: fail this channel open */
u8 *towire_dual_open_fail(const tal_t *ctx, const wirestring *reason)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_DUAL_OPEN_FAIL);
towire_wirestring(&p, reason);
return memcheck(p, tal_count(p));
}
bool fromwire_dual_open_fail(const tal_t *ctx, const void *p, wirestring **reason)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_DUAL_OPEN_FAIL)
return false;
*reason = fromwire_wirestring(ctx, &cursor, &plen);
return cursor != NULL;
}
/* WIRE: DUAL_OPEN_FAILED */
/* dualopend->master: we failed to negotiation channel */
u8 *towire_dual_open_failed(const tal_t *ctx, const wirestring *reason)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_DUAL_OPEN_FAILED);
towire_wirestring(&p, reason);
return memcheck(p, tal_count(p));
}
bool fromwire_dual_open_failed(const tal_t *ctx, const void *p, wirestring **reason)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_DUAL_OPEN_FAILED)
return false;
*reason = fromwire_wirestring(ctx, &cursor, &plen);
return cursor != NULL;
}
/* WIRE: DUAL_OPEN_DEV_MEMLEAK */
/* master -> dualopend: do you have a memleak? */
u8 *towire_dual_open_dev_memleak(const tal_t *ctx)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_DUAL_OPEN_DEV_MEMLEAK);
return memcheck(p, tal_count(p));
}
bool fromwire_dual_open_dev_memleak(const void *p)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_DUAL_OPEN_DEV_MEMLEAK)
return false;
return cursor != NULL;
}
/* WIRE: DUAL_OPEN_DEV_MEMLEAK_REPLY */
u8 *towire_dual_open_dev_memleak_reply(const tal_t *ctx, bool leak)
{
u8 *p = tal_arr(ctx, u8, 0);
towire_u16(&p, WIRE_DUAL_OPEN_DEV_MEMLEAK_REPLY);
towire_bool(&p, leak);
return memcheck(p, tal_count(p));
}
bool fromwire_dual_open_dev_memleak_reply(const void *p, bool *leak)
{
const u8 *cursor = p;
size_t plen = tal_count(p);
if (fromwire_u16(&cursor, &plen) != WIRE_DUAL_OPEN_DEV_MEMLEAK_REPLY)
return false;
*leak = fromwire_bool(&cursor, &plen);
return cursor != NULL;
}
// SHA256STAMP:1c4ae8e18ade1c0dcf975d8573e82c491a52fcda35d193b7302abda8d35dee8e

100
openingd/dualopend_wiregen.h

@ -0,0 +1,100 @@
/* This file was generated by generate-wire.py */
/* Do not modify this file! Modify the _csv file it was generated from. */
/* Original template can be found at tools/gen/header_template */
#ifndef LIGHTNING_OPENINGD_DUALOPEND_WIREGEN_H
#define LIGHTNING_OPENINGD_DUALOPEND_WIREGEN_H
#include <ccan/tal/tal.h>
#include <wire/tlvstream.h>
#include <wire/wire.h>
#include <bitcoin/chainparams.h>
#include <bitcoin/psbt.h>
#include <common/cryptomsg.h>
#include <common/channel_config.h>
#include <common/channel_id.h>
#include <common/derive_basepoints.h>
#include <common/features.h>
#include <common/penalty_base.h>
#include <common/per_peer_state.h>
enum dualopend_wire {
WIRE_DUAL_OPEN_INIT = 7000,
/* dualopend->master: they offered channel */
WIRE_DUAL_OPEN_GOT_OFFER = 7005,
/* master->dualopend: reply back with our first funding info/contribs */
WIRE_DUAL_OPEN_GOT_OFFER_REPLY = 7105,
/* dualopend->master: ready to commit channel open to database and */
/* get some signatures for the funding_tx. */
WIRE_DUAL_OPEN_COMMIT_RCVD = 7007,
/* dualopend->master: peer updated the psbt */
/* master->dualopend: response from hook when asking for next moves */
WIRE_DUAL_OPEN_PSBT_CHANGED = 7107,
/* master->dualopend: fail this channel open */
WIRE_DUAL_OPEN_FAIL = 7003,
/* dualopend->master: we failed to negotiation channel */
WIRE_DUAL_OPEN_FAILED = 7004,
/* master -> dualopend: do you have a memleak? */
WIRE_DUAL_OPEN_DEV_MEMLEAK = 7033,
WIRE_DUAL_OPEN_DEV_MEMLEAK_REPLY = 7133,
};
const char *dualopend_wire_name(int e);
/**
* Determine whether a given message type is defined as a message.
*
* Returns true if the message type is part of the message definitions we have
* generated parsers for, false if it is a custom message that cannot be
* handled internally.
*/
bool dualopend_wire_is_defined(u16 type);
/* WIRE: DUAL_OPEN_INIT */
u8 *towire_dual_open_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, bool option_anchor_outputs, const u8 *msg);
bool fromwire_dual_open_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, bool *option_anchor_outputs, u8 **msg);
/* WIRE: DUAL_OPEN_GOT_OFFER */
/* dualopend->master: they offered channel */
u8 *towire_dual_open_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_per_kw_funding, u32 feerate_per_kw, u16 to_self_delay, u16 max_accepted_htlcs, u8 channel_flags, u32 locktime, const u8 *shutdown_scriptpubkey);
bool fromwire_dual_open_got_offer(const tal_t *ctx, const void *p, 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_per_kw_funding, u32 *feerate_per_kw, u16 *to_self_delay, u16 *max_accepted_htlcs, u8 *channel_flags, u32 *locktime, u8 **shutdown_scriptpubkey);
/* WIRE: DUAL_OPEN_GOT_OFFER_REPLY */
/* master->dualopend: reply back with our first funding info/contribs */
u8 *towire_dual_open_got_offer_reply(const tal_t *ctx, struct amount_sat accepter_funding, const struct wally_psbt *psbt, const u8 *our_shutdown_scriptpubkey);
bool fromwire_dual_open_got_offer_reply(const tal_t *ctx, const void *p, struct amount_sat *accepter_funding, struct wally_psbt **psbt, u8 **our_shutdown_scriptpubkey);
/* WIRE: DUAL_OPEN_COMMIT_RCVD */
/* dualopend->master: ready to commit channel open to database and */
/* get some signatures for the funding_tx. */
u8 *towire_dual_open_commit_rcvd(const tal_t *ctx, const struct channel_config *their_config, const struct bitcoin_tx *remote_first_commit, const struct penalty_base *pbase, const struct bitcoin_signature *first_commit_sig, const struct wally_psbt *psbt, const struct channel_id *channel_id, 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_sat our_funding_sats, u8 channel_flags, u32 feerate_per_kw, const u8 *commitment_msg, struct amount_sat our_channel_reserve_satoshis, const u8 *local_shutdown_scriptpubkey, const u8 *remote_shutdown_scriptpubkey);
bool fromwire_dual_open_commit_rcvd(const tal_t *ctx, const void *p, struct channel_config *their_config, struct bitcoin_tx **remote_first_commit, struct penalty_base **pbase, struct bitcoin_signature *first_commit_sig, struct wally_psbt **psbt, struct channel_id *channel_id, 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_sat *our_funding_sats, u8 *channel_flags, u32 *feerate_per_kw, u8 **commitment_msg, struct amount_sat *our_channel_reserve_satoshis, u8 **local_shutdown_scriptpubkey, u8 **remote_shutdown_scriptpubkey);
/* WIRE: DUAL_OPEN_PSBT_CHANGED */
/* dualopend->master: peer updated the psbt */
/* master->dualopend: response from hook when asking for next moves */
u8 *towire_dual_open_psbt_changed(const tal_t *ctx, const struct channel_id *channel_id, const struct wally_psbt *psbt);
bool fromwire_dual_open_psbt_changed(const tal_t *ctx, const void *p, struct channel_id *channel_id, struct wally_psbt **psbt);
/* WIRE: DUAL_OPEN_FAIL */
/* master->dualopend: fail this channel open */
u8 *towire_dual_open_fail(const tal_t *ctx, const wirestring *reason);
bool fromwire_dual_open_fail(const tal_t *ctx, const void *p, wirestring **reason);
/* WIRE: DUAL_OPEN_FAILED */
/* dualopend->master: we failed to negotiation channel */
u8 *towire_dual_open_failed(const tal_t *ctx, const wirestring *reason);
bool fromwire_dual_open_failed(const tal_t *ctx, const void *p, wirestring **reason);
/* WIRE: DUAL_OPEN_DEV_MEMLEAK */
/* master -> dualopend: do you have a memleak? */
u8 *towire_dual_open_dev_memleak(const tal_t *ctx);
bool fromwire_dual_open_dev_memleak(const void *p);
/* WIRE: DUAL_OPEN_DEV_MEMLEAK_REPLY */
u8 *towire_dual_open_dev_memleak_reply(const tal_t *ctx, bool leak);
bool fromwire_dual_open_dev_memleak_reply(const void *p, bool *leak);
#endif /* LIGHTNING_OPENINGD_DUALOPEND_WIREGEN_H */
// SHA256STAMP:1c4ae8e18ade1c0dcf975d8573e82c491a52fcda35d193b7302abda8d35dee8e
Loading…
Cancel
Save