Merge rust-bitcoin/rust-bitcoin#2194: Script documentation weirdness and typos

e3f2c4fa43 Fix broken link in CONTRIBUTING.md (Vojtěch Toman)
e1c4986f4a Improve Script documentation and fix typos (Vojtěch Toman)

Pull request description:

  Fixes #2193 (first commit)
  Second commit fixes broken link in `CONTRIBUTING.md`

ACKs for top commit:
  Kixunil:
    ACK e3f2c4fa43
  sanket1729:
    ACK e3f2c4fa43

Tree-SHA512: f7bd83530a071a37028c611afa1dc43de31e57b241403fa9f451be375da3db041f41dc7e07d581d770c76ab7c7a7cc68e27e68bbfc71461fe933128e7b846ae9
This commit is contained in:
Andrew Poelstra 2023-11-16 01:29:08 +00:00
commit c03ef3c219
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
2 changed files with 5 additions and 5 deletions

View File

@ -241,7 +241,7 @@ easy and good test coverage of the codebase is an important goal. Refactoring
the project to enable fine-grained unit testing is also an ongoing effort. the project to enable fine-grained unit testing is also an ongoing effort.
Various methods of testing are in use (e.g. fuzzing, mutation), please see Various methods of testing are in use (e.g. fuzzing, mutation), please see
the [readme](./REAME.md) for more information. the [readme](./README.md) for more information.
## Going further ## Going further

View File

@ -220,7 +220,7 @@ impl Script {
/// ///
/// This may return `None` even when [`is_p2pk()`](Self::is_p2pk) returns true. /// This may return `None` even when [`is_p2pk()`](Self::is_p2pk) returns true.
/// This happens when the public key is invalid (e.g. the point not being on the curve). /// This happens when the public key is invalid (e.g. the point not being on the curve).
/// It also implies the script is unspendable. /// In this situation the script is unspendable.
#[inline] #[inline]
pub fn p2pk_public_key(&self) -> Option<PublicKey> { pub fn p2pk_public_key(&self) -> Option<PublicKey> {
PublicKey::from_slice(self.p2pk_pubkey_bytes()?).ok() PublicKey::from_slice(self.p2pk_pubkey_bytes()?).ok()
@ -521,12 +521,12 @@ impl Script {
InstructionIndices::from_instructions(self.instructions_minimal()) InstructionIndices::from_instructions(self.instructions_minimal())
} }
/// Writes the assembly decoding of the script to the formatter. /// Writes the human-readable assembly representation of the script to the formatter.
pub fn fmt_asm(&self, f: &mut dyn fmt::Write) -> fmt::Result { pub fn fmt_asm(&self, f: &mut dyn fmt::Write) -> fmt::Result {
bytes_to_asm_fmt(self.as_ref(), f) bytes_to_asm_fmt(self.as_ref(), f)
} }
/// Returns the assembly decoding of the script. /// Returns the human-readable assembly representation of the script.
pub fn to_asm_string(&self) -> String { pub fn to_asm_string(&self) -> String {
let mut buf = String::new(); let mut buf = String::new();
self.fmt_asm(&mut buf).unwrap(); self.fmt_asm(&mut buf).unwrap();
@ -537,7 +537,7 @@ impl Script {
/// ///
/// This is a more convenient and performant way to write `format!("{:x}", script)`. /// This is a more convenient and performant way to write `format!("{:x}", script)`.
/// For better performance you should generally prefer displaying the script but if `String` is /// For better performance you should generally prefer displaying the script but if `String` is
/// required (this is common in tests) this method is can be used. /// required (this is common in tests) this method can be used.
pub fn to_hex_string(&self) -> String { self.as_bytes().to_lower_hex_string() } pub fn to_hex_string(&self) -> String { self.as_bytes().to_lower_hex_string() }
/// Returns the first opcode of the script (if there is any). /// Returns the first opcode of the script (if there is any).