mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 01:43:36 +01:00
common: assume htlc_maximum_msat, don't check bit any more.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
253b25522b
commit
bb49e1bea5
@ -1228,7 +1228,6 @@ void gossmap_chan_get_update_details(const struct gossmap *map,
|
||||
u32 *fee_base_msat,
|
||||
u32 *fee_proportional_millionths,
|
||||
struct amount_msat *htlc_minimum_msat,
|
||||
/* iff message_flags & 1 */
|
||||
struct amount_msat *htlc_maximum_msat)
|
||||
{
|
||||
/* Note that first two bytes are message type */
|
||||
@ -1241,18 +1240,15 @@ void gossmap_chan_get_update_details(const struct gossmap *map,
|
||||
const size_t fee_base_off = htlc_minimum_off + 8;
|
||||
const size_t fee_prop_off = fee_base_off + 4;
|
||||
const size_t htlc_maximum_off = fee_prop_off + 4;
|
||||
u8 mflags;
|
||||
|
||||
assert(gossmap_chan_set(chan, dir));
|
||||
|
||||
if (timestamp)
|
||||
*timestamp = map_be32(map, timestamp_off);
|
||||
/* We need this (below), even if they don't want it */
|
||||
mflags = map_u8(map, message_flags_off);
|
||||
if (message_flags)
|
||||
*message_flags = mflags;
|
||||
if (channel_flags)
|
||||
*channel_flags = map_u8(map, channel_flags_off);
|
||||
if (message_flags)
|
||||
*message_flags = map_u8(map, message_flags_off);
|
||||
if (fee_base_msat)
|
||||
*fee_base_msat = map_be32(map, fee_base_off);
|
||||
if (fee_proportional_millionths)
|
||||
@ -1260,7 +1256,7 @@ void gossmap_chan_get_update_details(const struct gossmap *map,
|
||||
if (htlc_minimum_msat)
|
||||
*htlc_minimum_msat
|
||||
= amount_msat(map_be64(map, htlc_minimum_off));
|
||||
if (htlc_maximum_msat && (mflags & 1))
|
||||
if (htlc_maximum_msat)
|
||||
*htlc_maximum_msat
|
||||
= amount_msat(map_be64(map, htlc_maximum_off));
|
||||
}
|
||||
|
@ -161,7 +161,6 @@ void gossmap_chan_get_update_details(const struct gossmap *map,
|
||||
u32 *fee_base_msat,
|
||||
u32 *fee_proportional_millionths,
|
||||
struct amount_msat *htlc_minimum_msat,
|
||||
/* iff message_flags & 1 */
|
||||
struct amount_msat *htlc_maximum_msat);
|
||||
|
||||
/* Given a struct node, get the nth channel, and tell us if we're half[0/1].
|
||||
|
@ -251,11 +251,7 @@ class ChannelUpdate(object):
|
||||
(cu.htlc_minimum_msat,) = struct.unpack("!Q", b.read(8))
|
||||
(cu.fee_base_msat,) = struct.unpack("!I", b.read(4))
|
||||
(cu.fee_proportional_millionths,) = struct.unpack("!I", b.read(4))
|
||||
t = b.read(8)
|
||||
if len(t) == 8:
|
||||
(cu.htlc_maximum_msat,) = struct.unpack("!Q", t)
|
||||
else:
|
||||
cu.htlc_maximum_msat = None
|
||||
(cu.htlc_maximum_msat,) = struct.unpack("!Q", b.read(8))
|
||||
|
||||
return cu
|
||||
|
||||
|
@ -1322,21 +1322,10 @@ bool routing_add_channel_update(struct routing_state *rstate,
|
||||
sat = uc->sat;
|
||||
}
|
||||
|
||||
if (message_flags & ROUTING_OPT_HTLC_MAX_MSAT) {
|
||||
/* Reject update if the `htlc_maximum_msat` is greater
|
||||
* than the total available channel satoshis */
|
||||
if (amount_msat_greater_sat(htlc_maximum, sat))
|
||||
return false;
|
||||
} else {
|
||||
/* If not indicated, set htlc_max_msat to channel capacity */
|
||||
if (!amount_sat_to_msat(&htlc_maximum, sat)) {
|
||||
status_peer_broken(peer ? &peer->id : NULL,
|
||||
"Channel capacity %s overflows!",
|
||||
type_to_string(tmpctx, struct amount_sat,
|
||||
&sat));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/* Reject update if the `htlc_maximum_msat` is greater
|
||||
* than the total available channel satoshis */
|
||||
if (amount_msat_greater_sat(htlc_maximum, sat))
|
||||
return false;
|
||||
|
||||
/* Check timestamp is sane (unless from store). */
|
||||
if (!index && !timestamp_reasonable(rstate, timestamp)) {
|
||||
|
@ -280,10 +280,8 @@ static void json_add_halfchan(struct json_stream *response,
|
||||
json_add_num(response, "delay", c->half[dir].delay);
|
||||
json_add_amount_msat_only(response, "htlc_minimum_msat",
|
||||
htlc_minimum_msat);
|
||||
|
||||
if (message_flags & 1)
|
||||
json_add_amount_msat_only(response, "htlc_maximum_msat",
|
||||
htlc_maximum_msat);
|
||||
json_add_amount_msat_only(response, "htlc_maximum_msat",
|
||||
htlc_maximum_msat);
|
||||
json_add_hex_talarr(response, "features", chanfeatures);
|
||||
json_object_end(response);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user