sweep

package
v0.5.1-beta-rc4 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

Types

type BaseInput

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

BaseInput contains all the information needed to sweep a basic output (CSV/CLTV/no time lock)

func MakeBaseInput

func MakeBaseInput(outpoint *wire.OutPoint, witnessType lnwallet.WitnessType,
	signDescriptor *lnwallet.SignDescriptor) BaseInput

MakeBaseInput assembles a new BaseInput that can be used to construct a sweep transaction.

func (*BaseInput) BlocksToMaturity

func (bi *BaseInput) BlocksToMaturity() uint32

BlocksToMaturity returns the relative timelock, as a number of blocks, that must be built on top of the confirmation height before the output can be spent. For non-CSV locked inputs this is always zero.

func (*BaseInput) BuildWitness

func (bi *BaseInput) BuildWitness(signer lnwallet.Signer, txn *wire.MsgTx,
	hashCache *txscript.TxSigHashes, txinIdx int) ([][]byte, error)

BuildWitness computes a valid witness that allows us to spend from the breached output. It does so by generating the witness generation function, which is parameterized primarily by the witness type and sign descriptor. The method then returns the witness computed by invoking this function.

func (*BaseInput) OutPoint

func (i *BaseInput) OutPoint() *wire.OutPoint

OutPoint returns the breached output's identifier that is to be included as a transaction input.

func (*BaseInput) SignDesc

func (i *BaseInput) SignDesc() *lnwallet.SignDescriptor

SignDesc returns the breached output's SignDescriptor, which is used during signing to compute the witness.

func (*BaseInput) WitnessType

func (i *BaseInput) WitnessType() lnwallet.WitnessType

WitnessType returns the type of witness that must be generated to spend the breached output.

type HtlcSucceedInput

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

HtlcSucceedInput constitutes a sweep input that needs a pre-image. The input is expected to reside on the commitment tx of the remote party and should not be a second level tx output.

func MakeHtlcSucceedInput

func MakeHtlcSucceedInput(outpoint *wire.OutPoint,
	signDescriptor *lnwallet.SignDescriptor,
	preimage []byte) HtlcSucceedInput

MakeHtlcSucceedInput assembles a new redeem input that can be used to construct a sweep transaction.

func (*HtlcSucceedInput) BlocksToMaturity

func (h *HtlcSucceedInput) BlocksToMaturity() uint32

BlocksToMaturity returns the relative timelock, as a number of blocks, that must be built on top of the confirmation height before the output can be spent.

func (*HtlcSucceedInput) BuildWitness

func (h *HtlcSucceedInput) BuildWitness(signer lnwallet.Signer, txn *wire.MsgTx,
	hashCache *txscript.TxSigHashes, txinIdx int) ([][]byte, error)

BuildWitness computes a valid witness that allows us to spend from the breached output. For HtlcSpendInput it will need to make the preimage part of the witness.

func (*HtlcSucceedInput) OutPoint

func (i *HtlcSucceedInput) OutPoint() *wire.OutPoint

OutPoint returns the breached output's identifier that is to be included as a transaction input.

func (*HtlcSucceedInput) SignDesc

func (i *HtlcSucceedInput) SignDesc() *lnwallet.SignDescriptor

SignDesc returns the breached output's SignDescriptor, which is used during signing to compute the witness.

func (*HtlcSucceedInput) WitnessType

func (i *HtlcSucceedInput) WitnessType() lnwallet.WitnessType

WitnessType returns the type of witness that must be generated to spend the breached output.

type Input

type Input interface {
	// Outpoint returns the reference to the output being spent, used to
	// construct the corresponding transaction input.
	OutPoint() *wire.OutPoint

	// WitnessType returns an enum specifying the type of witness that must
	// be generated in order to spend this output.
	WitnessType() lnwallet.WitnessType

	// SignDesc returns a reference to a spendable output's sign
	// descriptor, which is used during signing to compute a valid witness
	// that spends this output.
	SignDesc() *lnwallet.SignDescriptor

	// BuildWitness returns a valid witness allowing this output to be
	// spent, the witness should be attached to the transaction at the
	// location determined by the given `txinIdx`.
	BuildWitness(signer lnwallet.Signer, txn *wire.MsgTx,
		hashCache *txscript.TxSigHashes,
		txinIdx int) ([][]byte, error)

	// BlocksToMaturity returns the relative timelock, as a number of
	// blocks, that must be built on top of the confirmation height before
	// the output can be spent. For non-CSV locked inputs this is always
	// zero.
	BlocksToMaturity() uint32
}

Input contains all data needed to construct a sweep tx input.

type UtxoSweeper

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

UtxoSweeper provides the functionality to generate sweep txes. The plan is to extend UtxoSweeper in the future to also manage the actual sweeping process by itself.

func New

func New(cfg *UtxoSweeperConfig) *UtxoSweeper

New returns a new UtxoSweeper instance.

func (*UtxoSweeper) CreateSweepTx

func (s *UtxoSweeper) CreateSweepTx(inputs []Input, confTarget uint32,
	currentBlockHeight uint32) (*wire.MsgTx, error)

CreateSweepTx accepts a list of inputs and signs and generates a txn that spends from them. This method also makes an accurate fee estimate before generating the required witnesses.

The created transaction has a single output sending all the funds back to the source wallet, after accounting for the fee estimate.

The value of currentBlockHeight argument will be set as the tx locktime. This function assumes that all CLTV inputs will be unlocked after currentBlockHeight. Reasons not to use the maximum of all actual CLTV expiry values of the inputs:

- Make handling re-orgs easier. - Thwart future possible fee sniping attempts. - Make us blend in with the bitcoind wallet.

type UtxoSweeperConfig

type UtxoSweeperConfig struct {
	// GenSweepScript generates a P2WKH script belonging to the wallet
	// where funds can be swept.
	GenSweepScript func() ([]byte, error)

	// Estimator is used when crafting sweep transactions to estimate the
	// necessary fee relative to the expected size of the sweep
	// transaction.
	Estimator lnwallet.FeeEstimator

	// Signer is used by the sweeper to generate valid witnesses at the
	// time the incubated outputs need to be spent.
	Signer lnwallet.Signer
}

UtxoSweeperConfig contains dependencies of UtxoSweeper.

Jump to

Keyboard shortcuts

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