mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
channeld: send commit tx and signature to master.
This also means we can simply drop it to chain on error. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
c389215a35
commit
80e28707a3
@ -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,
|
||||
|
@ -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
|
||||
|
|
@ -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);
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include <bitcoin/tx.h>
|
||||
#include <ccan/build_assert/build_assert.h>
|
||||
#include <ccan/mem/mem.h>
|
||||
#include <ccan/tal/str/str.h>
|
||||
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user