Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return warn instead of error when confirming unknown spending tx #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
20 changes: 9 additions & 11 deletions src/spclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)?;
}

Expand Down
Loading