Skip to content

Commit

Permalink
Merge pull request #200 from lightninglabs/minrelayfee
Browse files Browse the repository at this point in the history
Minrelayfee func
  • Loading branch information
guggero authored Oct 30, 2024
2 parents af1aae2 + f92358c commit 895a850
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions macaroon_recipes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions walletkit_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 895a850

Please sign in to comment.