]> Untitled Git - bdk/commitdiff
Rewrite the `non_witness_utxo` check
authorAlekos Filini <alekos.filini@gmail.com>
Thu, 6 May 2021 09:35:58 +0000 (11:35 +0200)
committerAlekos Filini <alekos.filini@gmail.com>
Thu, 6 May 2021 09:39:01 +0000 (11:39 +0200)
src/wallet/mod.rs

index 98be933837239a289ac4e61dd207f0db8002254c..4ddd7d362734d80b27502403298cbeb934a3bd29 100644 (file)
@@ -862,12 +862,10 @@ where
 
         // If we aren't allowed to use `witness_utxo`, ensure that every input has the
         // `non_witness_utxo`
-        if !sign_options.trust_witness_utxo {
-            for input in &psbt.inputs {
-                if input.non_witness_utxo.is_none() {
-                    return Err(Error::Signer(signer::SignerError::MissingNonWitnessUtxo));
-                }
-            }
+        if !sign_options.trust_witness_utxo
+            && psbt.inputs.iter().any(|i| i.non_witness_utxo.is_none())
+        {
+            return Err(Error::Signer(signer::SignerError::MissingNonWitnessUtxo));
         }
 
         for signer in self