Merge rust-bitcoin/rust-bitcoin#7119: Use SegWit consistently in docs and comments
What changed, and why it matters
This commit only fixes capitalization of the term 'SegWit' in documentation, comments, and test messages across the rust-bitcoin codebase. No code behavior changes, no security fix or vulnerability introduced.
No security action needed; this is a non-functional documentation cleanup. Normal review/merge hygiene applies.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The merge commit (308092ef) is a documentation-only consistency patch. It changes occurrences of ‘segwit’/’Segwit’ to ‘SegWit’ in doc comments, inline comments, and test assertion messages in 15 files. No executable logic, API signatures, serialization, cryptography, or consensus code is modified. There is no functional diff beyond prose capitalization.
Changed components
Inspect captured patch +32 / −32
### bitcoin/src/address.rs
@@ -2,7 +2,7 @@
//! Bitcoin addresses.
//!
-//! Support for segwit and legacy addresses (bech32 and base58 respectively).
+//! Support for SegWit and legacy addresses (bech32 and base58 respectively).
//!
//! # Examples
//!
### bitcoin/src/blockdata/script/owned.rs
@@ -125,7 +125,7 @@ crate::internal_macros::define_extension_trait! {
/// Constructs a scriptSig required to spend a P2SH-P2WPKH output.
///
/// The scriptSig pushes the P2WPKH redeem script (`0 <20-byte-pubkey-hash>`) which
- /// is required when spending a P2SH-wrapped Segwit output. The witness data should
+ /// is required when spending a P2SH-wrapped SegWit output. The witness data should
/// be provided separately using [`WitnessExt::p2wpkh`].
///
/// [`WitnessExt::p2wpkh`]: crate::blockdata::witness::WitnessExt::p2wpkh
@@ -137,7 +137,7 @@ crate::internal_macros::define_extension_trait! {
/// Constructs a scriptSig required to spend a P2SH-P2WSH output.
///
/// The scriptSig pushes the P2WSH redeem script (`0 <32-byte-script-hash>`) which
- /// is required when spending a P2SH-wrapped Segwit output. The witness data should
+ /// is required when spending a P2SH-wrapped SegWit output. The witness data should
/// be provided separately using [`WitnessExt::p2wsh`].
///
/// [`WitnessExt::p2wsh`]: crate::blockdata::witness::WitnessExt::p2wsh
### bitcoin/src/blockdata/script/witness_version.rs
@@ -28,7 +28,7 @@ impl TryFrom<Instruction<'_>> for WitnessVersion {
}
}
-/// Error types for the segwit version number.
+/// Error types for the SegWit version number.
pub mod error {
use core::convert::Infallible;
use core::fmt;
### bitcoin/src/blockdata/transaction.rs
@@ -125,7 +125,7 @@ internal_macros::define_extension_trait! {
/// Keep in mind that when adding a TxIn to a transaction, the total weight of the transaction
/// might increase more than `TxIn::segwit_weight`. This happens when:
/// - the new input added causes the input length `CompactSize` to increase its encoding length
- /// - the new input is the first segwit input added - this will add an additional 2WU to the
+ /// - the new input is the first SegWit input added - this will add an additional 2WU to the
/// transaction weight to take into account the SegWit marker
///
/// # Panics
### bitcoin/src/blockdata/witness.rs
@@ -124,11 +124,11 @@ internal_macros::define_extension_trait! {
P2TrSpend::from_witness(self)?.annex()
}
- /// Get the Segwit version 0 witness script.
+ /// Get the SegWit version 0 witness script.
///
/// Unlike the Taproot case, we do no validation to determine whether this is a
/// witness script: it may be a Taproot control block, annex, or some other kind
- /// of object. If you are not certain whether the output being spent is Segwit v0,
+ /// of object. If you are not certain whether the output being spent is SegWit v0,
/// use [`crate::script::Script::is_p2wsh`] on the output's script.
fn witness_script(&self) -> Option<&WitnessScript> { self.last().map(WitnessScript::from_bytes) }
}
### crypto/src/sighash.rs
@@ -118,7 +118,7 @@ pub enum EcdsaSighashType {
SinglePlusAnyoneCanPay,
/// Any other value: consensus-valid but non-standard
///
- /// The value is a `u32` because the legacy and segwit v0 signing algorithms hash the
+ /// The value is a `u32` because the legacy and SegWit v0 signing algorithms hash the
/// sighash type as 4 bytes, even though only the lowest byte is appended to the
/// signature in a transaction. On bitcoin the higher bits are always zero, but on replay-protected forks they are
/// sometimes set.
### docs/crates.md
@@ -9,7 +9,7 @@ entry in [roadmap.md] and likely also a file of their own.
## Current crates
- `addresses`: **Empty** placeholder (see future crates below).
-- `base58`: Bitcoin base58 encoding and decoding (for pre-segwit addresses).
+- `base58`: Bitcoin base58 encoding and decoding (for pre-SegWit addresses).
- `bitcoin`: The `rust-bitcoin` crate.
- `chacha20_poly1305`: ChaCha20 stream cipher with the Poly1305 MAC.
- `consensus_encoding`: Consensus encoding and decoding.
### fuzz/src/mutate/address.rs
@@ -2,7 +2,7 @@
//!
//! bech32's checksum is a BCH code, and base58's is four bytes of double SHA256 over a
//! positional radix encoding. Neither is invertible by byte mutation, so an unaided fuzzer
-//! essentially never produces a parsable address and the whole segwit path goes unexercised.
+//! essentially never produces a parsable address and the whole SegWit path goes unexercised.
//!
//! So rather than mutate the string, this mutator decodes it into a record, mutates the
//! record, and re-encodes.
@@ -12,7 +12,7 @@ use bitcoin::bech32::{self, Bech32, Bech32m, Fe32, Hrp};
use super::{Mutate, Rng};
-/// Longest program the unchecked segwit encoder takes without silently truncating.
+/// Longest program the unchecked SegWit encoder takes without silently truncating.
///
/// It writes into a fixed 90 byte buffer and drops whatever does not fit, which would leave a
/// string whose checksum is wrong for the wrong reason. The worst case is the longest HRP:
@@ -42,17 +42,17 @@ fn base58_decode(s: &str) -> Option<Vec<u8>> { bitcoin::base58::decode_check(s).
/// What kind of address a record describes.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum Form {
- /// A valid segwit address.
+ /// A valid SegWit address.
Segwit,
- /// A segwit address with a correct checksum but an invalid witness program, which is what
+ /// A SegWit address with a correct checksum but an invalid witness program, which is what
/// reaches the error paths behind `bech32::segwit::decode`.
SegwitNearMiss,
/// A base58check address.
Base58,
}
impl Form {
- /// Picks a form, weighted towards valid segwit addresses: those are the ones the target
+ /// Picks a form, weighted towards valid SegWit addresses: those are the ones the target
/// could never reach on its own, and the only ones its roundtrip assertion runs on.
fn pick(rng: &mut Rng) -> Self {
match rng.below(4) {
@@ -71,7 +71,7 @@ struct Record {
uppercase: bool,
/// Whether to build a base58 payload the parser is bound to reject.
malform: bool,
- /// Witness version for the segwit forms, prefix byte for base58.
+ /// Witness version for the SegWit forms, prefix byte for base58.
version: u8,
program: [u8; MAX_PROGRAM],
program_len: usize,
### primitives/src/block.rs
@@ -1870,7 +1870,7 @@ mod tests {
}];
let block = Block::new_unchecked(header, transactions);
- // Transaction with no inputs uses segwit serialization:
+ // Transaction with no inputs uses SegWit serialization:
// version (4) + marker (1) + flag (1) + input_count (1) + output_count (1) + lock_time (4)
let want = "010000009999999999999999999999999999999999999999999999999999999999999999777777777777777777777777777777777777777777777777777777777777777702000000030000000400000001010000000001000000000000";
### primitives/src/hash_types/ntxid.rs
@@ -13,9 +13,9 @@ use hashes::sha256d;
///
/// Computed on a transaction that has had the signatures removed.
///
-/// This type is needed only for legacy (pre-Segwit or P2SH-wrapped segwit version 0)
+/// This type is needed only for legacy (pre-SegWit or P2SH-wrapped SegWit version 0)
/// applications. Computing it clears the `script_sig` and `witness` fields of each input. The
-/// `script_sig` in Segwit transactions is already empty, so for Segwit transactions the ntxid
+/// `script_sig` in SegWit transactions is already empty, so for SegWit transactions the ntxid
/// will be equal to the txid, and you should simply use the latter.
///
/// This gives a way to identify a transaction that is "the same" as another in the sense of
### primitives/src/hash_types/witness_script_hash.rs
@@ -68,7 +68,7 @@ impl WScriptHash {
/// Constructs a new [`WScriptHash`] from any script irrespective of script size.
///
- /// If you hash a script that exceeds 10,000 bytes in size and use it to create a Segwit
+ /// If you hash a script that exceeds 10,000 bytes in size and use it to create a SegWit
/// output then the output will be unspendable (see [BIP-0141]).
///
/// ref: [BIP-0141](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki)
### primitives/src/script/mod.rs
@@ -96,15 +96,15 @@ pub type TapScriptBuf = ScriptBuf<TapScriptTag>;
/// A reference to a Segwit v1 Taproot script.
pub type TapScript = Script<TapScriptTag>;
-/// A Segwit v0 witness script.
+/// A SegWit v0 witness script.
pub type WitnessScriptBuf = ScriptBuf<WitnessScriptTag>;
-/// A reference to a Segwit v0 witness script.
+/// A reference to a SegWit v0 witness script.
pub type WitnessScript = Script<WitnessScriptTag>;
/// A reference to a script code (scriptCode) used in sighash computation.
///
-/// Used for legacy and Segwit v0 signature hashing. The `AsRef` implementations on
+/// Used for legacy and SegWit v0 signature hashing. The `AsRef` implementations on
/// [`WitnessScript`], [`RedeemScript`], [`ScriptPubKey`], and their owned `Buf` variants
/// borrow the entire script.
///
@@ -114,7 +114,7 @@ pub type WitnessScript = Script<WitnessScriptTag>;
/// `OP_CODESEPARATOR` before the signature checking opcode. If no
/// `OP_CODESEPARATOR` has executed, no prefix is removed.
///
-/// For Segwit v0, all `OP_CODESEPARATOR` instructions in the remaining script are
+/// For SegWit v0, all `OP_CODESEPARATOR` instructions in the remaining script are
/// kept, including those in unexecuted branches (see [BIP-0143]). For legacy
/// signature hashing, the remaining `OP_CODESEPARATOR` instructions are removed
/// when encoding the signing data.
@@ -147,15 +147,15 @@ pub(crate) fn new_witness_program_unchecked<T: AsRef<PushBytes>, Tg>(
Builder::new().push_opcode(version.into()).push_slice(program).into_script()
}
-/// Either a redeem script or a Segwit version 0 scriptpubkey.
+/// Either a redeem script or a SegWit version 0 scriptpubkey.
///
-/// In the case of P2SH-wrapped Segwit version outputs, we take a Segwit scriptPubKey
+/// In the case of P2SH-wrapped SegWit version outputs, we take a SegWit scriptPubKey
/// and put it in a redeem script slot. The Bitcoin script interpreter has special
/// logic to handle this case, which is reflected in our API in several methods
/// relating to P2SH and signature hashing. These methods take either a normal
-/// P2SH redeem script, or a Segwit version 0 scriptpubkey.
+/// P2SH redeem script, or a SegWit version 0 scriptpubkey.
///
-/// Segwit version 1 (Taproot) and higher do **not** support P2SH-wrapping, and hashing
+/// SegWit version 1 (Taproot) and higher do **not** support P2SH-wrapping, and hashing
/// such a script with [`ScriptHash::from_script`] returns an error.
pub trait ScriptHashableTag: sealed::Sealed {}
### primitives/src/script/tag.rs
@@ -44,7 +44,7 @@ impl Tag for SignetBlockScriptTag {}
pub enum TapScriptTag {}
impl Tag for TapScriptTag {}
-/// A Segwit v0 witness script.
+/// A SegWit v0 witness script.
#[derive(Debug, Clone, PartialOrd, Ord, PartialEq, Eq, Hash)]
pub enum WitnessScriptTag {}
impl Tag for WitnessScriptTag {}
### primitives/src/witness_version.rs
@@ -45,8 +45,8 @@ pub use self::error::{ParseWitnessVersionError, InvalidWitnessVersionError};
/// ]);
///
/// match script_pubkey.witness_version() {
-/// Some(WitnessVersion::V0) => println!("segwit v0 output (P2WPKH or P2WSH)"),
-/// Some(WitnessVersion::V1) => println!("segwit v1 output (Taproot)"),
+/// Some(WitnessVersion::V0) => println!("SegWit v0 output (P2WPKH or P2WSH)"),
+/// Some(WitnessVersion::V1) => println!("SegWit v1 output (Taproot)"),
/// Some(version) => println!("unknown witness version: {}", version),
/// None => println!("not a witness program"),
/// }
@@ -226,7 +226,7 @@ impl<'a> Arbitrary<'a> for WitnessVersion {
}
}
-/// Error types for the segwit version number.
+/// Error types for the SegWit version number.
pub mod error {
use core::convert::Infallible;
use core::fmt;
### primitives/tests/encoding.rs
@@ -337,7 +337,7 @@ fn decode_segwit_without_witnesses_errors() {
let mut slice = tx_bytes.as_slice();
let err = Transaction::decoder()
.push_bytes(&mut slice)
- .expect_err("segwit tx with no witnesses should error");
+ .expect_err("SegWit tx with no witnesses should error");
assert!(matches!(err, TransactionDecoderError { .. }));
}Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.