From 108aadd2a623c30b6b31084cb60ad83d4b1cea55 Mon Sep 17 00:00:00 2001
From: Gijs van Dam <gvandam@gmail.com>
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 | 19 +++++++++++++++++++
 2 files changed, 20 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..dfa57c5 100644
--- a/walletkit_client.go
+++ b/walletkit_client.go
@@ -540,6 +540,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.