pub struct TransactionOutput {
pub satoshis: u64,
pub locking_script: Script,
pub change: bool,
}Expand description
A single output in a BSV transaction.
Each output specifies a satoshi value and a locking_script
(scriptPubKey) that defines the conditions under which the funds
may be spent. The change flag is a local-only annotation used
during fee calculation to identify outputs that should receive any
leftover satoshis; it is not serialized.
§Wire format
| Field | Size |
|---|---|
| satoshis | 8 bytes (LE) |
| script length | VarInt |
| locking_script | variable |
Fields§
§satoshis: u64The number of satoshis (1 satoshi = 10^-8 BSV) locked by this output.
locking_script: ScriptThe locking script (scriptPubKey) that defines spending conditions.
change: boolLocal-only flag marking this output as a change output. Used by fee calculation; not serialized on the wire.
Implementations§
Source§impl TransactionOutput
impl TransactionOutput
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new TransactionOutput with zero satoshis and an empty script.
§Returns
A default TransactionOutput.
Sourcepub fn read_from(reader: &mut BsvReader<'_>) -> Result<Self, TransactionError>
pub fn read_from(reader: &mut BsvReader<'_>) -> Result<Self, TransactionError>
Deserialize a TransactionOutput from a BsvReader.
Reads 8-byte LE satoshis, a varint script length, and the script bytes.
§Arguments
reader- The reader positioned at the start of an encoded output.
§Returns
Ok(TransactionOutput) on success, or a TransactionError if the
data is truncated or malformed.
Sourcepub fn write_to(&self, writer: &mut BsvWriter)
pub fn write_to(&self, writer: &mut BsvWriter)
Serialize this TransactionOutput into a BsvWriter.
Writes 8-byte LE satoshis, a varint script length, and the script.
§Arguments
writer- The writer to append serialized bytes to.
Sourcepub fn bytes_for_sig_hash(&self) -> Vec<u8> ⓘ
pub fn bytes_for_sig_hash(&self) -> Vec<u8> ⓘ
Serialize this output for use in signature hash computation.
The format is identical to to_bytes: satoshis(8) + varint(script_len) + script.
§Returns
A Vec<u8> containing the serialized output suitable for sighash.
Sourcepub fn locking_script_hex(&self) -> String
pub fn locking_script_hex(&self) -> String
Return the locking script as a hex-encoded string.
§Returns
A lowercase hex string of the locking script bytes.
Trait Implementations§
Source§impl Clone for TransactionOutput
impl Clone for TransactionOutput
Source§fn clone(&self) -> TransactionOutput
fn clone(&self) -> TransactionOutput
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more