Skip to content

Commit

Permalink
Merge #852: Improve rustdocs for *_hash_ty methods
Browse files Browse the repository at this point in the history
7638d59 Improve rusntdocs for *_hash_ty methods (Tobin Harding)

Pull request description:

  Recently we added two new methods with rustdocs. The rustdocs have a few minor things that can be improved.

  - Use 'Returns' section for both success and error path returns
  - Use markdown heading for section
  - [Subjectively] improve wording of docs

  @rish-singhal this PR is minor rustdocs stuff that I have recently been learning myself. I hope this makes your future patches easier to do in regards to the docs. FTR there are `# Returns` sections and `# Examples` sections that one can use, no set rules as far as I can tell. I chose `# Returns` in this case because it seemed to work. Please feel free to NACK the wording changes if you do not agree.

ACKs for top commit:
  apoelstra:
    ACK 7638d59
  Kixunil:
    ACK 7638d59

Tree-SHA512: ac1629647a39789e9a162b54440798507c74501ef0a5014bc6dfe2cf5779588a304c059433b8387bbe06f413f0712d1204e4b7d912c79e31f9485f6ddcf9ceba
  • Loading branch information
apoelstra committed Mar 9, 2022
2 parents f733dc0 + 7638d59 commit 337caad
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/util/psbt/map/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,22 +191,24 @@ impl PsbtSigHashType {
}

impl Input {
/// Obtains the [`EcdsaSigHashType`] for this input if one is specified.
/// If no sighash type is specified, returns ['EcdsaSigHashType::All']
/// Obtains the [`EcdsaSigHashType`] for this input if one is specified. If no sighash type is
/// specified, returns [`EcdsaSigHashType::All`].
///
/// Errors:
/// If the sighash type is not a standard ecdsa sighash type
/// # Errors
///
/// If the `sighash_type` field is set to a non-standard ECDSA sighash value.
pub fn ecdsa_hash_ty(&self) -> Result<EcdsaSigHashType, NonStandardSigHashType> {
self.sighash_type
.map(|sighash_type| sighash_type.ecdsa_hash_ty())
.unwrap_or(Ok(EcdsaSigHashType::All))
}

/// Obtains the [`SchnorrSigHashType`] for this input if one is specified.
/// If no sighash type is specified, returns ['SchnorrSigHashType::Default']
/// Obtains the [`SchnorrSigHashType`] for this input if one is specified. If no sighash type is
/// specified, returns [`SchnorrSigHashType::Default`].
///
/// # Errors
///
/// Errors:
/// If the sighash type is an invalid schnorr sighash type
/// If the `sighash_type` field is set to a invalid Schnorr sighash value.
pub fn schnorr_hash_ty(&self) -> Result<SchnorrSigHashType, sighash::Error> {
self.sighash_type
.map(|sighash_type| sighash_type.schnorr_hash_ty())
Expand Down

0 comments on commit 337caad

Please sign in to comment.