Skip to content

Commit

Permalink
Revert "Send/receive cltv_expiry_delta in open/accept channel."
Browse files Browse the repository at this point in the history
This reverts commit 18e3f98.
  • Loading branch information
rustyrussell authored and cdecker committed Oct 11, 2017
1 parent cfac9a1 commit f32e0b3
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 58 deletions.
2 changes: 0 additions & 2 deletions common/channel_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -31,7 +30,6 @@
* * [`4`:`minimum_depth`]
* * [`2`:`to_self_delay`]
* * [`2`:`max_accepted_htlcs`]
* * [`2`:`cltv_expiry_delta`]
*/
struct channel_config {
/* Database ID */
Expand Down
12 changes: 4 additions & 8 deletions lightningd/peer_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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));

Expand Down
2 changes: 1 addition & 1 deletion lightningd/peer_htlcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion lightningd/peer_htlcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
29 changes: 7 additions & 22 deletions openingd/opening.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand All @@ -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;
Expand All @@ -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);

Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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());
Expand All @@ -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);
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 0 additions & 3 deletions openingd/opening_wire.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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 <common/bip32.h>
#include <common/htlc_wire.h>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
24 changes: 11 additions & 13 deletions wire/gen_peer_wire_csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 2 additions & 8 deletions wire/test/run-peer-wire.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down

0 comments on commit f32e0b3

Please sign in to comment.