X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Futil%2Fenforcing_trait_impls.rs;fp=lightning%2Fsrc%2Futil%2Fenforcing_trait_impls.rs;h=728caed098f277d67ab3d958452951e593824130;hb=f2a2fd0d48be78972ed81481c2dfbfb68ecda44e;hp=0000000000000000000000000000000000000000;hpb=8defcf1107a7f564ebce0048dd98ae72f2026db6;p=rust-lightning diff --git a/lightning/src/util/enforcing_trait_impls.rs b/lightning/src/util/enforcing_trait_impls.rs new file mode 100644 index 000000000..728caed09 --- /dev/null +++ b/lightning/src/util/enforcing_trait_impls.rs @@ -0,0 +1,29 @@ +use chain::keysinterface::{ChannelKeys, InMemoryChannelKeys}; + +use secp256k1::key::SecretKey; + +/// Enforces some rules on ChannelKeys calls. Eventually we will probably want to expose a variant +/// of this which would essentially be what you'd want to run on a hardware wallet. +pub struct EnforcingChannelKeys { + pub inner: InMemoryChannelKeys, +} + +impl EnforcingChannelKeys { + pub fn new(inner: InMemoryChannelKeys) -> Self { + Self { + inner, + } + } +} +impl ChannelKeys for EnforcingChannelKeys { + fn funding_key(&self) -> &SecretKey { self.inner.funding_key() } + fn revocation_base_key(&self) -> &SecretKey { self.inner.revocation_base_key() } + fn payment_base_key(&self) -> &SecretKey { self.inner.payment_base_key() } + fn delayed_payment_base_key(&self) -> &SecretKey { self.inner.delayed_payment_base_key() } + fn htlc_base_key(&self) -> &SecretKey { self.inner.htlc_base_key() } + fn commitment_seed(&self) -> &[u8; 32] { self.inner.commitment_seed() } +} + +impl_writeable!(EnforcingChannelKeys, 0, { + inner +});