mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
protocol: include next revocation hash in open packet.
This means we send the first two revocation hashes; this is important once we move to a commit model as we need to send (unsolicited) the signature for the *next* commit tx so we need its commit hash. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
53a8aef95c
commit
b017ca1240
@ -74,6 +74,7 @@ Pkt *pkt_open(const tal_t *ctx, const struct peer *peer,
|
|||||||
|
|
||||||
open_channel__init(o);
|
open_channel__init(o);
|
||||||
o->revocation_hash = sha256_to_proto(ctx, &peer->us.revocation_hash);
|
o->revocation_hash = sha256_to_proto(ctx, &peer->us.revocation_hash);
|
||||||
|
o->next_revocation_hash = sha256_to_proto(ctx, &peer->us.next_revocation_hash);
|
||||||
o->commit_key = pubkey_to_proto(o, &peer->us.commitkey);
|
o->commit_key = pubkey_to_proto(o, &peer->us.commitkey);
|
||||||
o->final_key = pubkey_to_proto(o, &peer->us.finalkey);
|
o->final_key = pubkey_to_proto(o, &peer->us.finalkey);
|
||||||
o->delay = tal(o, Locktime);
|
o->delay = tal(o, Locktime);
|
||||||
@ -317,6 +318,7 @@ Pkt *accept_pkt_open(const tal_t *ctx,
|
|||||||
o->final_key, &peer->them.finalkey))
|
o->final_key, &peer->them.finalkey))
|
||||||
return pkt_err(ctx, "Bad finalkey");
|
return pkt_err(ctx, "Bad finalkey");
|
||||||
proto_to_sha256(o->revocation_hash, &peer->them.revocation_hash);
|
proto_to_sha256(o->revocation_hash, &peer->them.revocation_hash);
|
||||||
|
proto_to_sha256(o->next_revocation_hash, &peer->them.next_revocation_hash);
|
||||||
|
|
||||||
/* Redeemscript for anchor. */
|
/* Redeemscript for anchor. */
|
||||||
peer->anchor.redeemscript
|
peer->anchor.redeemscript
|
||||||
|
@ -270,6 +270,7 @@ static struct io_plan *peer_crypto_on(struct io_conn *conn, struct peer *peer)
|
|||||||
{
|
{
|
||||||
peer_secrets_init(peer);
|
peer_secrets_init(peer);
|
||||||
peer_get_revocation_hash(peer, 0, &peer->us.revocation_hash);
|
peer_get_revocation_hash(peer, 0, &peer->us.revocation_hash);
|
||||||
|
peer_get_revocation_hash(peer, 1, &peer->us.next_revocation_hash);
|
||||||
|
|
||||||
assert(peer->state == STATE_INIT);
|
assert(peer->state == STATE_INIT);
|
||||||
|
|
||||||
|
@ -55,6 +55,8 @@ struct peer_visible_state {
|
|||||||
u64 commit_fee;
|
u64 commit_fee;
|
||||||
/* Revocation hash for latest commit tx. */
|
/* Revocation hash for latest commit tx. */
|
||||||
struct sha256 revocation_hash;
|
struct sha256 revocation_hash;
|
||||||
|
/* Revocation hash for next commit tx. */
|
||||||
|
struct sha256 next_revocation_hash;
|
||||||
/* Current commit tx. */
|
/* Current commit tx. */
|
||||||
struct bitcoin_tx *commit;
|
struct bitcoin_tx *commit;
|
||||||
};
|
};
|
||||||
|
@ -1381,7 +1381,7 @@ const ProtobufCEnumDescriptor open_channel__anchor_offer__descriptor =
|
|||||||
NULL,NULL,NULL,NULL /* reserved[1234] */
|
NULL,NULL,NULL,NULL /* reserved[1234] */
|
||||||
};
|
};
|
||||||
static const uint32_t open_channel__min_depth__default_value = 0u;
|
static const uint32_t open_channel__min_depth__default_value = 0u;
|
||||||
static const ProtobufCFieldDescriptor open_channel__field_descriptors[7] =
|
static const ProtobufCFieldDescriptor open_channel__field_descriptors[8] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
"delay",
|
"delay",
|
||||||
@ -1467,6 +1467,18 @@ static const ProtobufCFieldDescriptor open_channel__field_descriptors[7] =
|
|||||||
0, /* flags */
|
0, /* flags */
|
||||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"next_revocation_hash",
|
||||||
|
8,
|
||||||
|
PROTOBUF_C_LABEL_REQUIRED,
|
||||||
|
PROTOBUF_C_TYPE_MESSAGE,
|
||||||
|
0, /* quantifier_offset */
|
||||||
|
offsetof(OpenChannel, next_revocation_hash),
|
||||||
|
&sha256_hash__descriptor,
|
||||||
|
NULL,
|
||||||
|
0, /* flags */
|
||||||
|
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||||
|
},
|
||||||
};
|
};
|
||||||
static const unsigned open_channel__field_indices_by_name[] = {
|
static const unsigned open_channel__field_indices_by_name[] = {
|
||||||
4, /* field[4] = anch */
|
4, /* field[4] = anch */
|
||||||
@ -1475,12 +1487,13 @@ static const unsigned open_channel__field_indices_by_name[] = {
|
|||||||
0, /* field[0] = delay */
|
0, /* field[0] = delay */
|
||||||
3, /* field[3] = final_key */
|
3, /* field[3] = final_key */
|
||||||
5, /* field[5] = min_depth */
|
5, /* field[5] = min_depth */
|
||||||
|
7, /* field[7] = next_revocation_hash */
|
||||||
1, /* field[1] = revocation_hash */
|
1, /* field[1] = revocation_hash */
|
||||||
};
|
};
|
||||||
static const ProtobufCIntRange open_channel__number_ranges[1 + 1] =
|
static const ProtobufCIntRange open_channel__number_ranges[1 + 1] =
|
||||||
{
|
{
|
||||||
{ 1, 0 },
|
{ 1, 0 },
|
||||||
{ 0, 7 }
|
{ 0, 8 }
|
||||||
};
|
};
|
||||||
const ProtobufCMessageDescriptor open_channel__descriptor =
|
const ProtobufCMessageDescriptor open_channel__descriptor =
|
||||||
{
|
{
|
||||||
@ -1490,7 +1503,7 @@ const ProtobufCMessageDescriptor open_channel__descriptor =
|
|||||||
"OpenChannel",
|
"OpenChannel",
|
||||||
"",
|
"",
|
||||||
sizeof(OpenChannel),
|
sizeof(OpenChannel),
|
||||||
7,
|
8,
|
||||||
open_channel__field_descriptors,
|
open_channel__field_descriptors,
|
||||||
open_channel__field_indices_by_name,
|
open_channel__field_indices_by_name,
|
||||||
1, open_channel__number_ranges,
|
1, open_channel__number_ranges,
|
||||||
|
@ -180,6 +180,10 @@ struct _OpenChannel
|
|||||||
* Hash for revoking first commitment transaction.
|
* Hash for revoking first commitment transaction.
|
||||||
*/
|
*/
|
||||||
Sha256Hash *revocation_hash;
|
Sha256Hash *revocation_hash;
|
||||||
|
/*
|
||||||
|
* Hash for revoking second commitment transaction.
|
||||||
|
*/
|
||||||
|
Sha256Hash *next_revocation_hash;
|
||||||
/*
|
/*
|
||||||
* Pubkey for anchor to pay into commitment tx.
|
* Pubkey for anchor to pay into commitment tx.
|
||||||
*/
|
*/
|
||||||
@ -201,7 +205,7 @@ struct _OpenChannel
|
|||||||
};
|
};
|
||||||
#define OPEN_CHANNEL__INIT \
|
#define OPEN_CHANNEL__INIT \
|
||||||
{ PROTOBUF_C_MESSAGE_INIT (&open_channel__descriptor) \
|
{ PROTOBUF_C_MESSAGE_INIT (&open_channel__descriptor) \
|
||||||
, NULL, NULL, NULL, NULL, 0, 0,0u, 0 }
|
, NULL, NULL, NULL, NULL, NULL, 0, 0,0u, 0 }
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -65,6 +65,8 @@ message open_channel {
|
|||||||
required locktime delay = 1;
|
required locktime delay = 1;
|
||||||
// Hash for revoking first commitment transaction.
|
// Hash for revoking first commitment transaction.
|
||||||
required sha256_hash revocation_hash = 2;
|
required sha256_hash revocation_hash = 2;
|
||||||
|
// Hash for revoking second commitment transaction.
|
||||||
|
required sha256_hash next_revocation_hash = 8;
|
||||||
// Pubkey for anchor to pay into commitment tx.
|
// Pubkey for anchor to pay into commitment tx.
|
||||||
required bitcoin_pubkey commit_key = 3;
|
required bitcoin_pubkey commit_key = 3;
|
||||||
// How to pay money to us from commit_tx.
|
// How to pay money to us from commit_tx.
|
||||||
|
Loading…
Reference in New Issue
Block a user