From 685be2bd4fec315117eedfadf848244468e3619b Mon Sep 17 00:00:00 2001 From: cygnet Date: Sun, 1 Sep 2024 15:58:26 +0200 Subject: [PATCH] Return warn instead of error when confirming unknown spending tx --- Cargo.toml | 1 + src/spclient.rs | 20 +++++++++----------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2e4c97d..304a238 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,3 +14,4 @@ serde = { version = "1.0.188", features = ["derive"] } serde_json = "1.0.107" bitcoin = { version = "0.31.1", features = ["serde", "rand", "base64"] } rayon = "1.10.0" +log = "0.4" diff --git a/src/spclient.rs b/src/spclient.rs index 6c0c3eb..e9a11c3 100644 --- a/src/spclient.rs +++ b/src/spclient.rs @@ -1071,27 +1071,25 @@ impl SpWallet { })) } - pub fn confirm_recorded_outgoing_transaction( - &mut self, - outpoint: OutPoint, - blkheight: Height, - ) -> Result<()> { + pub fn confirm_recorded_outgoing_transaction(&mut self, outpoint: OutPoint, blkheight: Height) { for recorded_tx in self.tx_history.iter_mut() { match recorded_tx { RecordedTransaction::Outgoing(outgoing) if (outgoing.spent_outpoints.contains(&outpoint)) => { outgoing.confirmed_at = Some(blkheight); - return Ok(()); + return; } _ => (), } } - Err(Error::msg(format!( - "No outgoing tx found for input: {}", - outpoint - ))) + // If no recorded transaction has been found, this input was likely spent by + // another wallet that used the same seed. + // In this case, we simply don't track this transaction in the tx history. + // This can mean that the tx history gets desynced between different wallets, + // but this is acceptabble behavior for a silent payment wallet. + log::warn!("No outgoing tx found for input: {}", outpoint); } pub fn record_incoming_transaction( @@ -1161,7 +1159,7 @@ impl SpWallet { ) -> Result<()> { for outpoint in found_inputs { // this may confirm the same tx multiple times, but this shouldn't be a problem - self.confirm_recorded_outgoing_transaction(outpoint, blkheight)?; + self.confirm_recorded_outgoing_transaction(outpoint, blkheight); self.outputs.mark_mined(outpoint, blkhash)?; }