Skip to content

Stop using blockdata module #3231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions fuzz/src/chanmon_consistency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
//! channel being force-closed.

use bitcoin::amount::Amount;
use bitcoin::blockdata::constants::genesis_block;
use bitcoin::blockdata::locktime::absolute::LockTime;
use bitcoin::blockdata::opcodes;
use bitcoin::blockdata::script::{Builder, ScriptBuf};
use bitcoin::blockdata::transaction::{Transaction, TxOut};
use bitcoin::constants::genesis_block;
use bitcoin::locktime::absolute::LockTime;
use bitcoin::network::Network;
use bitcoin::opcodes;
use bitcoin::script::{Builder, ScriptBuf};
use bitcoin::transaction::Version;
use bitcoin::transaction::{Transaction, TxOut};

use bitcoin::hash_types::BlockHash;
use bitcoin::hashes::sha256::Hash as Sha256;
Expand Down
10 changes: 5 additions & 5 deletions fuzz/src/full_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
//! This test has been very useful, though due to its complexity good starting inputs are critical.

use bitcoin::amount::Amount;
use bitcoin::blockdata::constants::genesis_block;
use bitcoin::blockdata::locktime::absolute::LockTime;
use bitcoin::blockdata::opcodes;
use bitcoin::blockdata::script::{Builder, ScriptBuf};
use bitcoin::blockdata::transaction::{Transaction, TxOut};
use bitcoin::consensus::encode::deserialize;
use bitcoin::constants::genesis_block;
use bitcoin::locktime::absolute::LockTime;
use bitcoin::network::Network;
use bitcoin::opcodes;
use bitcoin::script::{Builder, ScriptBuf};
use bitcoin::transaction::Version;
use bitcoin::transaction::{Transaction, TxOut};

use bitcoin::hash_types::{BlockHash, Txid};
use bitcoin::hashes::hex::FromHex;
Expand Down
2 changes: 1 addition & 1 deletion fuzz/src/onion_message.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Imports that need to be added manually
use bech32::u5;
use bitcoin::blockdata::script::ScriptBuf;
use bitcoin::script::ScriptBuf;
use bitcoin::secp256k1::ecdh::SharedSecret;
use bitcoin::secp256k1::ecdsa::RecoverableSignature;
use bitcoin::secp256k1::schnorr;
Expand Down
6 changes: 3 additions & 3 deletions fuzz/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
// licenses.

use bitcoin::amount::Amount;
use bitcoin::blockdata::constants::ChainHash;
use bitcoin::blockdata::script::Builder;
use bitcoin::blockdata::transaction::TxOut;
use bitcoin::constants::ChainHash;
use bitcoin::script::Builder;
use bitcoin::transaction::TxOut;

