]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Use an explicit `Sign` type on the `ChannelMonitor` read tuple
authorMatt Corallo <git@bluematt.me>
Sat, 24 Dec 2022 04:16:48 +0000 (04:16 +0000)
committerMatt Corallo <git@bluematt.me>
Sat, 22 Jul 2023 00:13:24 +0000 (00:13 +0000)
The bindings currently get confused by the implicit `Sign` type, so
we temporarily remove it on the `impl` here.

lightning-persister/src/lib.rs
lightning/src/chain/channelmonitor.rs

index 670a7369d8b92c7bb415125f3dc49186c4b2f3d3..14093d16a00e3f85d3ff32c460f06d29f76c0a67 100644 (file)
@@ -19,7 +19,7 @@ extern crate libc;
 use bitcoin::hash_types::{BlockHash, Txid};
 use bitcoin::hashes::hex::FromHex;
 use lightning::chain::channelmonitor::ChannelMonitor;
-use lightning::sign::{EntropySource, SignerProvider};
+use lightning::sign::{EntropySource, SignerProvider, WriteableEcdsaChannelSigner};
 use lightning::util::ser::{ReadableArgs, Writeable};
 use lightning::util::persist::KVStorePersister;
 use std::fs;
@@ -58,12 +58,11 @@ impl FilesystemPersister {
        }
 
        /// Read `ChannelMonitor`s from disk.
-       pub fn read_channelmonitors<ES: Deref, SP: Deref> (
-               &self, entropy_source: ES, signer_provider: SP
-       ) -> std::io::Result<Vec<(BlockHash, ChannelMonitor<<SP::Target as SignerProvider>::Signer>)>>
+       pub fn read_channelmonitors<ES: Deref, WES: WriteableEcdsaChannelSigner, SP: SignerProvider<Signer = WES> + Sized, SPD: Deref<Target=SP>> (
+               &self, entropy_source: ES, signer_provider: SPD
+       ) -> Result<Vec<(BlockHash, ChannelMonitor<WES>)>, std::io::Error>
                where
                        ES::Target: EntropySource + Sized,
-                       SP::Target: SignerProvider + Sized
        {
                let mut path = PathBuf::from(&self.path_to_channel_data);
                path.push("monitors");
@@ -104,7 +103,7 @@ impl FilesystemPersister {
 
                        let contents = fs::read(&file.path())?;
                        let mut buffer = Cursor::new(&contents);
-                       match <(BlockHash, ChannelMonitor<<SP::Target as SignerProvider>::Signer>)>::read(&mut buffer, (&*entropy_source, &*signer_provider)) {
+                       match <(BlockHash, ChannelMonitor<WES>)>::read(&mut buffer, (&*entropy_source, &*signer_provider)) {
                                Ok((blockhash, channel_monitor)) => {
                                        if channel_monitor.get_funding_txo().0.txid != txid || channel_monitor.get_funding_txo().0.index != index {
                                                return Err(std::io::Error::new(std::io::ErrorKind::InvalidData,
index f98c0bcac8c0ef453d281b700272b8ac69dd4d06..2e4862f68e5a2b5a1f6f31ed25f41aa24d8a63f4 100644 (file)
@@ -3900,8 +3900,8 @@ where
 
 const MAX_ALLOC_SIZE: usize = 64*1024;
 
-impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP)>
-               for (BlockHash, ChannelMonitor<SP::Signer>) {
+impl<'a, 'b, ES: EntropySource, SP: SignerProvider<Signer=Signer>, Signer: WriteableEcdsaChannelSigner> ReadableArgs<(&'a ES, &'b SP)>
+               for (BlockHash, ChannelMonitor<Signer>) {
        fn read<R: io::Read>(reader: &mut R, args: (&'a ES, &'b SP)) -> Result<Self, DecodeError> {
                macro_rules! unwrap_obj {
                        ($key: expr) => {