pub struct NodeState {
    pub invoices: Map<PaymentHash, PaymentState>,
    pub issued_invoices: Map<PaymentHash, PaymentState>,
    pub payments: Map<PaymentHash, RoutedPayment>,
    pub excess_amount: u64,
    pub log_prefix: String,
    pub velocity_control: VelocityControl,
}
Expand description

Enforcement state for a node

Fields§

§invoices: Map<PaymentHash, PaymentState>

Added invoices for outgoing payments indexed by their payment hash

§issued_invoices: Map<PaymentHash, PaymentState>

Issued invoices for incoming payments indexed by their payment hash

§payments: Map<PaymentHash, RoutedPayment>

Payment states

§excess_amount: u64

Accumulator of excess payment amount in satoshi, for tracking certain payment corner cases. If this falls below zero, the attempted commit is failed.

§log_prefix: String

Prefix for emitted logs lines

§velocity_control: VelocityControl

Per node velocity control

Implementations§

source§

impl NodeState

source

pub fn new(velocity_control: VelocityControl) -> Self

Create a state

source

pub fn validate_payments( &self, channel_id: &ChannelId, incoming_payment_summary: &Map<PaymentHash, u64>, outgoing_payment_summary: &Map<PaymentHash, u64>, balance_delta: &BalanceDelta, validator: Arc<dyn Validator> ) -> Result<(), ValidationError>

Validate outgoing in-flight payment amounts as a result of a new commitment tx.

The following policies are checked:

  • no overpayment for any invoice.
  • Sends without invoices (e.g. keysend) are only allowed if policy.require_invoices is false.
source

pub fn apply_payments( &mut self, channel_id: &ChannelId, incoming_payment_summary: &Map<PaymentHash, u64>, outgoing_payment_summary: &Map<PaymentHash, u64>, balance_delta: &BalanceDelta, validator: Arc<dyn Validator> )

Apply outgoing in-flight payment amounts as a result of a new commitment tx. Must call [validate_payments] first.

source

pub fn htlc_fulfilled( &mut self, channel_id: &ChannelId, preimage: PaymentPreimage, validator: Arc<dyn Validator> )

Fulfills an HTLC. Performs bookkeeping on any invoice or routed payment with this payment hash.

Trait Implementations§

source§

impl Debug for NodeState

source§

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

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

impl PreimageMap for NodeState

source§

fn has_preimage(&self, hash: &PaymentHash) -> bool

Whether a preimage is known for the payment hash

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · 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.
const: unstable · 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