gossip: Annotate locally added channels with their capacity

We were adding channels without their capacity, and eventually annotated them
when we exchanged `channel_update`s. This worked as long as we weren't
considering the channel capacity, but would result in local-only channels to be
unusable once we start checking.
This commit is contained in:
Christian Decker 2018-07-31 11:57:30 +02:00
parent 8f38a46584
commit 8a34933c1a
6 changed files with 14 additions and 7 deletions

View File

@ -275,7 +275,8 @@ static void make_channel_local_active(struct peer *peer)
/* Tell gossipd about local channel. */
msg = towire_gossip_local_add_channel(NULL,
&peer->short_channel_ids[LOCAL],
&peer->node_ids[REMOTE]);
&peer->node_ids[REMOTE],
peer->channel->funding_msat / 1000);
wire_sync_write(GOSSIP_FD, take(msg));
/* Tell gossipd and the other side what parameters we expect should

View File

@ -121,6 +121,7 @@ gossip_send_gossip,,gossip,len*u8
gossip_local_add_channel,3017
gossip_local_add_channel,,short_channel_id,struct short_channel_id
gossip_local_add_channel,,remote_node_id,struct pubkey
gossip_local_add_channel,,satoshis,u64
gossip_local_channel_update,3026
gossip_local_channel_update,,short_channel_id,struct short_channel_id

1 #include <common/cryptomsg.h>
121 # master->gossipd a routing failure occurred gossip_get_txout_reply,,outscript,len*u8
122 gossip_routing_failure,3021 # master->gossipd a routing failure occurred
123 gossip_routing_failure,,erring_node,struct pubkey gossip_routing_failure,3021
124 gossip_routing_failure,,erring_node,struct pubkey
125 gossip_routing_failure,,erring_channel,struct short_channel_id
126 gossip_routing_failure,,failcode,u16
127 gossip_routing_failure,,len,u16

View File

@ -1672,9 +1672,13 @@ void handle_local_add_channel(struct routing_state *rstate, const u8 *msg)
{
struct short_channel_id scid;
struct pubkey remote_node_id;
struct chan *chan;
u64 satoshis;
if (!fromwire_gossip_local_add_channel(msg, &scid, &remote_node_id)) {
status_broken("Unable to parse local_add_channel message: %s", tal_hex(msg, msg));
if (!fromwire_gossip_local_add_channel(msg, &scid, &remote_node_id,
&satoshis)) {
status_broken("Unable to parse local_add_channel message: %s",
tal_hex(msg, msg));
return;
}
@ -1688,5 +1692,6 @@ void handle_local_add_channel(struct routing_state *rstate, const u8 *msg)
type_to_string(tmpctx, struct short_channel_id, &scid));
/* Create new (unannounced) channel */
new_chan(rstate, &scid, &rstate->local_id, &remote_node_id);
chan = new_chan(rstate, &scid, &rstate->local_id, &remote_node_id);
chan->satoshis = satoshis;
}

View File

@ -66,7 +66,7 @@ bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNE
bool fromwire_channel_update(const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u16 *flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, u64 *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED)
{ fprintf(stderr, "fromwire_channel_update called!\n"); abort(); }
/* Generated stub for fromwire_gossip_local_add_channel */
bool fromwire_gossip_local_add_channel(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *remote_node_id UNNEEDED)
bool fromwire_gossip_local_add_channel(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *remote_node_id UNNEEDED, u64 *satoshis UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_local_add_channel called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_channel_announcement */
bool fromwire_gossip_store_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED, u64 *satoshis UNNEEDED)

View File

@ -30,7 +30,7 @@ bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNE
bool fromwire_channel_update(const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u16 *flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, u64 *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED)
{ fprintf(stderr, "fromwire_channel_update called!\n"); abort(); }
/* Generated stub for fromwire_gossip_local_add_channel */
bool fromwire_gossip_local_add_channel(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *remote_node_id UNNEEDED)
bool fromwire_gossip_local_add_channel(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *remote_node_id UNNEEDED, u64 *satoshis UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_local_add_channel called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_channel_announcement */
bool fromwire_gossip_store_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED, u64 *satoshis UNNEEDED)

View File

@ -28,7 +28,7 @@ bool fromwire_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNE
bool fromwire_channel_update(const void *p UNNEEDED, secp256k1_ecdsa_signature *signature UNNEEDED, struct bitcoin_blkid *chain_hash UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, u32 *timestamp UNNEEDED, u16 *flags UNNEEDED, u16 *cltv_expiry_delta UNNEEDED, u64 *htlc_minimum_msat UNNEEDED, u32 *fee_base_msat UNNEEDED, u32 *fee_proportional_millionths UNNEEDED)
{ fprintf(stderr, "fromwire_channel_update called!\n"); abort(); }
/* Generated stub for fromwire_gossip_local_add_channel */
bool fromwire_gossip_local_add_channel(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *remote_node_id UNNEEDED)
bool fromwire_gossip_local_add_channel(const void *p UNNEEDED, struct short_channel_id *short_channel_id UNNEEDED, struct pubkey *remote_node_id UNNEEDED, u64 *satoshis UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_local_add_channel called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_channel_announcement */
bool fromwire_gossip_store_channel_announcement(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, u8 **announcement UNNEEDED, u64 *satoshis UNNEEDED)