From: Tobin C. Harding Date: Thu, 8 Aug 2024 06:09:30 +0000 (+1000) Subject: Use bitcoin::hex instead of bitcoin::hashes::hex X-Git-Tag: v0.0.124-beta~16^2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=eac1b87e65dce695bfd589fce7732bbf73605f25;p=rust-lightning Use bitcoin::hex instead of bitcoin::hashes::hex Use the `hex-conservative` crate directly from `bitcoin` instead of from `hashes`. Although it makes no real difference it is slightly more clear and more terse. --- diff --git a/fuzz/src/full_stack.rs b/fuzz/src/full_stack.rs index 0a4bb9809..5499dc5e9 100644 --- a/fuzz/src/full_stack.rs +++ b/fuzz/src/full_stack.rs @@ -24,10 +24,10 @@ use bitcoin::transaction::Version; use bitcoin::transaction::{Transaction, TxOut}; use bitcoin::hash_types::{BlockHash, Txid}; -use bitcoin::hashes::hex::FromHex; use bitcoin::hashes::sha256::Hash as Sha256; use bitcoin::hashes::sha256d::Hash as Sha256dHash; use bitcoin::hashes::Hash as _; +use bitcoin::hex::FromHex; use bitcoin::WPubkeyHash; use lightning::blinded_path::message::MessageContext; @@ -1087,7 +1087,7 @@ pub extern "C" fn full_stack_run(data: *const u8, datalen: usize) { #[cfg(test)] mod tests { - use bitcoin::hashes::hex::FromHex; + use bitcoin::hex::FromHex; use lightning::util::logger::{Logger, Record}; use std::collections::HashMap; use std::sync::{Arc, Mutex}; diff --git a/fuzz/src/onion_message.rs b/fuzz/src/onion_message.rs index 0b9aceaf9..a05551410 100644 --- a/fuzz/src/onion_message.rs +++ b/fuzz/src/onion_message.rs @@ -281,7 +281,7 @@ impl SignerProvider for KeyProvider { #[cfg(test)] mod tests { - use bitcoin::hashes::hex::FromHex; + use bitcoin::hex::FromHex; use lightning::util::logger::{Logger, Record}; use std::collections::HashMap; use std::sync::Mutex; diff --git a/lightning-block-sync/src/convert.rs b/lightning-block-sync/src/convert.rs index 9ab6ef23c..ea01039f2 100644 --- a/lightning-block-sync/src/convert.rs +++ b/lightning-block-sync/src/convert.rs @@ -5,7 +5,7 @@ use crate::{BlockHeaderData, BlockSourceError}; use bitcoin::block::{Block, Header}; use bitcoin::consensus::encode; use bitcoin::hash_types::{BlockHash, TxMerkleNode, Txid}; -use bitcoin::hashes::hex::FromHex; +use bitcoin::hex::FromHex; use bitcoin::Transaction; use serde_json; diff --git a/lightning-block-sync/src/utils.rs b/lightning-block-sync/src/utils.rs index 746dcb233..494a1e53f 100644 --- a/lightning-block-sync/src/utils.rs +++ b/lightning-block-sync/src/utils.rs @@ -1,4 +1,4 @@ -use bitcoin::hashes::hex::{FromHex, HexToArrayError}; +use bitcoin::hex::{FromHex, HexToArrayError}; use bitcoin::pow::Work; pub fn hex_to_work(hex: &str) -> Result { @@ -9,7 +9,7 @@ pub fn hex_to_work(hex: &str) -> Result { #[cfg(test)] mod tests { use super::*; - use bitcoin::hashes::hex::HexToBytesError; + use bitcoin::hex::HexToBytesError; use bitcoin::pow::Work; #[test] diff --git a/lightning-invoice/tests/ser_de.rs b/lightning-invoice/tests/ser_de.rs index 356cc9ae6..d0058c9a1 100644 --- a/lightning-invoice/tests/ser_de.rs +++ b/lightning-invoice/tests/ser_de.rs @@ -4,7 +4,7 @@ extern crate lightning_invoice; extern crate secp256k1; use bitcoin::{PubkeyHash, ScriptHash, WitnessVersion}; -use bitcoin::hashes::hex::FromHex; +use bitcoin::hex::FromHex; use bitcoin::hashes::{sha256, Hash}; use lightning_invoice::*; use secp256k1::PublicKey; diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs index 1eb40da57..10aab8287 100644 --- a/lightning/src/chain/channelmonitor.rs +++ b/lightning/src/chain/channelmonitor.rs @@ -4819,7 +4819,7 @@ mod tests { use bitcoin::sighash::EcdsaSighashType; use bitcoin::hashes::Hash; use bitcoin::hashes::sha256::Hash as Sha256; - use bitcoin::hashes::hex::FromHex; + use bitcoin::hex::FromHex; use bitcoin::hash_types::{BlockHash, Txid}; use bitcoin::network::Network; use bitcoin::secp256k1::{SecretKey,PublicKey}; diff --git a/lightning/src/chain/package.rs b/lightning/src/chain/package.rs index 77ac35668..b0dfca4c2 100644 --- a/lightning/src/chain/package.rs +++ b/lightning/src/chain/package.rs @@ -1205,7 +1205,7 @@ mod tests { use bitcoin::script::ScriptBuf; use bitcoin::transaction::OutPoint as BitcoinOutPoint; - use bitcoin::hashes::hex::FromHex; + use bitcoin::hex::FromHex; use bitcoin::secp256k1::{PublicKey,SecretKey}; use bitcoin::secp256k1::Secp256k1; diff --git a/lightning/src/chain/transaction.rs b/lightning/src/chain/transaction.rs index 9533836de..e9b75a639 100644 --- a/lightning/src/chain/transaction.rs +++ b/lightning/src/chain/transaction.rs @@ -92,7 +92,7 @@ mod tests { use bitcoin::transaction::Transaction; use bitcoin::consensus::encode; - use bitcoin::hashes::hex::FromHex; + use bitcoin::hex::FromHex; #[test] fn test_channel_id_calculation() { diff --git a/lightning/src/ln/chan_utils.rs b/lightning/src/ln/chan_utils.rs index cf42d5d84..4d2572e89 100644 --- a/lightning/src/ln/chan_utils.rs +++ b/lightning/src/ln/chan_utils.rs @@ -1842,7 +1842,7 @@ mod tests { use crate::sign::{ChannelSigner, SignerProvider}; use bitcoin::{Network, Txid, ScriptBuf}; use bitcoin::hashes::Hash; - use bitcoin::hashes::hex::FromHex; + use bitcoin::hex::FromHex; use crate::ln::types::PaymentHash; use bitcoin::address::Payload; use bitcoin::PublicKey as BitcoinPublicKey; diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index 7dd11b643..afd4e7357 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -9618,7 +9618,7 @@ mod tests { use bitcoin::secp256k1::{SecretKey,PublicKey}; use bitcoin::hashes::sha256::Hash as Sha256; use bitcoin::hashes::Hash; - use bitcoin::hashes::hex::FromHex; + use bitcoin::hex::FromHex; use bitcoin::locktime::absolute::LockTime; use bitcoin::{WitnessProgram, WitnessVersion, WPubkeyHash}; use crate::prelude::*; @@ -10272,7 +10272,7 @@ mod tests { use bitcoin::sighash; use bitcoin::consensus::encode::serialize; use bitcoin::sighash::EcdsaSighashType; - use bitcoin::hashes::hex::FromHex; + use bitcoin::hex::FromHex; use bitcoin::hash_types::Txid; use bitcoin::hex::DisplayHex; use bitcoin::secp256k1::Message; diff --git a/lightning/src/ln/channel_keys.rs b/lightning/src/ln/channel_keys.rs index 79993cd2a..d6a98e24e 100644 --- a/lightning/src/ln/channel_keys.rs +++ b/lightning/src/ln/channel_keys.rs @@ -256,7 +256,7 @@ key_read_write!(RevocationKey); #[cfg(test)] mod test { use super::derive_public_key; - use bitcoin::hashes::hex::FromHex; + use bitcoin::hex::FromHex; use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey}; #[test] diff --git a/lightning/src/ln/monitor_tests.rs b/lightning/src/ln/monitor_tests.rs index 7b43bf037..6f9a14577 100644 --- a/lightning/src/ln/monitor_tests.rs +++ b/lightning/src/ln/monitor_tests.rs @@ -28,7 +28,7 @@ use bitcoin::{Amount, PublicKey, ScriptBuf, Transaction, TxIn, TxOut, Witness}; use bitcoin::locktime::absolute::LockTime; use bitcoin::script::Builder; use bitcoin::opcodes; -use bitcoin::hashes::hex::FromHex; +use bitcoin::hex::FromHex; use bitcoin::secp256k1::{Secp256k1, SecretKey}; use bitcoin::sighash::{SighashCache, EcdsaSighashType}; use bitcoin::transaction::Version; diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index 82d0e6a83..5cc1257c4 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -3276,7 +3276,7 @@ mod tests { use crate::util::ser::{BigSize, FixedLengthReader, Hostname, LengthReadable, Readable, ReadableArgs, TransactionU16LenLimited, Writeable}; use crate::util::test_utils; - use bitcoin::hashes::hex::FromHex; + use bitcoin::hex::FromHex; use bitcoin::address::Address; use bitcoin::network::Network; use bitcoin::constants::ChainHash; diff --git a/lightning/src/ln/onion_route_tests.rs b/lightning/src/ln/onion_route_tests.rs index 485f05a35..bd28f9698 100644 --- a/lightning/src/ln/onion_route_tests.rs +++ b/lightning/src/ln/onion_route_tests.rs @@ -40,7 +40,7 @@ use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey}; use crate::io; use crate::prelude::*; -use bitcoin::hashes::hex::FromHex; +use bitcoin::hex::FromHex; use crate::ln::functional_test_utils::*; diff --git a/lightning/src/ln/onion_utils.rs b/lightning/src/ln/onion_utils.rs index bab81e2de..d6fe281d1 100644 --- a/lightning/src/ln/onion_utils.rs +++ b/lightning/src/ln/onion_utils.rs @@ -1280,7 +1280,7 @@ mod tests { #[allow(unused_imports)] use crate::prelude::*; - use bitcoin::hashes::hex::FromHex; + use bitcoin::hex::FromHex; use bitcoin::secp256k1::Secp256k1; use bitcoin::secp256k1::{PublicKey, SecretKey}; diff --git a/lightning/src/ln/peer_channel_encryptor.rs b/lightning/src/ln/peer_channel_encryptor.rs index df2a7bd89..00e45afb4 100644 --- a/lightning/src/ln/peer_channel_encryptor.rs +++ b/lightning/src/ln/peer_channel_encryptor.rs @@ -570,7 +570,7 @@ impl MessageBuf { mod tests { use super::{MessageBuf, LN_MAX_MSG_LEN}; - use bitcoin::hashes::hex::FromHex; + use bitcoin::hex::FromHex; use bitcoin::secp256k1::{PublicKey, SecretKey}; use bitcoin::secp256k1::Secp256k1; diff --git a/lightning/src/offers/merkle.rs b/lightning/src/offers/merkle.rs index 11f1d9713..90bfc859e 100644 --- a/lightning/src/offers/merkle.rs +++ b/lightning/src/offers/merkle.rs @@ -304,7 +304,7 @@ mod tests { use super::{SIGNATURE_TYPES, TlvStream, WithoutSignatures}; use bitcoin::hashes::{Hash, sha256}; - use bitcoin::hashes::hex::FromHex; + use bitcoin::hex::FromHex; use bitcoin::secp256k1::{Keypair, Message, Secp256k1, SecretKey}; use bitcoin::secp256k1::schnorr::Signature; use crate::offers::offer::{Amount, OfferBuilder}; diff --git a/lightning/src/onion_message/functional_tests.rs b/lightning/src/onion_message/functional_tests.rs index ad6fe7d99..7df69b823 100644 --- a/lightning/src/onion_message/functional_tests.rs +++ b/lightning/src/onion_message/functional_tests.rs @@ -25,7 +25,7 @@ use super::offers::{OffersMessage, OffersMessageHandler}; use super::packet::{OnionMessageContents, Packet}; use bitcoin::network::Network; -use bitcoin::hashes::hex::FromHex; +use bitcoin::hex::FromHex; use bitcoin::secp256k1::{All, PublicKey, Secp256k1, SecretKey}; use crate::io; diff --git a/lightning/src/onion_message/messenger.rs b/lightning/src/onion_message/messenger.rs index b14210db4..dc670cc84 100644 --- a/lightning/src/onion_message/messenger.rs +++ b/lightning/src/onion_message/messenger.rs @@ -144,7 +144,7 @@ for OnionMessenger where /// ``` /// # extern crate bitcoin; /// # use bitcoin::hashes::_export::_core::time::Duration; -/// # use bitcoin::hashes::hex::FromHex; +/// # use bitcoin::hex::FromHex; /// # use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey, self}; /// # use lightning::blinded_path::{BlindedPath, EmptyNodeIdLookUp}; /// # use lightning::blinded_path::message::{ForwardNode, MessageContext}; diff --git a/lightning/src/routing/gossip.rs b/lightning/src/routing/gossip.rs index a74a599ae..31f93db90 100644 --- a/lightning/src/routing/gossip.rs +++ b/lightning/src/routing/gossip.rs @@ -2430,7 +2430,7 @@ pub(crate) mod tests { use bitcoin::hashes::sha256d::Hash as Sha256dHash; use bitcoin::hashes::Hash; - use bitcoin::hashes::hex::FromHex; + use bitcoin::hex::FromHex; use bitcoin::network::Network; use bitcoin::amount::Amount; use bitcoin::constants::ChainHash; diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index d7c665ff1..0dd32353f 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -3598,7 +3598,7 @@ mod tests { use bitcoin::script::Builder; use bitcoin::opcodes; use bitcoin::transaction::TxOut; - use bitcoin::hashes::hex::FromHex; + use bitcoin::hex::FromHex; use bitcoin::secp256k1::{PublicKey,SecretKey}; use bitcoin::secp256k1::Secp256k1; diff --git a/lightning/src/routing/test_utils.rs b/lightning/src/routing/test_utils.rs index 939352cf5..cf991ed0a 100644 --- a/lightning/src/routing/test_utils.rs +++ b/lightning/src/routing/test_utils.rs @@ -16,7 +16,7 @@ use crate::util::ser::Writeable; use bitcoin::constants::ChainHash; use bitcoin::hashes::sha256d::Hash as Sha256dHash; use bitcoin::hashes::Hash; -use bitcoin::hashes::hex::FromHex; +use bitcoin::hex::FromHex; use bitcoin::network::Network; use bitcoin::secp256k1::{PublicKey,SecretKey}; use bitcoin::secp256k1::{Secp256k1, All}; diff --git a/lightning/src/sign/mod.rs b/lightning/src/sign/mod.rs index 2e6e69cc0..f5fc9bb19 100644 --- a/lightning/src/sign/mod.rs +++ b/lightning/src/sign/mod.rs @@ -328,7 +328,7 @@ impl SpendableOutputDescriptor { /// To get the proprietary field use: /// ``` /// use bitcoin::psbt::{Psbt}; - /// use bitcoin::hashes::hex::FromHex; + /// use bitcoin::hex::FromHex; /// /// # let s = "70736274ff0100520200000001dee978529ab3e61a2987bea5183713d0e6d5ceb5ac81100fdb54a1a2\ /// # 69cef505000000000090000000011f26000000000000160014abb3ab63280d4ccc5c11d6b50fd427a8\ diff --git a/lightning/src/util/ser.rs b/lightning/src/util/ser.rs index 2dda21523..3d3d97252 100644 --- a/lightning/src/util/ser.rs +++ b/lightning/src/util/ser.rs @@ -1507,7 +1507,7 @@ impl Readable for ClaimId { #[cfg(test)] mod tests { - use bitcoin::hashes::hex::FromHex; + use bitcoin::hex::FromHex; use bitcoin::secp256k1::ecdsa; use crate::util::ser::{Readable, Hostname, Writeable}; use crate::prelude::*; diff --git a/lightning/src/util/ser_macros.rs b/lightning/src/util/ser_macros.rs index f7a299d9b..210d8ff6d 100644 --- a/lightning/src/util/ser_macros.rs +++ b/lightning/src/util/ser_macros.rs @@ -1294,7 +1294,7 @@ mod tests { use crate::io::{self, Cursor}; use crate::ln::msgs::DecodeError; use crate::util::ser::{MaybeReadable, Readable, Writeable, HighZeroBytesDroppedBigSize, VecWriter}; - use bitcoin::hashes::hex::FromHex; + use bitcoin::hex::FromHex; use bitcoin::secp256k1::PublicKey; // The BOLT TLV test cases don't include any tests which use our "required-value" logic since diff --git a/lightning/src/util/transaction_utils.rs b/lightning/src/util/transaction_utils.rs index 99c556f63..7bc8175d8 100644 --- a/lightning/src/util/transaction_utils.rs +++ b/lightning/src/util/transaction_utils.rs @@ -78,7 +78,7 @@ mod tests { use bitcoin::script::Builder; use bitcoin::hash_types::Txid; use bitcoin::hashes::Hash; - use bitcoin::hashes::hex::FromHex; + use bitcoin::hex::FromHex; use bitcoin::{PubkeyHash, Sequence, Witness}; use alloc::vec;