utils

package
v0.31.8-beta Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// MaxFeeToAmountRatio is the maximum fee to total amount ratio allowed
	// for a sweep transaction.
	MaxFeeToAmountRatio = 0.2
)

Variables

This section is empty.

Functions

func Bip69Less

func Bip69Less(output1, output2 *wire.TxOut) bool

Bip69Less is taken from btcd in btcutil/txsort/txsort.go.

func ClampSweepFee

func ClampSweepFee(fee btcutil.Amount, totalAmount btcutil.Amount,
	ratio float64, minRelayFeeRate chainfee.SatPerKWeight,
	weight lntypes.WeightUnit) (btcutil.Amount, bool, error)

ClampSweepFee caps a fee to a percentage of the provided total amount and verifies the resulting fee rate is not below the minimum relay fee. It returns the clamped fee, whether it was clamped, or an error if the clamped fee would fall below the minimum relay fee.

func DustLimitForPkScript

func DustLimitForPkScript(pkscript []byte) btcutil.Amount

DustLimitForPkScript returns the dust limit for a given pkScript. An output must be greater or equal to this value.

func GetHtlc

func GetHtlc(hash lntypes.Hash, contract *loopdb.SwapContract,
	chainParams *chaincfg.Params) (*swap.Htlc, error)

GetHtlc composes and returns the on-chain swap script.

func GetHtlcScriptVersion

func GetHtlcScriptVersion(
	protocolVersion loopdb.ProtocolVersion) swap.ScriptVersion

GetHtlcScriptVersion returns the correct HTLC script version for the passed protocol version.

func MuSig2Sign

func MuSig2Sign(version input.MuSig2Version, privKeys []*btcec.PrivateKey,
	pubKeys []*btcec.PublicKey, tweaks *input.MuSig2Tweaks,
	msg [32]byte) ([]byte, error)

MuSig2Sign will create a MuSig2 signature for the passed message using the passed private keys.

func ObtainSwapPaymentAddr

func ObtainSwapPaymentAddr(swapInvoice string, chainParams *chaincfg.Params) (
	*[32]byte, error)

ObtainSwapPaymentAddr will retrieve the payment addr from the passed invoice.

Types

This section is empty.

Jump to

Keyboard shortcuts

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