BOLT #7: * 1. type: 258 (`channel_update`) * 2. data: * * [`signature`:`signature`] * * [`chain_hash`:`chain_hash`] * * [`short_channel_id`:`short_channel_id`] * * [`u32`:`timestamp`] * * [`byte`:`message_flags`] * * [`byte`:`channel_flags`] * * [`u16`:`cltv_expiry_delta`] * * [`u64`:`htlc_minimum_msat`] * * [`u32`:`fee_base_msat`] * * [`u32`:`fe
| 485 | * * [`u64`:`htlc_maximum_msat`] |
| 486 | */ |
| 487 | static bool update_channel(struct gossmap *map, size_t cupdate_off) |
| 488 | { |
| 489 | /* Note that first two bytes are message type */ |
| 490 | const size_t scid_off = cupdate_off + 2 + (64 + 32); |
| 491 | const size_t message_flags_off = scid_off + 8 + 4; |
| 492 | const size_t channel_flags_off = message_flags_off + 1; |
| 493 | const size_t cltv_expiry_delta_off = channel_flags_off + 1; |
| 494 | const size_t htlc_minimum_off = cltv_expiry_delta_off + 2; |
| 495 | const size_t fee_base_off = htlc_minimum_off + 8; |
| 496 | const size_t fee_prop_off = fee_base_off + 4; |
| 497 | const size_t htlc_maximum_off = fee_prop_off + 4; |
| 498 | struct short_channel_id scid; |
| 499 | struct gossmap_chan *chan; |
| 500 | struct half_chan hc; |
| 501 | u8 chanflags; |
| 502 | bool dumb_values; |
| 503 | |
| 504 | scid.u64 = map_be64(map, scid_off); |
| 505 | chan = gossmap_find_chan(map, &scid); |
| 506 | /* This can happen if channel gets deleted! */ |
| 507 | if (!chan) |
| 508 | return false; |
| 509 | |
| 510 | /* We round this *down*, since too-low min is more conservative */ |
| 511 | hc.htlc_min = u64_to_fp16(map_be64(map, htlc_minimum_off), false); |
| 512 | hc.htlc_max = u64_to_fp16(map_be64(map, htlc_maximum_off), true); |
| 513 | |
| 514 | chanflags = map_u8(map, channel_flags_off); |
| 515 | hc.enabled = !(chanflags & 2); |
| 516 | hc.base_fee = map_be32(map, fee_base_off); |
| 517 | hc.proportional_fee = map_be32(map, fee_prop_off); |
| 518 | hc.delay = map_be16(map, cltv_expiry_delta_off); |
| 519 | |
| 520 | /* Check they fit: we turn off if not. */ |
| 521 | if (hc.base_fee != map_be32(map, fee_base_off) |
| 522 | || hc.proportional_fee != map_be32(map, fee_prop_off) |
| 523 | || hc.delay != map_be16(map, cltv_expiry_delta_off)) { |
| 524 | dumb_values = true; |
| 525 | hc.htlc_max = 0; |
| 526 | hc.enabled = false; |
| 527 | } else |
| 528 | dumb_values = false; |
| 529 | |
| 530 | /* Preserve this */ |
| 531 | hc.nodeidx = chan->half[chanflags & 1].nodeidx; |
| 532 | chan->half[chanflags & 1] = hc; |
| 533 | chan->cupdate_off[chanflags & 1] = cupdate_off; |
| 534 | |
| 535 | return !dumb_values; |
| 536 | } |
| 537 | |
| 538 | static void remove_channel_by_deletemsg(struct gossmap *map, size_t del_off) |
| 539 | { |
no test coverage detected