From f92358c1724fb8642369fadb75a67ef17fb187c9 Mon Sep 17 00:00:00 2001 From: Gijs van Dam Date: Tue, 29 Oct 2024 21:35:43 +0100 Subject: [PATCH] MinRelayFee func in walletkit_client.go. Added MinRelayFee func to walletkit_client.go. --- macaroon_recipes.go | 1 + walletkit_client.go | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/macaroon_recipes.go b/macaroon_recipes.go index 0afd39d..6a83fef 100644 --- a/macaroon_recipes.go +++ b/macaroon_recipes.go @@ -43,6 +43,7 @@ var ( "EstimateFeeToP2WSH": "EstimateFee", "OpenChannelStream": "OpenChannel", "ListSweepsVerbose": "ListSweeps", + "MinRelayFee": "EstimateFee", } // ignores is a list of method names on the client implementations that diff --git a/walletkit_client.go b/walletkit_client.go index 99174f8..3dfbef9 100644 --- a/walletkit_client.go +++ b/walletkit_client.go @@ -111,6 +111,10 @@ type WalletKitClient interface { EstimateFeeRate(ctx context.Context, confTarget int32) (chainfee.SatPerKWeight, error) + // MinRelayFee returns the current minimum relay fee based on our chain + // backend in sat/kw. + MinRelayFee(ctx context.Context) (chainfee.SatPerKWeight, error) + // ListSweeps returns a list of sweep transaction ids known to our node. // Note that this function only looks up transaction ids, and does not // query our wallet for the full set of transactions. If startHeight is @@ -540,6 +544,25 @@ func (m *walletKitClient) EstimateFeeRate(ctx context.Context, confTarget int32) return chainfee.SatPerKWeight(resp.SatPerKw), nil } +// MinRelayFee returns the current minimum relay fee based on our chain backend +// in sat/kw. +func (m *walletKitClient) MinRelayFee( + ctx context.Context) (chainfee.SatPerKWeight, error) { + + rpcCtx, cancel := context.WithTimeout(ctx, m.timeout) + defer cancel() + + rpcCtx = m.walletKitMac.WithMacaroonAuth(rpcCtx) + resp, err := m.client.EstimateFee(rpcCtx, &walletrpc.EstimateFeeRequest{ + ConfTarget: 6, + }) + if err != nil { + return 0, err + } + + return chainfee.SatPerKWeight(resp.MinRelayFeeSatPerKw), nil +} + // ListSweeps returns a list of sweep transaction ids known to our node. // Note that this function only looks up transaction ids (Verbose=false), and // does not query our wallet for the full set of transactions.