diff --git a/lightningd/channel/channel.c b/lightningd/channel/channel.c index 6390c8359..0f7ab6433 100644 --- a/lightningd/channel/channel.c +++ b/lightningd/channel/channel.c @@ -742,7 +742,8 @@ static u8 *got_commitsig_msg(const tal_t *ctx, u64 local_commit_index, const secp256k1_ecdsa_signature *commit_sig, const secp256k1_ecdsa_signature *htlc_sigs, - const struct htlc **changed_htlcs) + const struct htlc **changed_htlcs, + const struct bitcoin_tx *committx) { const tal_t *tmpctx = tal_tmpctx(ctx); struct changed_htlc *changed; @@ -803,7 +804,8 @@ static u8 *got_commitsig_msg(const tal_t *ctx, shared_secret, fulfilled, failed, - changed); + changed, + committx); tal_free(tmpctx); return msg; } @@ -929,7 +931,7 @@ static struct io_plan *handle_peer_commit_sig(struct io_conn *conn, /* Tell master daemon, then wait for ack. */ msg = got_commitsig_msg(tmpctx, peer->next_index[LOCAL], &commit_sig, - htlc_sigs, changed_htlcs); + htlc_sigs, changed_htlcs, txs[0]); master_sync_reply(peer, take(msg), WIRE_CHANNEL_GOT_COMMITSIG_REPLY, diff --git a/lightningd/channel/channel_wire.csv b/lightningd/channel/channel_wire.csv index d2d06313d..9e9c45f9b 100644 --- a/lightningd/channel/channel_wire.csv +++ b/lightningd/channel/channel_wire.csv @@ -155,6 +155,7 @@ channel_got_commitsig,,failed,num_failed*struct failed_htlc # RCVD_ADD_ACK_COMMIT, RCVD_REMOVE_ACK_COMMIT channel_got_commitsig,,num_changed,u16 channel_got_commitsig,,changed,num_changed*struct changed_htlc +channel_got_commitsig,,tx,struct bitcoin_tx # Wait for reply, to make sure it's on disk before we send revocation. channel_got_commitsig_reply,121 diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index d7a0009bb..6c40d477b 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -103,12 +103,6 @@ static void drop_to_chain(struct peer *peer) struct secrets secrets; secp256k1_ecdsa_signature sig; - /* FIXME: Implement. */ - if (peer->state != CLOSINGD_SIGEXCHANGE) { - tal_free(tmpctx); - return; - } - derive_basepoints(peer->seed, &local_funding_pubkey, NULL, &secrets, NULL); diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index f7d9dcd69..e5ec28ec7 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -1003,6 +1004,7 @@ int peer_got_commitsig(struct peer *peer, const u8 *msg) struct fulfilled_htlc *fulfilled; struct failed_htlc *failed; struct changed_htlc *changed; + struct bitcoin_tx *tx = tal(msg, struct bitcoin_tx); size_t i; if (!fromwire_channel_got_commitsig(msg, msg, NULL, @@ -1013,7 +1015,8 @@ int peer_got_commitsig(struct peer *peer, const u8 *msg) &shared_secrets, &fulfilled, &failed, - &changed)) { + &changed, + tx)) { peer_internal_error(peer, "bad fromwire_channel_got_commitsig %s", tal_hex(peer, msg)); @@ -1059,6 +1062,8 @@ int peer_got_commitsig(struct peer *peer, const u8 *msg) if (!peer_save_commitsig_received(peer, commitnum)) return -1; + peer_last_tx(peer, tx, &commit_sig); + /* Tell it we've committed, and to go ahead with revoke. */ msg = towire_channel_got_commitsig_reply(msg); subd_send_msg(peer->owner, take(msg));