use lightning::blinded_path::{BlindedHop, BlindedPath, IntroductionNode};
use lightning::chain::transaction::OutPoint;
Expand Down
6 changes: 3 additions & 3 deletions lightning-background-processor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,13 +1011,13 @@ impl Drop for BackgroundProcessor {
#[cfg(all(feature = "std", test))]
mod tests {
use super::{BackgroundProcessor, GossipSync, FRESHNESS_TIMER};
use bitcoin::blockdata::constants::{genesis_block, ChainHash};
use bitcoin::blockdata::locktime::absolute::LockTime;
use bitcoin::blockdata::transaction::{Transaction, TxOut};
use bitcoin::constants::{genesis_block, ChainHash};
use bitcoin::hashes::Hash;
use bitcoin::locktime::absolute::LockTime;
use bitcoin::network::Network;
use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey};
use bitcoin::transaction::Version;
use bitcoin::transaction::{Transaction, TxOut};
use bitcoin::{Amount, ScriptBuf, Txid};
use core::sync::atomic::{AtomicBool, Ordering};
use lightning::chain::channelmonitor::ANTI_REORG_DELAY;
Expand Down
6 changes: 3 additions & 3 deletions lightning-block-sync/src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::http::{BinaryResponse, JsonResponse};
use crate::utils::hex_to_work;
use crate::{BlockHeaderData, BlockSourceError};

use bitcoin::blockdata::block::{Block, Header};
use bitcoin::block::{Block, Header};
use bitcoin::consensus::encode;
use bitcoin::hash_types::{BlockHash, TxMerkleNode, Txid};
use bitcoin::hashes::hex::FromHex;
Expand Down Expand Up @@ -95,7 +95,7 @@ impl TryFrom<serde_json::Value> for BlockHeaderData {

Ok(BlockHeaderData {
header: Header {
version: bitcoin::blockdata::block::Version::from_consensus(
version: bitcoin::block::Version::from_consensus(
get_field!("version", as_i64).try_into().map_err(|_| ())?,
),
prev_blockhash: if let Some(hash_str) = response.get("previousblockhash") {
Expand Down Expand Up @@ -292,7 +292,7 @@ impl TryInto<GetUtxosResponse> for JsonResponse {
#[cfg(test)]
pub(crate) mod tests {
use super::*;
use bitcoin::blockdata::constants::genesis_block;
use bitcoin::constants::genesis_block;
use bitcoin::hashes::Hash;
use bitcoin::network::Network;
use hex::DisplayHex;
Expand Down
6 changes: 3 additions & 3 deletions lightning-block-sync/src/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

use crate::{AsyncBlockSourceResult, BlockData, BlockSource, BlockSourceError};

use bitcoin::blockdata::block::Block;
use bitcoin::blockdata::constants::ChainHash;
use bitcoin::blockdata::transaction::{OutPoint, TxOut};
use bitcoin::block::Block;
use bitcoin::constants::ChainHash;
use bitcoin::hash_types::BlockHash;
use bitcoin::transaction::{OutPoint, TxOut};

use lightning::ln::peer_handler::APeerManager;

Expand Down
2 changes: 1 addition & 1 deletion lightning-block-sync/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use crate::poll::{ChainPoller, Validate, ValidatedBlockHeader};
use crate::{BlockSource, BlockSourceResult, Cache, ChainNotifier};

use bitcoin::blockdata::block::Header;
use bitcoin::block::Header;
use bitcoin::hash_types::BlockHash;
use bitcoin::network::Network;

Expand Down
2 changes: 1 addition & 1 deletion lightning-block-sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ mod utils;

use crate::poll::{ChainTip, Poll, ValidatedBlockHeader};

use bitcoin::blockdata::block::{Block, Header};
use bitcoin::block::{Block, Header};
use bitcoin::hash_types::BlockHash;
use bitcoin::pow::Work;

Expand Down
6 changes: 3 additions & 3 deletions lightning-block-sync/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use crate::{
UnboundedCache,
};

use bitcoin::blockdata::block::{Block, Header, Version};
use bitcoin::blockdata::constants::genesis_block;
use bitcoin::blockdata::locktime::absolute::LockTime;
use bitcoin::block::{Block, Header, Version};
use bitcoin::constants::genesis_block;
use bitcoin::hash_types::{BlockHash, TxMerkleNode};
use bitcoin::locktime::absolute::LockTime;
use bitcoin::network::Network;
use bitcoin::transaction;
use bitcoin::Transaction;
Expand Down
2 changes: 1 addition & 1 deletion lightning-invoice/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,7 @@ mod test {
} else {
None
};
let genesis_timestamp = bitcoin::blockdata::constants::genesis_block(bitcoin::Network::Testnet).header.time as u64;
let genesis_timestamp = bitcoin::constants::genesis_block(bitcoin::Network::Testnet).header.time as u64;
let non_default_invoice_expiry_secs = 4200;

let invoice =
Expand Down
2 changes: 1 addition & 1 deletion lightning-net-tokio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ impl Hash for SocketDescriptor {

#[cfg(test)]
mod tests {
use bitcoin::blockdata::constants::ChainHash;
use bitcoin::constants::ChainHash;
use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey};
use bitcoin::Network;
use lightning::events::*;
Expand Down
2 changes: 1 addition & 1 deletion lightning-rapid-gossip-sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
//! from disk, which we do by calling [`RapidGossipSync::update_network_graph`]:
//!
//! ```
//! use bitcoin::blockdata::constants::genesis_block;
//! use bitcoin::constants::genesis_block;
//! use bitcoin::Network;
//! use lightning::routing::gossip::NetworkGraph;
//! use lightning_rapid_gossip_sync::RapidGossipSync;
Expand Down
2 changes: 1 addition & 1 deletion lightning-rapid-gossip-sync/src/processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use core::cmp::max;
use core::ops::Deref;
use core::sync::atomic::Ordering;

use bitcoin::blockdata::constants::ChainHash;
use bitcoin::constants::ChainHash;
use bitcoin::secp256k1::PublicKey;

use lightning::io;
Expand Down
4 changes: 2 additions & 2 deletions lightning-transaction-sync/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use lightning_transaction_sync::ElectrumSyncClient;
use lightning_transaction_sync::EsploraSyncClient;

use bdk_macros::maybe_await;
use bitcoin::blockdata::block::Header;
use bitcoin::blockdata::constants::genesis_block;
use bitcoin::block::Header;
use bitcoin::constants::genesis_block;
use bitcoin::network::Network;
use bitcoin::{Amount, BlockHash, Txid};
use bitcoind::bitcoincore_rpc::RpcApi;
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/chain/chaininterface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use core::{cmp, ops::Deref};

use crate::prelude::*;

use bitcoin::blockdata::transaction::Transaction;
use bitcoin::transaction::Transaction;

// TODO: Define typed abstraction over feerates to handle their conversions.
pub(crate) fn compute_feerate_sat_per_1000_weight(fee_sat: u64, weight: u64) -> u32 {
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/chain/chainmonitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
//! events. The remote server would make use of [`ChainMonitor`] for block processing and for
//! servicing [`ChannelMonitor`] updates from the client.

use bitcoin::blockdata::block::Header;
use bitcoin::block::Header;
use bitcoin::hash_types::{Txid, BlockHash};

use crate::chain;
Expand Down
18 changes: 9 additions & 9 deletions lightning/src/chain/channelmonitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
//! ChannelMonitors to get out of the HSM and onto monitoring devices.

use bitcoin::amount::Amount;
use bitcoin::blockdata::block::Header;
use bitcoin::blockdata::transaction::{OutPoint as BitcoinOutPoint, TxOut, Transaction};
use bitcoin::blockdata::script::{Script, ScriptBuf};
use bitcoin::block::Header;
use bitcoin::transaction::{OutPoint as BitcoinOutPoint, TxOut, Transaction};
use bitcoin::script::{Script, ScriptBuf};

use bitcoin::hashes::Hash;
use bitcoin::hashes::sha256::Hash as Sha256;
Expand Down Expand Up @@ -2533,7 +2533,7 @@ macro_rules! fail_unbroadcast_htlcs {

#[cfg(test)]
pub fn deliberately_bogus_accepted_htlc_witness_program() -> Vec<u8> {
use bitcoin::blockdata::opcodes;
use bitcoin::opcodes;
let mut ret = [opcodes::all::OP_NOP.to_u8(); 136];
ret[131] = opcodes::all::OP_DROP.to_u8();
ret[132] = opcodes::all::OP_DROP.to_u8();
Expand Down Expand Up @@ -4810,11 +4810,11 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
#[cfg(test)]
mod tests {
use bitcoin::amount::Amount;
use bitcoin::blockdata::locktime::absolute::LockTime;
use bitcoin::blockdata::script::{ScriptBuf, Builder};
use bitcoin::blockdata::opcodes;
use bitcoin::blockdata::transaction::{Transaction, TxIn, TxOut, Version};
use bitcoin::blockdata::transaction::OutPoint as BitcoinOutPoint;
use bitcoin::locktime::absolute::LockTime;
use bitcoin::script::{ScriptBuf, Builder};
use bitcoin::opcodes;
use bitcoin::transaction::{Transaction, TxIn, TxOut, Version};
use bitcoin::transaction::OutPoint as BitcoinOutPoint;
use bitcoin::sighash;
use bitcoin::sighash::EcdsaSighashType;
use bitcoin::hashes::Hash;
Expand Down
6 changes: 3 additions & 3 deletions lightning/src/chain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

//! Structs and traits which allow other parts of rust-lightning to interact with the blockchain.

use bitcoin::blockdata::block::{Block, Header};
use bitcoin::blockdata::constants::genesis_block;
use bitcoin::blockdata::script::{Script, ScriptBuf};
use bitcoin::block::{Block, Header};
use bitcoin::constants::genesis_block;
use bitcoin::script::{Script, ScriptBuf};
use bitcoin::hash_types::{BlockHash, Txid};
use bitcoin::network::Network;
use bitcoin::secp256k1::PublicKey;
Expand Down
8 changes: 4 additions & 4 deletions lightning/src/chain/onchaintx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
//! building, tracking, bumping and notifications functions.

use bitcoin::amount::Amount;
use bitcoin::blockdata::locktime::absolute::LockTime;
use bitcoin::blockdata::transaction::Transaction;
use bitcoin::blockdata::transaction::OutPoint as BitcoinOutPoint;
use bitcoin::blockdata::script::{Script, ScriptBuf};
use bitcoin::locktime::absolute::LockTime;
use bitcoin::transaction::Transaction;
use bitcoin::transaction::OutPoint as BitcoinOutPoint;
use bitcoin::script::{Script, ScriptBuf};
use bitcoin::hashes::{Hash, HashEngine};
use bitcoin::hashes::sha256::Hash as Sha256;
use bitcoin::hash_types::{Txid, BlockHash};
Expand Down
16 changes: 8 additions & 8 deletions lightning/src/chain/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

use bitcoin::{Sequence, Witness};
use bitcoin::amount::Amount;
use bitcoin::blockdata::constants::WITNESS_SCALE_FACTOR;
use bitcoin::blockdata::locktime::absolute::LockTime;
use bitcoin::blockdata::transaction::{TxOut,TxIn, Transaction};
use bitcoin::blockdata::transaction::OutPoint as BitcoinOutPoint;
use bitcoin::blockdata::script::{Script, ScriptBuf};
use bitcoin::constants::WITNESS_SCALE_FACTOR;
use bitcoin::locktime::absolute::LockTime;
use bitcoin::transaction::{TxOut,TxIn, Transaction};
use bitcoin::transaction::OutPoint as BitcoinOutPoint;
use bitcoin::script::{Script, ScriptBuf};
use bitcoin::hash_types::Txid;
use bitcoin::secp256k1::{SecretKey,PublicKey};
use bitcoin::sighash::EcdsaSighashType;
Expand Down Expand Up @@ -1201,9 +1201,9 @@ mod tests {
use crate::ln::channel_keys::{DelayedPaymentBasepoint, HtlcBasepoint};

use bitcoin::amount::Amount;
use bitcoin::blockdata::constants::WITNESS_SCALE_FACTOR;
use bitcoin::blockdata::script::ScriptBuf;
use bitcoin::blockdata::transaction::OutPoint as BitcoinOutPoint;
use bitcoin::constants::WITNESS_SCALE_FACTOR;
use bitcoin::script::ScriptBuf;
use bitcoin::transaction::OutPoint as BitcoinOutPoint;

use bitcoin::hashes::hex::FromHex;

Expand Down
12 changes: 6 additions & 6 deletions lightning/src/chain/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
//! Types describing on-chain transactions.

use bitcoin::hash_types::Txid;
use bitcoin::blockdata::transaction::OutPoint as BitcoinOutPoint;
use bitcoin::blockdata::transaction::Transaction;
use bitcoin::transaction::OutPoint as BitcoinOutPoint;
use bitcoin::transaction::Transaction;

/// Transaction data where each item consists of a transaction reference paired with the index of
/// the transaction within a block.
Expand All @@ -23,8 +23,8 @@ use bitcoin::blockdata::transaction::Transaction;
/// extern crate bitcoin;
/// extern crate lightning;
///
/// use bitcoin::blockdata::block::Block;
/// use bitcoin::blockdata::constants::genesis_block;
/// use bitcoin::block::Block;
/// use bitcoin::constants::genesis_block;
/// use bitcoin::network::Network;
/// use lightning::chain::transaction::TransactionData;
///
Expand All @@ -45,7 +45,7 @@ pub type TransactionData<'a> = [(usize, &'a Transaction)];

/// A reference to a transaction output.
///
/// Differs from bitcoin::blockdata::transaction::OutPoint as the index is a u16 instead of u32
/// Differs from bitcoin::transaction::OutPoint as the index is a u16 instead of u32
/// due to LN's restrictions on index values. Should reduce (possibly) unsafe conversions this way.
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
pub struct OutPoint {
Expand Down Expand Up @@ -90,7 +90,7 @@ mod tests {
use crate::chain::transaction::OutPoint;
use crate::ln::types::ChannelId;

use bitcoin::blockdata::transaction::Transaction;
use bitcoin::transaction::Transaction;
use bitcoin::consensus::encode;
use bitcoin::hashes::hex::FromHex;

Expand Down
4 changes: 2 additions & 2 deletions lightning/src/events/bump_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ use crate::util::logger::Logger;

use bitcoin::{OutPoint, Psbt, PubkeyHash, Sequence, ScriptBuf, Transaction, TxIn, TxOut, Witness, WPubkeyHash};
use bitcoin::amount::Amount;
use bitcoin::blockdata::constants::WITNESS_SCALE_FACTOR;
use bitcoin::blockdata::locktime::absolute::LockTime;
use bitcoin::constants::WITNESS_SCALE_FACTOR;
use bitcoin::locktime::absolute::LockTime;
use bitcoin::consensus::Encodable;
use bitcoin::secp256k1;
use bitcoin::secp256k1::{PublicKey, Secp256k1};
Expand Down
4 changes: 2 additions & 2 deletions lightning/src/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ use crate::util::ser::{BigSize, FixedLengthReader, Writeable, Writer, MaybeReada
use crate::util::string::UntrustedString;

use bitcoin::{Transaction, OutPoint};
use bitcoin::blockdata::locktime::absolute::LockTime;
use bitcoin::blockdata::script::ScriptBuf;
use bitcoin::locktime::absolute::LockTime;
use bitcoin::script::ScriptBuf;
use bitcoin::hashes::Hash;
use bitcoin::hashes::sha256::Hash as Sha256;
use bitcoin::secp256k1::PublicKey;
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/ln/async_signer_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use std::collections::HashSet;

use bitcoin::{Transaction, TxOut, TxIn, Amount};
use bitcoin::blockdata::locktime::absolute::LockTime;
use bitcoin::locktime::absolute::LockTime;
use bitcoin::transaction::Version;

use crate::chain::channelmonitor::LATENCY_GRACE_PERIOD_BLOCKS;
Expand Down
Loading
Loading