Browse Source

peer_channeld: pass over PSBT, remove second message

We need the PSBT to create the finalized tx from once the peer's
tx_signatures are received. Since we're passing the PSBT, we no longer
need the secondary message to be passed, as it was derived from the
PSBT.

Also removes now unused witness serialization code
travis-experimental
niftynei 4 years ago
committed by Rusty Russell
parent
commit
b2ec5a9f45
  1. 18
      channeld/channeld.c
  2. 4
      channeld/channeld_wire.csv
  3. 16
      channeld/channeld_wiregen.c
  4. 7
      channeld/channeld_wiregen.h
  5. 10
      lightningd/channel_control.c
  6. 4
      lightningd/channel_control.h
  7. 68
      lightningd/dual_open_control.c
  8. 3
      lightningd/peer_control.c
  9. 4
      lightningd/test/run-invoice-select-inchan.c
  10. 2
      wallet/db_postgres_sqlgen.c
  11. 2
      wallet/db_sqlite3_sqlgen.c
  12. 1075
      wallet/statements.po
  13. 2
      wallet/statements_gettextgen.po
  14. 4
      wallet/test/run-wallet.c

18
channeld/channeld.c

@ -47,6 +47,7 @@
#include <common/peer_billboard.h>
#include <common/peer_failed.h>
#include <common/ping.h>
#include <common/psbt_open.h>
#include <common/read_peer_msg.h>
#include <common/sphinx.h>
#include <common/status.h>
@ -180,6 +181,9 @@ struct peer {
/* Penalty bases for this channel / peer. */
struct penalty_base **pbases;
/* PSBT, waiting for peer's tx_sigs */
struct wally_psbt *psbt;
};
static u8 *create_channel_announcement(const tal_t *ctx, struct peer *peer);
@ -3227,7 +3231,7 @@ static void init_channel(struct peer *peer)
enum side opener;
struct existing_htlc **htlcs;
bool reconnected;
u8 *fwd_msg_1, *fwd_msg_2;
u8 *fwd_msg;
const u8 *msg;
struct fee_states *fee_states;
u32 minimum_depth;
@ -3288,8 +3292,7 @@ static void init_channel(struct peer *peer)
&peer->shutdown_sent[REMOTE],
&peer->final_scriptpubkey,
&peer->channel_flags,
&fwd_msg_1,
&fwd_msg_2,
&fwd_msg,
&peer->announce_depth_reached,
&last_remote_per_commit_secret,
&peer->their_features,
@ -3300,7 +3303,8 @@ static void init_channel(struct peer *peer)
&option_anchor_outputs,
&dev_fast_gossip,
&dev_fail_process_onionpacket,
&pbases)) {
&pbases,
&peer->psbt)) {
master_badmsg(WIRE_CHANNELD_INIT, msg);
}
@ -3392,10 +3396,8 @@ static void init_channel(struct peer *peer)
peer_reconnect(peer, &last_remote_per_commit_secret);
/* If we have a messages to send, send them immediately */
if (fwd_msg_1)
sync_crypto_write(peer->pps, take(fwd_msg_1));
if (fwd_msg_2)
sync_crypto_write(peer->pps, take(fwd_msg_2));
if (fwd_msg)
sync_crypto_write(peer->pps, take(fwd_msg));
/* Reenable channel */
channel_announcement_negotiate(peer);

4
channeld/channeld_wire.csv

