From 7f21695a63729b8be4355eaac149aac104a91082 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 7 Aug 2015 12:45:30 +0930 Subject: [PATCH] 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 --- commit_tx.c | 2 +- lightning.pb-c.c | 12 ++++++------ lightning.pb-c.h | 4 ++-- lightning.proto | 4 ++-- pkt.c | 2 +- test-cli/create-commit-spend-tx.c | 2 +- test-cli/create-steal-tx.c | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/commit_tx.c b/commit_tx.c index 52b79d1c7..46444d4e6 100644 --- a/commit_tx.c +++ b/commit_tx.c @@ -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) */ diff --git a/lightning.pb-c.c b/lightning.pb-c.c index e1bebac80..eb0700df8 100644 --- a/lightning.pb-c.c +++ b/lightning.pb-c.c @@ -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 */ }; diff --git a/lightning.pb-c.h b/lightning.pb-c.h index 5913452a7..9b2f81302 100644 --- a/lightning.pb-c.h +++ b/lightning.pb-c.h @@ -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) \ diff --git a/lightning.proto b/lightning.proto index 9ef1d1e4b..b0fba5e41 100644 --- a/lightning.proto +++ b/lightning.proto @@ -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. } diff --git a/pkt.c b/pkt.c index 707209d04..a224e8cd4 100644 --- a/pkt.c +++ b/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; diff --git a/test-cli/create-commit-spend-tx.c b/test-cli/create-commit-spend-tx.c index dfc782516..a6f20ed8a 100644 --- a/test-cli/create-commit-spend-tx.c +++ b/test-cli/create-commit-spend-tx.c @@ -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. */ diff --git a/test-cli/create-steal-tx.c b/test-cli/create-steal-tx.c index 3980874d3..8fdfd4867 100644 --- a/test-cli/create-steal-tx.c +++ b/test-cli/create-steal-tx.c @@ -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))