]> Untitled Git - bdk/commitdiff
Derive Clone + Debug for TxBuilder
authorLLFourn <lloyd.fourn@gmail.com>
Fri, 22 Jan 2021 03:11:29 +0000 (14:11 +1100)
committerLLFourn <lloyd.fourn@gmail.com>
Fri, 22 Jan 2021 04:08:30 +0000 (15:08 +1100)
And make Wallet Debug while I'm at it.

examples/address_validator.rs
src/wallet/address_validator.rs
src/wallet/mod.rs
src/wallet/tx_builder.rs

index d00a239aeed9bb205f62c1cfc578184f501131ca..8730fb7948b4a90482cb0196665b7883562eff71 100644 (file)
@@ -35,6 +35,7 @@ use bitcoin::hashes::hex::FromHex;
 use bitcoin::util::bip32::Fingerprint;
 use bitcoin::{Network, Script};
 
+#[derive(Debug)]
 struct DummyValidator;
 impl AddressValidator for DummyValidator {
     fn validate(
index b84bee0c088b2f58d12773965193a60fdd6dfb4d..4484efef01ad4eea1171c905209afbb9b3096e84 100644 (file)
@@ -45,6 +45,7 @@
 //! # use bdk::address_validator::*;
 //! # use bdk::database::*;
 //! # use bdk::*;
+//! #[derive(Debug)]
 //! struct PrintAddressAndContinue;
 //!
 //! impl AddressValidator for PrintAddressAndContinue {
@@ -111,7 +112,7 @@ impl std::error::Error for AddressValidatorError {}
 /// validator will be propagated up to the original caller that triggered the address generation.
 ///
 /// For a usage example see [this module](crate::address_validator)'s documentation.
-pub trait AddressValidator: Send + Sync {
+pub trait AddressValidator: Send + Sync + fmt::Debug {
     /// Validate or inspect an address
     fn validate(
         &self,
@@ -128,6 +129,7 @@ mod test {
     use super::*;
     use crate::wallet::test::{get_funded_wallet, get_test_wpkh};
 
+    #[derive(Debug)]
     struct TestValidator;
     impl AddressValidator for TestValidator {
         fn validate(
index 7921a189c9e9ba14034fa5ada90c3790c6a8ee84..3b223bbaed5ed26e0c1966315bc381953522c3d0 100644 (file)
@@ -87,6 +87,7 @@ const CACHE_ADDR_BATCH_SIZE: u32 = 100;
 /// A wallet can be either "online" if the [`blockchain`](crate::blockchain) type provided
 /// implements [`Blockchain`], or "offline" if it is the unit type `()`. Offline wallets only expose
 /// methods that don't need any interaction with the blockchain to work.
+#[derive(Debug)]
 pub struct Wallet<B, D> {
     descriptor: ExtendedDescriptor,
     change_descriptor: Option<ExtendedDescriptor>,
index 92ea37c1eb1a3a4488a34b1938361e683063bd71..b8bc715d3c2b0fac51fccc94197b30f6c2ff408b 100644 (file)
@@ -127,6 +127,7 @@ impl TxBuilderContext for BumpFee {}
 /// [`build_fee_bump`]: Wallet::build_fee_bump
 /// [`finish`]: Self::finish
 /// [`coin_selection`]: Self::coin_selection
+#[derive(Clone, Debug)]
 pub struct TxBuilder<'a, B, D, Cs, Ctx> {
     pub(crate) wallet: &'a Wallet<B, D>,
     // params and coin_selection are Options not becasue they are optionally set (they are always
@@ -139,7 +140,7 @@ pub struct TxBuilder<'a, B, D, Cs, Ctx> {
 
 /// The parameters for transaction creation sans coin selection algorithm.
 //TODO: TxParams should eventually be exposed publicly.
-#[derive(Default, Debug)]
+#[derive(Default, Debug, Clone)]
 pub(crate) struct TxParams {
     pub(crate) recipients: Vec<(Script, u64)>,
     pub(crate) drain_wallet: bool,
@@ -168,7 +169,7 @@ pub(crate) struct PreviousFee {
     pub rate: f32,
 }
 
-#[derive(Debug)]
+#[derive(Debug, Clone, Copy)]
 pub(crate) enum FeePolicy {
     FeeRate(FeeRate),
     FeeAmount(u64),