Merge pull request #2503 from valentinewallace/2023-08-fix-router-debug-panic
[rust-lightning] / lightning / src / sign / type_resolver.rs
1 use crate::sign::{ChannelSigner, EcdsaChannelSigner};
2
3 pub(crate) enum ChannelSignerType<ECS: EcdsaChannelSigner> {
4         // in practice, this will only ever be an EcdsaChannelSigner (specifically, Writeable)
5         Ecdsa(ECS)
6 }
7
8 impl<ECS: EcdsaChannelSigner> ChannelSignerType<ECS>{
9         pub(crate) fn as_ref(&self) -> &dyn ChannelSigner {
10                 match self {
11                         ChannelSignerType::Ecdsa(ecs) => ecs
12                 }
13         }
14
15         pub(crate) fn as_mut(&mut self) -> &mut dyn ChannelSigner {
16                 match self {
17                         ChannelSignerType::Ecdsa(ecs) => ecs
18                 }
19         }
20
21         pub(crate) fn as_ecdsa(&self) -> Option<&ECS> {
22                 match self {
23                         ChannelSignerType::Ecdsa(ecs) => Some(ecs)
24                 }
25         }
26
27         pub(crate) fn as_mut_ecdsa(&mut self) -> Option<&mut ECS> {
28                 match self {
29                         ChannelSignerType::Ecdsa(ecs) => Some(ecs)
30                 }
31         }
32 }