Creates a new output template for use in a Bitcoin transaction.
The parameters for the output
The Bitcoin address to send funds to
OptionalamountSats?: stringThe amount to send in satoshis (as a string). Optional for malleable outputs.
Optionallocked?: booleanWhether the output amount is locked (immutable)
Get the recipient address
Get the amount in BTC
The amount in BTC (as a string)
Get the amount in satoshis
The amount in satoshis (as a string)
Set amount in satoshis
Check if the output is malleable (can be modified)
Checks if the output is valid according to basic Bitcoin transaction rules.
This method performs several checks to ensure the output is properly formed:
For locked outputs:
For all output types:
Note: This method does not perform exhaustive validation. For more thorough checks, consider implementing a separate, comprehensive validation method.
Special considerations:
True if the output is valid, false otherwise.
Locks the output, preventing further modifications to its amount.
This method sets the malleability of the output to false. Once called, the output amount cannot be changed. If the output is already locked, this method has no effect.
Typical use cases include:
An amount must be specified before locking. This is to prevent locking an output with a zero amount, which could lead to invalid transactions.
Represents a Bitcoin transaction output