Documentation
¶
Index ¶
- Constants
- func BuildForfeitTx(vtxoOutpoint *wire.OutPoint, vtxoAmount btcutil.Amount, ...) (*wire.MsgTx, error)
- func BuildForfeitTxWithContext(vtxoOutpoint *wire.OutPoint, vtxoAmount btcutil.Amount, ...) (*wire.MsgTx, error)
- func NewForfeitPrevOutFetcher(vtxo *VTXOSpendContext, connector *ConnectorSpendContext) (txscript.PrevOutputFetcher, error)
- func NewVTXOCollabSignDescriptor(vtxo *VTXOSpendContext, keyDesc keychain.KeyDescriptor, inputIndex int, ...) (*input.SignDescriptor, *arkscript.SpendInfo, error)
- func ValidateForfeitTx(forfeitTx *wire.MsgTx, params ForfeitTxParams) error
- type ConnectorSpendContext
- type ForfeitTxContext
- type ForfeitTxParams
- type VTXOSpendContext
Constants ¶
const ( // ForfeitVTXOInputIndex is the index of the VTXO input in the // forfeit tx. ForfeitVTXOInputIndex = 0 // ForfeitConnectorInputIndex is the index of the connector input. ForfeitConnectorInputIndex = 1 // ForfeitPenaltyOutputIndex is the index of the penalty output that // pays to the server's forfeit address. ForfeitPenaltyOutputIndex = 0 // ForfeitAnchorOutputIndex is the index of the ephemeral anchor output // for fee bumping via CPFP. ForfeitAnchorOutputIndex = 1 )
Variables ¶
This section is empty.
Functions ¶
func BuildForfeitTx ¶
func BuildForfeitTx(vtxoOutpoint *wire.OutPoint, vtxoAmount btcutil.Amount, connectorOutpoint *wire.OutPoint, connectorAmount btcutil.Amount, serverForfeitScript []byte) (*wire.MsgTx, error)
BuildForfeitTx creates a 2-input (VTXO + connector), 2-output (penalty + anchor) transaction.
func BuildForfeitTxWithContext ¶
func BuildForfeitTxWithContext(vtxoOutpoint *wire.OutPoint, vtxoAmount btcutil.Amount, connectorOutpoint *wire.OutPoint, connectorAmount btcutil.Amount, serverForfeitScript []byte, ctx ForfeitTxContext) (*wire.MsgTx, error)
BuildForfeitTxWithContext creates a forfeit transaction using the supplied tx-level requirements for the VTXO input spend path.
func NewForfeitPrevOutFetcher ¶
func NewForfeitPrevOutFetcher(vtxo *VTXOSpendContext, connector *ConnectorSpendContext) (txscript.PrevOutputFetcher, error)
NewForfeitPrevOutFetcher builds a prev-output fetcher for the two inputs.
func NewVTXOCollabSignDescriptor ¶
func NewVTXOCollabSignDescriptor(vtxo *VTXOSpendContext, keyDesc keychain.KeyDescriptor, inputIndex int, sigHashes *txscript.TxSigHashes, prevFetcher txscript.PrevOutputFetcher) (*input.SignDescriptor, *arkscript.SpendInfo, error)
NewVTXOCollabSignDescriptor returns the sign descriptor + spend info for a collaborative VTXO spend.
func ValidateForfeitTx ¶
func ValidateForfeitTx(forfeitTx *wire.MsgTx, params ForfeitTxParams) error
ValidateForfeitTx verifies that the forfeit transaction has the expected structure before signing. This validation is critical because once a VTXO actor signs a forfeit tx, they authorize the operator to claim their funds if they attempt to exit unilaterally. By validating the structure, we ensure the operator cannot construct a malformed transaction that violates the protocol rules.
The function checks:
- Exactly 2 inputs: VTXO at index 0, connector at index 1
- Exactly 2 outputs: penalty at index 0, P2A anchor at index 1
- Inputs match expected outpoints
- Penalty output pays to server's forfeit script
- Anchor output is standard P2A with zero value
Types ¶
type ConnectorSpendContext ¶
type ConnectorSpendContext struct {
// Outpoint is the outpoint of the connector output being spent.
Outpoint wire.OutPoint
// Output is the transaction output containing the connector script and
// amount (typically dust).
Output *wire.TxOut
}
ConnectorSpendContext describes the connector input being spent.
type ForfeitTxContext ¶
type ForfeitTxContext struct {
// VTXOSequence is the nSequence value for the VTXO input.
VTXOSequence uint32
// LockTime is the transaction nLockTime required by the chosen leaf.
LockTime uint32
}
ForfeitTxContext describes the tx-level requirements for a specific VTXO spend path used by a forfeit transaction.
type ForfeitTxParams ¶
type ForfeitTxParams struct {
// VTXOOutpoint is the expected VTXO input outpoint.
VTXOOutpoint wire.OutPoint
// ConnectorOutpoint is the expected connector input outpoint.
ConnectorOutpoint wire.OutPoint
// ServerForfeitScript is the expected penalty output script.
ServerForfeitScript []byte
// ExpectedAmount is the expected value of the penalty output. If zero,
// the amount check is skipped (useful when the caller doesn't know the
// exact amount but wants to validate structure).
ExpectedAmount btcutil.Amount
// ExpectedSequence is the expected nSequence for the VTXO
// input. Zero means the default final sequence is expected.
ExpectedSequence uint32
// ExpectedLockTime is the expected transaction nLockTime.
ExpectedLockTime uint32
}
ForfeitTxParams contains the expected parameters for validating a forfeit transaction structure. This is used to verify that a forfeit tx built by a VTXO actor matches the expected structure before submitting to the server.
type VTXOSpendContext ¶
type VTXOSpendContext struct {
// Outpoint is the outpoint of the VTXO output being spent.
Outpoint wire.OutPoint
// Output is the transaction output containing the VTXO script and
// amount.
Output *wire.TxOut
// TapScript contains the taproot script details for the VTXO,
// including the internal key and all script paths.
TapScript *waddrmgr.Tapscript
}
VTXOSpendContext describes the VTXO being spent.