Skip to content

Commit 895a850

Browse files
authored
Merge pull request #200 from lightninglabs/minrelayfee
Minrelayfee func
2 parents af1aae2 + f92358c commit 895a850

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

macaroon_recipes.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ var (
4343
"EstimateFeeToP2WSH": "EstimateFee",
4444
"OpenChannelStream": "OpenChannel",
4545
"ListSweepsVerbose": "ListSweeps",
46+
"MinRelayFee": "EstimateFee",
4647
}
4748

4849
// ignores is a list of method names on the client implementations that

walletkit_client.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ type WalletKitClient interface {
111111
EstimateFeeRate(ctx context.Context,
112112
confTarget int32) (chainfee.SatPerKWeight, error)
113113

114+
// MinRelayFee returns the current minimum relay fee based on our chain
115+
// backend in sat/kw.
116+
MinRelayFee(ctx context.Context) (chainfee.SatPerKWeight, error)
117+
114118
// ListSweeps returns a list of sweep transaction ids known to our node.
115119
// Note that this function only looks up transaction ids, and does not
116120
// 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)
540544
return chainfee.SatPerKWeight(resp.SatPerKw), nil
541545
}
542546

547+
// MinRelayFee returns the current minimum relay fee based on our chain backend
548+
// in sat/kw.
549+
func (m *walletKitClient) MinRelayFee(
550+
ctx context.Context) (chainfee.SatPerKWeight, error) {
551+
552+
rpcCtx, cancel := context.WithTimeout(ctx, m.timeout)
553+
defer cancel()
554+
555+
rpcCtx = m.walletKitMac.WithMacaroonAuth(rpcCtx)
556+
resp, err := m.client.EstimateFee(rpcCtx, &walletrpc.EstimateFeeRequest{
557+
ConfTarget: 6,
558+
})
559+
if err != nil {
560+
return 0, err
561+
}
562+
563+
return chainfee.SatPerKWeight(resp.MinRelayFeeSatPerKw), nil
564+
}
565+
543566
// ListSweeps returns a list of sweep transaction ids known to our node.
544567
// Note that this function only looks up transaction ids (Verbose=false), and
545568
// does not query our wallet for the full set of transactions.

0 commit comments

Comments
 (0)