Commit Graph

40 Commits

Author SHA1 Message Date
ziggie
02c1264c53
multi: prevent nil panics in stop methods.
With this PR we might call the stop method even when the start
method of a subsystem did not successfully finish therefore we
need to make sure we guard the stop methods for potential panics
if some variables are not initialized in the contructors of the
subsystems.
2024-07-31 14:43:34 +02:00
yyforyongyu
b6049ff94b
multi: add NewLogClosure in lnutils to avoid repetition
And replaces all usage of `logClosure` with `lnutils.LogClosure`.
2024-07-25 21:25:23 +08:00
yyforyongyu
7e60d41898
chainfee: make sure web API has been started before estimating
Previously we may get a floor feerate when calling `EstimateFeePerKW`
due to the fee estimator not finishing its startup process, which gives
us an empty fee map.

This is now fixed to return an error if the estimator is not started.
2024-07-24 20:05:00 +08:00
yyforyongyu
ce43e4bab7
chainfee: allow specifying min relay feerate from API source
This commit adds a new expected field, `min_relay_feerate`, in the
response body returned from the API source, allowing the API to specify
a min relay feerate to be used instead of the FeePerKwFloor.

This change is backwards compatible as for an old API source which
doesn't specify the `min_relay_feerate`, it will be interpreted as zero.
2024-07-24 20:05:00 +08:00
yyforyongyu
17a089c899
input+lnwallet: apply the new type lntypes.VByte 2024-05-25 13:37:16 +08:00
yyforyongyu
8da68bb7db
multi: apply the new type lntypes.WeightUnit 2024-05-25 13:37:13 +08:00
yyforyongyu
634967c5c8
chainfee: add FeeForVByte on SatPerKWeight 2024-05-24 22:49:20 +08:00
Tom Kirkpatrick
3837c3f12e
lnwallet: add configurable cache for web fee estimator
Add fee.min-update-timeout and fee.max-update-timeout config options to
allow configuration of the web fee estimator cache.
2024-05-04 14:41:41 +08:00
yyforyongyu
0fc5301d12
lnwallet+sweep: cap conf target used in fee estimator 2024-04-19 21:33:31 +08:00
yyforyongyu
ecd471ac75
lnwallet+sweep: calculate max allowed feerate on BumpResult
This commit adds the method `MaxFeeRateAllowed` to calculate the max fee
rate. The caller may specify a large MaxFeeRate value, which cannot be
cover by the budget. In that case, we default to use the max feerate
calculated using `budget/weight`.
2024-04-19 21:33:29 +08:00
yyforyongyu
6ff6c86155
multi: merge DetermineFeePerKw and Estimate
This commit moves `DetermineFeePerKw` into the `Estimate` method on
`FeePreference`. A few callsites previously calling `DetermineFeePerKw`
without the max fee rate is now also temporarily fixed by forcing them
to use `Estimate` with the default sweeper max fee rate.
2024-04-19 21:33:21 +08:00
Eugene Siegel
d5a13577bf
chainfee: introduce filterManager and use it for fee floor
This commit introduces a filterManager that uses our outbound peers'
feefilter values to determine an acceptable minimum feerate that
ensures successful transaction propagation. Under the hood, a moving
median is used as it is more resistant to shocks than a moving average.
2024-03-20 12:14:25 -04:00
ziggie
45c6ee69d2
chainfee: special case a zero fee estimation.
Bitcoind will not report any fee estimation in case it has not
enough data available. We used to just set the min mempool fee
in such cases but this might not represent the current fee situation
of the bitcoin network. We return an error now so that we will use
the fallback fee instead.
2024-03-19 16:56:14 +00:00
cuinix
60bc30dd08 remove repetitive words
Signed-off-by: cuinix <915115094@qq.com>
2024-03-07 14:05:47 +08:00
yyforyongyu
3c62ba57d3
chainfee: make timeout values constant 2023-10-29 13:24:28 +08:00
yyforyongyu
090892c613
chainfee: use proper mock for WebAPIFeeSource in tests 2023-10-29 13:24:27 +08:00
yyforyongyu
efcba4a836
chainfee: simplify WebAPIFeeSource interface
This commit removes the interface methods `GenQueryURL` and
`ParseResponse` so the `WebAPIEstimator` can care less about the
implementation details of this interface.
2023-10-29 13:24:27 +08:00
yyforyongyu
8ca48311ee
chainfee: add a new interface method GetFeeMap
This commit adds a new method `GetFeeMap` to handle querying the web API
and parse the response into a map that's used by the fee estimator. In
doing so we can provide a deeper abstraction over the `WebAPIFeeSource`
interface.
2023-10-29 13:24:27 +08:00
yyforyongyu
0532b82dd5
multi: add new method FeePerVByte to avoid manual conversion 2023-10-13 17:00:53 +08:00
yyforyongyu
bea0ffdf81 chainfee: add new unit SatPerVByte 2023-10-06 16:34:47 -07:00
Michael Rooke
78d9996620
trivial: Fix spelling errors
- Fixes some spelling in code comments and a couple of function names
2023-09-21 22:35:33 -04:00
yyforyongyu
d8924d26ce
chainfee: fix unit test for WebAPIEstimator 2023-09-05 07:44:01 +08:00
yyforyongyu
00fa2cb34a
lnwallet: add verbose test logs for TestWebAPIFeeEstimator 2023-03-22 23:55:11 +07:00
Tommy Volk
9a10c80bcb multi: move many t.Fatalf calls to require.NoError 2022-06-17 04:26:55 +00:00
Oliver Gugger
7dfe4018ce
multi: use btcd's btcec/v2 and btcutil modules
This commit was previously split into the following parts to ease
review:
 - 2d746f68: replace imports
 - 4008f0fd: use ecdsa.Signature
 - 849e33d1: remove btcec.S256()
 - b8f6ebbd: use v2 library correctly
 - fa80bca9: bump go modules
