From 9b8549011c99893740673dd8d8f031615a04ae73 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sun, 9 Sep 2018 17:31:34 -0700 Subject: [PATCH] lnwallet: add new WebApiFeeSource interface In this commit, we add a new interface which will allow callers to drop in an arbitrary Web API for fee estimation with an arbitrary request/response schema. Co-authored-by: Valentine Wallace --- lnwallet/fee_estimator.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lnwallet/fee_estimator.go b/lnwallet/fee_estimator.go index 76acc63a5..e075595f7 100644 --- a/lnwallet/fee_estimator.go +++ b/lnwallet/fee_estimator.go @@ -458,3 +458,19 @@ func (b *BitcoindFeeEstimator) fetchEstimate(confTarget uint32) (SatPerKWeight, // A compile-time assertion to ensure that BitcoindFeeEstimator implements the // FeeEstimator interface. var _ FeeEstimator = (*BitcoindFeeEstimator)(nil) + +// WebAPIFeeSource is an interface allows the WebAPIFeeEstimator to query an +// arbitrary HTTP-based fee estimator. Each new set/network will gain an +// implementation of this interface in order to allow the WebAPIFeeEstimator to +// be fully generic in its logic. +type WebAPIFeeSource interface { + // GenQueryURL generates the full query URL. The value returned by this + // method should be able to be used directly as a path for an HTTP GET + // request. + GenQueryURL() string + + // ParseResponse attempts to parse the body of the response generated + // by the above query URL. Typically this will be JSON, but the + // specifics are left to the WebAPIFeeSource implementation. + ParseResponse(r io.Reader) (map[uint32]uint32, error) +}