pub struct EnforcementState {
    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 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

§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 get_current_holder_commitment_info(&self) -> CommitmentInfo2

Get the current commitment info

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 ) -> ChannelBalance

Return channel balances

Trait Implementations§

source§

impl Clone for EnforcementState

source§

fn clone(&self) -> EnforcementState

Returns a copy 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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

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

§

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 Twhere T: for<'de> Deserialize<'de>,