Skip to content

Commit

Permalink
fix(electrum): Set last seen timestamp only for unconfirmed txs
Browse files Browse the repository at this point in the history
`determine_tx_anchor` will return None if a transaction is not
yet confirmed. Now when creating a graph update from
RelevantTxids we assume if the tx has no anchors, it must be
unconfirmed, and only then do we call `insert_seen_at` on
the update TxGraph.
  • Loading branch information
ValuedMammal committed Mar 24, 2024
1 parent 33b84c2 commit 84dc09e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions crates/electrum/src/electrum_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ impl RelevantTxids {
let new_txs = client.batch_transaction_get(&missing)?;
let mut graph = TxGraph::<ConfirmationHeightAnchor>::new(new_txs);
for (txid, anchors) in self.0 {
if let Some(seen_at) = seen_at {
let _ = graph.insert_seen_at(txid, seen_at);
if anchors.is_empty() {
// this tx is unconfirmed,
// record the last seen timestamp
if let Some(seen_at) = seen_at {
let _ = graph.insert_seen_at(txid, seen_at);
}
}
for anchor in anchors {
let _ = graph.insert_anchor(txid, anchor);
Expand Down

0 comments on commit 84dc09e

Please sign in to comment.