]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Drop explicit `bitcoin_hashes` dependency in `lightning-invoice`
authorMatt Corallo <git@bluematt.me>
Fri, 15 Dec 2023 18:14:56 +0000 (18:14 +0000)
committerMatt Corallo <git@bluematt.me>
Fri, 15 Dec 2023 22:31:51 +0000 (22:31 +0000)
Since `lightning-invoice` now depends on the `bitcoin` crate
directly, also depending on the `bitcoin_hashes` crate is redundant
and just means we confuse users by setting the `std` flag only on
`bitcoin`. Thus, we drop the explicit dependency here and replace
it with `bitcoin::hashes`.

lightning-invoice/Cargo.toml
lightning-invoice/src/de.rs
lightning-invoice/src/lib.rs
lightning-invoice/src/payment.rs
lightning-invoice/src/utils.rs
lightning-invoice/tests/ser_de.rs

index 5377b7ef3356313d46aec61bf40275a0d4e04a4a..a06cbee7a23cf91aa1eec34d47cd3a49eaa0a627 100644 (file)
@@ -17,14 +17,13 @@ rustdoc-args = ["--cfg", "docsrs"]
 [features]
 default = ["std"]
 no-std = ["hashbrown", "lightning/no-std"]
-std = ["bitcoin_hashes/std", "num-traits/std", "lightning/std", "bech32/std"]
+std = ["bitcoin/std", "num-traits/std", "lightning/std", "bech32/std"]
 
 [dependencies]
 bech32 = { version = "0.9.0", default-features = false }
 lightning = { version = "0.0.118", path = "../lightning", default-features = false }
 secp256k1 = { version = "0.27.0", default-features = false, features = ["recovery", "alloc"] }
 num-traits = { version = "0.2.8", default-features = false }
-bitcoin_hashes = { version = "0.12.0", default-features = false }
 hashbrown = { version = "0.8", optional = true }
 serde = { version = "1.0.118", optional = true }
 bitcoin = { version = "0.30.2", default-features = false }
index 0276b742f28405b21c2099adeb4333654784c231..c75373ea9dac3d127575b95d78954400164d1dc9 100644 (file)
@@ -11,8 +11,8 @@ use bech32::{u5, FromBase32};
 
 use bitcoin::{PubkeyHash, ScriptHash};
 use bitcoin::address::WitnessVersion;
-use bitcoin_hashes::Hash;
-use bitcoin_hashes::sha256;
+use bitcoin::hashes::Hash;
+use bitcoin::hashes::sha256;
 use crate::prelude::*;
 use lightning::ln::PaymentSecret;
 use lightning::routing::gossip::RoutingFees;
