lightningdevkit
Version:
Lightning Development Kit
52 lines (51 loc) • 1.99 kB
text/typescript
import { Result_MonitorNameIOErrorZ } from '../structs/Result_MonitorNameIOErrorZ.mjs';
import { CommonBase } from './CommonBase.mjs';
/**
* 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 {
* \t txid: Txid::from_str(\"deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef\").unwrap(),
* \t 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());
* ```
*/
export declare class MonitorName extends CommonBase {
/**
* 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.
*/
static constructor_new(name: string): Result_MonitorNameIOErrorZ;
/**
* Convert this monitor name to a str.
* This method is particularly useful when you need to use the monitor name
* as a key in a key-value store or when logging.
*/
as_str(): string;
}