MCPcopy Create free account
hub / github.com/ElementsProject/lightning / routing_add_channel_update

Function routing_add_channel_update

gossipd/routing.c:1285–1512  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1283}
1284
1285bool routing_add_channel_update(struct routing_state *rstate,
1286 const u8 *update TAKES,
1287 u32 index,
1288 struct peer *peer,
1289 bool ignore_timestamp,
1290 bool force_spam_flag)
1291{
1292 secp256k1_ecdsa_signature signature;
1293 struct short_channel_id short_channel_id;
1294 u32 timestamp;
1295 u8 message_flags, channel_flags;
1296 u16 expiry;
1297 struct amount_msat htlc_minimum, htlc_maximum;
1298 u32 fee_base_msat;
1299 u32 fee_proportional_millionths;
1300 struct bitcoin_blkid chain_hash;
1301 struct chan *chan;
1302 struct half_chan *hc;
1303 struct unupdated_channel *uc;
1304 u8 direction;
1305 struct amount_sat sat;
1306 bool spam;
1307
1308 /* Make sure we own msg, even if we don't save it. */
1309 if (taken(update))
1310 tal_steal(tmpctx, update);
1311
1312 if (!fromwire_channel_update(
1313 update, &signature, &chain_hash,
1314 &short_channel_id, &timestamp,
1315 &message_flags, &channel_flags,
1316 &expiry, &htlc_minimum, &fee_base_msat,
1317 &fee_proportional_millionths,
1318 &htlc_maximum))
1319 return false;
1320
1321 direction = channel_flags & 0x1;
1322 chan = get_channel(rstate, &short_channel_id);
1323
1324 if (chan) {
1325 uc = NULL;
1326 sat = chan->sat;
1327 } else {
1328 /* Maybe announcement was waiting for this update? */
1329 uc = get_unupdated_channel(rstate, &short_channel_id);
1330 if (!uc) {
1331 return false;
1332 }
1333 sat = uc->sat;
1334 }
1335
1336 /* Reject update if the `htlc_maximum_msat` is greater
1337 * than the total available channel satoshis */
1338 if (amount_msat_greater_sat(htlc_maximum, sat))
1339 return false;
1340
1341 /* Check timestamp is sane (unless from store). */
1342 if (!index && !timestamp_reasonable(rstate, timestamp)) {

Callers 3

gossip_store_loadFunction · 0.85
handle_channel_updateFunction · 0.85

Calls 15

takenFunction · 0.85
get_channelFunction · 0.85
get_unupdated_channelFunction · 0.85
amount_msat_greater_satFunction · 0.85
timestamp_reasonableFunction · 0.85
new_chanFunction · 0.85
is_halfchan_definedFunction · 0.85
ratelimitFunction · 0.85
is_chan_publicFunction · 0.85
local_directionFunction · 0.85
time_nowFunction · 0.85

Tested by

no test coverage detected