Skip to content

Commit 02a856c

Browse files
committed
f docs
1 parent 9392b72 commit 02a856c

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

lightning/src/sign/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,7 @@ impl HTLCDescriptor {
725725
/// A trait to handle Lightning channel key material without concretizing the channel type or
726726
/// the signature mechanism.
727727
pub trait ChannelSigner {
728+
/// Returns the commitment seed for the channel.
728729
fn commitment_seed(&self) -> [u8; 32];
729730
/// Returns the counterparty's pubkeys.
730731
///

lightning/src/util/dyn_signer.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
use std::any::Any;
2-
use std::io::Read;
1+
//! A dynamically dispatched signer
2+
3+
use core::any::Any;
4+
use crate::io::Read;
35

46
use delegate::delegate;
57

@@ -35,17 +37,22 @@ use crate::util::test_utils::OnlyReadsKeysInterface;
3537

3638
/// Helper to allow DynSigner to clone itself
3739
pub trait InnerSign: EcdsaChannelSigner + Send + Sync {
40+
/// Clone into a Box
3841
fn box_clone(&self) -> Box<dyn InnerSign>;
42+
/// Cast to Any for runtime type checking
3943
fn as_any(&self) -> &dyn Any;
44+
/// Serialize the signer
4045
fn vwrite(&self, writer: &mut Vec<u8>) -> Result<(), std::io::Error>;
4146
}
4247

4348
/// A ChannelSigner derived struct allowing run-time selection of a signer
4449
pub struct DynSigner {
50+
/// The inner signer
4551
pub inner: Box<dyn InnerSign>,
4652
}
4753

4854
impl DynSigner {
55+
/// Create a new DynSigner
4956
pub fn new<S: InnerSign + 'static>(inner: S) -> Self {
5057
DynSigner { inner: Box::new(inner) }
5158
}
@@ -189,11 +196,14 @@ impl InnerSign for InMemorySigner {
189196
}
190197
}
191198

199+
/// A convenience wrapper for DynKeysInterfaceTrait
192200
pub struct DynKeysInterface {
201+
/// The inner dyn keys interface
193202
pub inner: Box<dyn DynKeysInterfaceTrait<EcdsaSigner = DynSigner>>,
194203
}
195204

196205
impl DynKeysInterface {
206+
/// Create a new DynKeysInterface
197207
pub fn new(inner: Box<dyn DynKeysInterfaceTrait<EcdsaSigner = DynSigner>>) -> Self {
198208
DynKeysInterface { inner }
199209
}
@@ -264,15 +274,17 @@ impl OutputSpender for DynKeysInterface {
264274
}
265275
}
266276

267-
// A supertrait for all the traits that a keys interface implements
277+
/// A supertrait for all the traits that a keys interface implements
268278
pub trait DynKeysInterfaceTrait: NodeSigner + OutputSpender + SignerProvider<EcdsaSigner=DynSigner> + EntropySource + Send + Sync {
269279
}
270280

281+
/// A dyn wrapper for PhantomKeysManager
271282
pub struct DynPhantomKeysInterface {
272283
inner: PhantomKeysManager,
273284
}
274285

275286
impl DynPhantomKeysInterface {
287+
/// Create a new DynPhantomKeysInterface
276288
pub fn new(inner: PhantomKeysManager) -> Self {
277289
DynPhantomKeysInterface { inner }
278290
}
@@ -350,6 +362,7 @@ impl OutputSpender for DynPhantomKeysInterface {
350362

351363
impl DynKeysInterfaceTrait for DynPhantomKeysInterface {}
352364

365+
#[cfg(feature = "std")]
353366
impl ReadableArgs<&DynKeysInterface> for DynSigner {
354367
fn read<R: Read>(_reader: &mut R, _params: &DynKeysInterface) -> Result<Self, DecodeError> {
355368
todo!()

0 commit comments

Comments
 (0)