Browse Source

channeld: Passing additional info to channeld

The CLTV delta was hardcoded until now, which was causing me some head
scratching. I guess I asked for it ^^
ppa-0.6.1
Christian Decker 8 years ago
parent
commit
39115717f6
  1. 20
      lightningd/channel/channel.c
  2. 16
      lightningd/channel/channel_wire.csv
  3. 11
      lightningd/peer_control.c

20
lightningd/channel/channel.c

@ -99,6 +99,11 @@ struct peer {
/* Which direction of the channel do we control? */ /* Which direction of the channel do we control? */
u16 channel_direction; u16 channel_direction;
/* CLTV delta to announce to peers */
u16 cltv_delta;
u32 fee_base;
u32 fee_per_satoshi;
}; };
static u8 *create_channel_announcement(const tal_t *ctx, struct peer *peer); static u8 *create_channel_announcement(const tal_t *ctx, struct peer *peer);
@ -178,8 +183,9 @@ static void send_channel_update(struct peer *peer, bool disabled)
flags = peer->channel_direction | (disabled << 1); flags = peer->channel_direction | (disabled << 1);
cupdate = towire_channel_update( cupdate = towire_channel_update(
tmpctx, sig, &peer->short_channel_ids[LOCAL], timestamp, flags, 36, tmpctx, sig, &peer->short_channel_ids[LOCAL], timestamp, flags,
1, 10, peer->channel->view[LOCAL].feerate_per_kw); peer->cltv_delta, peer->fee_base, peer->fee_per_satoshi,
peer->channel->view[LOCAL].feerate_per_kw);
msg = towire_hsm_cupdate_sig_req(tmpctx, cupdate); msg = towire_hsm_cupdate_sig_req(tmpctx, cupdate);
@ -966,7 +972,6 @@ static void init_channel(struct peer *peer, const u8 *msg)
{ {
struct privkey seed; struct privkey seed;
struct basepoints points[NUM_SIDES]; struct basepoints points[NUM_SIDES];
u32 feerate;
u64 funding_satoshi, push_msat; u64 funding_satoshi, push_msat;
u16 funding_txout; u16 funding_txout;
struct pubkey funding_pubkey[NUM_SIDES]; struct pubkey funding_pubkey[NUM_SIDES];
@ -984,11 +989,14 @@ static void init_channel(struct peer *peer, const u8 *msg)
&points[REMOTE].delayed_payment, &points[REMOTE].delayed_payment,
&peer->old_per_commit[REMOTE], &peer->old_per_commit[REMOTE],
&am_funder, &am_funder,
&feerate, &funding_satoshi, &push_msat, &peer->fee_base,
&peer->fee_per_satoshi,
&funding_satoshi, &push_msat,
&seed, &seed,
&peer->node_ids[LOCAL], &peer->node_ids[LOCAL],
&peer->node_ids[REMOTE], &peer->node_ids[REMOTE],
&peer->commit_msec)) &peer->commit_msec,
&peer->cltv_delta))
status_failed(WIRE_CHANNEL_BAD_COMMAND, "%s", status_failed(WIRE_CHANNEL_BAD_COMMAND, "%s",
tal_hex(msg, msg)); tal_hex(msg, msg));
@ -1005,7 +1013,7 @@ static void init_channel(struct peer *peer, const u8 *msg)
&peer->old_per_commit[LOCAL])); &peer->old_per_commit[LOCAL]));
peer->channel = new_channel(peer, &funding_txid, funding_txout, peer->channel = new_channel(peer, &funding_txid, funding_txout,
funding_satoshi, push_msat, feerate, funding_satoshi, push_msat, peer->fee_base,
&peer->conf[LOCAL], &peer->conf[REMOTE], &peer->conf[LOCAL], &peer->conf[REMOTE],
&points[LOCAL], &points[REMOTE], &points[LOCAL], &points[REMOTE],
&funding_pubkey[LOCAL], &funding_pubkey[LOCAL],

16
lightningd/channel/channel_wire.csv

@ -33,13 +33,15 @@ channel_init,376,payment_basepoint,33
channel_init,409,delayed_payment_basepoint,33 channel_init,409,delayed_payment_basepoint,33
channel_init,442,their_per_commit_point,33 channel_init,442,their_per_commit_point,33
channel_init,475,am_funder,bool channel_init,475,am_funder,bool
channel_init,476,feerate,4 channel_init,476,fee_base,4
channel_init,480,funding_satoshi,8 channel_init,480,fee_proportional,4
channel_init,488,push_msat,8 channel_init,484,funding_satoshi,8
channel_init,496,seed,struct privkey channel_init,492,push_msat,8
channel_init,529,local_node_id,struct pubkey channel_init,500,seed,struct privkey
channel_init,562,remote_node_id,struct pubkey channel_init,533,local_node_id,struct pubkey
channel_init,595,commit_msec,4 channel_init,566,remote_node_id,struct pubkey
channel_init,599,commit_msec,4
channel_init,603,cltv_delta,u16
# Tx is deep enough, go! # Tx is deep enough, go!
channel_funding_locked,2 channel_funding_locked,2

Can't render this file because it has a wrong number of fields in line 2.

11
lightningd/peer_control.c

@ -1252,7 +1252,7 @@ static void peer_start_channeld(struct peer *peer, enum side funder,
const struct pubkey *their_per_commit_point) const struct pubkey *their_per_commit_point)
{ {
struct channeld_start *cds = tal(peer, struct channeld_start); struct channeld_start *cds = tal(peer, struct channeld_start);
struct config *cfg = &peer->ld->dstate.config;
/* Unowned: back to being owned by main daemon. */ /* Unowned: back to being owned by main daemon. */
peer->owner = NULL; peer->owner = NULL;
tal_steal(peer->ld, peer); tal_steal(peer->ld, peer);
@ -1279,15 +1279,16 @@ static void peer_start_channeld(struct peer *peer, enum side funder,
&theirbase->delayed_payment, &theirbase->delayed_payment,
their_per_commit_point, their_per_commit_point,
funder == LOCAL, funder == LOCAL,
/* FIXME: real feerate! */ cfg->fee_base,
15000, cfg->fee_per_satoshi,
peer->funding_satoshi, peer->funding_satoshi,
peer->push_msat, peer->push_msat,
peer->seed, peer->seed,
&peer->ld->dstate.id, &peer->ld->dstate.id,
peer->id, peer->id,
time_to_msec(peer->ld->dstate.config time_to_msec(cfg->commit_time),
.commit_time)); cfg->deadline_blocks
);
/* Get fd from hsm. */ /* Get fd from hsm. */
subd_req(peer, peer->ld->hsm, subd_req(peer, peer->ld->hsm,

Loading…
Cancel
Save