fix(electrum)!: Remove seen_at param from into_tx_graph
and `into_confirmation_time_tx_graph`, since now it makes sense to use `TxGraph::update_last_seen_unconfirmed`. Also, use `update_last_seen_unconfirmed` in examples for electrum/esplora. We show how to update the last seen time for transactions by calling `update_last_seen_unconfirmed` on the graph update returned from a blockchain source, passing in the current time, before applying it to another `TxGraph`.
This commit is contained in:
@@ -189,10 +189,14 @@ fn main() -> anyhow::Result<()> {
|
||||
// is reached. It returns a `TxGraph` update (`graph_update`) and a structure that
|
||||
// represents the last active spk derivation indices of keychains
|
||||
// (`keychain_indices_update`).
|
||||
let (graph_update, last_active_indices) = client
|
||||
let (mut graph_update, last_active_indices) = client
|
||||
.full_scan(keychain_spks, *stop_gap, scan_options.parallel_requests)
|
||||
.context("scanning for transactions")?;
|
||||
|
||||
// We want to keep track of the latest time a transaction was seen unconfirmed.
|
||||
let now = std::time::UNIX_EPOCH.elapsed().unwrap().as_secs();
|
||||
let _ = graph_update.update_last_seen_unconfirmed(now);
|
||||
|
||||
let mut graph = graph.lock().expect("mutex must not be poisoned");
|
||||
// Because we did a stop gap based scan we are likely to have some updates to our
|
||||
// deriviation indices. Usually before a scan you are on a fresh wallet with no
|
||||
@@ -307,9 +311,13 @@ fn main() -> anyhow::Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
let graph_update =
|
||||
let mut graph_update =
|
||||
client.sync(spks, txids, outpoints, scan_options.parallel_requests)?;
|
||||
|
||||
// Update last seen unconfirmed
|
||||
let now = std::time::UNIX_EPOCH.elapsed().unwrap().as_secs();
|
||||
let _ = graph_update.update_last_seen_unconfirmed(now);
|
||||
|
||||
graph.lock().unwrap().apply_update(graph_update)
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user