From: Arik Sosman Date: Fri, 28 Jun 2024 19:07:37 +0000 (-0400) Subject: TODO: FIXME! experimental upgrade to bitcoin 0.32.2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=f5883cf38780a7ac370b892e5e02fd22bfa9fddc;p=rust-lightning TODO: FIXME! experimental upgrade to bitcoin 0.32.2 --- diff --git a/lightning/Cargo.toml b/lightning/Cargo.toml index dfb17b957..b0d68fc10 100644 --- a/lightning/Cargo.toml +++ b/lightning/Cargo.toml @@ -32,7 +32,7 @@ unsafe_revoked_tx_signing = [] _test_vectors = [] no-std = ["hashbrown", "possiblyrandom", "core2/alloc", "libm"] -std = ["bitcoin/std", "bech32/std"] +std = ["bitcoin/std", "bech32/std", "core2/alloc"] # Generates low-r bitcoin signatures, which saves 1 byte in 50% of the cases grind_signatures = [] diff --git a/lightning/src/lib.rs b/lightning/src/lib.rs index 5274ea0bf..191788ad6 100644 --- a/lightning/src/lib.rs +++ b/lightning/src/lib.rs @@ -68,6 +68,8 @@ extern crate core; extern crate hex; #[cfg(any(test, feature = "_test_utils"))] extern crate regex; +extern crate core2; + #[cfg(not(feature = "std"))] extern crate core2; #[cfg(not(feature = "std"))] extern crate libm; @@ -86,12 +88,19 @@ pub mod events; pub(crate) mod crypto; +pub mod io { + pub use bitcoin::io::*; + + pub use core2::io::Seek; + pub use core2::io::SeekFrom; +} + #[cfg(feature = "std")] /// Re-export of either `core2::io` or `std::io`, depending on the `std` feature flag. -pub use std::io; +// pub use bitcoin::io; #[cfg(not(feature = "std"))] /// Re-export of either `core2::io` or `std::io`, depending on the `std` feature flag. -pub use core2::io; +// pub use bitcoin::io; #[cfg(not(feature = "std"))] #[doc(hidden)] diff --git a/lightning/src/util/ser.rs b/lightning/src/util/ser.rs index 42efdc46d..ec9022ca4 100644 --- a/lightning/src/util/ser.rs +++ b/lightning/src/util/ser.rs @@ -1238,7 +1238,7 @@ macro_rules! impl_consensus_ser { match consensus::encode::Decodable::consensus_decode(r) { Ok(t) => Ok(t), Err(consensus::encode::Error::Io(ref e)) if e.kind() == io::ErrorKind::UnexpectedEof => Err(DecodeError::ShortRead), - Err(consensus::encode::Error::Io(e)) => Err(DecodeError::Io(e.kind())), + Err(consensus::encode::Error::Io(e)) => Err(DecodeError::Io(e.kind().into())), Err(_) => Err(DecodeError::InvalidValue), } } @@ -1246,34 +1246,9 @@ macro_rules! impl_consensus_ser { } } -impl Into for bitcoin::io::ErrorKind { - fn into(self) -> io::ErrorKind { - todo!() - } -} - -impl Writeable for Witness { - fn write(&self, writer: &mut W) -> Result<(), io::Error> { - match self.consensus_encode(&mut WriterWriteAdaptor(writer)) { - Ok(_) => Ok(()), - Err(e) => Err(e.into()), - } - } -} -impl Readable for Witness { - fn read(r: &mut R) -> Result { - match consensus::encode::Decodable::consensus_decode(r) { - Ok(t) => Ok(t), - Err(consensus::encode::Error::Io(ref e)) if e.kind() == bitcoin::io::ErrorKind::UnexpectedEof => Err(DecodeError::ShortRead), - Err(consensus::encode::Error::Io(e)) => Err(DecodeError::Io(e.kind())), - Err(_) => Err(DecodeError::InvalidValue), - } - } -} - impl_consensus_ser!(Transaction); impl_consensus_ser!(TxOut); -// impl_consensus_ser!(Witness); +impl_consensus_ser!(Witness); impl Readable for Mutex { fn read(r: &mut R) -> Result {