Browse Source

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 <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 9 years ago
parent
commit
f662424b7b
  1. 10
      daemon/packets.c
  2. 8
      daemon/peer.c
  3. 19
      lightning.pb-c.c
  4. 6
      lightning.pb-c.h
  5. 3
      lightning.proto

10
daemon/packets.c

@ -130,14 +130,6 @@ void queue_pkt_anchor(struct peer *peer)
return; 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); 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)) if (!setup_first_commit(peer))
return pkt_err(peer, "Insufficient funds for fee"); 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) Pkt *accept_pkt_open_commit_sig(struct peer *peer, const Pkt *pkt)

8
daemon/peer.c

@ -221,12 +221,16 @@ static void peer_breakdown(struct peer *peer)
log_unusual(peer->log, "Peer breakdown: sending close tx"); log_unusual(peer->log, "Peer breakdown: sending close tx");
broadcast_tx(peer, bitcoin_close(peer)); broadcast_tx(peer, bitcoin_close(peer));
/* If we have a signed commit tx (maybe not if we just offered /* 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) { } else if (peer->local.commit->sig) {
log_unusual(peer->log, "Peer breakdown: sending commit tx"); log_unusual(peer->log, "Peer breakdown: sending commit tx");
broadcast_tx(peer, bitcoin_commit(peer)); broadcast_tx(peer, bitcoin_commit(peer));
} else } else {
log_info(peer->log, "Peer breakdown: nothing to do"); 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) static bool peer_uncommitted_changes(const struct peer *peer)

19
lightning.pb-c.c

@ -1481,7 +1481,7 @@ const ProtobufCMessageDescriptor open_channel__descriptor =
(ProtobufCMessageInit) open_channel__init, (ProtobufCMessageInit) open_channel__init,
NULL,NULL,NULL /* reserved[123] */ NULL,NULL,NULL /* reserved[123] */
}; };
static const ProtobufCFieldDescriptor open_anchor__field_descriptors[4] = static const ProtobufCFieldDescriptor open_anchor__field_descriptors[3] =
{ {
{ {
"txid", "txid",
@ -1519,29 +1519,16 @@ static const ProtobufCFieldDescriptor open_anchor__field_descriptors[4] =
0, /* flags */ 0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */ 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[] = { static const unsigned open_anchor__field_indices_by_name[] = {
2, /* field[2] = amount */ 2, /* field[2] = amount */
3, /* field[3] = commit_sig */
1, /* field[1] = output_index */ 1, /* field[1] = output_index */
0, /* field[0] = txid */ 0, /* field[0] = txid */
}; };
static const ProtobufCIntRange open_anchor__number_ranges[1 + 1] = static const ProtobufCIntRange open_anchor__number_ranges[1 + 1] =
{ {
{ 1, 0 }, { 1, 0 },
{ 0, 4 } { 0, 3 }
}; };
const ProtobufCMessageDescriptor open_anchor__descriptor = const ProtobufCMessageDescriptor open_anchor__descriptor =
{ {
@ -1551,7 +1538,7 @@ const ProtobufCMessageDescriptor open_anchor__descriptor =
"OpenAnchor", "OpenAnchor",
"", "",
sizeof(OpenAnchor), sizeof(OpenAnchor),
4, 3,
open_anchor__field_descriptors, open_anchor__field_descriptors,
open_anchor__field_indices_by_name, open_anchor__field_indices_by_name,
1, open_anchor__number_ranges, 1, open_anchor__number_ranges,

6
lightning.pb-c.h

@ -230,14 +230,10 @@ struct _OpenAnchor
* Amount of anchor output. * Amount of anchor output.
*/ */
uint64_t amount; uint64_t amount;
/*
* Signature for your initial commitment tx.
*/
Signature *commit_sig;
}; };
#define OPEN_ANCHOR__INIT \ #define OPEN_ANCHOR__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&open_anchor__descriptor) \ { PROTOBUF_C_MESSAGE_INIT (&open_anchor__descriptor) \
, NULL, 0, 0, NULL } , NULL, 0, 0 }
/* /*

3
lightning.proto

@ -97,9 +97,6 @@ message open_anchor {
required uint32 output_index = 2; required uint32 output_index = 2;
// Amount of anchor output. // Amount of anchor output.
required uint64 amount = 3; required uint64 amount = 3;
// Signature for your initial commitment tx.
required signature commit_sig = 4;
} }
// Reply: signature for your initial commitment tx // Reply: signature for your initial commitment tx

Loading…
Cancel
Save