From f32e0b35adc65fcc121c99710ef87af9af67bf40 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 11 Oct 2017 15:01:57 +1030 Subject: [PATCH] Revert "Send/receive cltv_expiry_delta in open/accept channel." This reverts commit 18e3f9820ffa00ae2f2fb68906ec8df3788ab4b5. --- common/channel_config.h | 2 -- lightningd/peer_control.c | 12 ++++-------- lightningd/peer_htlcs.c | 2 +- lightningd/peer_htlcs.h | 1 - openingd/opening.c | 29 +++++++---------------------- openingd/opening_wire.csv | 3 --- wire/gen_peer_wire_csv | 24 +++++++++++------------- wire/test/run-peer-wire.c | 10 ++-------- 8 files changed, 25 insertions(+), 58 deletions(-) diff --git a/common/channel_config.h b/common/channel_config.h index 8208bee93..ffc4b5429 100644 --- a/common/channel_config.h +++ b/common/channel_config.h @@ -19,7 +19,6 @@ * * [`4`:`feerate_per_kw`] * * [`2`:`to_self_delay`] * * [`2`:`max_accepted_htlcs`] - * * [`2`:`cltv_expiry_delta`] *... * 1. type: 33 (`accept_channel`) * 2. data: @@ -31,7 +30,6 @@ * * [`4`:`minimum_depth`] * * [`2`:`to_self_delay`] * * [`2`:`max_accepted_htlcs`] - * * [`2`:`cltv_expiry_delta`] */ struct channel_config { /* Database ID */ diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index c184b9be7..896142ab5 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -2272,8 +2272,7 @@ static bool opening_funder_finished(struct subd *opening, const u8 *resp, &fc->peer->minimum_depth, &channel_info->remote_fundingkey, &funding_txid, - &channel_info->feerate_per_kw, - &channel_info->their_cltv_expiry_delta)) { + &channel_info->feerate_per_kw)) { peer_internal_error(fc->peer, "bad shutdown_complete: %s", tal_hex(resp, resp)); return false; @@ -2394,8 +2393,7 @@ static bool opening_fundee_finished(struct subd *opening, &peer->push_msat, &peer->channel_flags, &channel_info->feerate_per_kw, - &funding_signed, - &channel_info->their_cltv_expiry_delta)) { + &funding_signed)) { log_broken(peer->log, "bad OPENING_FUNDEE_REPLY %s", tal_hex(reply, reply)); return false; @@ -2536,8 +2534,7 @@ void peer_fundee_open(struct peer *peer, const u8 *from_peer, &peer->our_config, max_to_self_delay, min_effective_htlc_capacity_msat, - cs, peer->seed, - ld->config.min_htlc_expiry); + cs, peer->seed); subd_send_msg(peer->owner, take(msg)); /* FIXME: Expose the min_feerate_per_kw and max_feerate_per_kw in the config */ @@ -2611,8 +2608,7 @@ static bool gossip_peer_released(struct subd *gossip, &fc->peer->our_config, max_to_self_delay, min_effective_htlc_capacity_msat, - &cs, fc->peer->seed, - ld->config.min_htlc_expiry); + &cs, fc->peer->seed); subd_send_msg(opening, take(msg)); diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index 047ec516a..49e7f1c58 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -521,7 +521,7 @@ static void forward_htlc(struct htlc_in *hin, /* BOLT #4: * - * If the `cltv_expiry` is too near, we tell them the the current channel + * If the cltv-expiry is too near, we tell them the the current channel * setting for the outgoing channel: * 1. type: UPDATE|14 (`expiry_too_soon`) * 2. data: diff --git a/lightningd/peer_htlcs.h b/lightningd/peer_htlcs.h index 8a7b36de2..33f976a32 100644 --- a/lightningd/peer_htlcs.h +++ b/lightningd/peer_htlcs.h @@ -15,7 +15,6 @@ struct channel_info { * and the remote_per_commit is for the commit_tx we're modifying now. */ struct pubkey remote_per_commit, old_remote_per_commit; u32 feerate_per_kw; - u16 their_cltv_expiry_delta; }; /* Get all HTLCs for a peer, to send in init message. */ diff --git a/openingd/opening.c b/openingd/opening.c index 2ed7e2cc6..e924e741d 100644 --- a/openingd/opening.c +++ b/openingd/opening.c @@ -199,7 +199,6 @@ static u8 *funder_channel(struct state *state, const struct pubkey *our_funding_pubkey, const struct basepoints *ours, u32 max_minimum_depth, - u16 our_cltv_expiry_delta, u64 change_satoshis, u32 change_keyindex, u8 channel_flags, const struct utxo *utxos, @@ -212,7 +211,6 @@ static u8 *funder_channel(struct state *state, struct pubkey their_funding_pubkey, changekey; secp256k1_ecdsa_signature sig; u32 minimum_depth; - u16 their_cltv_expiry_delta; const u8 *wscript; struct bitcoin_tx *funding; const struct utxo **utxomap; @@ -251,14 +249,12 @@ static u8 *funder_channel(struct state *state, state->feerate_per_kw, state->localconf.to_self_delay, state->localconf.max_accepted_htlcs, - our_cltv_expiry_delta, our_funding_pubkey, &ours->revocation, &ours->payment, &ours->delayed_payment, &state->next_per_commit[LOCAL], channel_flags); - if (!sync_crypto_write(&state->cs, PEER_FD, msg)) status_failed(STATUS_FAIL_PEER_IO, "Writing open_channel: %s", strerror(errno)); @@ -287,7 +283,6 @@ static u8 *funder_channel(struct state *state, &minimum_depth, &state->remoteconf->to_self_delay, &state->remoteconf->max_accepted_htlcs, - &their_cltv_expiry_delta, &their_funding_pubkey, &theirs.revocation, &theirs.payment, @@ -450,8 +445,7 @@ static u8 *funder_channel(struct state *state, minimum_depth, &their_funding_pubkey, &state->funding_txid, - state->feerate_per_kw, - their_cltv_expiry_delta); + state->feerate_per_kw); } /* This is handed the message the peer sent which caused gossip to stop: @@ -460,7 +454,6 @@ static u8 *fundee_channel(struct state *state, const struct pubkey *our_funding_pubkey, const struct basepoints *ours, u32 minimum_depth, - u16 our_cltv_expiry_delta, u32 min_feerate, u32 max_feerate, const u8 *peer_msg) { struct channel_id id_in; @@ -472,7 +465,6 @@ static u8 *fundee_channel(struct state *state, u8 *msg; const u8 *wscript; u8 channel_flags; - u16 their_cltv_expiry_delta; state->remoteconf = tal(state, struct channel_config); @@ -493,7 +485,6 @@ static u8 *fundee_channel(struct state *state, &state->feerate_per_kw, &state->remoteconf->to_self_delay, &state->remoteconf->max_accepted_htlcs, - &their_cltv_expiry_delta, &their_funding_pubkey, &theirs.revocation, &theirs.payment, @@ -565,7 +556,6 @@ static u8 *fundee_channel(struct state *state, minimum_depth, state->localconf.to_self_delay, state->localconf.max_accepted_htlcs, - our_cltv_expiry_delta, our_funding_pubkey, &ours->revocation, &ours->payment, @@ -678,8 +668,7 @@ static u8 *fundee_channel(struct state *state, state->push_msat, channel_flags, state->feerate_per_kw, - msg, - their_cltv_expiry_delta); + msg); } #ifndef TESTING @@ -698,7 +687,6 @@ int main(int argc, char *argv[]) struct utxo *utxos; struct ext_key bip32_base; u32 network_index; - u16 our_cltv_expiry_delta; if (argc == 2 && streq(argv[1], "--version")) { printf("%s\n", version()); @@ -720,8 +708,7 @@ int main(int argc, char *argv[]) &state->max_to_self_delay, &state->min_effective_htlc_capacity_msat, &state->cs, - &seed, - &our_cltv_expiry_delta)) + &seed)) master_badmsg(WIRE_OPENING_INIT, msg); tal_free(msg); @@ -754,16 +741,14 @@ int main(int argc, char *argv[]) &change_satoshis, &change_keyindex, &channel_flags, &utxos, &bip32_base)) msg = funder_channel(state, &our_funding_pubkey, &our_points, - max_minimum_depth, our_cltv_expiry_delta, - change_satoshis, change_keyindex, - channel_flags, + max_minimum_depth, change_satoshis, + change_keyindex, channel_flags, utxos, &bip32_base); else if (fromwire_opening_fundee(state, msg, NULL, &minimum_depth, &min_feerate, &max_feerate, &peer_msg)) msg = fundee_channel(state, &our_funding_pubkey, &our_points, - minimum_depth, our_cltv_expiry_delta, - min_feerate, max_feerate, - peer_msg); + minimum_depth, min_feerate, max_feerate, + peer_msg); else status_failed(STATUS_FAIL_MASTER_IO, "neither funder nor fundee: %s", diff --git a/openingd/opening_wire.csv b/openingd/opening_wire.csv index de6ed7f2f..1829fa5a3 100644 --- a/openingd/opening_wire.csv +++ b/openingd/opening_wire.csv @@ -11,7 +11,6 @@ opening_init,,min_effective_htlc_capacity_msat,u64 opening_init,,crypto_state,struct crypto_state # Seed to generate all the keys from opening_init,,seed,struct privkey -opening_init,,our_cltv_expiry_delta,u16 #include #include @@ -43,7 +42,6 @@ opening_funder_reply,,minimum_depth,u32 opening_funder_reply,,remote_fundingkey,struct pubkey opening_funder_reply,,funding_txid,struct sha256_double opening_funder_reply,,feerate_per_kw,u32 -opening_funder_reply,,their_cltv_expiry_delta,u16 # This means they offer the open (contains their offer packet) opening_fundee,6003 @@ -73,4 +71,3 @@ opening_fundee_reply,,feerate_per_kw,u32 # The (encrypted) funding signed message: send this and we're committed. opening_fundee_reply,,msglen,u16 opening_fundee_reply,,funding_signed_msg,msglen*u8 -opening_fundee_reply,,their_cltv_expiry_delta,u16 diff --git a/wire/gen_peer_wire_csv b/wire/gen_peer_wire_csv index 20008861c..a810f8465 100644 --- a/wire/gen_peer_wire_csv +++ b/wire/gen_peer_wire_csv @@ -26,13 +26,12 @@ open_channel,104,htlc_minimum_msat,8 open_channel,112,feerate_per_kw,4 open_channel,116,to_self_delay,2 open_channel,118,max_accepted_htlcs,2 -open_channel,120,cltv_expiry_delta,2 -open_channel,122,funding_pubkey,33 -open_channel,155,revocation_basepoint,33 -open_channel,188,payment_basepoint,33 -open_channel,221,delayed_payment_basepoint,33 -open_channel,254,first_per_commitment_point,33 -open_channel,287,channel_flags,1 +open_channel,120,funding_pubkey,33 +open_channel,153,revocation_basepoint,33 +open_channel,186,payment_basepoint,33 +open_channel,219,delayed_payment_basepoint,33 +open_channel,252,first_per_commitment_point,33 +open_channel,285,channel_flags,1 accept_channel,33 accept_channel,0,temporary_channel_id,32 accept_channel,32,dust_limit_satoshis,8 @@ -42,12 +41,11 @@ accept_channel,56,htlc_minimum_msat,8 accept_channel,64,minimum_depth,4 accept_channel,68,to_self_delay,2 accept_channel,70,max_accepted_htlcs,2 -accept_channel,72,cltv_expiry_delta,2 -accept_channel,74,funding_pubkey,33 -accept_channel,107,revocation_basepoint,33 -accept_channel,140,payment_basepoint,33 -accept_channel,173,delayed_payment_basepoint,33 -accept_channel,206,first_per_commitment_point,33 +accept_channel,72,funding_pubkey,33 +accept_channel,105,revocation_basepoint,33 +accept_channel,138,payment_basepoint,33 +accept_channel,171,delayed_payment_basepoint,33 +accept_channel,204,first_per_commitment_point,33 funding_created,34 funding_created,0,temporary_channel_id,32 funding_created,32,funding_txid,32 diff --git a/wire/test/run-peer-wire.c b/wire/test/run-peer-wire.c index 212d4ba94..e304f1365 100644 --- a/wire/test/run-peer-wire.c +++ b/wire/test/run-peer-wire.c @@ -105,7 +105,6 @@ struct msg_accept_channel { u32 minimum_depth; u16 to_self_delay; u16 max_accepted_htlcs; - u16 cltv_expiry_delta; struct pubkey funding_pubkey; struct pubkey revocation_basepoint; struct pubkey payment_basepoint; @@ -177,7 +176,6 @@ struct msg_open_channel { u32 feerate_per_kw; u16 to_self_delay; u16 max_accepted_htlcs; - u16 cltv_expiry_delta; struct pubkey funding_pubkey; struct pubkey revocation_basepoint; struct pubkey payment_basepoint; @@ -271,7 +269,6 @@ static void *towire_struct_open_channel(const tal_t *ctx, s->feerate_per_kw, s->to_self_delay, s->max_accepted_htlcs, - s->cltv_expiry_delta, &s->funding_pubkey, &s->revocation_basepoint, &s->payment_basepoint, @@ -296,7 +293,6 @@ static struct msg_open_channel *fromwire_struct_open_channel(const tal_t *ctx, c &s->feerate_per_kw, &s->to_self_delay, &s->max_accepted_htlcs, - &s->cltv_expiry_delta, &s->funding_pubkey, &s->revocation_basepoint, &s->payment_basepoint, @@ -319,7 +315,6 @@ static void *towire_struct_accept_channel(const tal_t *ctx, s->minimum_depth, s->to_self_delay, s->max_accepted_htlcs, - s->cltv_expiry_delta, &s->funding_pubkey, &s->revocation_basepoint, &s->payment_basepoint, @@ -338,7 +333,6 @@ static struct msg_accept_channel *fromwire_struct_accept_channel(const tal_t *ct &s->channel_reserve_satoshis, &s->htlc_minimum_msat, &s->minimum_depth, - &s->cltv_expiry_delta, &s->to_self_delay, &s->max_accepted_htlcs, &s->funding_pubkey, @@ -805,7 +799,7 @@ static bool revoke_and_ack_eq(const struct msg_revoke_and_ack *a, static bool open_channel_eq(const struct msg_open_channel *a, const struct msg_open_channel *b) { - return eq_with(a, b, cltv_expiry_delta) + return eq_with(a, b, max_accepted_htlcs) && eq_between(a, b, funding_pubkey, channel_flags); } @@ -819,7 +813,7 @@ static bool channel_update_eq(const struct msg_channel_update *a, static bool accept_channel_eq(const struct msg_accept_channel *a, const struct msg_accept_channel *b) { - return eq_with(a, b, cltv_expiry_delta) + return eq_with(a, b, max_accepted_htlcs) && eq_between(a, b, funding_pubkey, first_per_commitment_point); }