Impl PartialEq and Debug for InMemorySigner
authorbenthecarman <benthecarman@live.com>
Wed, 31 May 2023 22:47:54 +0000 (17:47 -0500)
committerbenthecarman <benthecarman@live.com>
Wed, 31 May 2023 23:19:31 +0000 (18:19 -0500)
These are needed for being able to compare a
ChannelMonitor<InMemorySigner> and are just nice to haves for
developers.

lightning/src/sign/mod.rs
lightning/src/util/atomic_counter.rs

index 226a2bab72b9c35d26bcac26d462a3d34bfe2a6c..da24510866e775742e9721cf0f68bdc0bd6774c2 100644 (file)
@@ -689,6 +689,7 @@ pub trait SignerProvider {
 ///
 /// This implementation performs no policy checks and is insufficient by itself as
 /// a secure external signer.
+#[derive(Debug)]
 pub struct InMemorySigner {
        /// Holder secret key in the 2-of-2 multisig script of a channel. This key also backs the
        /// holder's anchor output in a commitment transaction, if one is present.
@@ -718,6 +719,21 @@ pub struct InMemorySigner {
        rand_bytes_index: AtomicCounter,
 }
 
+impl PartialEq for InMemorySigner {
+       fn eq(&self, other: &Self) -> bool {
+               self.funding_key == other.funding_key &&
+                       self.revocation_base_key == other.revocation_base_key &&
+                       self.payment_key == other.payment_key &&
+                       self.delayed_payment_base_key == other.delayed_payment_base_key &&
+                       self.htlc_base_key == other.htlc_base_key &&
+                       self.commitment_seed == other.commitment_seed &&
+                       self.holder_channel_pubkeys == other.holder_channel_pubkeys &&
+                       self.channel_parameters == other.channel_parameters &&
+                       self.channel_value_satoshis == other.channel_value_satoshis &&
+                       self.channel_keys_id == other.channel_keys_id
+       }
+}
+
 impl Clone for InMemorySigner {
        fn clone(&self) -> Self {
                Self {
index 81cc1f496c36472d407964fc3a47ef07511fd239..d2e01411313d3c18c6dc7720c7cf68b0d0866e6a 100644 (file)
@@ -5,6 +5,7 @@ compile_error!("We need at least 32-bit pointers for atomic counter (and to have
 
 use core::sync::atomic::{AtomicUsize, Ordering};
 
+#[derive(Debug)]
 pub(crate) struct AtomicCounter {
        // Usize needs to be at least 32 bits to avoid overflowing both low and high. If usize is 64
        // bits we will never realistically count into high: