]> Untitled Git - bdk/commitdiff
[docs] Add docs to the 'wallet' module
authorSteve Myers <steve@notmandatory.org>
Fri, 11 Dec 2020 22:10:11 +0000 (14:10 -0800)
committerSteve Myers <steve@notmandatory.org>
Tue, 15 Dec 2020 23:12:32 +0000 (15:12 -0800)
src/wallet/address_validator.rs
src/wallet/coin_selection.rs
src/wallet/mod.rs
src/wallet/signer.rs
src/wallet/tx_builder.rs

index 391e2ad97a0bfc39ffd29508291b7bf10786adec..26f15a253cc6d7065ec8b5138b7a4f346fbe4c87 100644 (file)
@@ -84,10 +84,15 @@ use crate::types::KeychainKind;
 /// 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),
 }
 
index c706ec9f4d43bbccdf4d7eaab3fa52176d629ff5..f964f5dcb54f89838d3ae01c840508adc13a3f3c 100644 (file)
@@ -45,6 +45,7 @@
 //! # 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;
 //!
@@ -114,9 +115,9 @@ pub type DefaultCoinSelectionAlgorithm = BranchAndBoundCoinSelection;
 #[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)]
@@ -275,6 +276,7 @@ impl Default for BranchAndBoundCoinSelection {
 }
 
 impl BranchAndBoundCoinSelection {
+    /// Create new instance with target size for change output
     pub fn new(size_of_change: u64) -> Self {
         Self { size_of_change }
     }
index de69357aa79ba46b696a6f08b8b1c8fe503f4e8b..6db8f8d90082acfd1cb1f253e79ec3c0c1a406b1 100644 (file)
@@ -46,15 +46,11 @@ use miniscript::psbt::PsbtInputSatisfier;
 #[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;
 
@@ -962,7 +958,7 @@ where
         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
     }
index 43cff45a7dde793c68af65704e1ac0bd1abe3e6e..6ddf41623025400c18e5ff9c771c3f3c3ffc3568 100644 (file)
@@ -113,7 +113,9 @@ use crate::descriptor::XKeyUtils;
 /// 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),
 }
 
@@ -324,6 +326,7 @@ impl From<(SignerId, SignerOrdering)> for SignersContainerKey {
 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()
index 3cd784f01c992ee733a1050492d0cf3f2b26be1d..921081a3c2cb2e2a6725ae6efef0f4b5578ed950 100644 (file)
@@ -508,6 +508,7 @@ impl Default for TxOrdering {
 }
 
 impl TxOrdering {
+    /// Sort transaction inputs and outputs by [`TxOrdering`] variant
     pub fn sort_tx(&self, tx: &mut Transaction) {
         match self {
             TxOrdering::Untouched => {}