[docs] Add the docs to the keys
module
This commit is contained in:
parent
9bafdfe2d4
commit
1a90832f3a
@ -129,15 +129,19 @@ impl<Ctx: ScriptContext> DescriptorKey<Ctx> {
|
|||||||
/// Enum representation of the known valid [`ScriptContext`]s
|
/// Enum representation of the known valid [`ScriptContext`]s
|
||||||
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
|
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
|
||||||
pub enum ScriptContextEnum {
|
pub enum ScriptContextEnum {
|
||||||
|
/// Legacy scripts
|
||||||
Legacy,
|
Legacy,
|
||||||
|
/// Segwitv0 scripts
|
||||||
Segwitv0,
|
Segwitv0,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ScriptContextEnum {
|
impl ScriptContextEnum {
|
||||||
|
/// Returns whether the script context is [`ScriptContextEnum::Legacy`]
|
||||||
pub fn is_legacy(&self) -> bool {
|
pub fn is_legacy(&self) -> bool {
|
||||||
self == &ScriptContextEnum::Legacy
|
self == &ScriptContextEnum::Legacy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns whether the script context is [`ScriptContextEnum::Segwitv0`]
|
||||||
pub fn is_segwit_v0(&self) -> bool {
|
pub fn is_segwit_v0(&self) -> bool {
|
||||||
self == &ScriptContextEnum::Segwitv0
|
self == &ScriptContextEnum::Segwitv0
|
||||||
}
|
}
|
||||||
@ -145,12 +149,15 @@ impl ScriptContextEnum {
|
|||||||
|
|
||||||
/// Trait that adds extra useful methods to [`ScriptContext`]s
|
/// Trait that adds extra useful methods to [`ScriptContext`]s
|
||||||
pub trait ExtScriptContext: ScriptContext {
|
pub trait ExtScriptContext: ScriptContext {
|
||||||
|
/// Returns the [`ScriptContext`] as a [`ScriptContextEnum`]
|
||||||
fn as_enum() -> ScriptContextEnum;
|
fn as_enum() -> ScriptContextEnum;
|
||||||
|
|
||||||
|
/// Returns whether the script context is [`Legacy`](miniscript::Legacy)
|
||||||
fn is_legacy() -> bool {
|
fn is_legacy() -> bool {
|
||||||
Self::as_enum().is_legacy()
|
Self::as_enum().is_legacy()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns whether the script context is [`Segwitv0`](miniscript::Segwitv0)
|
||||||
fn is_segwit_v0() -> bool {
|
fn is_segwit_v0() -> bool {
|
||||||
Self::as_enum().is_segwit_v0()
|
Self::as_enum().is_segwit_v0()
|
||||||
}
|
}
|
||||||
@ -345,7 +352,7 @@ pub struct GeneratedKey<K, Ctx: ScriptContext> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<K, Ctx: ScriptContext> GeneratedKey<K, Ctx> {
|
impl<K, Ctx: ScriptContext> GeneratedKey<K, Ctx> {
|
||||||
pub fn new(key: K, valid_networks: ValidNetworks) -> Self {
|
fn new(key: K, valid_networks: ValidNetworks) -> Self {
|
||||||
GeneratedKey {
|
GeneratedKey {
|
||||||
key,
|
key,
|
||||||
valid_networks,
|
valid_networks,
|
||||||
@ -482,6 +489,7 @@ impl<Ctx: ScriptContext> GeneratableKey<Ctx> for bip32::ExtendedPrivKey {
|
|||||||
/// Defaults to creating compressed keys, which save on-chain bytes and fees
|
/// Defaults to creating compressed keys, which save on-chain bytes and fees
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct PrivateKeyGenerateOptions {
|
pub struct PrivateKeyGenerateOptions {
|
||||||
|
/// Whether the generated key should be "compressed" or not
|
||||||
pub compressed: bool,
|
pub compressed: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -670,12 +678,19 @@ impl<Ctx: ScriptContext> ToDescriptorKey<Ctx> for PrivateKey {
|
|||||||
/// Errors thrown while working with [`keys`](crate::keys)
|
/// Errors thrown while working with [`keys`](crate::keys)
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum KeyError {
|
pub enum KeyError {
|
||||||
|
/// The key cannot exist in the given script context
|
||||||
InvalidScriptContext,
|
InvalidScriptContext,
|
||||||
|
/// The key is not valid for the given network
|
||||||
InvalidNetwork,
|
InvalidNetwork,
|
||||||
|
/// The key has an invalid checksum
|
||||||
InvalidChecksum,
|
InvalidChecksum,
|
||||||
|
|
||||||
|
/// Custom error message
|
||||||
Message(String),
|
Message(String),
|
||||||
|
|
||||||
|
#[allow(missing_docs)]
|
||||||
BIP32(bitcoin::util::bip32::Error),
|
BIP32(bitcoin::util::bip32::Error),
|
||||||
|
#[allow(missing_docs)]
|
||||||
Miniscript(miniscript::Error),
|
Miniscript(miniscript::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,7 +256,6 @@ pub mod database;
|
|||||||
pub mod descriptor;
|
pub mod descriptor;
|
||||||
#[cfg(feature = "test-md-docs")]
|
#[cfg(feature = "test-md-docs")]
|
||||||
mod doctest;
|
mod doctest;
|
||||||
#[allow(missing_docs)] // TODO add missing docs and remove this allow
|
|
||||||
pub mod keys;
|
pub mod keys;
|
||||||
pub(crate) mod psbt;
|
pub(crate) mod psbt;
|
||||||
#[allow(missing_docs)] // TODO add missing docs and remove this allow
|
#[allow(missing_docs)] // TODO add missing docs and remove this allow
|
||||||
|
Loading…
x
Reference in New Issue
Block a user