mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
protocol: rename locktime fields to "delay" and "expiry"
For open transactions, locktime is a delay we require on the other side's to-self commit transaction outputs to ensure we can cut them off if necessary. For HTLCs, it's an absolute expiry time. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
3325c7320d
commit
7f21695a63
@ -35,7 +35,7 @@ struct bitcoin_tx *create_commit_tx(const tal_t *ctx,
|
||||
if (!proto_to_pubkey(theirs->final_key, &theirkey))
|
||||
return tal_free(tx);
|
||||
|
||||
if (!proto_to_locktime(theirs->locktime, &locktime))
|
||||
if (!proto_to_locktime(theirs->delay, &locktime))
|
||||
return tal_free(tx);
|
||||
|
||||
/* First output is a P2SH to a complex redeem script (usu. for me) */
|
||||
|
@ -1206,12 +1206,12 @@ static const ProtobufCFieldDescriptor open_channel__field_descriptors[7] =
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"locktime",
|
||||
"delay",
|
||||
2,
|
||||
PROTOBUF_C_LABEL_REQUIRED,
|
||||
PROTOBUF_C_TYPE_MESSAGE,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(OpenChannel, locktime),
|
||||
offsetof(OpenChannel, delay),
|
||||
&locktime__descriptor,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
@ -1282,8 +1282,8 @@ static const unsigned open_channel__field_indices_by_name[] = {
|
||||
4, /* field[4] = anch */
|
||||
3, /* field[3] = commit_key */
|
||||
6, /* field[6] = commitment_fee */
|
||||
1, /* field[1] = delay */
|
||||
0, /* field[0] = final_key */
|
||||
1, /* field[1] = locktime */
|
||||
5, /* field[5] = min_depth */
|
||||
2, /* field[2] = revocation_hash */
|
||||
};
|
||||
@ -1551,12 +1551,12 @@ static const ProtobufCFieldDescriptor update_add_htlc__field_descriptors[4] =
|
||||
0,NULL,NULL /* reserved1,reserved2, etc */
|
||||
},
|
||||
{
|
||||
"locktime",
|
||||
"expiry",
|
||||
4,
|
||||
PROTOBUF_C_LABEL_REQUIRED,
|
||||
PROTOBUF_C_TYPE_MESSAGE,
|
||||
0, /* quantifier_offset */
|
||||
offsetof(UpdateAddHtlc, locktime),
|
||||
offsetof(UpdateAddHtlc, expiry),
|
||||
&locktime__descriptor,
|
||||
NULL,
|
||||
0, /* flags */
|
||||
@ -1565,7 +1565,7 @@ static const ProtobufCFieldDescriptor update_add_htlc__field_descriptors[4] =
|
||||
};
|
||||
static const unsigned update_add_htlc__field_indices_by_name[] = {
|
||||
1, /* field[1] = amount */
|
||||
3, /* field[3] = locktime */
|
||||
3, /* field[3] = expiry */
|
||||
2, /* field[2] = r_hash */
|
||||
0, /* field[0] = revocation_hash */
|
||||
};
|
||||
|
@ -131,7 +131,7 @@ struct _OpenChannel
|
||||
/*
|
||||
* Relative locktime for outputs going to us.
|
||||
*/
|
||||
Locktime *locktime;
|
||||
Locktime *delay;
|
||||
/*
|
||||
* Hash for revoking first commitment transaction.
|
||||
*/
|
||||
@ -264,7 +264,7 @@ struct _UpdateAddHtlc
|
||||
/*
|
||||
* FIXME: Routing information.
|
||||
*/
|
||||
Locktime *locktime;
|
||||
Locktime *expiry;
|
||||
};
|
||||
#define UPDATE_ADD_HTLC__INIT \
|
||||
{ PROTOBUF_C_MESSAGE_INIT (&update_add_htlc__descriptor) \
|
||||
|
@ -44,7 +44,7 @@ message bitcoin_pubkey {
|
||||
// Set channel params.
|
||||
message open_channel {
|
||||
// Relative locktime for outputs going to us.
|
||||
required locktime locktime = 2;
|
||||
required locktime delay = 2;
|
||||
// Hash for revoking first commitment transaction.
|
||||
required sha256_hash revocation_hash = 4;
|
||||
// Pubkey for anchor to pay into commitment tx.
|
||||
@ -109,7 +109,7 @@ message update_add_htlc {
|
||||
// Hash for HTLC R value.
|
||||
required sha256_hash r_hash = 3;
|
||||
// Time at which HTLC expires (absolute)
|
||||
required locktime locktime = 4;
|
||||
required locktime expiry = 4;
|
||||
// FIXME: Routing information.
|
||||
}
|
||||
|
||||
|
2
pkt.c
2
pkt.c
@ -48,7 +48,7 @@ struct pkt *open_channel_pkt(const tal_t *ctx,
|
||||
o.final_key = pubkey_to_proto(ctx, final);
|
||||
lt.locktime_case = LOCKTIME__LOCKTIME_SECONDS;
|
||||
lt.seconds = rel_locktime_seconds;
|
||||
o.locktime = <
|
||||
o.delay = <
|
||||
o.commitment_fee = commitment_fee;
|
||||
if (offer_anchor)
|
||||
o.anch = OPEN_CHANNEL__ANCHOR_OFFER__WILL_CREATE_ANCHOR;
|
||||
|
@ -60,7 +60,7 @@ int main(int argc, char *argv[])
|
||||
o1 = pkt_from_file(argv[2], PKT__PKT_OPEN)->open;
|
||||
o2 = pkt_from_file(argv[3], PKT__PKT_OPEN)->open;
|
||||
a = pkt_from_file(argv[4], PKT__PKT_OPEN_ANCHOR)->open_anchor;
|
||||
if (!proto_to_locktime(o2->locktime, &locktime))
|
||||
if (!proto_to_locktime(o2->delay, &locktime))
|
||||
errx(1, "Invalid locktime in o2");
|
||||
|
||||
/* We need our private key to spend commit output. */
|
||||
|
@ -66,7 +66,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
o1 = pkt_from_file(argv[4], PKT__PKT_OPEN)->open;
|
||||
o2 = pkt_from_file(argv[5], PKT__PKT_OPEN)->open;
|
||||
if (!proto_to_locktime(o1->locktime, &locktime_seconds))
|
||||
if (!proto_to_locktime(o1->delay, &locktime_seconds))
|
||||
errx(1, "Invalid locktime in o2");
|
||||
|
||||
if (!pubkey_from_hexstr(argv[6], &outpubkey))
|
||||
|
Loading…
Reference in New Issue
Block a user