pub enum MonitorName {
V1Channel(OutPoint),
V2Channel(ChannelId),
}Expand description
A struct representing a name for a channel monitor.
MonitorName is primarily used within the MonitorUpdatingPersister
in functions that store or retrieve ChannelMonitor snapshots.
It provides a consistent way to generate a unique key for channel
monitors based on the channel’s funding OutPoint for v1 channels or
ChannelId for v2 channels. Use ChannelMonitor::persistence_key to
obtain the correct MonitorName.
While users of the Lightning Dev Kit library generally won’t need
to interact with MonitorName directly, it can be useful for:
- Custom persistence implementations
- Debugging or logging channel monitor operations
- Extending the functionality of the
MonitorUpdatingPersister
§Examples
use std::str::FromStr;
use bitcoin::Txid;
use bitcoin::hashes::hex::FromHex;
use lightning::util::persist::MonitorName;
use lightning::chain::transaction::OutPoint;
use lightning::ln::types::ChannelId;
// v1 channel
let outpoint = OutPoint {
txid: Txid::from_str("deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef").unwrap(),
index: 1,
};
let monitor_name = MonitorName::V1Channel(outpoint);
assert_eq!(&monitor_name.to_string(), "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef_1");
// v2 channel
let channel_id = ChannelId(<[u8; 32]>::from_hex("deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef").unwrap());
let monitor_name = MonitorName::V2Channel(channel_id);
assert_eq!(&monitor_name.to_string(), "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef");
// Using MonitorName to generate a storage key
let storage_key = format!("channel_monitors/{}", monitor_name);Variants§
V1Channel(OutPoint)
The outpoint of the channel’s funding transaction.
V2Channel(ChannelId)
The id of the channel produced by ChannelId::v2_from_revocation_basepoints.
Trait Implementations§
Source§impl Clone for MonitorName
impl Clone for MonitorName
Source§fn clone(&self) -> MonitorName
fn clone(&self) -> MonitorName
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MonitorName
impl Debug for MonitorName
Source§impl Display for MonitorName
impl Display for MonitorName
Source§impl Hash for MonitorName
impl Hash for MonitorName
Source§impl PartialEq for MonitorName
impl PartialEq for MonitorName
impl Copy for MonitorName
impl Eq for MonitorName
impl StructuralPartialEq for MonitorName
Auto Trait Implementations§
impl Freeze for MonitorName
impl RefUnwindSafe for MonitorName
impl Send for MonitorName
impl Sync for MonitorName
impl Unpin for MonitorName
impl UnwindSafe for MonitorName
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
Mutably borrows from an owned value. Read more