Struct MonitorName
pub struct MonitorName(/* private fields */);
Expand description
A struct representing a name for a channel monitor.
MonitorName
is primarily used within the MonitorUpdatingPersister
in functions that store or retrieve channel monitor snapshots.
It provides a consistent way to generate a unique key for channel
monitors based on their funding outpoints.
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 lightning::util::persist::MonitorName;
use lightning::chain::transaction::OutPoint;
let outpoint = OutPoint {
txid: Txid::from_str("deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef").unwrap(),
index: 1,
};
let monitor_name = MonitorName::from(outpoint);
assert_eq!(monitor_name.as_str(), "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef_1");
// Using MonitorName to generate a storage key
let storage_key = format!("channel_monitors/{}", monitor_name.as_str());
Implementations§
§impl MonitorName
impl MonitorName
pub fn new(name: String) -> Result<MonitorName, Error>
pub fn new(name: String) -> Result<MonitorName, Error>
Constructs a MonitorName
, after verifying that an OutPoint
can
be formed from the given name
.
This method is useful if you have a String and you want to verify that
it’s a valid storage key for a channel monitor.
Trait Implementations§
§impl Debug for MonitorName
impl Debug for MonitorName
§impl From<OutPoint> for MonitorName
impl From<OutPoint> for MonitorName
§fn from(value: OutPoint) -> MonitorName
fn from(value: OutPoint) -> MonitorName
Creates a MonitorName
from an OutPoint
.
This is typically used when you need to generate a storage key or identifier for a new or existing channel monitor.
§impl TryFrom<&MonitorName> for OutPoint
impl TryFrom<&MonitorName> for OutPoint
Auto Trait Implementations§
impl Freeze for MonitorName
impl Send for MonitorName
impl Sync for MonitorName
impl RefUnwindSafe for MonitorName
impl Unpin for MonitorName
impl UnwindSafe for MonitorName
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request