pub struct Policy {
pub to_self_delay_max: u16,
pub feerate_per_kw_range: Range<u32>,
pub minimum_depth: u32,
pub maximum_depth: Option<u32>,
pub funding_satoshis_min: Option<u64>,
pub htlc_minimum_msat_max: Option<u64>,
pub max_htlc_value_in_flight_msat_min: Option<u64>,
pub channel_reserve_satoshis_max_abs: Option<u64>,
pub channel_reserve_satoshis_max_percent: Option<u8>,
pub max_accepted_htlcs_min: Option<u16>,
pub dust_limit_satoshis_max: Option<u64>,
}
Expand description
Policy to validate channel parameters proposed by a remote peer.
By default, crate::Channel::new
uses reasonable default policy created
by Policy::default()
method. Channel creator may provide a custom policy
by using crate::Channel::with
method.
Fields§
§to_self_delay_max: u16
Reasonable limit to check value of to_self_delay
required by a remote
node, in blocks.
feerate_per_kw_range: Range<u32>
Range of acceptable channel fees.
minimum_depth: u32
Minimum funding transaction mining depth required from the remote node for a channel proposed by it.
maximum_depth: Option<u32>
Maximum funding transaction mining depth which may be required by a remote node for a channel opened by a local node.
funding_satoshis_min: Option<u64>
Minimum funding for a channel by this node.
htlc_minimum_msat_max: Option<u64>
The maximum acceptable limit on the value stored in a single HTLC.
max_htlc_value_in_flight_msat_min: Option<u64>
Minimum boundary for the upper limit of in-flight HTLC funds.
channel_reserve_satoshis_max_abs: Option<u64>
Maximum reserve for a channel from a local node required by the remote node in absolute value.
channel_reserve_satoshis_max_percent: Option<u8>
Maximum reserve for a channel from a local node required by the remote node in persents from the channel funding.
max_accepted_htlcs_min: Option<u16>
Minimum boundary to the limit of HTLCs offered to a remote peer.
dust_limit_satoshis_max: Option<u64>
Maximum value for the dust limit required by a remote node.
Implementations§
Source§impl Policy
impl Policy
Sourcepub fn with_clightning_defaults() -> Policy
pub fn with_clightning_defaults() -> Policy
Sets policy to match default policy used in c-lightning
Sourcepub fn with_lnd_defaults() -> Policy
pub fn with_lnd_defaults() -> Policy
Sets policy to match default policy used in LND
Sourcepub fn with_eclair_defaults() -> Policy
pub fn with_eclair_defaults() -> Policy
Sets policy to match default policy used in Eclair
Sourcepub fn validate_inbound(
&self,
open_channel: &OpenChannel,
) -> Result<PeerParams, PolicyError>
pub fn validate_inbound( &self, open_channel: &OpenChannel, ) -> Result<PeerParams, PolicyError>
Validates parameters proposed by remote peer in open_channel
message
against the policy
§Arguments
self
: local policy;open_channel
: BOLT-2 message received by the peer.
§Returns
PeerParams
to use for constructing channel transactions which should
be signed by the local node.
Sourcepub fn confirm_outbound(
&self,
our_params: PeerParams,
accept_channel: &AcceptChannel,
) -> Result<PeerParams, PolicyError>
pub fn confirm_outbound( &self, our_params: PeerParams, accept_channel: &AcceptChannel, ) -> Result<PeerParams, PolicyError>
Confirms that parameters which were asked by a remote node via
accept_channel
message are confirming our policy.
§Arguments
self
: local policy;params
: parameters proposed by the local node inopen_channel
message;accept_channel
: BOLT-2 message received by the peer.
§Returns
PeerParams
to use for constructing channel transactions which should
be signed by the local node.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Policy
impl<'de> Deserialize<'de> for Policy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl StrictDecode for Policy
impl StrictDecode for Policy
Source§fn strict_decode<D: Read>(d: D) -> Result<Self, Error>
fn strict_decode<D: Read>(d: D) -> Result<Self, Error>
std::io::Read
instance; must either
construct an instance or return implementation-specific error type.Source§fn strict_deserialize(data: impl AsRef<[u8]>) -> Result<Self, Error>
fn strict_deserialize(data: impl AsRef<[u8]>) -> Result<Self, Error>
StrictDecode::strict_decode
. If there are some data remains in the
buffer once deserialization is completed, fails with
Error::DataNotEntirelyConsumed
. Use io::Cursor
over the buffer and
StrictDecode::strict_decode
to avoid such failures.Source§fn strict_file_load(path: impl AsRef<Path>) -> Result<Self, Error>
fn strict_file_load(path: impl AsRef<Path>) -> Result<Self, Error>
path
and reconstructs object from it. Fails
with Error::DataNotEntirelyConsumed
if file contains remaining
data after the object reconstruction.Source§impl StrictEncode for Policy
impl StrictEncode for Policy
Source§fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>
fn strict_encode<E: Write>(&self, e: E) -> Result<usize, Error>
std::io::Write
instance; must return result
with either amount of bytes encoded – or implementation-specific
error type.Source§fn strict_serialize(&self) -> Result<Vec<u8>, Error>
fn strict_serialize(&self) -> Result<Vec<u8>, Error>
StrictEncode::strict_encode
functionSource§impl ToYamlString for Policy
Available on crate feature serde
only.
impl ToYamlString for Policy
serde
only.Source§fn to_yaml_string(&self) -> String
fn to_yaml_string(&self) -> String
self
into a YAML-encoded stringimpl Eq for Policy
impl StructuralPartialEq for Policy
Auto Trait Implementations§
impl Freeze for Policy
impl RefUnwindSafe for Policy
impl Send for Policy
impl Sync for Policy
impl Unpin for Policy
impl UnwindSafe for Policy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.