chanvalidate

package
v0.12.1-beta-branch Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidOutPoint is returned when the ChanLocator is unable to
	// find the target outpoint.
	ErrInvalidOutPoint = fmt.Errorf("output meant to create channel cannot " +
		"be found")

	// ErrWrongPkScript is returned when the alleged funding transaction is
	// found to have an incorrect pkSript.
	ErrWrongPkScript = fmt.Errorf("wrong pk script")

	// ErrInvalidSize is returned when the alleged funding transaction
	// output has the wrong size (channel capacity).
	ErrInvalidSize = fmt.Errorf("channel has wrong size")
)

Functions

func Validate

func Validate(ctx *Context) (*wire.OutPoint, error)

Validate given the specified context, this function validates that the alleged channel is well formed, and spendable (if the optional CommitCtx is specified). If this method returns an error, then the alleged channel is invalid and should be abandoned immediately.

Types

type ChanLocator

type ChanLocator interface {
	// Locate attempts to locate the funding output within the funding
	// transaction. It also returns the final out point of the channel
	// which uniquely identifies the output which creates the channel. If
	// the target output cannot be found, or cannot exist on the funding
	// transaction, then an error is to be returned.
	Locate(*wire.MsgTx) (*wire.TxOut, *wire.OutPoint, error)
}

ChanLocator abstracts away obtaining the output that created the channel, as well as validating its existence given the funding transaction. We need this as there are several ways (outpoint, short chan ID) to identify the output of a channel given the funding transaction.

type CommitmentContext

type CommitmentContext struct {
	// Value is the known size of the channel.
	Value btcutil.Amount

	// FullySignedCommitTx is the fully signed commitment transaction. This
	// should include a valid witness.
	FullySignedCommitTx *wire.MsgTx
}

CommitmentContext is optional validation context that can be passed into the main Validate for self-owned channel. The information in this context allows us to fully verify out initial commitment spend based on the on-chain state of the funding output.

type Context

type Context struct {
	// Locator is a concrete implementation of the ChanLocator interface.
	Locator ChanLocator

	// MultiSigPkScript is the fully serialized witness script of the
	// multi-sig output. This is the final witness program that should be
	// found in the funding output.
	MultiSigPkScript []byte

	// FundingTx is channel funding transaction as found confirmed in the
	// chain.
	FundingTx *wire.MsgTx

	// CommitCtx is an optional additional set of validation context
	// required to validate a self-owned channel. If present, then a full
	// Script VM validation will be performed.
	CommitCtx *CommitmentContext
}

Context is the main validation contxet. For a given channel, all fields but the optional CommitCtx should be populated based on existing known-to-be-valid parameters.

type ErrScriptValidateError

type ErrScriptValidateError struct {
	// contains filtered or unexported fields
}

ErrScriptValidateError is returned when Script VM validation fails for an alleged channel output.

func (*ErrScriptValidateError) Error

func (e *ErrScriptValidateError) Error() string

Error returns a human readable string describing the error.

func (*ErrScriptValidateError) Unwrap

func (e *ErrScriptValidateError) Unwrap() error

Unwrap returns the underlying wrapped VM execution failure error.

type OutPointChanLocator

type OutPointChanLocator struct {
	// ChanPoint is the expected chan point.
	ChanPoint wire.OutPoint
}

OutPointChanLocator is an implementation of the ChanLocator that can be used when one already knows the expected chan point.

func (*OutPointChanLocator) Locate

func (o *OutPointChanLocator) Locate(fundingTx *wire.MsgTx) (
	*wire.TxOut, *wire.OutPoint, error)

Locate attempts to locate the funding output within the passed funding transaction.

NOTE: Part of the ChanLocator interface.

type ShortChanIDChanLocator

type ShortChanIDChanLocator struct {
	// ID is the short channel ID of the target channel.
	ID lnwire.ShortChannelID
}

ShortChanIDChanLocator is an implementation of the ChanLocator that can be used when one only knows the short channel ID of a channel. This should be used in contexts when one is verifying a 3rd party channel.

func (*ShortChanIDChanLocator) Locate

func (s *ShortChanIDChanLocator) Locate(fundingTx *wire.MsgTx) (
	*wire.TxOut, *wire.OutPoint, error)

Locate attempts to locate the funding output within the passed funding transaction.

NOTE: Part of the ChanLocator interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL