]> Untitled Git - bdk/commitdiff
Add comment explaining why params and coin_selection are Options
authorLLFourn <lloyd.fourn@gmail.com>
Tue, 5 Jan 2021 00:43:49 +0000 (11:43 +1100)
committerLLFourn <lloyd.fourn@gmail.com>
Fri, 22 Jan 2021 03:33:37 +0000 (14:33 +1100)
src/wallet/tx_builder.rs

index d7b379f47528e3155b975feb011f6a6f815ed51b..089aad432b2d3a0c84dd634a306260115bd9066c 100644 (file)
@@ -124,8 +124,11 @@ impl TxBuilderContext for BumpFee {}
 /// [`finish`]: Self::finish
 /// [`coin_selection`]: Self::coin_selection
 pub struct TxBuilder<'a, B, D, Cs, Ctx> {
-    pub(crate) params: Option<TxParams>,
     pub(crate) wallet: &'a Wallet<B, D>,
+    // params and coin_selection are Options not becasue they are optionally set (they are always
+    // there) but because `.finish()` uses `Option::take` to get an owned value from a &mut self.
+    // They are only `None` after `.finish()` is called.
+    pub(crate) params: Option<TxParams>,
     pub(crate) coin_selection: Option<Cs>,
     pub(crate) phantom: PhantomData<Ctx>,
 }