dual-fund: patch in channel_type logic

There's no reason not to use the channel-types (same as v1s) for v2
opens.

Brings us into compliance with ACINQ's implementation afaict
This commit is contained in:
niftynei
2022-10-21 16:16:45 -05:00
committed by Rusty Russell
parent 4fe8e1eccf
commit df4bd6287a
5 changed files with 91 additions and 37 deletions

View File

@@ -1199,7 +1199,8 @@ wallet_commit_channel(struct lightningd *ld,
const struct amount_sat lease_fee,
secp256k1_ecdsa_signature *lease_commit_sig STEALS,
const u32 lease_chan_max_msat,
const u16 lease_chan_max_ppt)
const u16 lease_chan_max_ppt,
const struct channel_type *type)
{
struct amount_msat our_msat, lease_fee_msat;
struct channel_inflight *inflight;
@@ -1256,7 +1257,9 @@ wallet_commit_channel(struct lightningd *ld,
channel->scb->funding = *funding;
channel->scb->cid = channel->cid;
channel->scb->funding_sats = total_funding;
channel->scb->type = channel_type_dup(channel->scb, channel->type);
channel->type = channel_type_dup(channel, type);
channel->scb->type = channel_type_dup(channel->scb, type);
if (our_upfront_shutdown_script)
channel->shutdown_scriptpubkey[LOCAL]
@@ -2915,6 +2918,7 @@ static void handle_commit_received(struct subd *dualopend,
struct openchannel2_psbt_payload *payload;
struct channel_inflight *inflight;
struct command *cmd = oa->cmd;
struct channel_type *channel_type;
secp256k1_ecdsa_signature *lease_commit_sig;
if (!fromwire_dualopend_commit_rcvd(tmpctx, msg,
@@ -2942,7 +2946,8 @@ static void handle_commit_received(struct subd *dualopend,
&lease_fee,
&lease_commit_sig,
&lease_chan_max_msat,
&lease_chan_max_ppt)) {
&lease_chan_max_ppt,
&channel_type)) {
channel_internal_error(channel,
"Bad WIRE_DUALOPEND_COMMIT_RCVD: %s",
tal_hex(msg, msg));
@@ -2976,7 +2981,8 @@ static void handle_commit_received(struct subd *dualopend,
lease_fee,
lease_commit_sig,
lease_chan_max_msat,
lease_chan_max_ppt))) {
lease_chan_max_ppt,
channel_type))) {
channel_internal_error(channel,
"wallet_commit_channel failed"
" (chan %s)",
@@ -3524,7 +3530,8 @@ bool peer_restart_dualopend(struct peer *peer,
inflight->lease_chan_max_msat,
inflight->lease_chan_max_ppt,
/* FIXME: requested lease? */
NULL);
NULL,
channel->type);
subd_send_msg(channel->owner, take(msg));
return true;