operation

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const DustThreshold = 546

Variables

This section is empty.

Functions

This section is empty.

Types

type AnalysisStatus

type AnalysisStatus string
const (
	AnalysisStatusOk                       AnalysisStatus = "Ok"
	AnalysisStatusAmountGreaterThanBalance AnalysisStatus = "GreaterThanBalance"
	AnalysisStatusAmountTooSmall           AnalysisStatus = "AmountTooSmall"
	AnalysisStatusUnpayable                AnalysisStatus = "Unpayable"
)

type FeeWindow

type FeeWindow struct {
	TargetedFees map[uint]float64
}

func (*FeeWindow) FastestFeeRate added in v0.10.0

func (f *FeeWindow) FastestFeeRate() float64

FastestFeeRate gets the fastest fee rate, in satoshis per weight unit.

func (*FeeWindow) MinimumFeeRate added in v0.10.0

func (f *FeeWindow) MinimumFeeRate(confirmationTarget uint) (float64, error)

MinimumFeeRate gets the minimum available fee rate that will hit a given confirmation target. We make no guesses (no averages or interpolations), so we might overshoot the fee if data is too sparse. Note: the lower the confirmation target, the faster the tx will confirm, and greater the fee(rate) will be.

func (*FeeWindow) NextHighestBlock added in v0.10.0

func (f *FeeWindow) NextHighestBlock(feeRate float64) uint

NextHighestBlock finds the next highest confirmation/block target for a certain feeRate. Let me explain, we have a map that associates a conf-target with a fee rate. Now we want to know associate a conf-target with a given fee rate. We want the NEXT conf-target as we usually want this data for predictions or estimations and this makes the predictions for the fee rate to "fall on the correct side" (e.g when estimating max time to confirmation for a given fee rate). Note: code is not our best work of art. The target < next comparison is to account for our TargetedFees map not necessarily being sorted.

func (*FeeWindow) SwapFeeRate

func (f *FeeWindow) SwapFeeRate(confirmationsNeeded uint) (float64, error)

SwapFeeRate gets the appropriate fee rate for a given swap (depends on confirmations needed). Useful method for when swap doesn't have a fixed amount (e.g AmountLessInvoices + use all funds).

type NextTransactionSize

type NextTransactionSize struct {
	SizeProgression   []SizeForAmount
	ExpectedDebtInSat int64
}

func (*NextTransactionSize) TotalBalance

func (nts *NextTransactionSize) TotalBalance() int64

func (*NextTransactionSize) UtxoBalance

func (nts *NextTransactionSize) UtxoBalance() int64

type PaymentAnalysis

type PaymentAnalysis struct {
	Status      AnalysisStatus
	AmountInSat int64
	FeeInSat    int64
	SwapFees    *fees.SwapFees
	TotalInSat  int64
}

type PaymentAnalyzer added in v0.10.0

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

func NewPaymentAnalyzer

func NewPaymentAnalyzer(feeWindow *FeeWindow, nts *NextTransactionSize) *PaymentAnalyzer

func (*PaymentAnalyzer) MaxFeeRateToAddress added in v0.10.0

func (a *PaymentAnalyzer) MaxFeeRateToAddress(payment *PaymentToAddress) float64

MaxFeeRateToAddress computes the maximum fee rate that can be used when paying a given amount. This does not imply that the payment _can be made_. When given invalid parameters, it's likely to still obtain a value here and the resulting analysis would be Unpayable. It's up to the caller to first verify the amount is payable, and only then call this method.

func (*PaymentAnalyzer) ToAddress added in v0.10.0

func (a *PaymentAnalyzer) ToAddress(payment *PaymentToAddress) (*PaymentAnalysis, error)

func (*PaymentAnalyzer) ToInvoice added in v0.10.0

func (a *PaymentAnalyzer) ToInvoice(payment *PaymentToInvoice) (*PaymentAnalysis, error)

type PaymentToAddress

type PaymentToAddress struct {
	TakeFeeFromAmount     bool
	AmountInSat           int64
	FeeRateInSatsPerVByte float64
}

type PaymentToInvoice

type PaymentToInvoice struct {
	TakeFeeFromAmount     bool
	AmountInSat           int64
	SwapFees              *fees.SwapFees              // Nullable before we know the paymentAmount for amountless invoice
	BestRouteFees         []fees.BestRouteFees        // Nullable when we know the amount beforehand (invoice with amount)
	FundingOutputPolicies *fees.FundingOutputPolicies // Nullable when we know the amount beforehand (invoice with amount)
}

type SizeForAmount

type SizeForAmount struct {
	AmountInSat int64
	SizeInVByte int64
}

Jump to

Keyboard shortcuts

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