Skip to content

Commit

Permalink
[docs-only] Use backtick in addition to square parentheses for types …
Browse files Browse the repository at this point in the history
…references, clarify legacy, non_exhaustive comment, remove std::
  • Loading branch information
RCasatta committed Aug 31, 2021
1 parent f223be6 commit c704ee7
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/util/sighash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//!
//! Implementation of the algorithm to compute the message to be signed according to [Bip341](https://github.com/bitcoin/bips/blob/150ab6f5c3aca9da05fccc5b435e9667853407f4/bip-0341.mediawiki),
//! [Bip143](https://github.com/bitcoin/bips/blob/99701f68a88ce33b2d0838eb84e115cef505b4c2/bip-0143.mediawiki)
//! and legacy
//! and legacy (before Bip143)
//!

pub use blockdata::transaction::SigHashType as LegacySigHashType;
Expand All @@ -36,7 +36,7 @@ use prelude::*;
pub struct SigHashCache<T: Deref<Target = Transaction>> {
/// Access to transaction required for various introspection, moreover type
/// `T: Deref<Target=Transaction>` allows to accept borrow and mutable borrow, the
/// latter in particular is necessary for [SigHashCache::witness_mut]
/// latter in particular is necessary for [`SigHashCache::witness_mut`]
tx: T,

/// Common cache for taproot and segwit inputs. It's an option because it's not needed for legacy inputs
Expand All @@ -60,7 +60,7 @@ struct CommonCache {
outputs: sha256::Hash,
}

/// Values cached for segwit inputs, it's equal to [CommonCache] plus another round of `sha256`
/// Values cached for segwit inputs, it's equal to [`CommonCache`] plus another round of `sha256`
#[derive(Debug)]
struct SegwitCache {
prevouts: sha256d::Hash,
Expand All @@ -76,12 +76,12 @@ struct TaprootCache {
}

/// Contains outputs of previous transactions.
/// In the case [SigHashType] variant is `ANYONECANPAY`, [Prevouts::One] may be provided
/// In the case [`SigHashType`] variant is `ANYONECANPAY`, [`Prevouts::One`] may be provided
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub enum Prevouts<'u> {
/// `One` variant allows to provide the single Prevout needed. It's useful for example
/// when modifier `ANYONECANPAY` is provided, only prevout of the current input is needed.
/// The first `usize` argument is the input index this [TxOut] is referring to.
/// The first `usize` argument is the input index this [`TxOut`] is referring to.
One(usize, &'u TxOut),
/// When `ANYONECANPAY` is not provided, or the caller is handy giving all prevouts so the same
/// variable can be used for multiple inputs.
Expand All @@ -103,7 +103,7 @@ pub struct ScriptPath<'s> {
/// Fixed values so they can be casted as integer types for encoding
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub enum SigHashType {
/// 0x0: Used when not explicitly specified, defaulting to [SigHashType::All]
/// 0x0: Used when not explicitly specified, defaulting to [`SigHashType::All`]
Default = 0x00,
/// 0x1: Sign all outputs
All = 0x01,
Expand All @@ -121,7 +121,7 @@ pub enum SigHashType {
/// 0x83: Sign one output and only this input (see `Single` for what "one output" means)
SinglePlusAnyoneCanPay = 0x83,

/// Reserved for future use
/// Reserved for future use, `#[non_exhaustive]` is not available with current MSRV
Reserved = 0xFF,
}

Expand Down Expand Up @@ -154,7 +154,7 @@ pub enum Error {
PrevoutsSize,

/// Requested a prevout index which is greater than the number of prevouts provided or a
/// [Prevouts::One] with different index
/// [`Prevouts::One`] with different index
PrevoutIndex,

/// A single prevout has been provided but all prevouts are needed without `ANYONECANPAY`
Expand Down Expand Up @@ -271,7 +271,7 @@ impl<R: Deref<Target = Transaction>> SigHashCache<R> {
}

/// Encode the BIP341 signing data for any flag type into a given object implementing a
/// std::io::Write trait.
/// io::Write trait.
pub fn taproot_encode_signing_data_to<Write: io::Write>(
&mut self,
mut writer: Write,
Expand Down Expand Up @@ -433,7 +433,7 @@ impl<R: Deref<Target = Transaction>> SigHashCache<R> {
}

/// Encode the BIP143 signing data for any flag type into a given object implementing a
/// [std::io::Write] trait.
/// [`std::io::Write`] trait.
pub fn segwit_encode_signing_data_to<Write: io::Write>(
&mut self,
mut writer: Write,
Expand Down Expand Up @@ -517,7 +517,7 @@ impl<R: Deref<Target = Transaction>> SigHashCache<R> {
}

/// Encode the legacy signing data for any flag type into a given object implementing a
/// [std::io::Write] trait. Internally calls [Transaction::encode_signing_data_to]
/// [`std::io::Write`] trait. Internally calls [`Transaction::encode_signing_data_to`]
pub fn legacy_encode_signing_data_to<Write: io::Write, U: Into<u32>>(
&self,
mut writer: Write,
Expand Down

0 comments on commit c704ee7

Please sign in to comment.