/// Errors that can be returned to fail the validation of an address
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum AddressValidatorError {
+ /// User rejected the address
UserRejected,
+ /// Network connection error
ConnectionError,
+ /// Network request timeout error
TimeoutError,
+ /// Invalid script
InvalidScript,
+ /// A custom error message
Message(String),
}
//! # use bdk::wallet::coin_selection::*;
//! # use bdk::database::Database;
//! # use bdk::*;
+//! # const TXIN_BASE_WEIGHT: usize = (32 + 4 + 4 + 1) * 4;
//! #[derive(Debug)]
//! struct AlwaysSpendEverything;
//!
#[cfg(test)]
pub type DefaultCoinSelectionAlgorithm = LargestFirstCoinSelection; // make the tests more predictable
-// Base weight of a Txin, not counting the weight needed for satisfaying it.
+// Base weight of a Txin, not counting the weight needed for satisfying it.
// prev_txid (32 bytes) + prev_vout (4 bytes) + sequence (4 bytes) + script_len (1 bytes)
-pub const TXIN_BASE_WEIGHT: usize = (32 + 4 + 4 + 1) * 4;
+pub(crate) const TXIN_BASE_WEIGHT: usize = (32 + 4 + 4 + 1) * 4;
/// Result of a successful coin selection
#[derive(Debug)]
}
impl BranchAndBoundCoinSelection {
+ /// Create new instance with target size for change output
pub fn new(size_of_change: u64) -> Self {
Self { size_of_change }
}
#[allow(unused_imports)]
use log::{debug, error, info, trace};
-#[allow(missing_docs)] // TODO add missing docs and remove this allow
pub mod address_validator;
-#[allow(missing_docs)] // TODO add missing docs and remove this allow
pub mod coin_selection;
pub mod export;
-#[allow(missing_docs)] // TODO add missing docs and remove this allow
pub mod signer;
pub mod time;
-#[allow(missing_docs)] // TODO add missing docs and remove this allow
pub mod tx_builder;
pub(crate) mod utils;
Ok((psbt, finished))
}
- #[allow(missing_docs)] // TODO add missing docs and remove this allow
+ /// Return the secp256k1 context used for all signing operations
pub fn secp_ctx(&self) -> &SecpCtx {
&self.secp
}
/// multiple of them
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum SignerId {
+ /// Bitcoin HASH160 (RIPEMD160 after SHA256) hash of an ECDSA public key
PkHash(hash160::Hash),
+ /// The fingerprint of a BIP32 extended key
Fingerprint(Fingerprint),
}
pub struct SignersContainer(HashMap<SignersContainerKey, Arc<dyn Signer>>);
impl SignersContainer {
+ /// Create a map of public keys to secret keys
pub fn as_key_map(&self, secp: &SecpCtx) -> KeyMap {
self.0
.values()
}
impl TxOrdering {
+ /// Sort transaction inputs and outputs by [`TxOrdering`] variant
pub fn sort_tx(&self, tx: &mut Transaction) {
match self {
TxOrdering::Untouched => {}