Skip to content

Commit

Permalink
[bdk_chain_redesign] Rm anchor type param for structs that don't use it
Browse files Browse the repository at this point in the history
  • Loading branch information
evanlinjin committed Mar 28, 2023
1 parent 3440a05 commit 34d0277
Show file tree
Hide file tree
Showing 16 changed files with 174 additions and 201 deletions.
28 changes: 14 additions & 14 deletions crates/bdk/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,19 @@ const COINBASE_MATURITY: u32 = 100;
pub struct Wallet<D = ()> {
signers: Arc<SignersContainer>,
change_signers: Arc<SignersContainer>,
keychain_tracker: KeychainTracker<KeychainKind, BlockId, ConfirmationTime>,
persist: persist::Persist<KeychainKind, BlockId, ConfirmationTime, D>,
keychain_tracker: KeychainTracker<KeychainKind, ConfirmationTime>,
persist: persist::Persist<KeychainKind, ConfirmationTime, D>,
network: Network,
secp: SecpCtx,
}

/// The update to a [`Wallet`] used in [`Wallet::apply_update`]. This is usually returned from blockchain data sources.
/// The type parameter `T` indicates the kind of transaction contained in the update. It's usually a [`bitcoin::Transaction`].
pub type Update = KeychainScan<KeychainKind, BlockId, ConfirmationTime>;
pub type Update = KeychainScan<KeychainKind, ConfirmationTime>;
/// Error indicating that something was wrong with an [`Update<T>`].
pub type UpdateError = chain_graph::UpdateError<ConfirmationTime>;
/// The changeset produced internally by applying an update
pub(crate) type ChangeSet = KeychainChangeSet<KeychainKind, BlockId, ConfirmationTime>;
pub(crate) type ChangeSet = KeychainChangeSet<KeychainKind, ConfirmationTime>;

/// The address index selection strategy to use to derived an address from the wallet's external
/// descriptor. See [`Wallet::get_address`]. If you're unsure which one to use use `WalletIndex::New`.
Expand Down Expand Up @@ -197,7 +197,7 @@ impl<D> Wallet<D> {
network: Network,
) -> Result<Self, NewError<D::LoadError>>
where
D: persist::PersistBackend<KeychainKind, BlockId, ConfirmationTime>,
D: persist::PersistBackend<KeychainKind, ConfirmationTime>,
{
let secp = Secp256k1::new();

Expand Down Expand Up @@ -259,7 +259,7 @@ impl<D> Wallet<D> {
/// (i.e. does not end with /*) then the same address will always be returned for any [`AddressIndex`].
pub fn get_address(&mut self, address_index: AddressIndex) -> AddressInfo
where
D: persist::PersistBackend<KeychainKind, BlockId, ConfirmationTime>,
D: persist::PersistBackend<KeychainKind, ConfirmationTime>,
{
self._get_address(address_index, KeychainKind::External)
}
Expand All @@ -273,14 +273,14 @@ impl<D> Wallet<D> {
/// be returned for any [`AddressIndex`].
pub fn get_internal_address(&mut self, address_index: AddressIndex) -> AddressInfo
where
D: persist::PersistBackend<KeychainKind, BlockId, ConfirmationTime>,
D: persist::PersistBackend<KeychainKind, ConfirmationTime>,
{
self._get_address(address_index, KeychainKind::Internal)
}

fn _get_address(&mut self, address_index: AddressIndex, keychain: KeychainKind) -> AddressInfo
where
D: persist::PersistBackend<KeychainKind, BlockId, ConfirmationTime>,
D: persist::PersistBackend<KeychainKind, ConfirmationTime>,
{
let keychain = self.map_keychain(keychain);
let txout_index = &mut self.keychain_tracker.txout_index;
Expand Down Expand Up @@ -620,7 +620,7 @@ impl<D> Wallet<D> {
params: TxParams,
) -> Result<(psbt::PartiallySignedTransaction, TransactionDetails), Error>
where
D: persist::PersistBackend<KeychainKind, BlockId, ConfirmationTime>,
D: persist::PersistBackend<KeychainKind, ConfirmationTime>,
{
let external_descriptor = self
.keychain_tracker
Expand Down Expand Up @@ -1694,7 +1694,7 @@ impl<D> Wallet<D> {
/// [`commit`]: Self::commit
pub fn apply_update(&mut self, update: Update) -> Result<(), UpdateError>
where
D: persist::PersistBackend<KeychainKind, BlockId, ConfirmationTime>,
D: persist::PersistBackend<KeychainKind, ConfirmationTime>,
{
let changeset = self.keychain_tracker.apply_update(update)?;
self.persist.stage(changeset);
Expand All @@ -1706,7 +1706,7 @@ impl<D> Wallet<D> {
/// [`staged`]: Self::staged
pub fn commit(&mut self) -> Result<(), D::WriteError>
where
D: persist::PersistBackend<KeychainKind, BlockId, ConfirmationTime>,
D: persist::PersistBackend<KeychainKind, ConfirmationTime>,
{
self.persist.commit()
}
Expand All @@ -1724,7 +1724,7 @@ impl<D> Wallet<D> {
}

/// Get a reference to the inner [`ChainGraph`](bdk_chain::chain_graph::ChainGraph).
pub fn as_chain_graph(&self) -> &bdk_chain::chain_graph::ChainGraph<BlockId, ConfirmationTime> {
pub fn as_chain_graph(&self) -> &bdk_chain::chain_graph::ChainGraph<ConfirmationTime> {
self.keychain_tracker.chain_graph()
}
}
Expand All @@ -1735,8 +1735,8 @@ impl<D> AsRef<bdk_chain::tx_graph::TxGraph> for Wallet<D> {
}
}

impl<D> AsRef<bdk_chain::chain_graph::ChainGraph<BlockId, ConfirmationTime>> for Wallet<D> {
fn as_ref(&self) -> &bdk_chain::chain_graph::ChainGraph<BlockId, ConfirmationTime> {
impl<D> AsRef<bdk_chain::chain_graph::ChainGraph<ConfirmationTime>> for Wallet<D> {
fn as_ref(&self) -> &bdk_chain::chain_graph::ChainGraph<ConfirmationTime> {
self.keychain_tracker.chain_graph()
}
}
Expand Down
3 changes: 1 addition & 2 deletions crates/bdk/src/wallet/tx_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
use crate::collections::BTreeMap;
use crate::collections::HashSet;
use alloc::{boxed::Box, rc::Rc, string::String, vec::Vec};
use bdk_chain::BlockId;
use bdk_chain::ConfirmationTime;
use core::cell::RefCell;
use core::marker::PhantomData;
Expand Down Expand Up @@ -527,7 +526,7 @@ impl<'a, D, Cs: CoinSelectionAlgorithm, Ctx: TxBuilderContext> TxBuilder<'a, D,
/// [`BIP174`]: https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki
pub fn finish(self) -> Result<(Psbt, TransactionDetails), Error>
where
D: persist::PersistBackend<KeychainKind, BlockId, ConfirmationTime>,
D: persist::PersistBackend<KeychainKind, ConfirmationTime>,
{
self.wallet
.borrow_mut()
Expand Down
Loading

0 comments on commit 34d0277

Please sign in to comment.