@ -1,3 +1,4 @@
#include <bitcoin/psbt.h>
#include <common/cryptomsg.h>
#include <common/channel_config.h>
#include <common/channel_id.h>
@ -57,8 +58,6 @@ msgdata,channeld_init,final_scriptpubkey,u8,final_scriptpubkey_len
msgdata,channeld_init,flags,u8,
msgdata,channeld_init,init_peer_pkt_len,u16,
msgdata,channeld_init,init_peer_pkt,u8,init_peer_pkt_len
msgdata,channeld_init,init_peer_pkt_two_len,u16,
msgdata,channeld_init,init_peer_pkt_two,u8,init_peer_pkt_two_len
msgdata,channeld_init,reached_announce_depth,bool,
msgdata,channeld_init,last_remote_secret,secret,
msgdata,channeld_init,flen,u16,
@ -73,6 +72,7 @@ msgdata,channeld_init,dev_fast_gossip,bool,
msgdata,channeld_init,dev_fail_process_onionpacket,bool,
msgdata,channeld_init,num_penalty_bases,u32,
msgdata,channeld_init,pbases,penalty_base,num_penalty_bases
msgdata,channeld_init,psbt,wally_psbt,
# master->channeld funding hit new depth(funding locked if >= lock depth)
msgtype,channeld_funding_depth,1002

Can't render this file because it has a wrong number of fields in line 10.

16
channeld/channeld_wiregen.c

