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.
Types ¶
type BitcoindEstimator ¶
type BitcoindEstimator struct {
// contains filtered or unexported fields
}
BitcoindEstimator is an implementation of the Estimator interface backed by the RPC interface of an active bitcoind node. This implementation will proxy any fee estimation requests to bitcoind's RPC interface.
func NewBitcoindEstimator ¶
func NewBitcoindEstimator(rpcConfig rpcclient.ConnConfig, feeMode string, fallBackFeeRate SatPerKWeight) (*BitcoindEstimator, error)
NewBitcoindEstimator creates a new BitcoindEstimator given a fully populated rpc config that is able to successfully connect and authenticate with the bitcoind node, and also a fall back fee rate. The fallback fee rate is used in the occasion that the estimator has insufficient data, or returns zero for a fee estimate.
func (*BitcoindEstimator) EstimateFeePerKW ¶
func (b *BitcoindEstimator) EstimateFeePerKW( numBlocks uint32) (SatPerKWeight, error)
EstimateFeePerKW takes in a target for the number of blocks until an initial confirmation and returns the estimated fee expressed in sat/kw.
NOTE: This method is part of the Estimator interface.
func (*BitcoindEstimator) RelayFeePerKW ¶
func (b *BitcoindEstimator) RelayFeePerKW() SatPerKWeight
RelayFeePerKW returns the minimum fee rate required for transactions to be relayed.
NOTE: This method is part of the Estimator interface.
func (*BitcoindEstimator) Start ¶
func (b *BitcoindEstimator) Start() error
Start signals the Estimator to start any processes or goroutines it needs to perform its duty.
NOTE: This method is part of the Estimator interface.
func (*BitcoindEstimator) Stop ¶
func (b *BitcoindEstimator) Stop() error
Stop stops any spawned goroutines and cleans up the resources used by the fee estimator.
NOTE: This method is part of the Estimator interface.
type BtcdEstimator ¶
type BtcdEstimator struct {
// contains filtered or unexported fields
}
BtcdEstimator is an implementation of the Estimator interface backed by the RPC interface of an active btcd node. This implementation will proxy any fee estimation requests to btcd's RPC interface.
func NewBtcdEstimator ¶
func NewBtcdEstimator(rpcConfig rpcclient.ConnConfig, fallBackFeeRate SatPerKWeight) (*BtcdEstimator, error)
NewBtcdEstimator creates a new BtcdEstimator given a fully populated rpc config that is able to successfully connect and authenticate with the btcd node, and also a fall back fee rate. The fallback fee rate is used in the occasion that the estimator has insufficient data, or returns zero for a fee estimate.
func (*BtcdEstimator) EstimateFeePerKW ¶
func (b *BtcdEstimator) EstimateFeePerKW(numBlocks uint32) (SatPerKWeight, error)
EstimateFeePerKW takes in a target for the number of blocks until an initial confirmation and returns the estimated fee expressed in sat/kw.
NOTE: This method is part of the Estimator interface.
func (*BtcdEstimator) RelayFeePerKW ¶
func (b *BtcdEstimator) RelayFeePerKW() SatPerKWeight
RelayFeePerKW returns the minimum fee rate required for transactions to be relayed.
NOTE: This method is part of the Estimator interface.
func (*BtcdEstimator) Start ¶
func (b *BtcdEstimator) Start() error
Start signals the Estimator to start any processes or goroutines it needs to perform its duty.
NOTE: This method is part of the Estimator interface.
func (*BtcdEstimator) Stop ¶
func (b *BtcdEstimator) Stop() error
Stop stops any spawned goroutines and cleans up the resources used by the fee estimator.
NOTE: This method is part of the Estimator interface.
type Estimator ¶
type Estimator interface { // EstimateFeePerKW takes in a target for the number of blocks until an // initial confirmation and returns the estimated fee expressed in // sat/kw. EstimateFeePerKW(numBlocks uint32) (SatPerKWeight, error) // Start signals the Estimator to start any processes or goroutines // it needs to perform its duty. Start() error // Stop stops any spawned goroutines and cleans up the resources used // by the fee estimator. Stop() error // RelayFeePerKW returns the minimum fee rate required for transactions // to be relayed. This is also the basis for calculation of the dust // limit. RelayFeePerKW() SatPerKWeight }
Estimator provides the ability to estimate on-chain transaction fees for various combinations of transaction sizes and desired confirmation time (measured by number of blocks).
type SatPerKVByte ¶
SatPerKVByte represents a fee rate in sat/kb.
func (SatPerKVByte) FeeForVSize ¶
func (s SatPerKVByte) FeeForVSize(vbytes int64) btcutil.Amount
FeeForVSize calculates the fee resulting from this fee rate and the given vsize in vbytes.
func (SatPerKVByte) FeePerKWeight ¶
func (s SatPerKVByte) FeePerKWeight() SatPerKWeight
FeePerKWeight converts the current fee rate from sat/kb to sat/kw.
func (SatPerKVByte) String ¶
func (s SatPerKVByte) String() string
String returns a human-readable string of the fee rate.
type SatPerKWeight ¶
SatPerKWeight represents a fee rate in sat/kw.
const ( // FeePerKwFloor is the lowest fee rate in sat/kw that we should use for // estimating transaction fees before signing. FeePerKwFloor SatPerKWeight = 253 // AbsoluteFeePerKwFloor is the lowest fee rate in sat/kw of a // transaction that we should ever _create_. This is the the equivalent // of 1 sat/byte in sat/kw. AbsoluteFeePerKwFloor SatPerKWeight = 250 )
func (SatPerKWeight) FeeForWeight ¶
func (s SatPerKWeight) FeeForWeight(wu int64) btcutil.Amount
FeeForWeight calculates the fee resulting from this fee rate and the given weight in weight units (wu).
func (SatPerKWeight) FeePerKVByte ¶
func (s SatPerKWeight) FeePerKVByte() SatPerKVByte
FeePerKVByte converts the current fee rate from sat/kw to sat/kb.
func (SatPerKWeight) String ¶
func (s SatPerKWeight) String() string
String returns a human-readable string of the fee rate.
type SparseConfFeeSource ¶
type SparseConfFeeSource struct { // URL is the fee estimation API specified by the user. URL string }
SparseConfFeeSource is an implementation of the WebAPIFeeSource that utilizes a user-specified fee estimation API for Bitcoin. It expects the response to be in the JSON format: `fee_by_block_target: { ... }` where the value maps block targets to fee estimates (in sat per kilovbyte).
func (SparseConfFeeSource) GenQueryURL ¶
func (s SparseConfFeeSource) GenQueryURL() string
GenQueryURL generates the full query URL. The value returned by this method should be able to be used directly as a path for an HTTP GET request.
NOTE: Part of the WebAPIFeeSource interface.
func (SparseConfFeeSource) ParseResponse ¶
ParseResponse attempts to parse the body of the response generated by the above query URL. Typically this will be JSON, but the specifics are left to the WebAPIFeeSource implementation.
NOTE: Part of the WebAPIFeeSource interface.
type StaticEstimator ¶
type StaticEstimator struct {
// contains filtered or unexported fields
}
StaticEstimator will return a static value for all fee calculation requests. It is designed to be replaced by a proper fee calculation implementation. The fees are not accessible directly, because changing them would not be thread safe.
func NewStaticEstimator ¶
func NewStaticEstimator(feePerKW, relayFee SatPerKWeight) *StaticEstimator
NewStaticEstimator returns a new static fee estimator instance.
func (StaticEstimator) EstimateFeePerKW ¶
func (e StaticEstimator) EstimateFeePerKW(numBlocks uint32) (SatPerKWeight, error)
EstimateFeePerKW will return a static value for fee calculations.
NOTE: This method is part of the Estimator interface.
func (StaticEstimator) RelayFeePerKW ¶
func (e StaticEstimator) RelayFeePerKW() SatPerKWeight
RelayFeePerKW returns the minimum fee rate required for transactions to be relayed.
NOTE: This method is part of the Estimator interface.
func (StaticEstimator) Start ¶
func (e StaticEstimator) Start() error
Start signals the Estimator to start any processes or goroutines it needs to perform its duty.
NOTE: This method is part of the Estimator interface.
func (StaticEstimator) Stop ¶
func (e StaticEstimator) Stop() error
Stop stops any spawned goroutines and cleans up the resources used by the fee estimator.
NOTE: This method is part of the Estimator interface.
type WebAPIEstimator ¶
type WebAPIEstimator struct {
// contains filtered or unexported fields
}
WebAPIEstimator is an implementation of the Estimator interface that queries an HTTP-based fee estimation from an existing web API.
func NewWebAPIEstimator ¶
func NewWebAPIEstimator(api WebAPIFeeSource, noCache bool) *WebAPIEstimator
NewWebAPIEstimator creates a new WebAPIEstimator from a given URL and a fallback default fee. The fees are updated whenever a new block is mined.
func (*WebAPIEstimator) EstimateFeePerKW ¶
func (w *WebAPIEstimator) EstimateFeePerKW(numBlocks uint32) (SatPerKWeight, error)
EstimateFeePerKW takes in a target for the number of blocks until an initial confirmation and returns the estimated fee expressed in sat/kw.
NOTE: This method is part of the Estimator interface.
func (*WebAPIEstimator) RelayFeePerKW ¶
func (w *WebAPIEstimator) RelayFeePerKW() SatPerKWeight
RelayFeePerKW returns the minimum fee rate required for transactions to be relayed.
NOTE: This method is part of the Estimator interface.
func (*WebAPIEstimator) Start ¶
func (w *WebAPIEstimator) Start() error
Start signals the Estimator to start any processes or goroutines it needs to perform its duty.
NOTE: This method is part of the Estimator interface.
func (*WebAPIEstimator) Stop ¶
func (w *WebAPIEstimator) Stop() error
Stop stops any spawned goroutines and cleans up the resources used by the fee estimator.
NOTE: This method is part of the Estimator interface.
type WebAPIFeeSource ¶
type WebAPIFeeSource interface { // GenQueryURL generates the full query URL. The value returned by this // method should be able to be used directly as a path for an HTTP GET // request. GenQueryURL() string // ParseResponse attempts to parse the body of the response generated // by the above query URL. Typically this will be JSON, but the // specifics are left to the WebAPIFeeSource implementation. ParseResponse(r io.Reader) (map[uint32]uint32, error) }
WebAPIFeeSource is an interface allows the WebAPIEstimator to query an arbitrary HTTP-based fee estimator. Each new set/network will gain an implementation of this interface in order to allow the WebAPIEstimator to be fully generic in its logic.