Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: bitcoindevkit/bdk
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c94f27b7373eb61f436441f43bc30c40f530e3a0
Choose a base ref
..
head repository: bitcoindevkit/bdk
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b21ea0fe53710cf5ae037d9da48d48355e9f654e
Choose a head ref
8 changes: 3 additions & 5 deletions crates/electrum/src/electrum_ext.rs
Original file line number Diff line number Diff line change
@@ -40,16 +40,14 @@ impl RelevantTxids {
pub fn into_tx_graph(
self,
client: &Client,
seen_at: Option<u64>,
seen_at: u64,
missing: Vec<Txid>,
) -> Result<TxGraph<ConfirmationHeightAnchor>, Error> {
let new_txs = client.batch_transaction_get(&missing)?;
let mut graph = TxGraph::<ConfirmationHeightAnchor>::new(new_txs);
for (txid, anchors) in self.0 {
if anchors.is_empty() {
if let Some(seen_at) = seen_at {
let _ = graph.insert_seen_at(txid, seen_at);
}
let _ = graph.insert_seen_at(txid, seen_at);
}
for anchor in anchors {
let _ = graph.insert_anchor(txid, anchor);
@@ -69,7 +67,7 @@ impl RelevantTxids {
pub fn into_confirmation_time_tx_graph(
self,
client: &Client,
seen_at: Option<u64>,
seen_at: u64,
missing: Vec<Txid>,
) -> Result<TxGraph<ConfirmationTimeHeightAnchor>, Error> {
let graph = self.into_tx_graph(client, seen_at, missing)?;
7 changes: 3 additions & 4 deletions crates/electrum/tests/test_electrum.rs
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ fn scan_detects_confirmed_tx() -> Result<()> {
} = client.sync(recv_chain.tip(), [spk_to_track], None, None, 5)?;

let missing = relevant_txids.missing_full_txs(recv_graph.graph());
let graph_update = relevant_txids.into_confirmation_time_tx_graph(&client, None, missing)?;
let graph_update = relevant_txids.into_confirmation_time_tx_graph(&client, 0, missing)?;
let _ = recv_chain
.apply_update(chain_update)
.map_err(|err| anyhow::anyhow!("LocalChain update error: {:?}", err))?;
@@ -134,7 +134,7 @@ fn tx_can_become_unconfirmed_after_reorg() -> Result<()> {
} = client.sync(recv_chain.tip(), [spk_to_track.clone()], None, None, 5)?;

let missing = relevant_txids.missing_full_txs(recv_graph.graph());
let graph_update = relevant_txids.into_confirmation_time_tx_graph(&client, None, missing)?;
let graph_update = relevant_txids.into_confirmation_time_tx_graph(&client, 0, missing)?;
let _ = recv_chain
.apply_update(chain_update)
.map_err(|err| anyhow::anyhow!("LocalChain update error: {:?}", err))?;
@@ -164,8 +164,7 @@ fn tx_can_become_unconfirmed_after_reorg() -> Result<()> {
} = client.sync(recv_chain.tip(), [spk_to_track.clone()], None, None, 5)?;

let missing = relevant_txids.missing_full_txs(recv_graph.graph());
let graph_update =
relevant_txids.into_confirmation_time_tx_graph(&client, None, missing)?;
let graph_update = relevant_txids.into_confirmation_time_tx_graph(&client, 1, missing)?;
let _ = recv_chain
.apply_update(chain_update)
.map_err(|err| anyhow::anyhow!("LocalChain update error: {:?}", err))?;
2 changes: 1 addition & 1 deletion example-crates/example_electrum/src/main.rs
Original file line number Diff line number Diff line change
@@ -304,7 +304,7 @@ fn main() -> anyhow::Result<()> {
.expect("must get time")
.as_secs();

let graph_update = relevant_txids.into_tx_graph(&client, Some(now), missing_txids)?;
let graph_update = relevant_txids.into_tx_graph(&client, now, missing_txids)?;

let db_changeset = {
let mut chain = chain.lock().unwrap();
4 changes: 1 addition & 3 deletions example-crates/wallet_electrum/src/main.rs
Original file line number Diff line number Diff line change
@@ -66,10 +66,8 @@ fn main() -> Result<(), anyhow::Error> {
println!();

let missing = relevant_txids.missing_full_txs(wallet.as_ref());
let mut graph_update =
relevant_txids.into_confirmation_time_tx_graph(&client, None, missing)?;
let now = std::time::UNIX_EPOCH.elapsed().unwrap().as_secs();
let _ = graph_update.update_last_seen_unconfirmed(now);
let graph_update = relevant_txids.into_confirmation_time_tx_graph(&client, now, missing)?;

let wallet_update = Update {
last_active_indices: keychain_update,