Struct lightning_signer::node::NodeState
source · 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
impl NodeState
sourcepub fn new(velocity_control: VelocityControl) -> Self
pub fn new(velocity_control: VelocityControl) -> Self
Create a state
sourcepub 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>
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.
sourcepub 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>
)
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.
sourcepub fn htlc_fulfilled(
&mut self,
channel_id: &ChannelId,
preimage: PaymentPreimage,
validator: Arc<dyn Validator>
)
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 PreimageMap for NodeState
impl PreimageMap for NodeState
source§fn has_preimage(&self, hash: &PaymentHash) -> bool
fn has_preimage(&self, hash: &PaymentHash) -> bool
Whether a preimage is known for the payment hash