diff --git a/channeld/channeld.c b/channeld/channeld.c index c00081a78e0e..c9ed41d7b2b3 100644 --- a/channeld/channeld.c +++ b/channeld/channeld.c @@ -511,13 +511,14 @@ static void check_mutual_splice_locked(struct peer *peer) } /* Our peer told us they saw our splice confirm on chain with `splice_locked`. - * If we see it to we jump into tansitioning to post-splice, otherwise we mark + * If we see it to we jump into transitioning to post-splice, otherwise we mark * a flag and wait until we see it on chain too. */ static void handle_peer_splice_locked(struct peer *peer, const u8 *msg) { struct channel_id chanid; + struct bitcoin_txid splice_txid; - if (!fromwire_splice_locked(msg, &chanid)) + if (!fromwire_splice_locked(msg, &chanid, &splice_txid)) peer_failed_warn(peer->pps, &peer->channel_id, "Bad splice_locked %s", tal_hex(msg, msg)); @@ -3306,7 +3307,7 @@ static void resume_splice_negotiation(struct peer *peer, struct bitcoin_tx *bitcoin_tx; u32 splice_funding_index; const u8 *msg, *sigmsg; - u32 chan_output_index; + u32 new_output_index; struct pubkey *their_pubkey; struct bitcoin_tx *final_tx; struct bitcoin_txid final_txid; @@ -3337,8 +3338,8 @@ static void resume_splice_negotiation(struct peer *peer, &peer->channel->funding_pubkey[LOCAL], &peer->channel->funding_pubkey[REMOTE]); - find_channel_output(peer, current_psbt, &chan_output_index, - &peer->channel->funding_pubkey[REMOTE]); + find_channel_output(peer, current_psbt, &new_output_index, + &inflight->remote_funding); splice_funding_index = find_channel_funding_input(current_psbt, &peer->channel->funding); @@ -3622,7 +3623,7 @@ static void resume_splice_negotiation(struct peer *peer, final_tx = bitcoin_tx_with_psbt(tmpctx, current_psbt); msg = towire_channeld_splice_confirmed_signed(tmpctx, final_tx, - chan_output_index); + new_output_index); wire_sync_write(MASTER_FD, take(msg)); } } @@ -3944,6 +3945,7 @@ static void splice_initiator(struct peer *peer, const u8 *inmsg) ictx->shared_outpoint = tal(ictx, struct bitcoin_outpoint); *ictx->shared_outpoint = peer->channel->funding; ictx->funding_tx = prev_tx; + status_info("splice_initiator ictx->shared_outpoint = %s",(ictx->shared_outpoint?"defined":"null")); peer->splicing->tx_add_input_count = 0; peer->splicing->tx_add_output_count = 0; @@ -3995,6 +3997,7 @@ static void splice_initiator_user_finalized(struct peer *peer) ictx->shared_outpoint = tal(ictx, struct bitcoin_outpoint); *ictx->shared_outpoint = peer->channel->funding; + status_info("splice_initiator_user_finalized: ictx->shared_outpoint = %s",(ictx->shared_outpoint?"defined":"null")); ictx->funding_tx = prev_tx; error = process_interactivetx_updates(tmpctx, ictx, @@ -4143,6 +4146,10 @@ static void splice_initiator_user_update(struct peer *peer, const u8 *inmsg) ictx->tx_add_input_count = peer->splicing->tx_add_input_count; ictx->tx_add_output_count = peer->splicing->tx_add_output_count; + ictx->shared_outpoint = tal(ictx, struct bitcoin_outpoint); + *ictx->shared_outpoint = peer->channel->funding; + ictx->funding_tx = bitcoin_tx_from_txid(peer, peer->channel->funding.txid); + /* If there no are no changes, we consider the splice user finalized */ if (!interactivetx_has_changes(ictx, ictx->desired_psbt)) { splice_initiator_user_finalized(peer); @@ -5214,7 +5221,7 @@ static void peer_reconnect(struct peer *peer, status_info("We have no pending splice but peer" " expects one; resending splice_lock"); peer_write(peer->pps, - take(towire_splice_locked(NULL, &peer->channel_id))); + take(towire_splice_locked(NULL, &peer->channel_id, &peer->channel->funding.txid))); } else { splice_abort(peer, "next_funding_txid not recognized." @@ -5593,10 +5600,10 @@ static void handle_funding_depth(struct peer *peer, const u8 *msg) } else if(splicing && !peer->splice_state->locked_ready[LOCAL]) { assert(scid); - msg = towire_splice_locked(NULL, &peer->channel_id); - peer->splice_state->locked_txid = txid; + msg = towire_splice_locked(NULL, &peer->channel_id, &peer->splice_state->locked_txid); + peer_write(peer->pps, take(msg)); peer->splice_state->locked_ready[LOCAL] = true; diff --git a/common/interactivetx.c b/common/interactivetx.c index a9163a7dcf1c..ef8763e8e3a0 100644 --- a/common/interactivetx.c +++ b/common/interactivetx.c @@ -227,12 +227,22 @@ static char *send_next(const tal_t *ctx, /* If this the shared channel input, we send funding txid in * in tlvs and do not send prevtx */ + status_info("ictx->shared_outpoint = %s",(ictx->shared_outpoint?"defined":"null")); + char txid_hex[65]; + if (ictx->shared_outpoint && bitcoin_txid_to_hex(&(ictx->shared_outpoint->txid), txid_hex, sizeof(txid_hex))) { + status_info("ictx->shared_outpoint->txid=%s, ictx->shared_outpoint->n=%d", txid_hex, ictx->shared_outpoint->n); + } + if (bitcoin_txid_to_hex(&(point.txid), txid_hex, sizeof(txid_hex))) { + status_info("point.txid=%s, point.n=%d", txid_hex, point.n); + } + status_info("here2"); if (ictx->shared_outpoint && bitcoin_outpoint_eq(&point, ictx->shared_outpoint)) { - struct tlv_tx_add_input_tlvs *tlvs = tal(tmpctx, struct tlv_tx_add_input_tlvs); + struct tlv_tx_add_input_tlvs *tlvs = tlv_tx_add_input_tlvs_new(tmpctx); tlvs->shared_input_txid = tal_dup(tlvs, struct bitcoin_txid, &point.txid); + status_info("Adding shared input %s", tal_hexstr(ctx, &serial_id, sizeof(serial_id))); msg = towire_tx_add_input(NULL, cid, serial_id, NULL, in->input.index, in->input.sequence, tlvs); @@ -240,6 +250,7 @@ static char *send_next(const tal_t *ctx, msg = towire_tx_add_input(NULL, cid, serial_id, prevtx, in->input.index, in->input.sequence, NULL); + status_info("Adding splice input %s", tal_hexstr(ctx, &serial_id, sizeof(serial_id))); } tal_arr_remove(&set->added_ins, 0); diff --git a/wire/peer_wire.csv b/wire/peer_wire.csv index c36d90807b08..183a2c143cc4 100644 --- a/wire/peer_wire.csv +++ b/wire/peer_wire.csv @@ -223,6 +223,7 @@ msgdata,splice_ack,relative_satoshis,s64, msgdata,splice_ack,funding_pubkey,point, msgtype,splice_locked,77, msgdata,splice_locked,channel_id,channel_id, +msgdata,splice_locked,splice_txid,sha256, msgtype,shutdown,38 msgdata,shutdown,channel_id,channel_id, msgdata,shutdown,len,u16,