From f662424b7bdd7ee379b8ceb37f650ae5e0d3692e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 26 May 2016 15:25:24 +0930 Subject: [PATCH] protocol: don't sign initial commitment for non-funder. As per lightning-rfc commit b8469aa758a1a7ebbd73c987be3e5207b778241b ("re-protocol: don't hand signature to non-funding side initially.") Signed-off-by: Rusty Russell --- daemon/packets.c | 10 +--------- daemon/peer.c | 8 ++++++-- lightning.pb-c.c | 19 +++---------------- lightning.pb-c.h | 6 +----- lightning.proto | 3 --- 5 files changed, 11 insertions(+), 35 deletions(-) diff --git a/daemon/packets.c b/daemon/packets.c index 2611c56dd..f89454cd5 100644 --- a/daemon/packets.c +++ b/daemon/packets.c @@ -130,14 +130,6 @@ void queue_pkt_anchor(struct peer *peer) return; } - /* Sign their commit sig */ - peer->remote.commit->sig = tal(peer->remote.commit, - struct bitcoin_signature); - peer->remote.commit->sig->stype = SIGHASH_ALL; - peer_sign_theircommit(peer, peer->remote.commit->tx, - &peer->remote.commit->sig->sig); - a->commit_sig = signature_to_proto(a, &peer->remote.commit->sig->sig); - queue_pkt(peer, PKT__PKT_OPEN_ANCHOR, a); } @@ -560,7 +552,7 @@ Pkt *accept_pkt_anchor(struct peer *peer, const Pkt *pkt) if (!setup_first_commit(peer)) return pkt_err(peer, "Insufficient funds for fee"); - return check_and_save_commit_sig(peer, peer->local.commit, a->commit_sig); + return NULL; } Pkt *accept_pkt_open_commit_sig(struct peer *peer, const Pkt *pkt) diff --git a/daemon/peer.c b/daemon/peer.c index a7ce598eb..dc2a49a72 100644 --- a/daemon/peer.c +++ b/daemon/peer.c @@ -221,12 +221,16 @@ static void peer_breakdown(struct peer *peer) log_unusual(peer->log, "Peer breakdown: sending close tx"); broadcast_tx(peer, bitcoin_close(peer)); /* If we have a signed commit tx (maybe not if we just offered - * anchor), use it. */ + * anchor, or they supplied anchor). */ } else if (peer->local.commit->sig) { log_unusual(peer->log, "Peer breakdown: sending commit tx"); broadcast_tx(peer, bitcoin_commit(peer)); - } else + } else { log_info(peer->log, "Peer breakdown: nothing to do"); + /* We close immediately. */ + set_peer_state(peer, STATE_CLOSED, __func__); + io_wake(peer); + } } static bool peer_uncommitted_changes(const struct peer *peer) diff --git a/lightning.pb-c.c b/lightning.pb-c.c index daebea5ca..603005836 100644 --- a/lightning.pb-c.c +++ b/lightning.pb-c.c @@ -1481,7 +1481,7 @@ const ProtobufCMessageDescriptor open_channel__descriptor = (ProtobufCMessageInit) open_channel__init, NULL,NULL,NULL /* reserved[123] */ }; -static const ProtobufCFieldDescriptor open_anchor__field_descriptors[4] = +static const ProtobufCFieldDescriptor open_anchor__field_descriptors[3] = { { "txid", @@ -1519,29 +1519,16 @@ static const ProtobufCFieldDescriptor open_anchor__field_descriptors[4] = 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, - { - "commit_sig", - 4, - PROTOBUF_C_LABEL_REQUIRED, - PROTOBUF_C_TYPE_MESSAGE, - 0, /* quantifier_offset */ - offsetof(OpenAnchor, commit_sig), - &signature__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, }; static const unsigned open_anchor__field_indices_by_name[] = { 2, /* field[2] = amount */ - 3, /* field[3] = commit_sig */ 1, /* field[1] = output_index */ 0, /* field[0] = txid */ }; static const ProtobufCIntRange open_anchor__number_ranges[1 + 1] = { { 1, 0 }, - { 0, 4 } + { 0, 3 } }; const ProtobufCMessageDescriptor open_anchor__descriptor = { @@ -1551,7 +1538,7 @@ const ProtobufCMessageDescriptor open_anchor__descriptor = "OpenAnchor", "", sizeof(OpenAnchor), - 4, + 3, open_anchor__field_descriptors, open_anchor__field_indices_by_name, 1, open_anchor__number_ranges, diff --git a/lightning.pb-c.h b/lightning.pb-c.h index 0e787666c..b30df4f1f 100644 --- a/lightning.pb-c.h +++ b/lightning.pb-c.h @@ -230,14 +230,10 @@ struct _OpenAnchor * Amount of anchor output. */ uint64_t amount; - /* - * Signature for your initial commitment tx. - */ - Signature *commit_sig; }; #define OPEN_ANCHOR__INIT \ { PROTOBUF_C_MESSAGE_INIT (&open_anchor__descriptor) \ - , NULL, 0, 0, NULL } + , NULL, 0, 0 } /* diff --git a/lightning.proto b/lightning.proto index a6bc9864e..0683967b9 100644 --- a/lightning.proto +++ b/lightning.proto @@ -97,9 +97,6 @@ message open_anchor { required uint32 output_index = 2; // Amount of anchor output. required uint64 amount = 3; - - // Signature for your initial commitment tx. - required signature commit_sig = 4; } // Reply: signature for your initial commitment tx