Merge rust-bitcoin/rust-bitcoin#2761: psbt: documentation examples for PsbtSighashType

4f0eafa2b1 psbt: documentation examples for PsbtSighashType (Jose Storopoli)

Pull request description:

  Partially addresses #2751 by adding examples (testable code) for `PsbtSighashType`

ACKs for top commit:
  tcharding:
    ACK 4f0eafa2b1
  apoelstra:
    ACK 4f0eafa2b1

Tree-SHA512: 4ba728d2a73f25440bda2c0953ca3bab9e6c97604c3ecd9a564a56f3a685131c6f53366a9c5fad9e237b87f8541fea20e281e3181d864a99651a1a071dcd473a
This commit is contained in:
Andrew Poelstra 2024-05-13 13:40:11 +00:00
commit 4e45950483
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 10 additions and 0 deletions

View File

@ -136,6 +136,16 @@ pub struct Input {
/// type can be either [`EcdsaSighashType`] or [`TapSighashType`] but it is not possible to know
/// directly which signature hash type the user is dealing with. Therefore, the user is responsible
/// for converting to/from [`PsbtSighashType`] from/to the desired signature hash type they need.
///
/// # Examples
///
/// ```
/// use bitcoin::{EcdsaSighashType, TapSighashType};
/// use bitcoin::psbt::PsbtSighashType;
///
/// let ecdsa_sighash_all: PsbtSighashType = EcdsaSighashType::All.into();
/// let tap_sighash_all: PsbtSighashType = TapSighashType::All.into();
/// ```
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]