Skip to content

Commit 8b0fd27

Browse files
committed
f: doc updates and clean ups
1 parent d6887f0 commit 8b0fd27

File tree

2 files changed

+10
-34
lines changed

2 files changed

+10
-34
lines changed

lightning/src/events/bump_transaction/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ pub struct CoinSelection {
322322
/// sign for them. The coin selection method aims to mimic Bitcoin Core's `fundrawtransaction` RPC,
323323
/// which most wallets should be able to satisfy. Otherwise, consider implementing [`WalletSource`],
324324
/// which can provide a default implementation of this trait when used with [`Wallet`].
325+
///
326+
/// For a synchronous version of this trait, see [`sync::CoinSelectionSourceSync`].
325327
pub trait CoinSelectionSource {
326328
/// Performs coin selection of a set of UTXOs, with at least 1 confirmation each, that are
327329
/// available to spend. Implementations are free to pick their coin selection algorithm of
@@ -363,6 +365,8 @@ pub trait CoinSelectionSource {
363365

364366
/// An alternative to [`CoinSelectionSource`] that can be implemented and used along [`Wallet`] to
365367
/// provide a default implementation to [`CoinSelectionSource`].
368+
///
369+
/// For a synchronous version of this trait, see [`sync::WalletSourceSync`].
366370
pub trait WalletSource {
367371
/// Returns all UTXOs, with at least 1 confirmation each, that are available to spend.
368372
fn list_confirmed_utxos<'a>(&'a self) -> AsyncResult<'a, Vec<Utxo>>;
@@ -381,6 +385,8 @@ pub trait WalletSource {
381385
/// A wrapper over [`WalletSource`] that implements [`CoinSelection`] by preferring UTXOs that would
382386
/// avoid conflicting double spends. If not enough UTXOs are available to do so, conflicting double
383387
/// spends may happen.
388+
///
389+
/// For a synchronous version of this wrapper, see [`sync::WalletSync`].
384390
pub struct Wallet<W: Deref + MaybeSync + MaybeSend, L: Deref + MaybeSync + MaybeSend>
385391
where
386392
W::Target: WalletSource + MaybeSend,
@@ -574,6 +580,8 @@ where
574580
/// [`CoinSelectionSource`] to fee bump transactions via Child-Pays-For-Parent (CPFP) or
575581
/// Replace-By-Fee (RBF).
576582
///
583+
/// For a synchronous version of this handler, see [`sync::BumpTransactionEventHandlerSync`].
584+
///
577585
/// [`Event::BumpTransaction`]: crate::events::Event::BumpTransaction
578586
pub struct BumpTransactionEventHandler<B: Deref, C: Deref, SP: Deref, L: Deref>
579587
where

lightning/src/events/bump_transaction/sync.rs

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -39,45 +39,24 @@ pub trait WalletSourceSync {
3939
fn sign_psbt(&self, psbt: Psbt) -> Result<Transaction, ()>;
4040
}
4141

42-
/// A wrapper around [`WalletSourceSync`] to allow for async calls.
43-
///
44-
/// This wrapper isn't intended to be used directly, because that would risk blocking an async context. Instead, it is
45-
/// built for you in [`WalletSync::new`].
46-
#[doc(hidden)]
4742
pub(crate) struct WalletSourceSyncWrapper<T: Deref>(T)
4843
where
4944
T::Target: WalletSourceSync;
5045

51-
impl<T: Deref> WalletSourceSyncWrapper<T>
52-
where
53-
T::Target: WalletSourceSync,
54-
{
55-
/// Creates a new [`WalletSourceSyncWrapper`].
56-
pub fn new(source: T) -> Self {
57-
Self(source)
58-
}
59-
}
6046
impl<T: Deref> WalletSource for WalletSourceSyncWrapper<T>
6147
where
6248
T::Target: WalletSourceSync,
6349
{
64-
/// Returns all UTXOs, with at least 1 confirmation each, that are available to spend. Wraps
65-
/// [`WalletSourceSync::list_confirmed_utxos`].
6650
fn list_confirmed_utxos<'a>(&'a self) -> AsyncResult<'a, Vec<Utxo>> {
6751
let utxos = self.0.list_confirmed_utxos();
6852
Box::pin(async move { utxos })
6953
}
7054

71-
/// Returns a script to use for change above dust resulting from a successful coin selection attempt. Wraps
72-
/// [`WalletSourceSync::get_change_script`].
7355
fn get_change_script<'a>(&'a self) -> AsyncResult<'a, ScriptBuf> {
7456
let script = self.0.get_change_script();
7557
Box::pin(async move { script })
7658
}
7759

78-
/// Signs and provides the full [`TxIn::script_sig`] and [`TxIn::witness`] for all inputs within the transaction
79-
/// known to the wallet (i.e., any provided via [`WalletSource::list_confirmed_utxos`]). Wraps
80-
/// [`WalletSourceSync::sign_psbt`].
8160
fn sign_psbt<'a>(&'a self, psbt: Psbt) -> AsyncResult<'a, Transaction> {
8261
let signed_psbt = self.0.sign_psbt(psbt);
8362
Box::pin(async move { signed_psbt })
@@ -100,7 +79,7 @@ where
10079
{
10180
/// Constructs a new [`WalletSync`] instance.
10281
pub fn new(source: W, logger: L) -> Self {
103-
Self { wallet: Wallet::new(Arc::new(WalletSourceSyncWrapper::new(source)), logger) }
82+
Self { wallet: Wallet::new(Arc::new(WalletSourceSyncWrapper(source)), logger) }
10483
}
10584
}
10685

@@ -145,8 +124,7 @@ where
145124
}
146125
}
147126

148-
/// A synchronous helper trait that can be used to implement [`CoinSelectionSource`] in a synchronous
149-
/// context.
127+
/// A synchronous version of the [`CoinSelectionSource`] trait.
150128
pub trait CoinSelectionSourceSync {
151129
/// A synchronous version of [`CoinSelectionSource::select_confirmed_utxos`].
152130
fn select_confirmed_utxos(
@@ -162,16 +140,6 @@ struct CoinSelectionSourceSyncWrapper<T: Deref>(T)
162140
where
163141
T::Target: CoinSelectionSourceSync;
164142

165-
impl<T: Deref> CoinSelectionSourceSyncWrapper<T>
166-
where
167-
T::Target: CoinSelectionSourceSync,
168-
{
169-
#[allow(dead_code)]
170-
pub fn new(source: T) -> Self {
171-
Self(source)
172-
}
173-
}
174-
175143
impl<T: Deref> CoinSelectionSource for CoinSelectionSourceSyncWrapper<T>
176144
where
177145
T::Target: CoinSelectionSourceSync,

0 commit comments

Comments
 (0)