Skip to content

Commit

Permalink
Upgrade bitcoin
Browse files Browse the repository at this point in the history
Upgrade dependencies required to use the recently released
`rust-bitcoin v0.31.0` release.

Co-authored-by: Roman Zeyde <[email protected]>
  • Loading branch information
tcharding and romanz committed Nov 15, 2023
1 parent 56aad37 commit b6271ba
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 44 deletions.
55 changes: 32 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ spec = "internal/config_specification.toml"

[dependencies]
anyhow = "1.0"
bitcoin = { version = "0.30.0", features = ["serde", "rand-std"] }
bitcoin_slices = { version = "0.6", features =["bitcoin", "sha2"] }
bitcoincore-rpc = "0.17.0"
bitcoin = { version = "0.31.0", features = ["serde", "rand-std"] }
bitcoin_slices = { version = "0.7", features = ["bitcoin", "sha2"] }
bitcoincore-rpc = { version = "0.18" }
configure_me = "0.4"
crossbeam-channel = "0.5"
dirs-next = "2.0"
Expand Down
2 changes: 1 addition & 1 deletion internal/config_specification.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ doc = "JSONRPC authentication cookie file (default: ~/.bitcoin/.cookie)"
[[param]]
name = "network"
type = "crate::config::BitcoinNetwork"
convert_into = "::bitcoin::network::constants::Network"
convert_into = "::bitcoin::Network"
doc = "Select Bitcoin network type ('bitcoin', 'testnet', 'regtest' or 'signet')"
default = "Default::default()"

Expand Down
2 changes: 1 addition & 1 deletion src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl Cache {
pub fn add_tx(&self, txid: Txid, f: impl FnOnce() -> Transaction) {
self.txs.write().entry(txid).or_insert_with(|| {
let tx = f();
self.txs_size.observe("serialized", tx.size() as f64);
self.txs_size.observe("serialized", tx.total_size() as f64);
tx
});
}
Expand Down
7 changes: 3 additions & 4 deletions src/chain.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::collections::HashMap;

use bitcoin::blockdata::block::Header as BlockHeader;
use bitcoin::network::constants;
use bitcoin::BlockHash;
use bitcoin::{BlockHash, Network};

/// A new header found, to be added to the chain at specific height
pub(crate) struct NewHeader {
Expand Down Expand Up @@ -37,7 +36,7 @@ pub struct Chain {

impl Chain {
// create an empty chain
pub fn new(network: constants::Network) -> Self {
pub fn new(network: Network) -> Self {
let genesis = bitcoin::blockdata::constants::genesis_block(network);
let genesis_hash = genesis.block_hash();
Self {
Expand Down Expand Up @@ -148,7 +147,7 @@ mod tests {
use super::{Chain, NewHeader};
use bitcoin::blockdata::block::Header as BlockHeader;
use bitcoin::consensus::deserialize;
use bitcoin::network::constants::Network::Regtest;
use bitcoin::Network::Regtest;
use hex_lit::hex;

#[test]
Expand Down
3 changes: 2 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use bitcoin::network::constants::{Magic, Network};
use bitcoin::p2p::Magic;
use bitcoin::Network;
use bitcoincore_rpc::Auth;
use dirs_next::home_dir;

Expand Down
16 changes: 6 additions & 10 deletions src/p2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ use bitcoin::{
Decodable,
},
hashes::Hash,
network::{
address,
constants::{self, Magic},
p2p::{
self, address,
message::{self, CommandString, NetworkMessage},
message_blockdata::{GetHeadersMessage, Inventory},
message_network,
message_network, Magic,
},
secp256k1::{self, rand::Rng},
Block, BlockHash, Network,
Expand Down Expand Up @@ -199,10 +198,7 @@ impl Connection {
};
send_duration.observe_duration("send", || {
trace!("send: {:?}", msg);
let raw_msg = message::RawNetworkMessage {
magic,
payload: msg,
};
let raw_msg = message::RawNetworkMessage::new(magic, msg);
buffer.clear();
raw_msg
.consensus_encode(&mut buffer)
Expand Down Expand Up @@ -331,10 +327,10 @@ fn build_version_message() -> NetworkMessage {
.expect("Time error")
.as_secs() as i64;

let services = constants::ServiceFlags::NONE;
let services = p2p::ServiceFlags::NONE;

NetworkMessage::Version(message_network::VersionMessage {
version: constants::PROTOCOL_VERSION,
version: p2p::PROTOCOL_VERSION,
services,
timestamp,
receiver: address::Address::new(&addr, services),
Expand Down
2 changes: 1 addition & 1 deletion src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ fn filter_outputs(tx: &Transaction, scripthash: ScriptHash) -> Vec<TxOutput> {
if ScriptHash::new(&txo.script_pubkey) == scripthash {
Some(TxOutput {
index: vout,
value: Amount::from_sat(txo.value),
value: txo.value,
})
} else {
None
Expand Down

0 comments on commit b6271ba

Please sign in to comment.