Struct EnforcementState

Source
pub struct EnforcementState {
Show 13 fields pub next_holder_commit_num: u64, pub next_counterparty_commit_num: u64, pub next_counterparty_revoke_num: u64, pub current_counterparty_point: Option<PublicKey>, pub previous_counterparty_point: Option<PublicKey>, pub current_holder_commit_info: Option<CommitmentInfo2>, pub current_counterparty_signatures: Option<CommitmentSignatures>, pub next_holder_commit_info: Option<(CommitmentInfo2, CommitmentSignatures)>, pub current_counterparty_commit_info: Option<CommitmentInfo2>, pub previous_counterparty_commit_info: Option<CommitmentInfo2>, pub channel_closed: bool, pub initial_holder_value: u64, pub counterparty_secrets: Option<CounterpartyCommitmentSecrets>,
}
Expand description

Enforcement state for a channel

This keeps track of commitments on both sides and whether the channel was closed.

Fields§

§next_holder_commit_num: u64§next_counterparty_commit_num: u64§next_counterparty_revoke_num: u64§current_counterparty_point: Option<PublicKey>§previous_counterparty_point: Option<PublicKey>§current_holder_commit_info: Option<CommitmentInfo2>§current_counterparty_signatures: Option<CommitmentSignatures>

Counterparty signatures on holder’s commitment

§next_holder_commit_info: Option<(CommitmentInfo2, CommitmentSignatures)>

Next holder commitment

§current_counterparty_commit_info: Option<CommitmentInfo2>§previous_counterparty_commit_info: Option<CommitmentInfo2>§channel_closed: bool§initial_holder_value: u64§counterparty_secrets: Option<CounterpartyCommitmentSecrets>

Counterparty revocation secrets. This is an Option for backwards compatibility with old databases.

Implementations§

Source§

impl EnforcementState

Source

pub fn new(initial_holder_value: u64) -> EnforcementState

Create state for a new channel.

initial_holder_value is in satoshi and represents the lowest value that we expect the initial commitment to send to us.

Source

pub fn minimum_to_holder_value(&self, epsilon_sat: u64) -> Option<u64>

Returns the minimum amount to_holder from both commitments or None if the amounts are not within epsilon_sat.

Source

pub fn minimum_to_counterparty_value(&self, epsilon_sat: u64) -> Option<u64>

Returns the minimum amount to_counterparty from both commitments or None if the amounts are not within epsilon_sat.

Source

pub fn set_next_holder_commit_num( &mut self, num: u64, current_commitment_info: CommitmentInfo2, counterparty_signatures: CommitmentSignatures, )

Set next holder commitment number Policy enforcement must be performed by the caller

Source

pub fn set_next_counterparty_commit_num( &mut self, num: u64, current_point: PublicKey, current_commitment_info: CommitmentInfo2, )

Set next counterparty commitment number

Source

pub fn get_previous_counterparty_point(&self, num: u64) -> Option<PublicKey>

Previous counterparty commitment point, or None if unknown

Source

pub fn get_previous_counterparty_commit_info( &self, num: u64, ) -> Option<CommitmentInfo2>

Previous counterparty commitment info

Source

pub fn set_next_counterparty_revoke_num(&mut self, num: u64)

Set next counterparty revoked commitment number

Source

pub fn payments_summary( &self, new_holder_tx: Option<&CommitmentInfo2>, new_counterparty_tx: Option<&CommitmentInfo2>, ) -> Map<PaymentHash, u64>

Summarize in-flight outgoing payments, possibly with new holder offered or counterparty received commitment tx. The amounts are in satoshi. HTLCs belonging to a payment are summed for each of the holder and counterparty txs. The greater value is taken as the actual in-flight value.

Source

pub fn incoming_payments_summary( &self, new_holder_tx: Option<&CommitmentInfo2>, new_counterparty_tx: Option<&CommitmentInfo2>, ) -> Map<PaymentHash, u64>

Summarize in-flight incoming payments, possibly with new holder offered or counterparty received commitment tx. The amounts are in satoshi. HTLCs belonging to a payment are summed for each of the holder and counterparty txs. The smaller value is taken as the actual in-flight value.

Source

pub fn claimable_balances<T: PreimageMap>( &self, preimage_map: &T, new_holder_tx: Option<&CommitmentInfo2>, new_counterparty_tx: Option<&CommitmentInfo2>, channel_setup: &ChannelSetup, ) -> BalanceDelta

The claimable balance before and after a new commitment tx

See CommitmentInfo2::claimable_balance

Source

pub fn balance<T: PreimageMap + Debug>( &self, preimage_map: &T, channel_setup: &ChannelSetup, is_ready: bool, ) -> ChannelBalance

Return channel balances

Trait Implementations§

Source§

impl Clone for EnforcementState

Source§

fn clone(&self) -> EnforcementState

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EnforcementState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for EnforcementState

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for EnforcementState

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,