|
36 | 36 | //! # Ok::<(), anyhow::Error>(())
|
37 | 37 | //! ```
|
38 | 38 |
|
39 |
| -use alloc::{boxed::Box, rc::Rc, string::String, vec::Vec}; |
40 |
| -use core::cell::RefCell; |
| 39 | +use alloc::{boxed::Box, string::String, vec::Vec}; |
41 | 40 | use core::fmt;
|
42 | 41 |
|
43 | 42 | use alloc::sync::Arc;
|
@@ -111,7 +110,7 @@ use crate::{KeychainKind, LocalOutput, Utxo, WeightedUtxo};
|
111 | 110 | /// [`coin_selection`]: Self::coin_selection
|
112 | 111 | #[derive(Debug)]
|
113 | 112 | pub struct TxBuilder<'a, Cs> {
|
114 |
| - pub(crate) wallet: Rc<RefCell<&'a mut Wallet>>, |
| 113 | + pub(crate) wallet: &'a mut Wallet, |
115 | 114 | pub(crate) params: TxParams,
|
116 | 115 | pub(crate) coin_selection: Cs,
|
117 | 116 | }
|
@@ -161,16 +160,6 @@ impl Default for FeePolicy {
|
161 | 160 | }
|
162 | 161 | }
|
163 | 162 |
|
164 |
| -impl<'a, Cs: Clone> Clone for TxBuilder<'a, Cs> { |
165 |
| - fn clone(&self) -> Self { |
166 |
| - TxBuilder { |
167 |
| - wallet: self.wallet.clone(), |
168 |
| - params: self.params.clone(), |
169 |
| - coin_selection: self.coin_selection.clone(), |
170 |
| - } |
171 |
| - } |
172 |
| -} |
173 |
| - |
174 | 163 | // Methods supported for any CoinSelectionAlgorithm.
|
175 | 164 | impl<'a, Cs> TxBuilder<'a, Cs> {
|
176 | 165 | /// Set a custom fee rate.
|
@@ -286,7 +275,7 @@ impl<'a, Cs> TxBuilder<'a, Cs> {
|
286 | 275 | /// the "utxos" and the "unspendable" list, it will be spent.
|
287 | 276 | pub fn add_utxos(&mut self, outpoints: &[OutPoint]) -> Result<&mut Self, AddUtxoError> {
|
288 | 277 | {
|
289 |
| - let wallet = self.wallet.borrow(); |
| 278 | + let wallet = &mut self.wallet; |
290 | 279 | let utxos = outpoints
|
291 | 280 | .iter()
|
292 | 281 | .map(|outpoint| {
|
@@ -682,9 +671,7 @@ impl<'a, Cs: CoinSelectionAlgorithm> TxBuilder<'a, Cs> {
|
682 | 671 | /// **WARNING**: To avoid change address reuse you must persist the changes resulting from one
|
683 | 672 | /// or more calls to this method before closing the wallet. See [`Wallet::reveal_next_address`].
|
684 | 673 | pub fn finish_with_aux_rand(self, rng: &mut impl RngCore) -> Result<Psbt, CreateTxError> {
|
685 |
| - self.wallet |
686 |
| - .borrow_mut() |
687 |
| - .create_tx(self.coin_selection, self.params, rng) |
| 674 | + self.wallet.create_tx(self.coin_selection, self.params, rng) |
688 | 675 | }
|
689 | 676 | }
|
690 | 677 |
|
@@ -750,7 +737,7 @@ impl fmt::Display for AddForeignUtxoError {
|
750 | 737 | #[cfg(feature = "std")]
|
751 | 738 | impl std::error::Error for AddForeignUtxoError {}
|
752 | 739 |
|
753 |
| -type TxSort<T> = dyn Fn(&T, &T) -> core::cmp::Ordering; |
| 740 | +type TxSort<T> = dyn (Fn(&T, &T) -> core::cmp::Ordering) + Send + Sync; |
754 | 741 |
|
755 | 742 | /// Ordering of the transaction's inputs and outputs
|
756 | 743 | #[derive(Clone, Default)]
|
|
0 commit comments