@ -98,13 +98,12 @@ bool channeld_wire_is_defined(u16 type)
/* WIRE: CHANNELD_INIT */
/* Begin! (passes gossipd-client fd) */
u8 *towire_channeld_init(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_features, const struct channel_id *channel_id, const struct bitcoin_txid *funding_txid, u16 funding_txout, struct amount_sat funding_satoshi, u32 minimum_depth, const struct channel_config *our_config, const struct channel_config *their_config, const struct fee_states *fee_states, u32 feerate_min, u32 feerate_max, u32 feerate_penalty, const struct bitcoin_signature *first_commit_sig, const struct per_peer_state *per_peer_state, const struct pubkey *remote_fundingkey, const struct basepoints *remote_basepoints, const struct pubkey *remote_per_commit, const struct pubkey *old_remote_per_commit, enum side opener, u32 fee_base, u32 fee_proportional, struct amount_msat local_msatoshi, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, const struct node_id *local_node_id, const struct node_id *remote_node_id, u32 commit_msec, u16 cltv_delta, bool last_was_revoke, const struct changed_htlc *last_sent_commit, u64 next_index_local, u64 next_index_remote, u64 revocations_received, u64 next_htlc_id, const struct existing_htlc **htlcs, bool local_funding_locked, bool remote_funding_locked, const struct short_channel_id *funding_short_id, bool reestablish, bool send_shutdown, bool remote_shutdown_received, const u8 *final_scriptpubkey, u8 flags, const u8 *init_peer_pkt, const u8 *init_peer_pkt_two, bool reached_announce_depth, const struct secret *last_remote_secret, const u8 *their_features, const u8 *upfront_shutdown_script, const secp256k1_ecdsa_signature *remote_ann_node_sig, const secp256k1_ecdsa_signature *remote_ann_bitcoin_sig, bool option_static_remotekey, bool option_anchor_outputs, bool dev_fast_gossip, bool dev_fail_process_onionpacket, const struct penalty_base *pbases)
u8 *towire_channeld_init(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_features, const struct channel_id *channel_id, const struct bitcoin_txid *funding_txid, u16 funding_txout, struct amount_sat funding_satoshi, u32 minimum_depth, const struct channel_config *our_config, const struct channel_config *their_config, const struct fee_states *fee_states, u32 feerate_min, u32 feerate_max, u32 feerate_penalty, const struct bitcoin_signature *first_commit_sig, const struct per_peer_state *per_peer_state, const struct pubkey *remote_fundingkey, const struct basepoints *remote_basepoints, const struct pubkey *remote_per_commit, const struct pubkey *old_remote_per_commit, enum side opener, u32 fee_base, u32 fee_proportional, struct amount_msat local_msatoshi, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, const struct node_id *local_node_id, const struct node_id *remote_node_id, u32 commit_msec, u16 cltv_delta, bool last_was_revoke, const struct changed_htlc *last_sent_commit, u64 next_index_local, u64 next_index_remote, u64 revocations_received, u64 next_htlc_id, const struct existing_htlc **htlcs, bool local_funding_locked, bool remote_funding_locked, const struct short_channel_id *funding_short_id, bool reestablish, bool send_shutdown, bool remote_shutdown_received, const u8 *final_scriptpubkey, u8 flags, const u8 *init_peer_pkt, bool reached_announce_depth, const struct secret *last_remote_secret, const u8 *their_features, const u8 *upfront_shutdown_script, const secp256k1_ecdsa_signature *remote_ann_node_sig, const secp256k1_ecdsa_signature *remote_ann_bitcoin_sig, bool option_static_remotekey, bool option_anchor_outputs, bool dev_fast_gossip, bool dev_fail_process_onionpacket, const struct penalty_base *pbases, const struct wally_psbt *psbt)
{
u16 num_last_sent_commit = tal_count(last_sent_commit);
u16 num_existing_htlcs = tal_count(htlcs);
u16 final_scriptpubkey_len = tal_count(final_scriptpubkey);
u16 init_peer_pkt_len = tal_count(init_peer_pkt);
u16 init_peer_pkt_two_len = tal_count(init_peer_pkt_two);
u16 flen = tal_count(their_features);
u16 upfront_shutdown_script_len = tal_count(upfront_shutdown_script);
u32 num_penalty_bases = tal_count(pbases);
@ -162,8 +161,6 @@ u8 *towire_channeld_init(const tal_t *ctx, const struct chainparams *chainparams
towire_u8(&p, flags);
towire_u16(&p, init_peer_pkt_len);
towire_u8_array(&p, init_peer_pkt, init_peer_pkt_len);
towire_u16(&p, init_peer_pkt_two_len);
towire_u8_array(&p, init_peer_pkt_two, init_peer_pkt_two_len);
towire_bool(&p, reached_announce_depth);
towire_secret(&p, last_remote_secret);
towire_u16(&p, flen);
@ -189,16 +186,16 @@ u8 *towire_channeld_init(const tal_t *ctx, const struct chainparams *chainparams
towire_u32(&p, num_penalty_bases);
for (size_t i = 0; i < num_penalty_bases; i++)
towire_penalty_base(&p, pbases + i);
towire_wally_psbt(&p, psbt);
return memcheck(p, tal_count(p));
}
bool fromwire_channeld_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_features, struct channel_id *channel_id, struct bitcoin_txid *funding_txid, u16 *funding_txout, struct amount_sat *funding_satoshi, u32 *minimum_depth, struct channel_config *our_config, struct channel_config *their_config, struct fee_states **fee_states, u32 *feerate_min, u32 *feerate_max, u32 *feerate_penalty, struct bitcoin_signature *first_commit_sig, struct per_peer_state **per_peer_state, struct pubkey *remote_fundingkey, struct basepoints *remote_basepoints, struct pubkey *remote_per_commit, struct pubkey *old_remote_per_commit, enum side *opener, u32 *fee_base, u32 *fee_proportional, struct amount_msat *local_msatoshi, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, struct node_id *local_node_id, struct node_id *remote_node_id, u32 *commit_msec, u16 *cltv_delta, bool *last_was_revoke, struct changed_htlc **last_sent_commit, u64 *next_index_local, u64 *next_index_remote, u64 *revocations_received, u64 *next_htlc_id, struct existing_htlc ***htlcs, bool *local_funding_locked, bool *remote_funding_locked, struct short_channel_id *funding_short_id, bool *reestablish, bool *send_shutdown, bool *remote_shutdown_received, u8 **final_scriptpubkey, u8 *flags, u8 **init_peer_pkt, u8 **init_peer_pkt_two, bool *reached_announce_depth, struct secret *last_remote_secret, u8 **their_features, u8 **upfront_shutdown_script, secp256k1_ecdsa_signature **remote_ann_node_sig, secp256k1_ecdsa_signature **remote_ann_bitcoin_sig, bool *option_static_remotekey, bool *option_anchor_outputs, bool *dev_fast_gossip, bool *dev_fail_process_onionpacket, struct penalty_base **pbases)
bool fromwire_channeld_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_features, struct channel_id *channel_id, struct bitcoin_txid *funding_txid, u16 *funding_txout, struct amount_sat *funding_satoshi, u32 *minimum_depth, struct channel_config *our_config, struct channel_config *their_config, struct fee_states **fee_states, u32 *feerate_min, u32 *feerate_max, u32 *feerate_penalty, struct bitcoin_signature *first_commit_sig, struct per_peer_state **per_peer_state, struct pubkey *remote_fundingkey, struct basepoints *remote_basepoints, struct pubkey *remote_per_commit, struct pubkey *old_remote_per_commit, enum side *opener, u32 *fee_base, u32 *fee_proportional, struct amount_msat *local_msatoshi, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, struct node_id *local_node_id, struct node_id *remote_node_id, u32 *commit_msec, u16 *cltv_delta, bool *last_was_revoke, struct changed_htlc **last_sent_commit, u64 *next_index_local, u64 *next_index_remote, u64 *revocations_received, u64 *next_htlc_id, struct existing_htlc ***htlcs, bool *local_funding_locked, bool *remote_funding_locked, struct short_channel_id *funding_short_id, bool *reestablish, bool *send_shutdown, bool *remote_shutdown_received, u8 **final_scriptpubkey, u8 *flags, u8 **init_peer_pkt, bool *reached_announce_depth, struct secret *last_remote_secret, u8 **their_features, u8 **upfront_shutdown_script, secp256k1_ecdsa_signature **remote_ann_node_sig, secp256k1_ecdsa_signature **remote_ann_bitcoin_sig, bool *option_static_remotekey, bool *option_anchor_outputs, bool *dev_fast_gossip, bool *dev_fail_process_onionpacket, struct penalty_base **pbases, struct wally_psbt **psbt)
{
u16 num_last_sent_commit;
u16 num_existing_htlcs;
u16 final_scriptpubkey_len;
u16 init_peer_pkt_len;
u16 init_peer_pkt_two_len;
u16 flen;
u16 upfront_shutdown_script_len;
u32 num_penalty_bases;
@ -267,10 +264,6 @@ bool fromwire_channeld_init(const tal_t *ctx, const void *p, const struct chainp
// 2nd case init_peer_pkt
*init_peer_pkt = init_peer_pkt_len ? tal_arr(ctx, u8, init_peer_pkt_len) : NULL;
fromwire_u8_array(&cursor, &plen, *init_peer_pkt, init_peer_pkt_len);
init_peer_pkt_two_len = fromwire_u16(&cursor, &plen);
// 2nd case init_peer_pkt_two
*init_peer_pkt_two = init_peer_pkt_two_len ? tal_arr(ctx, u8, init_peer_pkt_two_len) : NULL;
fromwire_u8_array(&cursor, &plen, *init_peer_pkt_two, init_peer_pkt_two_len);
*reached_announce_depth = fromwire_bool(&cursor, &plen);
fromwire_secret(&cursor, &plen, last_remote_secret);
flen = fromwire_u16(&cursor, &plen);
@ -302,6 +295,7 @@ bool fromwire_channeld_init(const tal_t *ctx, const void *p, const struct chainp
*pbases = num_penalty_bases ? tal_arr(ctx, struct penalty_base, num_penalty_bases) : NULL;
for (size_t i = 0; i < num_penalty_bases; i++)
fromwire_penalty_base(&cursor, &plen, *pbases + i);
*psbt = fromwire_wally_psbt(ctx, &cursor, &plen);
return cursor != NULL;
}
@ -1194,4 +1188,4 @@ bool fromwire_send_onionmsg(const tal_t *ctx, const void *p, u8 onion[1366], str
}
return cursor != NULL;
}
// SHA256STAMP:51cb93dbaf723c888a9ac8f99222c4e85b64bfdefcd374ae62f6557e9d628d8b
// SHA256STAMP:8ba694ae5e240ca5622d6860d1fa2b5116e44b2b8d5bfe0a77d88d4aab979906

7
channeld/channeld_wiregen.h

@ -7,6 +7,7 @@
#include <ccan/tal/tal.h>
#include <wire/tlvstream.h>
#include <wire/wire.h>
#include <bitcoin/psbt.h>
#include <common/cryptomsg.h>
#include <common/channel_config.h>
#include <common/channel_id.h>
@ -89,8 +90,8 @@ bool channeld_wire_is_defined(u16 type);
/* WIRE: CHANNELD_INIT */
/* Begin! (passes gossipd-client fd) */
u8 *towire_channeld_init(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_features, const struct channel_id *channel_id, const struct bitcoin_txid *funding_txid, u16 funding_txout, struct amount_sat funding_satoshi, u32 minimum_depth, const struct channel_config *our_config, const struct channel_config *their_config, const struct fee_states *fee_states, u32 feerate_min, u32 feerate_max, u32 feerate_penalty, const struct bitcoin_signature *first_commit_sig, const struct per_peer_state *per_peer_state, const struct pubkey *remote_fundingkey, const struct basepoints *remote_basepoints, const struct pubkey *remote_per_commit, const struct pubkey *old_remote_per_commit, enum side opener, u32 fee_base, u32 fee_proportional, struct amount_msat local_msatoshi, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, const struct node_id *local_node_id, const struct node_id *remote_node_id, u32 commit_msec, u16 cltv_delta, bool last_was_revoke, const struct changed_htlc *last_sent_commit, u64 next_index_local, u64 next_index_remote, u64 revocations_received, u64 next_htlc_id, const struct existing_htlc **htlcs, bool local_funding_locked, bool remote_funding_locked, const struct short_channel_id *funding_short_id, bool reestablish, bool send_shutdown, bool remote_shutdown_received, const u8 *final_scriptpubkey, u8 flags, const u8 *init_peer_pkt, const u8 *init_peer_pkt_two, bool reached_announce_depth, const struct secret *last_remote_secret, const u8 *their_features, const u8 *upfront_shutdown_script, const secp256k1_ecdsa_signature *remote_ann_node_sig, const secp256k1_ecdsa_signature *remote_ann_bitcoin_sig, bool option_static_remotekey, bool option_anchor_outputs, bool dev_fast_gossip, bool dev_fail_process_onionpacket, const struct penalty_base *pbases);
bool fromwire_channeld_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_features, struct channel_id *channel_id, struct bitcoin_txid *funding_txid, u16 *funding_txout, struct amount_sat *funding_satoshi, u32 *minimum_depth, struct channel_config *our_config, struct channel_config *their_config, struct fee_states **fee_states, u32 *feerate_min, u32 *feerate_max, u32 *feerate_penalty, struct bitcoin_signature *first_commit_sig, struct per_peer_state **per_peer_state, struct pubkey *remote_fundingkey, struct basepoints *remote_basepoints, struct pubkey *remote_per_commit, struct pubkey *old_remote_per_commit, enum side *opener, u32 *fee_base, u32 *fee_proportional, struct amount_msat *local_msatoshi, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, struct node_id *local_node_id, struct node_id *remote_node_id, u32 *commit_msec, u16 *cltv_delta, bool *last_was_revoke, struct changed_htlc **last_sent_commit, u64 *next_index_local, u64 *next_index_remote, u64 *revocations_received, u64 *next_htlc_id, struct existing_htlc ***htlcs, bool *local_funding_locked, bool *remote_funding_locked, struct short_channel_id *funding_short_id, bool *reestablish, bool *send_shutdown, bool *remote_shutdown_received, u8 **final_scriptpubkey, u8 *flags, u8 **init_peer_pkt, u8 **init_peer_pkt_two, bool *reached_announce_depth, struct secret *last_remote_secret, u8 **their_features, u8 **upfront_shutdown_script, secp256k1_ecdsa_signature **remote_ann_node_sig, secp256k1_ecdsa_signature **remote_ann_bitcoin_sig, bool *option_static_remotekey, bool *option_anchor_outputs, bool *dev_fast_gossip, bool *dev_fail_process_onionpacket, struct penalty_base **pbases);
u8 *towire_channeld_init(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_features, const struct channel_id *channel_id, const struct bitcoin_txid *funding_txid, u16 funding_txout, struct amount_sat funding_satoshi, u32 minimum_depth, const struct channel_config *our_config, const struct channel_config *their_config, const struct fee_states *fee_states, u32 feerate_min, u32 feerate_max, u32 feerate_penalty, const struct bitcoin_signature *first_commit_sig, const struct per_peer_state *per_peer_state, const struct pubkey *remote_fundingkey, const struct basepoints *remote_basepoints, const struct pubkey *remote_per_commit, const struct pubkey *old_remote_per_commit, enum side opener, u32 fee_base, u32 fee_proportional, struct amount_msat local_msatoshi, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, const struct node_id *local_node_id, const struct node_id *remote_node_id, u32 commit_msec, u16 cltv_delta, bool last_was_revoke, const struct changed_htlc *last_sent_commit, u64 next_index_local, u64 next_index_remote, u64 revocations_received, u64 next_htlc_id, const struct existing_htlc **htlcs, bool local_funding_locked, bool remote_funding_locked, const struct short_channel_id *funding_short_id, bool reestablish, bool send_shutdown, bool remote_shutdown_received, const u8 *final_scriptpubkey, u8 flags, const u8 *init_peer_pkt, bool reached_announce_depth, const struct secret *last_remote_secret, const u8 *their_features, const u8 *upfront_shutdown_script, const secp256k1_ecdsa_signature *remote_ann_node_sig, const secp256k1_ecdsa_signature *remote_ann_bitcoin_sig, bool option_static_remotekey, bool option_anchor_outputs, bool dev_fast_gossip, bool dev_fail_process_onionpacket, const struct penalty_base *pbases, const struct wally_psbt *psbt);
bool fromwire_channeld_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_features, struct channel_id *channel_id, struct bitcoin_txid *funding_txid, u16 *funding_txout, struct amount_sat *funding_satoshi, u32 *minimum_depth, struct channel_config *our_config, struct channel_config *their_config, struct fee_states **fee_states, u32 *feerate_min, u32 *feerate_max, u32 *feerate_penalty, struct bitcoin_signature *first_commit_sig, struct per_peer_state **per_peer_state, struct pubkey *remote_fundingkey, struct basepoints *remote_basepoints, struct pubkey *remote_per_commit, struct pubkey *old_remote_per_commit, enum side *opener, u32 *fee_base, u32 *fee_proportional, struct amount_msat *local_msatoshi, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, struct node_id *local_node_id, struct node_id *remote_node_id, u32 *commit_msec, u16 *cltv_delta, bool *last_was_revoke, struct changed_htlc **last_sent_commit, u64 *next_index_local, u64 *next_index_remote, u64 *revocations_received, u64 *next_htlc_id, struct existing_htlc ***htlcs, bool *local_funding_locked, bool *remote_funding_locked, struct short_channel_id *funding_short_id, bool *reestablish, bool *send_shutdown, bool *remote_shutdown_received, u8 **final_scriptpubkey, u8 *flags, u8 **init_peer_pkt, bool *reached_announce_depth, struct secret *last_remote_secret, u8 **their_features, u8 **upfront_shutdown_script, secp256k1_ecdsa_signature **remote_ann_node_sig, secp256k1_ecdsa_signature **remote_ann_bitcoin_sig, bool *option_static_remotekey, bool *option_anchor_outputs, bool *dev_fast_gossip, bool *dev_fail_process_onionpacket, struct penalty_base **pbases, struct wally_psbt **psbt);
/* WIRE: CHANNELD_FUNDING_DEPTH */
/* master->channeld funding hit new depth(funding locked if >= lock depth) */
@ -230,4 +231,4 @@ bool fromwire_send_onionmsg(const tal_t *ctx, const void *p, u8 onion[1366], str
#endif /* LIGHTNING_CHANNELD_CHANNELD_WIREGEN_H */
// SHA256STAMP:51cb93dbaf723c888a9ac8f99222c4e85b64bfdefcd374ae62f6557e9d628d8b
// SHA256STAMP:8ba694ae5e240ca5622d6860d1fa2b5116e44b2b8d5bfe0a77d88d4aab979906

10
lightningd/channel_control.c

@ -415,8 +415,8 @@ static unsigned channel_msg(struct subd *sd, const u8 *msg, const int *fds)
void peer_start_channeld(struct channel *channel,
struct per_peer_state *pps,
const u8 *fwd_msg_1,
const u8 *fwd_msg_2,
const u8 *fwd_msg,
const struct wally_psbt *psbt,
bool reconnected)
{
u8 *initmsg;
@ -557,8 +557,7 @@ void peer_start_channeld(struct channel *channel,
channel->shutdown_scriptpubkey[REMOTE] != NULL,
channel->shutdown_scriptpubkey[LOCAL],
channel->channel_flags,
fwd_msg_1,
fwd_msg_2,
fwd_msg,
reached_announce_depth,
&last_remote_per_commit_secret,
channel->peer->their_features,
@ -571,7 +570,8 @@ void peer_start_channeld(struct channel *channel,
channel->option_anchor_outputs,
IFDEV(ld->dev_fast_gossip, false),
IFDEV(dev_fail_process_onionpacket, false),
pbases);
pbases,
psbt);
/* We don't expect a response: we are triggered by funding_depth_cb. */
subd_send_msg(channel->owner, take(initmsg));

4
lightningd/channel_control.h

@ -12,8 +12,8 @@ struct peer;
void peer_start_channeld(struct channel *channel,
struct per_peer_state *pps,
const u8 *fwd_msg_1,
const u8 *fwd_msg_2,
const u8 *fwd_msg,
const struct wally_psbt *psbt,
bool reconnected);
/* Returns true if subd told, otherwise false. */

68
lightningd/dual_open_control.c

@ -38,57 +38,6 @@ struct commit_rcvd {
struct uncommitted_channel *uc;
};
static const struct witness_stack **
psbt_to_witness_stacks(const tal_t *ctx, struct log *log,
const struct wally_psbt *psbt, enum side opener)
{
size_t stack_index;
u16 serial_id;
const struct witness_stack **stacks
= tal_arr(ctx, const struct witness_stack *, psbt->num_inputs);
stack_index = 0;
for (size_t i = 0; i < psbt->num_inputs; i++) {
if (!psbt_get_serial_id(&psbt->inputs[i].unknowns, &serial_id)) {
log_broken(log, "dual funding PSBT must have serial_id for each "
"input, none found for input %zu", i);
return NULL;
}
if (serial_id % 2 == opener) {
struct wally_tx_witness_stack *wtx_s =
psbt->inputs[i].final_witness;
struct witness_stack *stack =
tal(stacks, struct witness_stack);
/* Convert the wally_tx_witness_stack to
* a witness_stack entry */
stack->witness_element =
tal_arr(stack, struct witness_element *,
wtx_s->num_items);
for (size_t j = 0; j < tal_count(stack->witness_element); j++) {
stack->witness_element[j] = tal(stack,
struct witness_element);
stack->witness_element[j]->witness =
tal_dup_arr(stack, u8,
wtx_s->items[j].witness,
wtx_s->items[j].witness_len,
0);
}
stacks[stack_index++] = stack;
}
}
if (stack_index == 0)
return tal_free(stacks);
tal_resize(&stacks, stack_index);
return stacks;
}
static bool psbt_side_finalized(struct log *log, struct wally_psbt *psbt, enum side opener)
{
u16 serial_id;
@ -116,26 +65,13 @@ static void handle_signed_psbt(struct lightningd *ld,
const struct wally_psbt *psbt,
struct commit_rcvd *rcvd)
{
const struct witness_stack **ws =
psbt_to_witness_stacks(tmpctx, ld->log, psbt, REMOTE);
const u8 *fwd_msg_2;
/* We've already confirmed that all of the supplied info is good,
* so now go ahead and create a tx_signatures msg.
* We'll pass the tx_sigs msg and the already-created
* commitment_signed tx to channeld, who will send
* both of them to the peer. */
fwd_msg_2 = towire_tx_signatures(rcvd, &rcvd->channel->cid,
&rcvd->channel->funding_txid,
ws);
channel_watch_funding(ld, rcvd->channel);
peer_start_channeld(rcvd->channel,
rcvd->pps,
rcvd->commitment_msg,
fwd_msg_2, false);
psbt, false);
tal_free(rcvd->uc);
}
/* ~Map of the Territory~

3
lightningd/peer_control.c

@ -992,7 +992,8 @@ peer_connected_hook_cb(struct peer_connected_hook_payload *payload STEALS,
assert(!channel->owner);
channel->peer->addr = addr;
peer_start_channeld(channel, payload->pps, NULL, NULL,
peer_start_channeld(channel, payload->pps,
NULL, NULL,
true);
tal_free(payload);
return;

4
lightningd/test/run-invoice-select-inchan.c

@ -463,8 +463,8 @@ struct channel *peer_normal_channel(struct peer *peer UNNEEDED)
/* Generated stub for peer_start_channeld */
void peer_start_channeld(struct channel *channel UNNEEDED,
struct per_peer_state *pps UNNEEDED,
const u8 *fwd_msg_1 UNNEEDED,
const u8 *fwd_msg_2 UNNEEDED,
const u8 *fwd_msg UNNEEDED,
const struct wally_psbt *psbt UNNEEDED,
bool reconnected UNNEEDED)
{ fprintf(stderr, "peer_start_channeld called!\n"); abort(); }
/* Generated stub for peer_start_closingd */

2
wallet/db_postgres_sqlgen.c

@ -1654,4 +1654,4 @@ struct db_query db_postgres_queries[] = {
#endif /* LIGHTNINGD_WALLET_GEN_DB_POSTGRES */
// SHA256STAMP:e395834264c88a46c76e9e19347340507d615ad7902ddb5e179f253db7dc55e7
// SHA256STAMP:7822f20e594b864ce83c94471a44146bb094f3ffef61b5107505e3d3091bfd28

2
wallet/db_sqlite3_sqlgen.c

@ -1654,4 +1654,4 @@ struct db_query db_sqlite3_queries[] = {
#endif /* LIGHTNINGD_WALLET_GEN_DB_SQLITE3 */
// SHA256STAMP:e395834264c88a46c76e9e19347340507d615ad7902ddb5e179f253db7dc55e7
// SHA256STAMP:7822f20e594b864ce83c94471a44146bb094f3ffef61b5107505e3d3091bfd28

1075
wallet/statements.po

File diff suppressed because it is too large

2
wallet/statements_gettextgen.po

@ -1089,4 +1089,4 @@ msgstr ""
#: wallet/test/run-wallet.c:1359
msgid "INSERT INTO channels (id) VALUES (1);"
msgstr ""
# SHA256STAMP:06772e06eea0d31f3172982d9a4fac7326f8ce39868ff405fd4e7babe923f17c
# SHA256STAMP:d7ed3fc011780a6ec24db6ce4dc521588fabd0df1a520403942317d60d03a56f

4
wallet/test/run-wallet.c

@ -576,8 +576,8 @@ void peer_memleak_done(struct command *cmd UNNEEDED, struct subd *leaker UNNEEDE
/* Generated stub for peer_start_channeld */
void peer_start_channeld(struct channel *channel UNNEEDED,
struct per_peer_state *pps UNNEEDED,
const u8 *fwd_msg_1 UNNEEDED,
const u8 *fwd_msg_2 UNNEEDED,
const u8 *fwd_msg UNNEEDED,
const struct wally_psbt *psbt UNNEEDED,
bool reconnected UNNEEDED)
{ fprintf(stderr, "peer_start_channeld called!\n"); abort(); }
/* Generated stub for peer_start_closingd */

Loading…
Cancel
Save