Run the formatter

Run `cargo +nightly fmt`, no manual changes.
This commit is contained in:
Tobin C. Harding 2024-08-27 16:27:41 +10:00
parent 02c7d504fa
commit 8b089ffe40
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 47 additions and 46 deletions

View File

@ -355,57 +355,58 @@ impl TxOut {
}
mod tmp {
use super::*;
impl TxOut {
/// The weight of this output.
///
/// Keep in mind that when adding a [`TxOut`] to a [`Transaction`] the total weight of the
/// transaction might increase more than `TxOut::weight`. This happens when the new output added
/// causes the output length `VarInt` to increase its encoding length.
///
/// # Panics
///
/// If output size * 4 overflows, this should never happen under normal conditions. Use
/// `Weght::from_vb_checked(self.size().to_u64())` if you are concerned.
pub fn weight(&self) -> Weight {
// Size is equivalent to virtual size since all bytes of a TxOut are non-witness bytes.
Weight::from_vb(self.size().to_u64()).expect("should never happen under normal conditions")
}
use super::*;
impl TxOut {
/// The weight of this output.
///
/// Keep in mind that when adding a [`TxOut`] to a [`Transaction`] the total weight of the
/// transaction might increase more than `TxOut::weight`. This happens when the new output added
/// causes the output length `VarInt` to increase its encoding length.
///
/// # Panics
///
/// If output size * 4 overflows, this should never happen under normal conditions. Use
/// `Weght::from_vb_checked(self.size().to_u64())` if you are concerned.
pub fn weight(&self) -> Weight {
// Size is equivalent to virtual size since all bytes of a TxOut are non-witness bytes.
Weight::from_vb(self.size().to_u64())
.expect("should never happen under normal conditions")
}
/// Returns the total number of bytes that this output contributes to a transaction.
///
/// There is no difference between base size vs total size for outputs.
pub fn size(&self) -> usize { size_from_script_pubkey(&self.script_pubkey) }
/// Returns the total number of bytes that this output contributes to a transaction.
///
/// There is no difference between base size vs total size for outputs.
pub fn size(&self) -> usize { size_from_script_pubkey(&self.script_pubkey) }
/// Creates a `TxOut` with given script and the smallest possible `value` that is **not** dust
/// per current Core policy.
///
/// Dust depends on the -dustrelayfee value of the Bitcoin Core node you are broadcasting to.
/// This function uses the default value of 0.00003 BTC/kB (3 sat/vByte).
///
/// To use a custom value, use [`minimal_non_dust_custom`].
///
/// [`minimal_non_dust_custom`]: TxOut::minimal_non_dust_custom
pub fn minimal_non_dust(script_pubkey: ScriptBuf) -> Self {
TxOut { value: script_pubkey.minimal_non_dust(), script_pubkey }
}
/// Creates a `TxOut` with given script and the smallest possible `value` that is **not** dust
/// per current Core policy.
///
/// Dust depends on the -dustrelayfee value of the Bitcoin Core node you are broadcasting to.
/// This function uses the default value of 0.00003 BTC/kB (3 sat/vByte).
///
/// To use a custom value, use [`minimal_non_dust_custom`].
///
/// [`minimal_non_dust_custom`]: TxOut::minimal_non_dust_custom
pub fn minimal_non_dust(script_pubkey: ScriptBuf) -> Self {
TxOut { value: script_pubkey.minimal_non_dust(), script_pubkey }
}
/// Creates a `TxOut` with given script and the smallest possible `value` that is **not** dust
/// per current Core policy.
///
/// Dust depends on the -dustrelayfee value of the Bitcoin Core node you are broadcasting to.
/// This function lets you set the fee rate used in dust calculation.
///
/// The current default value in Bitcoin Core (as of v26) is 3 sat/vByte.
///
/// To use the default Bitcoin Core value, use [`minimal_non_dust`].
///
/// [`minimal_non_dust`]: TxOut::minimal_non_dust
pub fn minimal_non_dust_custom(script_pubkey: ScriptBuf, dust_relay_fee: FeeRate) -> Self {
TxOut { value: script_pubkey.minimal_non_dust_custom(dust_relay_fee), script_pubkey }
/// Creates a `TxOut` with given script and the smallest possible `value` that is **not** dust
/// per current Core policy.
///
/// Dust depends on the -dustrelayfee value of the Bitcoin Core node you are broadcasting to.
/// This function lets you set the fee rate used in dust calculation.
///
/// The current default value in Bitcoin Core (as of v26) is 3 sat/vByte.
///
/// To use the default Bitcoin Core value, use [`minimal_non_dust`].
///
/// [`minimal_non_dust`]: TxOut::minimal_non_dust
pub fn minimal_non_dust_custom(script_pubkey: ScriptBuf, dust_relay_fee: FeeRate) -> Self {
TxOut { value: script_pubkey.minimal_non_dust_custom(dust_relay_fee), script_pubkey }
}
}
}
}
#[cfg(feature = "arbitrary")]
impl<'a> Arbitrary<'a> for TxOut {