]> Untitled Git - bdk/commitdiff
Use collect to avoid iter unwrapping Options
authorLLFourn <lloyd.fourn@gmail.com>
Wed, 14 Oct 2020 02:55:33 +0000 (13:55 +1100)
committerLLFourn <lloyd.fourn@gmail.com>
Thu, 15 Oct 2020 02:41:36 +0000 (13:41 +1100)
src/wallet/mod.rs

index 1629107be28688af7447b5625e9cc4662da8640b..a8beb4e7f3643b6394f26b5cd57a8fc5a4faaead 100644 (file)
@@ -947,12 +947,10 @@ where
                 let full_utxos = raw_utxos
                     .iter()
                     .map(|u| self.database.borrow().get_utxo(&u))
-                    .collect::<Result<Vec<_>, _>>()?;
-                if !full_utxos.iter().all(|u| u.is_some()) {
-                    return Err(Error::UnknownUTXO);
-                }
+                    .collect::<Result<Option<Vec<_>>, _>>()?
+                    .ok_or(Error::UnknownUTXO)?;
 
-                Ok((full_utxos.into_iter().map(|x| x.unwrap()).collect(), true))
+                Ok((full_utxos, true))
             }
             // otherwise limit ourselves to the spendable utxos for the selected policy, and the `send_all` setting
             None => {