Dynamic min-relay-fee and dust amount (#280)

* [btc-embedded] add chainfee.Estimator and extraAPI interfaces

* dynamic fee amount

* dynamic dust amount

* [client] fix linter errors

* [domain] fix unit tests

* [server] return dust amount in GetInfo RPC

* [sdk] fix lnd dependencie

* go work sync

* fix witness stack size forfeit tx size estimator

* remove hardcoded fee values in covenant txbuilder

* lower liquid feerate

* fix after reviews

* go work sync
This commit is contained in:
Louis Singer
2024-09-10 17:22:09 +02:00
committed by GitHub
parent a8cf0ed204
commit 0fb34cb13d
75 changed files with 2061 additions and 594 deletions

View File

@@ -26,7 +26,7 @@ const (
PUBKEY = "public_key"
NETWORK = "network"
EXPLORER = "explorer"
MIN_RELAY_FEE = "min_relay_fee"
DUST = "dust"
defaultNetwork = "liquid"
state_file = "state.json"
@@ -40,8 +40,8 @@ var initialState = map[string]string{
ENCRYPTED_PRVKEY: "",
PASSWORD_HASH: "",
PUBKEY: "",
DUST: "546",
NETWORK: defaultNetwork,
MIN_RELAY_FEE: "",
}
func GetNetwork(ctx *cli.Context) (*common.Network, error) {
@@ -75,24 +75,6 @@ func GetRoundLifetime(ctx *cli.Context) (int64, error) {
return int64(roundLifetime), nil
}
func GetMinRelayFee(ctx *cli.Context) (int64, error) {
state, err := GetState(ctx)
if err != nil {
return -1, err
}
fee := state[MIN_RELAY_FEE]
if len(fee) <= 0 {
return -1, fmt.Errorf("missing min relay fee")
}
minRelayFee, err := strconv.Atoi(fee)
if err != nil {
return -1, err
}
return int64(minRelayFee), nil
}
func GetUnilateralExitDelay(ctx *cli.Context) (int64, error) {
state, err := GetState(ctx)
if err != nil {
@@ -171,6 +153,25 @@ func GetAspPublicKey(ctx *cli.Context) (*secp256k1.PublicKey, error) {
return secp256k1.ParsePubKey(pubKeyBytes)
}
func GetDust(ctx *cli.Context) (uint64, error) {
state, err := GetState(ctx)
if err != nil {
return 0, err
}
dust := state[DUST]
if len(dust) <= 0 {
return 0, fmt.Errorf("missing dust")
}
dustAmount, err := strconv.Atoi(dust)
if err != nil {
return 0, err
}
return uint64(dustAmount), nil
}
func GetState(ctx *cli.Context) (map[string]string, error) {
datadir := ctx.String("datadir")
stateFilePath := filepath.Join(datadir, state_file)