Skip to content
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ Cargo.lock
# Example persisted files.
*.db
*.sqlite*

crates/electrum/target
Copy link
Copy Markdown
Member

@notmandatory notmandatory Jul 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit but this line isn't needed. Can be taking out in one of the current open PRs.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or **/target to ignore all target sub directories.

4 changes: 2 additions & 2 deletions crates/bitcoind_rpc/examples/filter_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn main() -> anyhow::Result<()> {
// apply relevant blocks
if let Event::Block(EventInner { height, ref block }) = event {
let _ = graph.apply_block_relevant(block, height);
println!("Matched block {}", curr);
println!("Matched block {curr}");
}
if curr % 1000 == 0 {
let progress = (curr - start_height) as f32 / blocks_to_scan as f32;
Expand Down Expand Up @@ -107,7 +107,7 @@ fn main() -> anyhow::Result<()> {

let unused_spk = graph.index.reveal_next_spk("external").unwrap().0 .1;
let unused_address = Address::from_script(&unused_spk, NETWORK)?;
println!("Next external address: {}", unused_address);
println!("Next external address: {unused_address}");

Ok(())
}
9 changes: 3 additions & 6 deletions crates/bitcoind_rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,7 @@ mod test {
for txid in &mempool_txids {
assert!(
emitter.expected_mempool_txids.contains(txid),
"Expected txid {:?} missing",
txid
"Expected txid {txid:?} missing"
);
}
}
Expand All @@ -502,15 +501,13 @@ mod test {
for txid in confirmed_txids {
assert!(
!emitter.expected_mempool_txids.contains(&txid),
"Expected txid {:?} should have been removed",
txid
"Expected txid {txid:?} should have been removed"
);
}
for txid in &mempool_txids {
assert!(
emitter.expected_mempool_txids.contains(txid),
"Expected txid {:?} missing",
txid
"Expected txid {txid:?} missing"
);
}
}
Expand Down
3 changes: 1 addition & 2 deletions crates/bitcoind_rpc/tests/test_emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,7 @@ fn tx_can_become_unconfirmed_after_reorg() -> anyhow::Result<()> {
confirmed: SEND_AMOUNT * (ADDITIONAL_COUNT - reorg_count) as u64,
..Balance::default()
},
"reorg_count: {}",
reorg_count,
"reorg_count: {reorg_count}",
);
}

Expand Down
4 changes: 2 additions & 2 deletions crates/chain/src/indexer/keychain_txout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,15 +594,15 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {
let _inserted = self
.inner
.insert_spk((keychain.clone(), new_index), new_spk);
debug_assert!(_inserted, "replenish lookahead: must not have existing spk: keychain={:?}, lookahead={}, next_index={}", keychain, lookahead, next_index);
debug_assert!(_inserted, "replenish lookahead: must not have existing spk: keychain={keychain:?}, lookahead={lookahead}, next_index={next_index}");
}
} else {
let spk_iter = SpkIterator::new_with_range(descriptor, next_index..stop_index);
for (new_index, new_spk) in spk_iter {
let _inserted = self
.inner
.insert_spk((keychain.clone(), new_index), new_spk);
debug_assert!(_inserted, "replenish lookahead: must not have existing spk: keychain={:?}, lookahead={}, next_index={}", keychain, lookahead, next_index);
debug_assert!(_inserted, "replenish lookahead: must not have existing spk: keychain={keychain:?}, lookahead={lookahead}, next_index={next_index}");
}
}
}
Expand Down
14 changes: 4 additions & 10 deletions crates/chain/src/rusqlite_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,14 @@ pub const SCHEMAS_TABLE_NAME: &str = "bdk_schemas";

/// Initialize the schema table.
fn init_schemas_table(db_tx: &Transaction) -> rusqlite::Result<()> {
let sql = format!("CREATE TABLE IF NOT EXISTS {}( name TEXT PRIMARY KEY NOT NULL, version INTEGER NOT NULL ) STRICT", SCHEMAS_TABLE_NAME);
let sql = format!("CREATE TABLE IF NOT EXISTS {SCHEMAS_TABLE_NAME}( name TEXT PRIMARY KEY NOT NULL, version INTEGER NOT NULL ) STRICT");
db_tx.execute(&sql, ())?;
Ok(())
}