2022-03-09 19:02:37 +01:00
Oliver Gugger
895a2e497b
multi: formatting and comment fixes 2022-02-10 11:02:02 +01:00
Elle Mouton
2449e66d29
lnwallet+docs: minrelayfee always above fee floor
The minimum relay fee is always ensured to be above our fee floor except
in the very first min relay fee query to bitcoind. This commit ensures
that the fee floor is respected in this first query.
2021-12-13 08:22:34 +02:00
yyforyongyu
7e7fca78c4
chainfee: update test TestWebAPIFeeEstimator 2021-12-07 20:18:24 +08:00
yyforyongyu
655ce00220
chainfee: handle conf target not found in cache 2021-12-07 20:18:24 +08:00
Elle Mouton
ad2859c863
chainfee: fetch fresh relay fee for btcd
This commit adds a function to the BtcdEstimator that fetches the
current min relay fee from the btcd node.
2021-10-05 18:30:41 +02:00
Elle Mouton
55077d9404
chainfee: fetch new relay fee from bitcoind
This commit adds a fetchMinMempoolFee function to the BitcoindEstimator
that fetches the current min mempool fee from the bitcoind backend. The
commit then also updates the BitcoindEstimator to use a minFeeManager
for it's minFeeManager member and uses the fetchMinMempoolFee function
to initialise this.
2021-10-05 18:30:41 +02:00
Elle Mouton
c01699853d
chainfee: add minFeeManager
This commit adds a minFeeManager which holds a copy of minFeePerKW
and updates this fee every few calls.
2021-10-05 18:30:41 +02:00
yyforyongyu
1abc5f8b00
chainfee: change min conf target to be 1
This commit changes the minBlockTarget used by the WebAPIEstimator to be
1, inline with the bitcoind's accepted min conf target.
2021-06-29 20:25:46 +08:00
yyforyongyu
5f0561fdbc
chainfee: replace conf target when it exceeds the maxBlockTarget
In this commit, we add a check inside EstimateFeePerKW for bitcoind so
that when the conf target exceeds the maxBlockTarget, we will use
maxBlockTarget instead.
2021-06-29 20:25:46 +08:00
yyforyongyu
6242158d51
chainfee: fix maxBlockTarget value 2021-06-29 20:25:45 +08:00
Joost Jager
166be979dd
lnwallet: add no cache option to web api estimator 2020-09-14 11:51:03 +02:00
Joost Jager
23cd2f40eb
lnwallet: remove unused WebAPIEstimator field 2020-09-14 11:51:01 +02:00
Conner Fromknecht
89bd58786e
lnwallet/channel: enforce absolute fee floor of 250 sat/kw
This enforces the _actualized_ fee rate of the  commitment transaction,
rather than the fee floor used for estimation. The new value of 250
sat/kw corresponds to 1 sat/byte, rather than 253 which is only rounded
up during estimation to account for the fact that BOLT 3 rounds down to
the nearest satoshi and that the vbyte fee estimation is lossy.

Previously we would incorrectly fail to sign the next commitment even
though the fee was technically high enough. Restarting with this commit
should solve the issue as long as the channel hasn't already gone to
chain.
2020-04-21 12:37:34 -07:00
yyforyongyu
97da7b3444 multi: support config bitcoind fee estimate mode 2020-03-25 14:59:23 +08:00
Olaoluwa Osuntokun
777ed104a3
chainfee: create new chainfee package extracting fees from lnwallet
In this commit, we create a new chainfee package, that houses all fee
related functionality used within the codebase. The creation of this new
package furthers our long-term goal of extracting functionality from the
bloated `lnwallet` package into new distinct packages. Additionally,
this new packages resolves a class of import cycle that could arise if a
new package that was imported by something in `lnwallet` wanted to use
the existing fee related functions in the prior `lnwallet` package.
2019-10-31 16:41:57 -07:00