From d20545fe8a375ea298f7f4e41a92f0b28bf58034 Mon Sep 17 00:00:00 2001 From: carla Date: Tue, 28 Apr 2020 20:59:07 +0200 Subject: [PATCH] frdrpc: add fiat estimate method --- frdrpc/fiat_estimate.go | 71 +++++++ frdrpc/rpc.pb.go | 419 +++++++++++++++++++++++++++++++++------- frdrpc/rpc.pb.gw.go | 41 ++++ frdrpc/rpc.proto | 47 +++++ frdrpc/rpc.swagger.json | 85 ++++++++ frdrpc/rpcserver.go | 20 ++ 6 files changed, 618 insertions(+), 65 deletions(-) create mode 100644 frdrpc/fiat_estimate.go diff --git a/frdrpc/fiat_estimate.go b/frdrpc/fiat_estimate.go new file mode 100644 index 0000000..b5ea5d2 --- /dev/null +++ b/frdrpc/fiat_estimate.go @@ -0,0 +1,71 @@ +package frdrpc + +import ( + "fmt" + "time" + + "github.com/lightninglabs/faraday/fiat" + "github.com/lightningnetwork/lnd/lnwire" +) + +func parseFiatRequest(req *FiatEstimateRequest) (fiat.Granularity, + []*fiat.PriceRequest, error) { + + granularity := fiat.GranularityMinute + + switch req.Granularity { + // If granularity is not set, allow it to default to one minute + case FiatEstimateRequest_UNKNOWN: + + case FiatEstimateRequest_MINUTE: + granularity = fiat.GranularityMinute + + case FiatEstimateRequest_FIVE_MINUTES: + granularity = fiat.Granularity5Minute + + case FiatEstimateRequest_FIFTEEN_MINUTES: + granularity = fiat.Granularity15Minute + + case FiatEstimateRequest_THIRTY_MINUTES: + granularity = fiat.Granularity30Minute + + case FiatEstimateRequest_HOUR: + granularity = fiat.GranularityHour + + case FiatEstimateRequest_SIX_HOURS: + granularity = fiat.Granularity6Hour + + case FiatEstimateRequest_TWELVE_HOURS: + granularity = fiat.Granularity12Hour + + case FiatEstimateRequest_DAY: + granularity = fiat.GranularityDay + + default: + return granularity, nil, fmt.Errorf("unknown granularity: %v", + req.Granularity) + } + + requests := make([]*fiat.PriceRequest, len(req.Requests)) + + for i, request := range req.Requests { + requests[i] = &fiat.PriceRequest{ + Identifier: request.Id, + Value: lnwire.MilliSatoshi(request.AmountMsat), + Timestamp: time.Unix(request.Timestamp, 0), + } + } + + return granularity, requests, nil +} + +func fiatEstimateResponse(prices map[string]float64) *FiatEstimateResponse { + fiatVals := make(map[string]float32, len(prices)) + for k, v := range prices { + fiatVals[k] = float32(v) + } + + return &FiatEstimateResponse{ + FiatValues: fiatVals, + } +} diff --git a/frdrpc/rpc.pb.go b/frdrpc/rpc.pb.go index 7481a0d..b6c94b1 100644 --- a/frdrpc/rpc.pb.go +++ b/frdrpc/rpc.pb.go @@ -60,6 +60,54 @@ func (CloseRecommendationRequest_Metric) EnumDescriptor() ([]byte, []int) { return fileDescriptor_77a6da22d6a3feb1, []int{0, 0} } +// Granularity describes the aggregation level at which the Bitcoin price +// is provided. +type FiatEstimateRequest_Granularity int32 + +const ( + FiatEstimateRequest_UNKNOWN FiatEstimateRequest_Granularity = 0 + FiatEstimateRequest_MINUTE FiatEstimateRequest_Granularity = 1 + FiatEstimateRequest_FIVE_MINUTES FiatEstimateRequest_Granularity = 2 + FiatEstimateRequest_FIFTEEN_MINUTES FiatEstimateRequest_Granularity = 3 + FiatEstimateRequest_THIRTY_MINUTES FiatEstimateRequest_Granularity = 4 + FiatEstimateRequest_HOUR FiatEstimateRequest_Granularity = 5 + FiatEstimateRequest_SIX_HOURS FiatEstimateRequest_Granularity = 6 + FiatEstimateRequest_TWELVE_HOURS FiatEstimateRequest_Granularity = 7 + FiatEstimateRequest_DAY FiatEstimateRequest_Granularity = 8 +) + +var FiatEstimateRequest_Granularity_name = map[int32]string{ + 0: "UNKNOWN", + 1: "MINUTE", + 2: "FIVE_MINUTES", + 3: "FIFTEEN_MINUTES", + 4: "THIRTY_MINUTES", + 5: "HOUR", + 6: "SIX_HOURS", + 7: "TWELVE_HOURS", + 8: "DAY", +} + +var FiatEstimateRequest_Granularity_value = map[string]int32{ + "UNKNOWN": 0, + "MINUTE": 1, + "FIVE_MINUTES": 2, + "FIFTEEN_MINUTES": 3, + "THIRTY_MINUTES": 4, + "HOUR": 5, + "SIX_HOURS": 6, + "TWELVE_HOURS": 7, + "DAY": 8, +} + +func (x FiatEstimateRequest_Granularity) String() string { + return proto.EnumName(FiatEstimateRequest_Granularity_name, int32(x)) +} + +func (FiatEstimateRequest_Granularity) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_77a6da22d6a3feb1, []int{12, 0} +} + type CloseRecommendationRequest struct { // //The minimum amount of time in seconds that a channel should have been @@ -795,8 +843,184 @@ func (m *ChannelInsight) GetPrivate() bool { return false } +type FiatEstimateRequest struct { + Requests []*FiatEstimateRequest_PriceRequest `protobuf:"bytes,1,rep,name=requests,proto3" json:"requests,omitempty"` + Granularity FiatEstimateRequest_Granularity `protobuf:"varint,2,opt,name=granularity,proto3,enum=frdrpc.FiatEstimateRequest_Granularity" json:"granularity,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *FiatEstimateRequest) Reset() { *m = FiatEstimateRequest{} } +func (m *FiatEstimateRequest) String() string { return proto.CompactTextString(m) } +func (*FiatEstimateRequest) ProtoMessage() {} +func (*FiatEstimateRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_77a6da22d6a3feb1, []int{12} +} + +func (m *FiatEstimateRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_FiatEstimateRequest.Unmarshal(m, b) +} +func (m *FiatEstimateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_FiatEstimateRequest.Marshal(b, m, deterministic) +} +func (m *FiatEstimateRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_FiatEstimateRequest.Merge(m, src) +} +func (m *FiatEstimateRequest) XXX_Size() int { + return xxx_messageInfo_FiatEstimateRequest.Size(m) +} +func (m *FiatEstimateRequest) XXX_DiscardUnknown() { + xxx_messageInfo_FiatEstimateRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_FiatEstimateRequest proto.InternalMessageInfo + +func (m *FiatEstimateRequest) GetRequests() []*FiatEstimateRequest_PriceRequest { + if m != nil { + return m.Requests + } + return nil +} + +func (m *FiatEstimateRequest) GetGranularity() FiatEstimateRequest_Granularity { + if m != nil { + return m.Granularity + } + return FiatEstimateRequest_UNKNOWN +} + +type FiatEstimateRequest_PriceRequest struct { + // id is a unique identifier for the request. + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // The amount to be converted to fiat in millisatoshis. + AmountMsat uint64 `protobuf:"varint,2,opt,name=amount_msat,json=amountMsat,proto3" json:"amount_msat,omitempty"` + // The unix timestamp at which the price should be quoted. + Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *FiatEstimateRequest_PriceRequest) Reset() { *m = FiatEstimateRequest_PriceRequest{} } +func (m *FiatEstimateRequest_PriceRequest) String() string { return proto.CompactTextString(m) } +func (*FiatEstimateRequest_PriceRequest) ProtoMessage() {} +func (*FiatEstimateRequest_PriceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_77a6da22d6a3feb1, []int{12, 0} +} + +func (m *FiatEstimateRequest_PriceRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_FiatEstimateRequest_PriceRequest.Unmarshal(m, b) +} +func (m *FiatEstimateRequest_PriceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_FiatEstimateRequest_PriceRequest.Marshal(b, m, deterministic) +} +func (m *FiatEstimateRequest_PriceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_FiatEstimateRequest_PriceRequest.Merge(m, src) +} +func (m *FiatEstimateRequest_PriceRequest) XXX_Size() int { + return xxx_messageInfo_FiatEstimateRequest_PriceRequest.Size(m) +} +func (m *FiatEstimateRequest_PriceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_FiatEstimateRequest_PriceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_FiatEstimateRequest_PriceRequest proto.InternalMessageInfo + +func (m *FiatEstimateRequest_PriceRequest) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +func (m *FiatEstimateRequest_PriceRequest) GetAmountMsat() uint64 { + if m != nil { + return m.AmountMsat + } + return 0 +} + +func (m *FiatEstimateRequest_PriceRequest) GetTimestamp() int64 { + if m != nil { + return m.Timestamp + } + return 0 +} + +type PriceResponse struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *PriceResponse) Reset() { *m = PriceResponse{} } +func (m *PriceResponse) String() string { return proto.CompactTextString(m) } +func (*PriceResponse) ProtoMessage() {} +func (*PriceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_77a6da22d6a3feb1, []int{13} +} + +func (m *PriceResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_PriceResponse.Unmarshal(m, b) +} +func (m *PriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_PriceResponse.Marshal(b, m, deterministic) +} +func (m *PriceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_PriceResponse.Merge(m, src) +} +func (m *PriceResponse) XXX_Size() int { + return xxx_messageInfo_PriceResponse.Size(m) +} +func (m *PriceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_PriceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_PriceResponse proto.InternalMessageInfo + +type FiatEstimateResponse struct { + FiatValues map[string]float32 `protobuf:"bytes,1,rep,name=fiat_values,json=fiatValues,proto3" json:"fiat_values,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"fixed32,2,opt,name=value,proto3"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *FiatEstimateResponse) Reset() { *m = FiatEstimateResponse{} } +func (m *FiatEstimateResponse) String() string { return proto.CompactTextString(m) } +func (*FiatEstimateResponse) ProtoMessage() {} +func (*FiatEstimateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_77a6da22d6a3feb1, []int{14} +} + +func (m *FiatEstimateResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_FiatEstimateResponse.Unmarshal(m, b) +} +func (m *FiatEstimateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_FiatEstimateResponse.Marshal(b, m, deterministic) +} +func (m *FiatEstimateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_FiatEstimateResponse.Merge(m, src) +} +func (m *FiatEstimateResponse) XXX_Size() int { + return xxx_messageInfo_FiatEstimateResponse.Size(m) +} +func (m *FiatEstimateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_FiatEstimateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_FiatEstimateResponse proto.InternalMessageInfo + +func (m *FiatEstimateResponse) GetFiatValues() map[string]float32 { + if m != nil { + return m.FiatValues + } + return nil +} + func init() { proto.RegisterEnum("frdrpc.CloseRecommendationRequest_Metric", CloseRecommendationRequest_Metric_name, CloseRecommendationRequest_Metric_value) + proto.RegisterEnum("frdrpc.FiatEstimateRequest_Granularity", FiatEstimateRequest_Granularity_name, FiatEstimateRequest_Granularity_value) proto.RegisterType((*CloseRecommendationRequest)(nil), "frdrpc.CloseRecommendationRequest") proto.RegisterType((*OutlierRecommendationsRequest)(nil), "frdrpc.OutlierRecommendationsRequest") proto.RegisterType((*ThresholdRecommendationsRequest)(nil), "frdrpc.ThresholdRecommendationsRequest") @@ -810,76 +1034,98 @@ func init() { proto.RegisterType((*ChannelInsightsRequest)(nil), "frdrpc.ChannelInsightsRequest") proto.RegisterType((*ChannelInsightsResponse)(nil), "frdrpc.ChannelInsightsResponse") proto.RegisterType((*ChannelInsight)(nil), "frdrpc.ChannelInsight") + proto.RegisterType((*FiatEstimateRequest)(nil), "frdrpc.FiatEstimateRequest") + proto.RegisterType((*FiatEstimateRequest_PriceRequest)(nil), "frdrpc.FiatEstimateRequest.PriceRequest") + proto.RegisterType((*PriceResponse)(nil), "frdrpc.PriceResponse") + proto.RegisterType((*FiatEstimateResponse)(nil), "frdrpc.FiatEstimateResponse") + proto.RegisterMapType((map[string]float32)(nil), "frdrpc.FiatEstimateResponse.FiatValuesEntry") } func init() { proto.RegisterFile("rpc.proto", fileDescriptor_77a6da22d6a3feb1) } var fileDescriptor_77a6da22d6a3feb1 = []byte{ - // 1019 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0x67, 0xed, 0xc4, 0x69, 0x9e, 0x6b, 0xc7, 0x9d, 0xfc, 0xc1, 0x84, 0x84, 0x44, 0xab, 0x96, - 0xba, 0xb4, 0xd8, 0xad, 0xb9, 0x20, 0x4e, 0x44, 0x91, 0x29, 0x16, 0xb5, 0x1d, 0x6d, 0x9d, 0x70, - 0x41, 0x5a, 0x2d, 0xbb, 0x13, 0x67, 0xc0, 0x3b, 0xb3, 0x9d, 0x99, 0xb5, 0x14, 0x21, 0x2e, 0x7c, - 0x01, 0x0e, 0xbd, 0x70, 0xe1, 0xcc, 0x57, 0xe0, 0x43, 0x70, 0x41, 0x88, 0x6f, 0xc0, 0x87, 0xe0, - 0x88, 0x76, 0x66, 0xf6, 0x9f, 0x71, 0x1a, 0x2e, 0xdc, 0xbc, 0xbf, 0xdf, 0x6f, 0xde, 0xef, 0xcd, - 0x7b, 0x33, 0xf3, 0x0c, 0x9b, 0x3c, 0xf2, 0xbb, 0x11, 0x67, 0x92, 0xa1, 0xda, 0x25, 0x0f, 0x78, - 0xe4, 0xef, 0x1f, 0xcc, 0x18, 0x9b, 0xcd, 0x71, 0xcf, 0x8b, 0x48, 0xcf, 0xa3, 0x94, 0x49, 0x4f, - 0x12, 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f, 0xac, 0x41, 0xe3, 0x33, 0x8f, 0x7b, 0x81, 0x77, - 0xfd, 0x12, 0xf3, 0x05, 0xe6, 0xe8, 0x27, 0x0b, 0xf6, 0x56, 0x0f, 0x25, 0xf4, 0x20, 0xed, 0xd4, - 0x1b, 0x87, 0xd6, 0xfe, 0xfd, 0x37, 0xcc, 0x81, 0xec, 0x40, 0xd8, 0xcf, 0x7e, 0xf8, 0xe3, 0xaf, - 0xd7, 0x95, 0xc7, 0xe8, 0x51, 0x6f, 0xf1, 0xac, 0x77, 0xa9, 0x53, 0xe8, 0x99, 0x69, 0x24, 0x7a, - 0xdf, 0x15, 0xc6, 0x4b, 0x57, 0x8f, 0xe6, 0xef, 0xd1, 0xcf, 0x16, 0xb4, 0x6f, 0x9a, 0x4c, 0xe8, - 0x61, 0xea, 0x7a, 0xcb, 0xec, 0xfa, 0x8f, 0xe9, 0xf5, 0x55, 0x7a, 0x4f, 0xd0, 0x07, 0xc5, 0xf4, - 0xb2, 0xb9, 0xb4, 0x3a, 0x3f, 0xb2, 0xfc, 0x7c, 0x1d, 0xac, 0x7e, 0xf0, 0x4c, 0x22, 0x87, 0x37, - 0xb0, 0x26, 0x83, 0x77, 0x55, 0x06, 0xbb, 0x68, 0xbb, 0x98, 0x01, 0xd7, 0x52, 0x14, 0xc1, 0xd6, - 0xd2, 0x4d, 0x43, 0xef, 0xad, 0xbe, 0x47, 0xd9, 0xbe, 0x8f, 0x6e, 0xe4, 0x8d, 0xe1, 0x81, 0x32, - 0xdc, 0x43, 0x3b, 0x45, 0xc3, 0xf4, 0xb2, 0x7e, 0x5d, 0x53, 0x7f, 0xd7, 0x3e, 0xfa, 0x27, 0x00, - 0x00, 0xff, 0xff, 0x49, 0xe9, 0x31, 0xd3, 0xe1, 0x09, 0x00, 0x00, + // 1287 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x4f, 0x6f, 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31, 0x45, 0x3f, 0x6b, 0xb0, 0xb3, 0xfa, 0xb1, 0x83, 0xee, 0xc4, + 0x51, 0x5e, 0xf9, 0x18, 0x6a, 0xdd, 0xbe, 0xe2, 0x7d, 0x91, 0x34, 0x1a, 0xe3, 0xd1, 0xf7, 0x7f, + 0xfc, 0xf5, 0xaa, 0x70, 0x1f, 0xdd, 0xeb, 0x9e, 0x3f, 0xea, 0x9e, 0xca, 0x10, 0xba, 0xea, 0x95, + 0x13, 0x75, 0xbf, 0xcd, 0x3c, 0x5b, 0x3a, 0xf2, 0xc9, 0xf7, 0x1d, 0x7a, 0xad, 0x41, 0xf3, 0xb2, + 0x17, 0x0f, 0x4a, 0xb6, 0xeb, 0x5b, 0xde, 0x44, 0xff, 0x32, 0xbc, 0x9e, 0x08, 0xef, 0x01, 0x7a, + 0x3f, 0x1b, 0x5e, 0xf2, 0xde, 0x59, 0x1d, 0x1f, 0x59, 0xbe, 0x16, 0x77, 0x57, 0x5f, 0xa4, 0x2a, + 0x90, 0x9b, 0x97, 0xb0, 0x2a, 0x82, 0x1b, 0x22, 0x82, 0xeb, 0x68, 0x2b, 0x1b, 0x01, 0x95, 0x52, + 0x14, 0x42, 0x63, 0xa9, 0x83, 0xa3, 0x77, 0x57, 0xf7, 0xe7, 0x64, 0xdd, 0xb7, 0x2e, 0xe5, 0x95, + 0xe1, 0xae, 0x30, 0xdc, 0x41, 0xdb, 0x59, 0xc3, 0xf8, 0x12, 0x40, 0x2e, 0x6c, 0x66, 0x37, 0x27, + 0xba, 0x71, 0x45, 0x7b, 0x68, 0xed, 0x5e, 0xb5, 0x9f, 0x8d, 0xa6, 0x30, 0x42, 0x48, 0xcf, 0x1a, + 0xf1, 0x3d, 0xfd, 0x55, 0x49, 0xfc, 0xd7, 0xf8, 0xf0, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6a, + 0xcb, 0x78, 0xd5, 0x9e, 0x0c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -920,6 +1166,12 @@ type FaradayServerClient interface { //Example request: //http://localhost:8466/v1/faraday/insights ChannelInsights(ctx context.Context, in *ChannelInsightsRequest, opts ...grpc.CallOption) (*ChannelInsightsResponse, error) + //* frcli: + //Get fiat prices for btc. + // + //Example request: + //http://localhost:8466/v1/faraday/fiat + FiatEstimate(ctx context.Context, in *FiatEstimateRequest, opts ...grpc.CallOption) (*FiatEstimateResponse, error) } type faradayServerClient struct { @@ -966,6 +1218,15 @@ func (c *faradayServerClient) ChannelInsights(ctx context.Context, in *ChannelIn return out, nil } +func (c *faradayServerClient) FiatEstimate(ctx context.Context, in *FiatEstimateRequest, opts ...grpc.CallOption) (*FiatEstimateResponse, error) { + out := new(FiatEstimateResponse) + err := c.cc.Invoke(ctx, "/frdrpc.FaradayServer/FiatEstimate", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // FaradayServerServer is the server API for FaradayServer service. type FaradayServerServer interface { //* frcli: `outliers` @@ -994,6 +1255,12 @@ type FaradayServerServer interface { //Example request: //http://localhost:8466/v1/faraday/insights ChannelInsights(context.Context, *ChannelInsightsRequest) (*ChannelInsightsResponse, error) + //* frcli: + //Get fiat prices for btc. + // + //Example request: + //http://localhost:8466/v1/faraday/fiat + FiatEstimate(context.Context, *FiatEstimateRequest) (*FiatEstimateResponse, error) } func RegisterFaradayServerServer(s *grpc.Server, srv FaradayServerServer) { @@ -1072,6 +1339,24 @@ func _FaradayServer_ChannelInsights_Handler(srv interface{}, ctx context.Context return interceptor(ctx, in, info, handler) } +func _FaradayServer_FiatEstimate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(FiatEstimateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(FaradayServerServer).FiatEstimate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/frdrpc.FaradayServer/FiatEstimate", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(FaradayServerServer).FiatEstimate(ctx, req.(*FiatEstimateRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _FaradayServer_serviceDesc = grpc.ServiceDesc{ ServiceName: "frdrpc.FaradayServer", HandlerType: (*FaradayServerServer)(nil), @@ -1092,6 +1377,10 @@ var _FaradayServer_serviceDesc = grpc.ServiceDesc{ MethodName: "ChannelInsights", Handler: _FaradayServer_ChannelInsights_Handler, }, + { + MethodName: "FiatEstimate", + Handler: _FaradayServer_FiatEstimate_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "rpc.proto", diff --git a/frdrpc/rpc.pb.gw.go b/frdrpc/rpc.pb.gw.go index c26a61e..811ef37 100644 --- a/frdrpc/rpc.pb.gw.go +++ b/frdrpc/rpc.pb.gw.go @@ -130,6 +130,23 @@ func request_FaradayServer_ChannelInsights_0(ctx context.Context, marshaler runt } +var ( + filter_FaradayServer_FiatEstimate_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_FaradayServer_FiatEstimate_0(ctx context.Context, marshaler runtime.Marshaler, client FaradayServerClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq FiatEstimateRequest + var metadata runtime.ServerMetadata + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_FaradayServer_FiatEstimate_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.FiatEstimate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + // RegisterFaradayServerHandlerFromEndpoint is same as RegisterFaradayServerHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. func RegisterFaradayServerHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { @@ -248,6 +265,26 @@ func RegisterFaradayServerHandlerClient(ctx context.Context, mux *runtime.ServeM }) + mux.Handle("GET", pattern_FaradayServer_FiatEstimate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_FaradayServer_FiatEstimate_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_FaradayServer_FiatEstimate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -259,6 +296,8 @@ var ( pattern_FaradayServer_RevenueReport_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "faraday", "revenue"}, "")) pattern_FaradayServer_ChannelInsights_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "faraday", "insights"}, "")) + + pattern_FaradayServer_FiatEstimate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "faraday", "fiat"}, "")) ) var ( @@ -269,4 +308,6 @@ var ( forward_FaradayServer_RevenueReport_0 = runtime.ForwardResponseMessage forward_FaradayServer_ChannelInsights_0 = runtime.ForwardResponseMessage + + forward_FaradayServer_FiatEstimate_0 = runtime.ForwardResponseMessage ) diff --git a/frdrpc/rpc.proto b/frdrpc/rpc.proto index 58fd302..0bf6258 100644 --- a/frdrpc/rpc.proto +++ b/frdrpc/rpc.proto @@ -57,6 +57,18 @@ service FaradayServer { get: "/v1/faraday/insights" }; } + + /** frcli: + Get fiat prices for btc. + + Example request: + http://localhost:8466/v1/faraday/fiat + */ + rpc FiatEstimate (FiatEstimateRequest) returns (FiatEstimateResponse) { + option (google.api.http) = { + get: "/v1/faraday/fiat" + }; + } } message CloseRecommendationRequest { @@ -294,3 +306,38 @@ message ChannelInsight { // True if the channel is private. bool private = 8; } + +message FiatEstimateRequest { + message PriceRequest { + // id is a unique identifier for the request. + string id = 1; + + // The amount to be converted to fiat in millisatoshis. + uint64 amount_msat = 2; + + // The unix timestamp at which the price should be quoted. + int64 timestamp = 3; + } + + repeated PriceRequest requests = 1; + + // Granularity describes the aggregation level at which the Bitcoin price + // is provided. + enum Granularity { + UNKNOWN = 0; + MINUTE = 1; + FIVE_MINUTES = 2; + FIFTEEN_MINUTES = 3; + THIRTY_MINUTES = 4; + HOUR = 5; + SIX_HOURS = 6; + TWELVE_HOURS = 7; + DAY = 8; + } + + Granularity granularity = 2; +} + +message FiatEstimateResponse { + map fiat_values = 1; +} \ No newline at end of file diff --git a/frdrpc/rpc.swagger.json b/frdrpc/rpc.swagger.json index 21dfdba..01eca7e 100644 --- a/frdrpc/rpc.swagger.json +++ b/frdrpc/rpc.swagger.json @@ -15,6 +15,44 @@ "application/json" ], "paths": { + "/v1/faraday/fiat": { + "get": { + "summary": "* frcli:\nGet fiat prices for btc.", + "description": "Example request:\nhttp://localhost:8466/v1/faraday/fiat", + "operationId": "FiatEstimate", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/frdrpcFiatEstimateResponse" + } + } + }, + "parameters": [ + { + "name": "granularity", + "in": "query", + "required": false, + "type": "string", + "enum": [ + "UNKNOWN", + "MINUTE", + "FIVE_MINUTES", + "FIFTEEN_MINUTES", + "THIRTY_MINUTES", + "HOUR", + "SIX_HOURS", + "TWELVE_HOURS", + "DAY" + ], + "default": "UNKNOWN" + } + ], + "tags": [ + "FaradayServer" + ] + } + }, "/v1/faraday/insights": { "get": { "summary": "* frcli: `insights`\nList currently open channel with routing and uptime information.", @@ -196,6 +234,41 @@ ], "default": "UNKNOWN" }, + "FiatEstimateRequestGranularity": { + "type": "string", + "enum": [ + "UNKNOWN", + "MINUTE", + "FIVE_MINUTES", + "FIFTEEN_MINUTES", + "THIRTY_MINUTES", + "HOUR", + "SIX_HOURS", + "TWELVE_HOURS", + "DAY" + ], + "default": "UNKNOWN", + "description": "Granularity describes the aggregation level at which the Bitcoin price\nis provided." + }, + "FiatEstimateRequestPriceRequest": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "id is a unique identifier for the request." + }, + "amount_msat": { + "type": "string", + "format": "uint64", + "description": "The amount to be converted to fiat in millisatoshis." + }, + "timestamp": { + "type": "string", + "format": "int64", + "description": "The unix timestamp at which the price should be quoted." + } + } + }, "frdrpcChannelInsight": { "type": "object", "properties": { @@ -288,6 +361,18 @@ } } }, + "frdrpcFiatEstimateResponse": { + "type": "object", + "properties": { + "fiat_values": { + "type": "object", + "additionalProperties": { + "type": "number", + "format": "float" + } + } + } + }, "frdrpcPairReport": { "type": "object", "properties": { diff --git a/frdrpc/rpcserver.go b/frdrpc/rpcserver.go index 30389de..afd511d 100644 --- a/frdrpc/rpcserver.go +++ b/frdrpc/rpcserver.go @@ -17,6 +17,8 @@ import ( "sync" "sync/atomic" + "github.com/lightninglabs/faraday/fiat" + proxy "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/lightninglabs/faraday/recommend" "github.com/lightninglabs/faraday/revenue" @@ -276,6 +278,24 @@ func (s *RPCServer) ChannelInsights(ctx context.Context, return rpcChannelInsightsResponse(insights), nil } +// FiatEstimate provides a fiat estimate for a set of timestamped bitcoin +// prices. +func (s *RPCServer) FiatEstimate(ctx context.Context, + req *FiatEstimateRequest) (*FiatEstimateResponse, error) { + + granularity, reqs, err := parseFiatRequest(req) + if err != nil { + return nil, err + } + + prices, err := fiat.GetPrices(ctx, reqs, granularity) + if err != nil { + return nil, err + } + + return fiatEstimateResponse(prices), nil +} + // allowCORS wraps the given http.Handler with a function that adds the // Access-Control-Allow-Origin header to the response. func allowCORS(handler http.Handler, origin string) http.Handler {