diff --git a/src/event.rs b/src/event.rs index 285856291..1a0c99231 100644 --- a/src/event.rs +++ b/src/event.rs @@ -564,7 +564,10 @@ where &Secp256k1::new(), ); match res { - Ok(spending_tx) => self.wallet.broadcast_transaction(&spending_tx), + Ok(Some(spending_tx)) => self.wallet.broadcast_transaction(&spending_tx), + Ok(None) => { + log_info!(self.logger, "All outputs already handled"); + } Err(err) => { log_error!(self.logger, "Error spending outputs: {:?}", err); } diff --git a/src/wallet.rs b/src/wallet.rs index 78fa6e567..8d1310798 100644 --- a/src/wallet.rs +++ b/src/wallet.rs @@ -362,19 +362,24 @@ where &self, descriptors: &[&SpendableOutputDescriptor], outputs: Vec, change_destination_script: Script, feerate_sat_per_1000_weight: u32, secp_ctx: &Secp256k1, - ) -> Result { + ) -> Result, ()> { let only_non_static = &descriptors .iter() .filter(|desc| !matches!(desc, SpendableOutputDescriptor::StaticOutput { .. })) .copied() .collect::>(); - self.inner.spend_spendable_outputs( - only_non_static, - outputs, - change_destination_script, - feerate_sat_per_1000_weight, - secp_ctx, - ) + if only_non_static.is_empty() { + return Ok(None); + } + self.inner + .spend_spendable_outputs( + only_non_static, + outputs, + change_destination_script, + feerate_sat_per_1000_weight, + secp_ctx, + ) + .map(Some) } pub fn sign_message(&self, msg: &[u8]) -> Result {