EXPECTED_ROUTING_GRAPH_SNAPSHOT_SHASUM: 05a5361278f68ee2afd086cc04a1f927a63924be451f3221d380533acfacc303
- name: Fetch rapid graph sync reference input
run: |
- curl --verbose -L -o lightning-rapid-gossip-sync/res/full_graph.lngossip https://bitcoin.ninja/ldk-compressed_graph-bc08df7542-2022-05-05.bin
+ curl --verbose -L -o lightning-rapid-gossip-sync/res/full_graph.lngossip https://bitcoin.ninja/ldk-compressed_graph-285cb27df79-2022-07-21.bin
echo "Sha sum: $(sha256sum lightning-rapid-gossip-sync/res/full_graph.lngossip | awk '{ print $1 }')"
if [ "$(sha256sum lightning-rapid-gossip-sync/res/full_graph.lngossip | awk '{ print $1 }')" != "${EXPECTED_RAPID_GOSSIP_SHASUM}" ]; then
echo "Bad hash"
exit 1
fi
env:
- EXPECTED_RAPID_GOSSIP_SHASUM: 9637b91cea9d64320cf48fc0787c70fe69fc062f90d3512e207044110cadfd7b
+ EXPECTED_RAPID_GOSSIP_SHASUM: e0f5d11641c11896d7af3a2246d3d6c3f1720b7d2d17aab321ecce82e6b7deb8
- name: Test with Network Graph on Rust ${{ matrix.toolchain }}
run: |
cd lightning
let sync_result = rapid_sync
.sync_network_graph_with_file_path("./res/full_graph.lngossip");
if let Err(crate::error::GraphSyncError::DecodeError(DecodeError::Io(io_error))) = &sync_result {
- let error_string = format!("Input file lightning-rapid-gossip-sync/res/full_graph.lngossip is missing! Download it from https://bitcoin.ninja/ldk-compressed_graph-bc08df7542-2022-05-05.bin\n\n{:?}", io_error);
+ let error_string = format!("Input file lightning-rapid-gossip-sync/res/full_graph.lngossip is missing! Download it from https://bitcoin.ninja/ldk-compressed_graph-285cb27df79-2022-07-21.bin\n\n{:?}", io_error);
#[cfg(not(require_route_graph_test))]
{
println!("{}", error_string);
use bitcoin::secp256k1::PublicKey;
use lightning::ln::msgs::{
- DecodeError, ErrorAction, LightningError, OptionalField, UnsignedChannelUpdate,
+ DecodeError, ErrorAction, LightningError, UnsignedChannelUpdate,
};
use lightning::routing::gossip::NetworkGraph;
use lightning::util::logger::Logger;
let default_htlc_minimum_msat: u64 = Readable::read(&mut read_cursor)?;
let default_fee_base_msat: u32 = Readable::read(&mut read_cursor)?;
let default_fee_proportional_millionths: u32 = Readable::read(&mut read_cursor)?;
- let tentative_default_htlc_maximum_msat: u64 = Readable::read(&mut read_cursor)?;
- let default_htlc_maximum_msat = if tentative_default_htlc_maximum_msat == u64::max_value() {
- OptionalField::Absent
- } else {
- OptionalField::Present(tentative_default_htlc_maximum_msat)
- };
+ let default_htlc_maximum_msat: u64 = Readable::read(&mut read_cursor)?;
for _ in 0..update_count {
let scid_delta: BigSize = Readable::read(read_cursor)?;
flags: standard_channel_flags,
cltv_expiry_delta: default_cltv_expiry_delta,
htlc_minimum_msat: default_htlc_minimum_msat,
- htlc_maximum_msat: default_htlc_maximum_msat.clone(),
+ htlc_maximum_msat: default_htlc_maximum_msat,
fee_base_msat: default_fee_base_msat,
fee_proportional_millionths: default_fee_proportional_millionths,
excess_data: vec![],
action: ErrorAction::IgnoreError,
})?;
- let htlc_maximum_msat =
- if let Some(htlc_maximum_msat) = directional_info.htlc_maximum_msat {
- OptionalField::Present(htlc_maximum_msat)
- } else {
- OptionalField::Absent
- };
-
UnsignedChannelUpdate {
chain_hash,
short_channel_id,
flags: standard_channel_flags,
cltv_expiry_delta: directional_info.cltv_expiry_delta,
htlc_minimum_msat: directional_info.htlc_minimum_msat,
- htlc_maximum_msat,
+ htlc_maximum_msat: directional_info.htlc_maximum_msat,
fee_base_msat: directional_info.fees.base_msat,
fee_proportional_millionths: directional_info.fees.proportional_millionths,
excess_data: vec![],
}
if channel_flags & 0b_0000_0100 > 0 {
- let tentative_htlc_maximum_msat: u64 = Readable::read(read_cursor)?;
- synthetic_update.htlc_maximum_msat = if tentative_htlc_maximum_msat == u64::max_value()
- {
- OptionalField::Absent
- } else {
- OptionalField::Present(tentative_htlc_maximum_msat)
- };
+ let htlc_maximum_msat: u64 = Readable::read(read_cursor)?;
+ synthetic_update.htlc_maximum_msat = htlc_maximum_msat;
}
network_graph.update_channel_unsigned(&synthetic_update)?;
use ln::channel::{Channel, InboundHTLCOutput, OutboundHTLCOutput, InboundHTLCState, OutboundHTLCState, HTLCCandidate, HTLCInitiator};
use ln::channel::{MAX_FUNDING_SATOSHIS_NO_WUMBO, TOTAL_BITCOIN_SUPPLY_SATOSHIS};
use ln::features::{InitFeatures, ChannelTypeFeatures};
- use ln::msgs::{ChannelUpdate, DataLossProtect, DecodeError, OptionalField, UnsignedChannelUpdate};
+ use ln::msgs::{ChannelUpdate, DataLossProtect, DecodeError, OptionalField, UnsignedChannelUpdate, MAX_VALUE_MSAT};
use ln::script::ShutdownScript;
use ln::chan_utils;
use ln::chan_utils::{htlc_success_tx_weight, htlc_timeout_tx_weight};
flags: 0,
cltv_expiry_delta: 100,
htlc_minimum_msat: 5,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 110,
fee_proportional_millionths: 11,
excess_data: Vec::new(),
use ln::msgs;
use ln::msgs::NetAddress;
use ln::onion_utils;
-use ln::msgs::{ChannelMessageHandler, DecodeError, LightningError, MAX_VALUE_MSAT, OptionalField};
+use ln::msgs::{ChannelMessageHandler, DecodeError, LightningError, MAX_VALUE_MSAT};
use ln::wire::Encode;
use chain::keysinterface::{Sign, KeysInterface, KeysManager, InMemorySigner, Recipient};
use util::config::{UserConfig, ChannelConfig};
flags: (!were_node_one) as u8 | ((!chan.is_live() as u8) << 1),
cltv_expiry_delta: chan.get_cltv_expiry_delta(),
htlc_minimum_msat: chan.get_counterparty_htlc_minimum_msat(),
- htlc_maximum_msat: OptionalField::Present(chan.get_announced_htlc_max_msat()),
+ htlc_maximum_msat: chan.get_announced_htlc_max_msat(),
fee_base_msat: chan.get_outbound_forwarding_fee_base_msat(),
fee_proportional_millionths: chan.get_fee_proportional_millionths(),
excess_data: Vec::new(),
use routing::router::{PaymentParameters, Route, RouteHop, RouteParameters, find_route, get_route};
use ln::features::{ChannelFeatures, InitFeatures, InvoiceFeatures, NodeFeatures};
use ln::msgs;
-use ln::msgs::{ChannelMessageHandler, RoutingMessageHandler, OptionalField, ErrorAction};
+use ln::msgs::{ChannelMessageHandler, RoutingMessageHandler, ErrorAction};
use util::enforcing_trait_impls::EnforcingSigner;
use util::{byte_utils, test_utils};
use util::events::{Event, MessageSendEvent, MessageSendEventsProvider, PaymentPurpose, ClosureReason};
// Assert that `node[0]`'s `ChannelUpdate` is capped at 50 percent of the `channel_value`, as
// that's the value of `node[1]`'s `holder_max_htlc_value_in_flight_msat`.
- assert_eq!(node_0_chan_update.contents.htlc_maximum_msat, OptionalField::Present(channel_value_50_percent_msat));
+ assert_eq!(node_0_chan_update.contents.htlc_maximum_msat, channel_value_50_percent_msat);
// Assert that `node[1]`'s `ChannelUpdate` is capped at 30 percent of the `channel_value`, as
// that's the value of `node[0]`'s `holder_max_htlc_value_in_flight_msat`.
- assert_eq!(node_1_chan_update.contents.htlc_maximum_msat, OptionalField::Present(channel_value_30_percent_msat));
+ assert_eq!(node_1_chan_update.contents.htlc_maximum_msat, channel_value_30_percent_msat);
// Assert that `node[2]`'s `ChannelUpdate` is capped at 90 percent of the `channel_value`, as
// the value of `node[3]`'s `holder_max_htlc_value_in_flight_msat` (100%), exceeds 90% of the
// `channel_value`.
- assert_eq!(node_2_chan_update.contents.htlc_maximum_msat, OptionalField::Present(channel_value_90_percent_msat));
+ assert_eq!(node_2_chan_update.contents.htlc_maximum_msat, channel_value_90_percent_msat);
// Assert that `node[3]`'s `ChannelUpdate` is capped at 90 percent of the `channel_value`, as
// the value of `node[2]`'s `holder_max_htlc_value_in_flight_msat` (95%), exceeds 90% of the
// `channel_value`.
- assert_eq!(node_3_chan_update.contents.htlc_maximum_msat, OptionalField::Present(channel_value_90_percent_msat));
+ assert_eq!(node_3_chan_update.contents.htlc_maximum_msat, channel_value_90_percent_msat);
}
#[test]
pub cltv_expiry_delta: u16,
/// The minimum HTLC size incoming to sender, in milli-satoshi
pub htlc_minimum_msat: u64,
- /// Optionally, the maximum HTLC value incoming to sender, in milli-satoshi
- pub htlc_maximum_msat: OptionalField<u64>,
+ /// The maximum HTLC value incoming to sender, in milli-satoshi. Used to be optional.
+ pub htlc_maximum_msat: u64,
/// The base HTLC fee charged by sender, in milli-satoshi
pub fee_base_msat: u32,
/// The amount to fee multiplier, in micro-satoshi
impl Writeable for UnsignedChannelUpdate {
fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
- let mut message_flags: u8 = 0;
- if let OptionalField::Present(_) = self.htlc_maximum_msat {
- message_flags = 1;
- }
+ // `message_flags` used to indicate presence of `htlc_maximum_msat`, but was deprecated in the spec.
+ const MESSAGE_FLAGS: u8 = 1;
self.chain_hash.write(w)?;
self.short_channel_id.write(w)?;
self.timestamp.write(w)?;
- let all_flags = self.flags as u16 | ((message_flags as u16) << 8);
+ let all_flags = self.flags as u16 | ((MESSAGE_FLAGS as u16) << 8);
all_flags.write(w)?;
self.cltv_expiry_delta.write(w)?;
self.htlc_minimum_msat.write(w)?;
impl Readable for UnsignedChannelUpdate {
fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
- let has_htlc_maximum_msat;
Ok(Self {
chain_hash: Readable::read(r)?,
short_channel_id: Readable::read(r)?,
timestamp: Readable::read(r)?,
flags: {
let flags: u16 = Readable::read(r)?;
- let message_flags = flags >> 8;
- has_htlc_maximum_msat = (message_flags as i32 & 1) == 1;
+ // Note: we ignore the `message_flags` for now, since it was deprecated by the spec.
flags as u8
},
cltv_expiry_delta: Readable::read(r)?,
htlc_minimum_msat: Readable::read(r)?,
fee_base_msat: Readable::read(r)?,
fee_proportional_millionths: Readable::read(r)?,
- htlc_maximum_msat: if has_htlc_maximum_msat { Readable::read(r)? } else { OptionalField::Absent },
+ htlc_maximum_msat: Readable::read(r)?,
excess_data: read_to_end(r)?,
})
}
do_encoding_node_announcement(false, false, true, false, true, false, false, false);
}
- fn do_encoding_channel_update(direction: bool, disable: bool, htlc_maximum_msat: bool, excess_data: bool) {
+ fn do_encoding_channel_update(direction: bool, disable: bool, excess_data: bool) {
let secp_ctx = Secp256k1::new();
let (privkey_1, _) = get_keys_from!("0101010101010101010101010101010101010101010101010101010101010101", secp_ctx);
let sig_1 = get_sig_on!(privkey_1, secp_ctx, String::from("01010101010101010101010101010101"));
flags: if direction { 1 } else { 0 } | if disable { 1 << 1 } else { 0 },
cltv_expiry_delta: 144,
htlc_minimum_msat: 1000000,
- htlc_maximum_msat: if htlc_maximum_msat { OptionalField::Present(131355275467161) } else { OptionalField::Absent },
+ htlc_maximum_msat: 131355275467161,
fee_base_msat: 10000,
fee_proportional_millionths: 20,
excess_data: if excess_data { vec![0, 0, 0, 0, 59, 154, 202, 0] } else { Vec::new() }
let mut target_value = hex::decode("d977cb9b53d93a6ff64bb5f1e158b4094b66e798fb12911168a3ccdf80a83096340a6a95da0ae8d9f776528eecdbb747eb6b545495a4319ed5378e35b21e073a").unwrap();
target_value.append(&mut hex::decode("000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f").unwrap());
target_value.append(&mut hex::decode("00083a840000034d013413a7").unwrap());
- if htlc_maximum_msat {
- target_value.append(&mut hex::decode("01").unwrap());
- } else {
- target_value.append(&mut hex::decode("00").unwrap());
- }
+ target_value.append(&mut hex::decode("01").unwrap());
target_value.append(&mut hex::decode("00").unwrap());
if direction {
let flag = target_value.last_mut().unwrap();
*flag = *flag | 1 << 1;
}
target_value.append(&mut hex::decode("009000000000000f42400000271000000014").unwrap());
- if htlc_maximum_msat {
- target_value.append(&mut hex::decode("0000777788889999").unwrap());
- }
+ target_value.append(&mut hex::decode("0000777788889999").unwrap());
if excess_data {
target_value.append(&mut hex::decode("000000003b9aca00").unwrap());
}
#[test]
fn encoding_channel_update() {
- do_encoding_channel_update(false, false, false, false);
- do_encoding_channel_update(false, false, false, true);
- do_encoding_channel_update(true, false, false, false);
- do_encoding_channel_update(true, false, false, true);
- do_encoding_channel_update(false, true, false, false);
- do_encoding_channel_update(false, true, false, true);
- do_encoding_channel_update(false, false, true, false);
- do_encoding_channel_update(false, false, true, true);
- do_encoding_channel_update(true, true, true, false);
- do_encoding_channel_update(true, true, true, true);
+ do_encoding_channel_update(false, false, false);
+ do_encoding_channel_update(false, false, true);
+ do_encoding_channel_update(true, false, false);
+ do_encoding_channel_update(true, false, true);
+ do_encoding_channel_update(false, true, false);
+ do_encoding_channel_update(false, true, true);
+ do_encoding_channel_update(true, true, false);
+ do_encoding_channel_update(true, true, true);
}
fn do_encoding_open_channel(random_bit: bool, shutdown: bool, incl_chan_type: bool) {
use routing::router::{get_route, PaymentParameters, Route, RouteHint, RouteHintHop};
use ln::features::{InitFeatures, InvoiceFeatures, NodeFeatures};
use ln::msgs;
-use ln::msgs::{ChannelMessageHandler, ChannelUpdate, OptionalField};
+use ln::msgs::{ChannelMessageHandler, ChannelUpdate};
use ln::wire::Encode;
use util::events::{Event, MessageSendEvent, MessageSendEventsProvider};
use util::ser::{ReadableArgs, Writeable, Writer};
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: msgs::MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: vec![],
use routing::router::{PaymentParameters, RouteHint, RouteHintHop};
use ln::features::{InitFeatures, InvoiceFeatures, ChannelTypeFeatures};
use ln::msgs;
-use ln::msgs::{ChannelMessageHandler, RoutingMessageHandler, OptionalField, ChannelUpdate, ErrorAction};
+use ln::msgs::{ChannelMessageHandler, RoutingMessageHandler, ChannelUpdate, ErrorAction};
use ln::wire::Encode;
use util::enforcing_trait_impls::EnforcingSigner;
use util::events::{ClosureReason, Event, MessageSendEvent, MessageSendEventsProvider};
flags: 1,
cltv_expiry_delta: accept_forward_cfg.channel_config.cltv_expiry_delta,
htlc_minimum_msat: 1_000,
- htlc_maximum_msat: OptionalField::Present(1_000_000), // Defaults to 10% of the channel value
+ htlc_maximum_msat: 1_000_000, // Defaults to 10% of the channel value
fee_base_msat: last_hop[0].counterparty.forwarding_info.as_ref().unwrap().fee_base_msat,
fee_proportional_millionths: last_hop[0].counterparty.forwarding_info.as_ref().unwrap().fee_proportional_millionths,
excess_data: Vec::new(),
use chain::Access;
use ln::features::{ChannelFeatures, NodeFeatures};
use ln::msgs::{DecodeError, ErrorAction, Init, LightningError, RoutingMessageHandler, NetAddress, MAX_VALUE_MSAT};
-use ln::msgs::{ChannelAnnouncement, ChannelUpdate, NodeAnnouncement, OptionalField, GossipTimestampFilter};
+use ln::msgs::{ChannelAnnouncement, ChannelUpdate, NodeAnnouncement, GossipTimestampFilter};
use ln::msgs::{QueryChannelRange, ReplyChannelRange, QueryShortChannelIds, ReplyShortChannelIdsEnd};
use ln::msgs;
-use util::ser::{Readable, ReadableArgs, Writeable, Writer};
+use util::ser::{Readable, ReadableArgs, Writeable, Writer, MaybeReadable};
use util::logger::{Logger, Level};
use util::events::{Event, EventHandler, MessageSendEvent, MessageSendEventsProvider};
use util::scid_utils::{block_from_scid, scid_from_parts, MAX_SCID_BLOCK};
/// The minimum value, which must be relayed to the next hop via the channel
pub htlc_minimum_msat: u64,
/// The maximum value which may be relayed to the next hop via the channel.
- pub htlc_maximum_msat: Option<u64>,
+ pub htlc_maximum_msat: u64,
/// Fees charged when the channel is used for routing
pub fees: RoutingFees,
/// Most recent update for the channel received from the network
}
}
-impl_writeable_tlv_based!(ChannelUpdateInfo, {
- (0, last_update, required),
- (2, enabled, required),
- (4, cltv_expiry_delta, required),
- (6, htlc_minimum_msat, required),
- (8, htlc_maximum_msat, required),
- (10, fees, required),
- (12, last_update_message, required),
-});
+impl Writeable for ChannelUpdateInfo {
+ fn write<W: ::util::ser::Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
+ write_tlv_fields!(writer, {
+ (0, self.last_update, required),
+ (2, self.enabled, required),
+ (4, self.cltv_expiry_delta, required),
+ (6, self.htlc_minimum_msat, required),
+ // Writing htlc_maximum_msat as an Option<u64> is required to maintain backwards
+ // compatibility with LDK versions prior to v0.0.110.
+ (8, Some(self.htlc_maximum_msat), required),
+ (10, self.fees, required),
+ (12, self.last_update_message, required),
+ });
+ Ok(())
+ }
+}
+
+impl Readable for ChannelUpdateInfo {
+ fn read<R: io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
+ init_tlv_field_var!(last_update, required);
+ init_tlv_field_var!(enabled, required);
+ init_tlv_field_var!(cltv_expiry_delta, required);
+ init_tlv_field_var!(htlc_minimum_msat, required);
+ init_tlv_field_var!(htlc_maximum_msat, option);
+ init_tlv_field_var!(fees, required);
+ init_tlv_field_var!(last_update_message, required);
+
+ read_tlv_fields!(reader, {
+ (0, last_update, required),
+ (2, enabled, required),
+ (4, cltv_expiry_delta, required),
+ (6, htlc_minimum_msat, required),
+ (8, htlc_maximum_msat, required),
+ (10, fees, required),
+ (12, last_update_message, required)
+ });
+
+ if let Some(htlc_maximum_msat) = htlc_maximum_msat {
+ Ok(ChannelUpdateInfo {
+ last_update: init_tlv_based_struct_field!(last_update, required),
+ enabled: init_tlv_based_struct_field!(enabled, required),
+ cltv_expiry_delta: init_tlv_based_struct_field!(cltv_expiry_delta, required),
+ htlc_minimum_msat: init_tlv_based_struct_field!(htlc_minimum_msat, required),
+ htlc_maximum_msat,
+ fees: init_tlv_based_struct_field!(fees, required),
+ last_update_message: init_tlv_based_struct_field!(last_update_message, required),
+ })
+ } else {
+ Err(DecodeError::InvalidValue)
+ }
+ }
+}
#[derive(Clone, Debug, PartialEq)]
/// Details about a channel (both directions).
}
}
-impl_writeable_tlv_based!(ChannelInfo, {
- (0, features, required),
- (1, announcement_received_time, (default_value, 0)),
- (2, node_one, required),
- (4, one_to_two, required),
- (6, node_two, required),
- (8, two_to_one, required),
- (10, capacity_sats, required),
- (12, announcement_message, required),
-});
+impl Writeable for ChannelInfo {
+ fn write<W: ::util::ser::Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
+ write_tlv_fields!(writer, {
+ (0, self.features, required),
+ (1, self.announcement_received_time, (default_value, 0)),
+ (2, self.node_one, required),
+ (4, self.one_to_two, required),
+ (6, self.node_two, required),
+ (8, self.two_to_one, required),
+ (10, self.capacity_sats, required),
+ (12, self.announcement_message, required),
+ });
+ Ok(())
+ }
+}
+
+// A wrapper allowing for the optional deseralization of ChannelUpdateInfo. Utilizing this is
+// necessary to maintain backwards compatibility with previous serializations of `ChannelUpdateInfo`
+// that may have no `htlc_maximum_msat` field set. In case the field is absent, we simply ignore
+// the error and continue reading the `ChannelInfo`. Hopefully, we'll then eventually receive newer
+// channel updates via the gossip network.
+struct ChannelUpdateInfoDeserWrapper(Option<ChannelUpdateInfo>);
+
+impl MaybeReadable for ChannelUpdateInfoDeserWrapper {
+ fn read<R: io::Read>(reader: &mut R) -> Result<Option<Self>, DecodeError> {
+ match ::util::ser::Readable::read(reader) {
+ Ok(channel_update_option) => Ok(Some(Self(channel_update_option))),
+ Err(DecodeError::ShortRead) => Ok(None),
+ Err(DecodeError::InvalidValue) => Ok(None),
+ Err(err) => Err(err),
+ }
+ }
+}
+
+impl Readable for ChannelInfo {
+ fn read<R: io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
+ init_tlv_field_var!(features, required);
+ init_tlv_field_var!(announcement_received_time, (default_value, 0));
+ init_tlv_field_var!(node_one, required);
+ let mut one_to_two_wrap: Option<ChannelUpdateInfoDeserWrapper> = None;
+ init_tlv_field_var!(node_two, required);
+ let mut two_to_one_wrap: Option<ChannelUpdateInfoDeserWrapper> = None;
+ init_tlv_field_var!(capacity_sats, required);
+ init_tlv_field_var!(announcement_message, required);
+ read_tlv_fields!(reader, {
+ (0, features, required),
+ (1, announcement_received_time, (default_value, 0)),
+ (2, node_one, required),
+ (4, one_to_two_wrap, ignorable),
+ (6, node_two, required),
+ (8, two_to_one_wrap, ignorable),
+ (10, capacity_sats, required),
+ (12, announcement_message, required),
+ });
+
+ Ok(ChannelInfo {
+ features: init_tlv_based_struct_field!(features, required),
+ node_one: init_tlv_based_struct_field!(node_one, required),
+ one_to_two: one_to_two_wrap.map(|w| w.0).unwrap_or(None),
+ node_two: init_tlv_based_struct_field!(node_two, required),
+ two_to_one: two_to_one_wrap.map(|w| w.0).unwrap_or(None),
+ capacity_sats: init_tlv_based_struct_field!(capacity_sats, required),
+ announcement_message: init_tlv_based_struct_field!(announcement_message, required),
+ announcement_received_time: init_tlv_based_struct_field!(announcement_received_time, (default_value, 0)),
+ })
+ }
+}
/// A wrapper around [`ChannelInfo`] representing information about the channel as directed from a
/// source node to a target node.
impl<'a> DirectedChannelInfo<'a> {
#[inline]
fn new(channel: &'a ChannelInfo, direction: Option<&'a ChannelUpdateInfo>) -> Self {
- let htlc_maximum_msat = direction.and_then(|direction| direction.htlc_maximum_msat);
+ let htlc_maximum_msat = direction.map(|direction| direction.htlc_maximum_msat);
let capacity_msat = channel.capacity_sats.map(|capacity_sats| capacity_sats * 1000);
let (htlc_maximum_msat, effective_capacity) = match (htlc_maximum_msat, capacity_msat) {
match channels.get_mut(&msg.short_channel_id) {
None => return Err(LightningError{err: "Couldn't find channel for update".to_owned(), action: ErrorAction::IgnoreError}),
Some(channel) => {
- if let OptionalField::Present(htlc_maximum_msat) = msg.htlc_maximum_msat {
- if htlc_maximum_msat > MAX_VALUE_MSAT {
- return Err(LightningError{err: "htlc_maximum_msat is larger than maximum possible msats".to_owned(), action: ErrorAction::IgnoreError});
- }
+ if msg.htlc_maximum_msat > MAX_VALUE_MSAT {
+ return Err(LightningError{err:
+ "htlc_maximum_msat is larger than maximum possible msats".to_owned(),
+ action: ErrorAction::IgnoreError});
+ }
- if let Some(capacity_sats) = channel.capacity_sats {
- // It's possible channel capacity is available now, although it wasn't available at announcement (so the field is None).
- // Don't query UTXO set here to reduce DoS risks.
- if capacity_sats > MAX_VALUE_MSAT / 1000 || htlc_maximum_msat > capacity_sats * 1000 {
- return Err(LightningError{err: "htlc_maximum_msat is larger than channel capacity or capacity is bogus".to_owned(), action: ErrorAction::IgnoreError});
- }
+ if let Some(capacity_sats) = channel.capacity_sats {
+ // It's possible channel capacity is available now, although it wasn't available at announcement (so the field is None).
+ // Don't query UTXO set here to reduce DoS risks.
+ if capacity_sats > MAX_VALUE_MSAT / 1000 || msg.htlc_maximum_msat > capacity_sats * 1000 {
+ return Err(LightningError{err:
+ "htlc_maximum_msat is larger than channel capacity or capacity is bogus".to_owned(),
+ action: ErrorAction::IgnoreError});
}
}
macro_rules! check_update_latest {
last_update: msg.timestamp,
cltv_expiry_delta: msg.cltv_expiry_delta,
htlc_minimum_msat: msg.htlc_minimum_msat,
- htlc_maximum_msat: if let OptionalField::Present(max_value) = msg.htlc_maximum_msat { Some(max_value) } else { None },
+ htlc_maximum_msat: msg.htlc_maximum_msat,
fees: RoutingFees {
base_msat: msg.fee_base_msat,
proportional_millionths: msg.fee_proportional_millionths,
use chain;
use ln::PaymentHash;
use ln::features::{ChannelFeatures, InitFeatures, NodeFeatures};
- use routing::gossip::{P2PGossipSync, NetworkGraph, NetworkUpdate, NodeAlias, MAX_EXCESS_BYTES_FOR_RELAY};
- use ln::msgs::{Init, OptionalField, RoutingMessageHandler, UnsignedNodeAnnouncement, NodeAnnouncement,
+ use routing::gossip::{P2PGossipSync, NetworkGraph, NetworkUpdate, NodeAlias, MAX_EXCESS_BYTES_FOR_RELAY, NodeId, RoutingFees, ChannelUpdateInfo, ChannelInfo, NodeAnnouncementInfo, NodeInfo};
+ use ln::msgs::{Init, RoutingMessageHandler, UnsignedNodeAnnouncement, NodeAnnouncement,
UnsignedChannelAnnouncement, ChannelAnnouncement, UnsignedChannelUpdate, ChannelUpdate,
ReplyChannelRange, QueryChannelRange, QueryShortChannelIds, MAX_VALUE_MSAT};
use util::test_utils;
flags: 0,
cltv_expiry_delta: 144,
htlc_minimum_msat: 1_000_000,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: 1_000_000,
fee_base_msat: 10_000,
fee_proportional_millionths: 20,
excess_data: Vec::new()
let valid_channel_update = get_signed_channel_update(|_| {}, node_1_privkey, &secp_ctx);
match gossip_sync.handle_channel_update(&valid_channel_update) {
Ok(res) => assert!(res),
- _ => panic!()
+ _ => panic!(),
};
{
};
let valid_channel_update = get_signed_channel_update(|unsigned_channel_update| {
- unsigned_channel_update.htlc_maximum_msat = OptionalField::Present(MAX_VALUE_MSAT + 1);
+ unsigned_channel_update.htlc_maximum_msat = MAX_VALUE_MSAT + 1;
unsigned_channel_update.timestamp += 110;
}, node_1_privkey, &secp_ctx);
match gossip_sync.handle_channel_update(&valid_channel_update) {
};
let valid_channel_update = get_signed_channel_update(|unsigned_channel_update| {
- unsigned_channel_update.htlc_maximum_msat = OptionalField::Present(amount_sats * 1000 + 1);
+ unsigned_channel_update.htlc_maximum_msat = amount_sats * 1000 + 1;
unsigned_channel_update.timestamp += 110;
}, node_1_privkey, &secp_ctx);
match gossip_sync.handle_channel_update(&valid_channel_update) {
use chain::transaction::OutPoint;
use chain::keysinterface::KeysInterface;
use ln::features::{ChannelFeatures, InitFeatures, InvoiceFeatures, NodeFeatures};
- use ln::msgs::{ErrorAction, LightningError, OptionalField, UnsignedChannelAnnouncement, ChannelAnnouncement, RoutingMessageHandler,
- NodeAnnouncement, UnsignedNodeAnnouncement, ChannelUpdate, UnsignedChannelUpdate};
+ use ln::msgs::{ErrorAction, LightningError, UnsignedChannelAnnouncement, ChannelAnnouncement, RoutingMessageHandler,
+ NodeAnnouncement, UnsignedNodeAnnouncement, ChannelUpdate, UnsignedChannelUpdate, MAX_VALUE_MSAT};
use ln::channelmanager;
use util::test_utils;
use util::chacha20::ChaCha20;
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 1,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 1,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: (5 << 4) | 3,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: u32::max_value(),
fee_proportional_millionths: u32::max_value(),
excess_data: Vec::new()
flags: 1,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: (5 << 4) | 3,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: u32::max_value(),
fee_proportional_millionths: u32::max_value(),
excess_data: Vec::new()
flags: 1,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: (3 << 4) | 1,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 1,
cltv_expiry_delta: (3 << 4) | 2,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 100,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: (4 << 4) | 1,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 1000000,
excess_data: Vec::new()
flags: 1,
cltv_expiry_delta: (4 << 4) | 2,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: (13 << 4) | 1,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 2000000,
excess_data: Vec::new()
flags: 1,
cltv_expiry_delta: (13 << 4) | 2,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: (6 << 4) | 1,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 1,
cltv_expiry_delta: (6 << 4) | 2,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new(),
flags: 0,
cltv_expiry_delta: (11 << 4) | 1,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 1,
cltv_expiry_delta: (11 << 4) | 2,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: (7 << 4) | 1,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 1000000,
excess_data: Vec::new()
flags: 1,
cltv_expiry_delta: (7 << 4) | 2,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 2, // to disable
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 2, // to disable
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 2, // to disable
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 2, // to disable
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 2, // to disable
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 200_000_000,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(199_999_999),
+ htlc_maximum_msat: 199_999_999,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 35_000,
- htlc_maximum_msat: OptionalField::Present(40_000),
+ htlc_maximum_msat: 40_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 35_000,
- htlc_maximum_msat: OptionalField::Present(40_000),
+ htlc_maximum_msat: 40_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 2, // to disable
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 65_000,
- htlc_maximum_msat: OptionalField::Present(80_000),
+ htlc_maximum_msat: 80_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 100_000,
excess_data: Vec::new()
flags: 2, // to disable
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 2, // to disable
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 2, // to disable
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 2, // to disable
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 2, // to disable
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 2, // to disable
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 2,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 2,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(1_000_000_000),
+ htlc_maximum_msat: 1_000_000_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: 250_000_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 2,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(1_000_000_000),
+ htlc_maximum_msat: 1_000_000_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(1_000_000_000),
+ htlc_maximum_msat: 1_000_000_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(15_000),
+ htlc_maximum_msat: 15_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 2,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: (3 << 4) | 1,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: 15_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 1,
cltv_expiry_delta: (3 << 4) | 2,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: 15_000,
fee_base_msat: 100,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(10_000),
+ htlc_maximum_msat: 10_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 2,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 2,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(50_000),
+ htlc_maximum_msat: 50_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 1_000_000,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(50_000),
+ htlc_maximum_msat: 50_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(50_000),
+ htlc_maximum_msat: 50_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(60_000),
+ htlc_maximum_msat: 60_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(60_000),
+ htlc_maximum_msat: 60_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(200_000),
+ htlc_maximum_msat: 200_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(180_000),
+ htlc_maximum_msat: 180_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 2,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 2,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(200_000),
+ htlc_maximum_msat: 200_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(200_000),
+ htlc_maximum_msat: 200_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(200_000),
+ htlc_maximum_msat: 200_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 2,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 2,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(200_000),
+ htlc_maximum_msat: 200_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(200_000),
+ htlc_maximum_msat: 200_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(200_000),
+ htlc_maximum_msat: 200_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 1_000,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 2,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 2,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(250_000),
+ htlc_maximum_msat: 250_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 150_000,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: (5 << 4) | 5,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(99_000),
+ htlc_maximum_msat: 99_000,
fee_base_msat: u32::max_value(),
fee_proportional_millionths: u32::max_value(),
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: (5 << 4) | 3,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(99_000),
+ htlc_maximum_msat: 99_000,
fee_base_msat: u32::max_value(),
fee_proportional_millionths: u32::max_value(),
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: (4 << 4) | 1,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 1,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0|2, // Channel disabled
cltv_expiry_delta: (13 << 4) | 1,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 2000000,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(100_000),
+ htlc_maximum_msat: 100_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(50_000),
+ htlc_maximum_msat: 50_000,
fee_base_msat: 100,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(60_000),
+ htlc_maximum_msat: 60_000,
fee_base_msat: 100,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(60_000),
+ htlc_maximum_msat: 60_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(20_000),
+ htlc_maximum_msat: 20_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(20_000),
+ htlc_maximum_msat: 20_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: (6 << 4) | 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: (5 << 4) | 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 100,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: (4 << 4) | 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: (3 << 4) | 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: (2 << 4) | 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: (1 << 4) | 0,
htlc_minimum_msat: 100,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(85_000),
+ htlc_maximum_msat: 85_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: (4 << 4) | 1,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(270_000),
+ htlc_maximum_msat: 270_000,
fee_base_msat: 0,
fee_proportional_millionths: 1000000,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(80_000),
+ htlc_maximum_msat: 80_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: (4 << 4) | 1,
htlc_minimum_msat: 90_000,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: (4 << 4) | 1,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(250_000_000),
+ htlc_maximum_msat: 250_000_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
flags: 0,
cltv_expiry_delta: (13 << 4) | 1,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(250_000_000),
+ htlc_maximum_msat: 250_000_000,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: Vec::new()
use util::time::tests::SinceEpoch;
use ln::features::{ChannelFeatures, NodeFeatures};
- use ln::msgs::{ChannelAnnouncement, ChannelUpdate, OptionalField, UnsignedChannelAnnouncement, UnsignedChannelUpdate};
+ use ln::msgs::{ChannelAnnouncement, ChannelUpdate, UnsignedChannelAnnouncement, UnsignedChannelUpdate};
use routing::gossip::{EffectiveCapacity, NetworkGraph, NodeId};
use routing::router::RouteHop;
use routing::scoring::{ChannelUsage, Score};
flags,
cltv_expiry_delta: 18,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Present(1_000),
+ htlc_maximum_msat: 1_000,
fee_base_msat: 1,
fee_proportional_millionths: 0,
excess_data: Vec::new(),
use chain::keysinterface;
use ln::features::{ChannelFeatures, InitFeatures};
use ln::{msgs, wire};
-use ln::msgs::OptionalField;
use ln::script::ShutdownScript;
use routing::scoring::FixedPenaltyScorer;
use util::enforcing_trait_impls::{EnforcingSigner, EnforcementState};
flags: 0,
cltv_expiry_delta: 0,
htlc_minimum_msat: 0,
- htlc_maximum_msat: OptionalField::Absent,
+ htlc_maximum_msat: msgs::MAX_VALUE_MSAT,
fee_base_msat: 0,
fee_proportional_millionths: 0,
excess_data: vec![],