/// Get schema version of `schema_name`.
fn schema_version(db_tx: &Transaction, schema_name: &str) -> rusqlite::Result<Option<u32>> {
let sql = format!(
"SELECT version FROM {} WHERE name=:name",
SCHEMAS_TABLE_NAME
);
let sql = format!("SELECT version FROM {SCHEMAS_TABLE_NAME} WHERE name=:name");
db_tx
.query_row(&sql, named_params! { ":name": schema_name }, |row| {
row.get::<_, u32>("version")
Expand All @@ -46,10 +43,7 @@ fn set_schema_version(
schema_name: &str,
schema_version: u32,
) -> rusqlite::Result<()> {
let sql = format!(
"REPLACE INTO {}(name, version) VALUES(:name, :version)",
SCHEMAS_TABLE_NAME,
);
let sql = format!("REPLACE INTO {SCHEMAS_TABLE_NAME}(name, version) VALUES(:name, :version)");
db_tx.execute(
&sql,
named_params! { ":name": schema_name, ":version": schema_version },
Expand Down Expand Up @@ -799,7 +793,7 @@ mod test {
":block_hash": Impl(anchor_block.hash),
}) {
Ok(updated) => assert_eq!(updated, 1),
Err(err) => panic!("update failed: {}", err),
Err(err) => panic!("update failed: {err}"),
}
}
}
Expand Down
10 changes: 2 additions & 8 deletions crates/chain/src/tx_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,7 @@ impl fmt::Display for CalculateFeeError {
match self {
CalculateFeeError::MissingTxOut(outpoints) => write!(
f,
"missing `TxOut` for one or more of the inputs of the tx: {:?}",
outpoints
"missing `TxOut` for one or more of the inputs of the tx: {outpoints:?}",
),
CalculateFeeError::NegativeFee(fee) => write!(
f,
Expand Down Expand Up @@ -1119,12 +1118,7 @@ impl<A: Anchor> TxGraph<A> {
if !canonical_tx.tx_node.tx.is_coinbase() {
for txin in &canonical_tx.tx_node.tx.input {
let _res = canon_spends.insert(txin.previous_output, txid);
assert!(
_res.is_none(),
"tried to replace {:?} with {:?}",
_res,
txid
);
assert!(_res.is_none(), "tried to replace {_res:?} with {txid:?}",);
}
}
canon_txs.insert(txid, canonical_tx);
Expand Down
2 changes: 1 addition & 1 deletion crates/chain/tests/test_indexed_tx_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ fn test_list_owned_txouts() {
let chain_tip = local_chain
.get(height)
.map(|cp| cp.block_id())
.unwrap_or_else(|| panic!("block must exist at {}", height));
.unwrap_or_else(|| panic!("block must exist at {height}"));
let txouts = graph
.graph()
.filter_chain_txouts(
Expand Down
5 changes: 2 additions & 3 deletions crates/chain/tests/test_local_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,9 @@ fn local_chain_insert_block() {
assert_eq!(
chain.insert_block(t.insert.into()),
t.expected_result,
"[{}] unexpected result when inserting block",
i,
"[{i}] unexpected result when inserting block",
);
assert_eq!(chain, t.expected_final, "[{}] unexpected final chain", i,);
assert_eq!(chain, t.expected_final, "[{i}] unexpected final chain",);
}
}

Expand Down
16 changes: 6 additions & 10 deletions crates/chain/tests/test_tx_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ fn test_calculate_fee_on_coinbase() {
fn test_walk_ancestors() {
let local_chain = LocalChain::from_blocks(
(0..=20)
.map(|ht| (ht, BlockHash::hash(format!("Block Hash {}", ht).as_bytes())))
.map(|ht| (ht, BlockHash::hash(format!("Block Hash {ht}").as_bytes())))
.collect(),
)
.expect("must contain genesis hash");
Expand Down Expand Up @@ -935,7 +935,7 @@ fn test_descendants_no_repeat() {
fn test_chain_spends() {
let local_chain = LocalChain::from_blocks(
(0..=100)
.map(|ht| (ht, BlockHash::hash(format!("Block Hash {}", ht).as_bytes())))
.map(|ht| (ht, BlockHash::hash(format!("Block Hash {ht}").as_bytes())))
.collect(),
)
.expect("must have genesis hash");
Expand Down Expand Up @@ -1453,23 +1453,19 @@ fn tx_graph_update_conversion() {
.iter()
.map(|tx| tx.compute_txid())
.collect::<HashSet<Txid>>(),
"{}: txs do not match",
test_name
"{test_name}: txs do not match"
);
assert_eq!(
update.txouts, update_from_tx_graph.txouts,
"{}: txouts do not match",
test_name
"{test_name}: txouts do not match"
);
assert_eq!(
update.anchors, update_from_tx_graph.anchors,
"{}: anchors do not match",
test_name
"{test_name}: anchors do not match"
);
assert_eq!(
update.seen_ats, update_from_tx_graph.seen_ats,
"{}: seen_ats do not match",
test_name
"{test_name}: seen_ats do not match"
);
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/core/src/spk_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ impl<I: core::fmt::Debug + core::any::Any> core::fmt::Display for SyncItem<'_, I
match self {
SyncItem::Spk(i, spk) => {
if (i as &dyn core::any::Any).is::<()>() {
write!(f, "script '{}'", spk)
write!(f, "script '{spk}'")
} else {
write!(f, "script {:?} '{}'", i, spk)
write!(f, "script {i:?} '{spk}'")
}
}
SyncItem::Txid(txid) => write!(f, "txid '{}'", txid),
SyncItem::OutPoint(op) => write!(f, "outpoint '{}'", op),
SyncItem::Txid(txid) => write!(f, "txid '{txid}'"),
SyncItem::OutPoint(op) => write!(f, "outpoint '{op}'"),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/electrum/src/bdk_electrum_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ impl<E: ElectrumApi> BdkElectrumClient<E> {
batch.raw(
"blockchain.transaction.get_merkle".into(),
vec![
electrum_client::Param::String(format!("{:x}", txid)),
electrum_client::Param::String(format!("{txid:x}")),
electrum_client::Param::Usize(height),
],
);
Expand Down
3 changes: 1 addition & 2 deletions crates/electrum/tests/test_electrum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -723,8 +723,7 @@ fn tx_can_become_unconfirmed_after_reorg() -> anyhow::Result<()> {
confirmed: SEND_AMOUNT * (REORG_COUNT - depth) as u64,
..Balance::default()
},
"reorg_count: {}",
depth,
"reorg_count: {depth}",
);
}

Expand Down
4 changes: 2 additions & 2 deletions crates/esplora/src/blocking_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,10 +866,10 @@ mod test {
.iter()
.map(|&h| {
let anchor_blockhash: BlockHash = bdk_chain::bitcoin::hashes::Hash::hash(
&format!("hash_at_height_{}", h).into_bytes(),
&format!("hash_at_height_{h}").into_bytes(),
);
let txid: Txid = bdk_chain::bitcoin::hashes::Hash::hash(
&format!("txid_at_height_{}", h).into_bytes(),
&format!("txid_at_height_{h}").into_bytes(),
);
let anchor = ConfirmationBlockTime {
block_id: BlockId {
Expand Down
2 changes: 2 additions & 0 deletions crates/esplora/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ mod async_ext;
#[cfg(feature = "async")]
pub use async_ext::*;

#[allow(dead_code)]
fn insert_anchor_or_seen_at_from_status(
update: &mut TxUpdate<ConfirmationBlockTime>,
start_time: u64,
Expand All @@ -61,6 +62,7 @@ fn insert_anchor_or_seen_at_from_status(

/// Inserts floating txouts into `tx_graph` using [`Vin`](esplora_client::api::Vin)s returned by
/// Esplora.
#[allow(dead_code)]
fn insert_prevouts(
update: &mut TxUpdate<ConfirmationBlockTime>,
esplora_inputs: impl IntoIterator<Item = esplora_client::api::Vin>,
Expand Down
7 changes: 3 additions & 4 deletions crates/file_store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ pub enum StoreError {
impl core::fmt::Display for StoreError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Io(e) => write!(f, "io error trying to read file: {}", e),
Self::Io(e) => write!(f, "io error trying to read file: {e}"),
Self::InvalidMagicBytes { got, expected } => write!(
f,
"file has invalid magic bytes: expected={:?} got={:?}",
expected, got,
"file has invalid magic bytes: expected={expected:?} got={got:?}",
),
Self::Bincode(e) => write!(f, "bincode error while reading entry {}", e),
Self::Bincode(e) => write!(f, "bincode error while reading entry {e}"),
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions crates/file_store/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ where
.serialize_into(&mut self.db_file, changeset)
.map_err(|e| match *e {
bincode::ErrorKind::Io(error) => error,
unexpected_err => panic!("unexpected bincode error: {}", unexpected_err),
unexpected_err => panic!("unexpected bincode error: {unexpected_err}"),
})?;

Ok(())
Expand Down Expand Up @@ -323,7 +323,7 @@ mod test {
error: StoreError::Io(e),
..
}) => assert_eq!(e.kind(), std::io::ErrorKind::UnexpectedEof),
unexpected => panic!("unexpected result: {:?}", unexpected),
unexpected => panic!("unexpected result: {unexpected:?}"),
};
}

Expand All @@ -342,7 +342,7 @@ mod test {
}) => {
assert_eq!(got, invalid_magic_bytes.as_bytes())
}
unexpected => panic!("unexpected result: {:?}", unexpected),
unexpected => panic!("unexpected result: {unexpected:?}"),
};
}

Expand Down Expand Up @@ -372,7 +372,7 @@ mod test {
}) => {
assert_eq!(changeset, Some(test_changesets))
}
unexpected_res => panic!("unexpected result: {:?}", unexpected_res),
unexpected_res => panic!("unexpected result: {unexpected_res:?}"),
}
}

Expand Down Expand Up @@ -400,7 +400,7 @@ mod test {
}) => {
assert_eq!(changeset, Some(test_changesets))
}
unexpected_res => panic!("unexpected result: {:?}", unexpected_res),
unexpected_res => panic!("unexpected result: {unexpected_res:?}"),
}
}

Expand Down Expand Up @@ -476,7 +476,7 @@ mod test {
let last_changeset_bytes = bincode_options().serialize(&last_changeset).unwrap();

for short_write_len in 1..last_changeset_bytes.len() - 1 {
let file_path = temp_dir.path().join(format!("{}.dat", short_write_len));
let file_path = temp_dir.path().join(format!("{short_write_len}.dat"));

// simulate creating a file, writing data where the last write is incomplete
{
Expand Down
10 changes: 5 additions & 5 deletions examples/example_cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,12 +488,12 @@ pub fn handle_commands<CS: clap::Subcommand, S: clap::Args>(
..Default::default()
})?;
let addr = Address::from_script(spk.as_script(), network)?;
println!("[address @ {}] {}", spk_i, addr);
println!("[address @ {spk_i}] {addr}");
Ok(())
}
AddressCmd::Index => {
for (keychain, derivation_index) in index.last_revealed_indices() {
println!("{:?}: {}", keychain, derivation_index);
println!("{keychain:?}: {derivation_index}");
}
Ok(())
}
Expand Down Expand Up @@ -523,7 +523,7 @@ pub fn handle_commands<CS: clap::Subcommand, S: clap::Args>(
title_str: &'a str,
items: impl IntoIterator<Item = (&'a str, Amount)>,
) {
println!("{}:", title_str);
println!("{title_str}:");
for (name, amount) in items.into_iter() {
println!(" {:<10} {:>12} sats", name, amount.to_sat())
}
Expand Down Expand Up @@ -932,8 +932,8 @@ fn generate_bip86_helper(network: impl Into<NetworkKind>) -> anyhow::Result<()>
let (internal_descriptor, internal_keymap) =
<Descriptor<DescriptorPublicKey>>::parse_descriptor(&secp, internal_desc)?;
println!("Public");
println!("{}", descriptor);
println!("{}", internal_descriptor);
println!("{descriptor}");
println!("{internal_descriptor}");
println!("\nPrivate");
println!("{}", descriptor.to_string_with_secret(&keymap));
println!(
Expand Down
Loading
Loading