Derive Clone + Debug for TxBuilder
And make Wallet Debug while I'm at it.
This commit is contained in:
parent
10fcba9439
commit
6fe3be0243
@ -35,6 +35,7 @@ use bitcoin::hashes::hex::FromHex;
|
|||||||
use bitcoin::util::bip32::Fingerprint;
|
use bitcoin::util::bip32::Fingerprint;
|
||||||
use bitcoin::{Network, Script};
|
use bitcoin::{Network, Script};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
struct DummyValidator;
|
struct DummyValidator;
|
||||||
impl AddressValidator for DummyValidator {
|
impl AddressValidator for DummyValidator {
|
||||||
fn validate(
|
fn validate(
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
//! # use bdk::address_validator::*;
|
//! # use bdk::address_validator::*;
|
||||||
//! # use bdk::database::*;
|
//! # use bdk::database::*;
|
||||||
//! # use bdk::*;
|
//! # use bdk::*;
|
||||||
|
//! #[derive(Debug)]
|
||||||
//! struct PrintAddressAndContinue;
|
//! struct PrintAddressAndContinue;
|
||||||
//!
|
//!
|
||||||
//! impl AddressValidator for 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.
|
/// 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.
|
/// 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
|
/// Validate or inspect an address
|
||||||
fn validate(
|
fn validate(
|
||||||
&self,
|
&self,
|
||||||
@ -128,6 +129,7 @@ mod test {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::wallet::test::{get_funded_wallet, get_test_wpkh};
|
use crate::wallet::test::{get_funded_wallet, get_test_wpkh};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
struct TestValidator;
|
struct TestValidator;
|
||||||
impl AddressValidator for TestValidator {
|
impl AddressValidator for TestValidator {
|
||||||
fn validate(
|
fn validate(
|
||||||
|
@ -87,6 +87,7 @@ const CACHE_ADDR_BATCH_SIZE: u32 = 100;
|
|||||||
/// A wallet can be either "online" if the [`blockchain`](crate::blockchain) type provided
|
/// 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
|
/// 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.
|
/// methods that don't need any interaction with the blockchain to work.
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Wallet<B, D> {
|
pub struct Wallet<B, D> {
|
||||||
descriptor: ExtendedDescriptor,
|
descriptor: ExtendedDescriptor,
|
||||||
change_descriptor: Option<ExtendedDescriptor>,
|
change_descriptor: Option<ExtendedDescriptor>,
|
||||||
|
@ -127,6 +127,7 @@ impl TxBuilderContext for BumpFee {}
|
|||||||
/// [`build_fee_bump`]: Wallet::build_fee_bump
|
/// [`build_fee_bump`]: Wallet::build_fee_bump
|
||||||
/// [`finish`]: Self::finish
|
/// [`finish`]: Self::finish
|
||||||
/// [`coin_selection`]: Self::coin_selection
|
/// [`coin_selection`]: Self::coin_selection
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
pub struct TxBuilder<'a, B, D, Cs, Ctx> {
|
pub struct TxBuilder<'a, B, D, Cs, Ctx> {
|
||||||
pub(crate) wallet: &'a Wallet<B, D>,
|
pub(crate) wallet: &'a Wallet<B, D>,
|
||||||
// params and coin_selection are Options not becasue they are optionally set (they are always
|
// 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.
|
/// The parameters for transaction creation sans coin selection algorithm.
|
||||||
//TODO: TxParams should eventually be exposed publicly.
|
//TODO: TxParams should eventually be exposed publicly.
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug, Clone)]
|
||||||
pub(crate) struct TxParams {
|
pub(crate) struct TxParams {
|
||||||
pub(crate) recipients: Vec<(Script, u64)>,
|
pub(crate) recipients: Vec<(Script, u64)>,
|
||||||
pub(crate) drain_wallet: bool,
|
pub(crate) drain_wallet: bool,
|
||||||
@ -168,7 +169,7 @@ pub(crate) struct PreviousFee {
|
|||||||
pub rate: f32,
|
pub rate: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub(crate) enum FeePolicy {
|
pub(crate) enum FeePolicy {
|
||||||
FeeRate(FeeRate),
|
FeeRate(FeeRate),
|
||||||
FeeAmount(u64),
|
FeeAmount(u64),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user