@@ -564,14 +564,14 @@ impl FromBase32 for Fallback {
                        17 => {
                                let pkh = match PubkeyHash::from_slice(&bytes) {
                                        Ok(pkh) => pkh,
-                                       Err(bitcoin_hashes::Error::InvalidLength(_, _)) => return Err(Bolt11ParseError::InvalidPubKeyHashLength),
+                                       Err(bitcoin::hashes::Error::InvalidLength(_, _)) => return Err(Bolt11ParseError::InvalidPubKeyHashLength),
                                };
                                Ok(Fallback::PubKeyHash(pkh))
                        }
                        18 => {
                                let sh = match ScriptHash::from_slice(&bytes) {
                                        Ok(sh) => sh,
-                                       Err(bitcoin_hashes::Error::InvalidLength(_, _)) => return Err(Bolt11ParseError::InvalidScriptHashLength),
+                                       Err(bitcoin::hashes::Error::InvalidLength(_, _)) => return Err(Bolt11ParseError::InvalidScriptHashLength),
                                };
                                Ok(Fallback::ScriptHash(sh))
                        }
@@ -726,7 +726,7 @@ mod test {
        use crate::de::Bolt11ParseError;
        use secp256k1::PublicKey;
        use bech32::u5;
-       use bitcoin_hashes::sha256;
+       use bitcoin::hashes::sha256;
        use std::str::FromStr;
 
        const CHARSET_REV: [i8; 128] = [
@@ -856,7 +856,7 @@ mod test {
                use bech32::FromBase32;
                use bitcoin::{PubkeyHash, ScriptHash};
                use bitcoin::address::WitnessVersion;
-               use bitcoin_hashes::Hash;
+               use bitcoin::hashes::Hash;
 
                let cases = vec![
                        (
index c2e1ecf2d923c926db4385ef6ba4e75769b4ced6..690bf57640862daae0adb55019ab48d90a2384a0 100644 (file)
@@ -30,7 +30,6 @@ pub mod payment;
 pub mod utils;
 
 extern crate bech32;
-extern crate bitcoin_hashes;
 #[macro_use] extern crate lightning;
 extern crate num_traits;
 extern crate secp256k1;
@@ -46,7 +45,7 @@ use std::time::SystemTime;
 use bech32::u5;
 use bitcoin::{Address, Network, PubkeyHash, ScriptHash};
 use bitcoin::address::{Payload, WitnessProgram, WitnessVersion};
-use bitcoin_hashes::{Hash, sha256};
+use bitcoin::hashes::{Hash, sha256};
 use lightning::ln::features::Bolt11InvoiceFeatures;
 use lightning::util::invoice::construct_invoice_preimage;
 
@@ -166,10 +165,10 @@ pub const DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA: u64 = 18;
 /// extern crate secp256k1;
 /// extern crate lightning;
 /// extern crate lightning_invoice;
-/// extern crate bitcoin_hashes;
+/// extern crate bitcoin;
 ///
-/// use bitcoin_hashes::Hash;
-/// use bitcoin_hashes::sha256;
+/// use bitcoin::hashes::Hash;
+/// use bitcoin::hashes::sha256;
 ///
 /// use secp256k1::Secp256k1;
 /// use secp256k1::SecretKey;
@@ -1756,7 +1755,7 @@ impl<'de> Deserialize<'de> for Bolt11Invoice {
 #[cfg(test)]
 mod test {
        use bitcoin::ScriptBuf;
-       use bitcoin_hashes::sha256;
+       use bitcoin::hashes::sha256;
        use std::str::FromStr;
 
        #[test]
index 7306d12f5e6c0061825ebf1d2fde3c2decafde79..b8f564ef573bf9b37dba86350bf73df745f42b0a 100644 (file)
@@ -10,7 +10,7 @@
 //! Convenient utilities for paying Lightning invoices.
 
 use crate::Bolt11Invoice;
-use crate::bitcoin_hashes::Hash;
+use bitcoin::hashes::Hash;
 
 use lightning::ln::PaymentHash;
 use lightning::ln::channelmanager::RecipientOnionFields;
@@ -84,7 +84,7 @@ fn params_from_invoice(invoice: &Bolt11Invoice, amount_msat: u64)
 mod tests {
        use super::*;
        use crate::{InvoiceBuilder, Currency};
-       use bitcoin_hashes::sha256::Hash as Sha256;
+       use bitcoin::hashes::sha256::Hash as Sha256;
        use lightning::events::Event;
        use lightning::ln::channelmanager::{Retry, PaymentId};
        use lightning::ln::msgs::ChannelMessageHandler;
index 1248221a32ee3b800d8ec3fec9964d82649d9791..3a337a9a4b964dea101ee04ea5f6346b4b68fe27 100644 (file)
@@ -4,7 +4,7 @@ use crate::{Bolt11Invoice, CreationError, Currency, InvoiceBuilder, SignOrCreati
 
 use crate::{prelude::*, Description, Bolt11InvoiceDescription, Sha256};
 use bech32::ToBase32;
-use bitcoin_hashes::Hash;
+use bitcoin::hashes::Hash;
 use lightning::chain;
 use lightning::chain::chaininterface::{BroadcasterInterface, FeeEstimator};
 use lightning::sign::{Recipient, NodeSigner, SignerProvider, EntropySource};
@@ -819,8 +819,8 @@ mod test {
        use core::cell::RefCell;
        use core::time::Duration;
        use crate::{Currency, Description, Bolt11InvoiceDescription, SignOrCreationError, CreationError};
-       use bitcoin_hashes::{Hash, sha256};
-       use bitcoin_hashes::sha256::Hash as Sha256;
+       use bitcoin::hashes::{Hash, sha256};
+       use bitcoin::hashes::sha256::Hash as Sha256;
        use lightning::sign::PhantomKeysManager;
        use lightning::events::{MessageSendEvent, MessageSendEventsProvider, Event, EventsProvider};
        use lightning::ln::{PaymentPreimage, PaymentHash};
index 98886bef78809aeb7bd9ef9e1784e72e3cf96e4a..92bc87bef63e86e98c7678b88dc2ce251352c874 100644 (file)
@@ -1,5 +1,4 @@
 extern crate bech32;
-extern crate bitcoin_hashes;
 extern crate lightning;
 extern crate lightning_invoice;
 extern crate secp256k1;
@@ -8,7 +7,7 @@ extern crate hex;
 use bitcoin::address::WitnessVersion;
 use bitcoin::{PubkeyHash, ScriptHash};
 use bitcoin::hashes::hex::FromHex;
-use bitcoin_hashes::{sha256, Hash};
+use bitcoin::hashes::{sha256, Hash};
 use lightning::ln::PaymentSecret;
 use lightning::routing::gossip::RoutingFees;
 use lightning::routing::router::{RouteHint, RouteHintHop};