From 38769fb388b187ec51913fe768900938c9b7f2f0 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 22 Oct 2018 21:43:47 -0700 Subject: [PATCH] lnrpc/routerrpc: add protos for new Router sub-server --- lnrpc/routerpc/log.go | 45 ++++ lnrpc/routerrpc/router.pb.go | 441 +++++++++++++++++++++++++++++++++++ lnrpc/routerrpc/router.proto | 103 ++++++++ 3 files changed, 589 insertions(+) create mode 100644 lnrpc/routerpc/log.go create mode 100644 lnrpc/routerrpc/router.pb.go create mode 100644 lnrpc/routerrpc/router.proto diff --git a/lnrpc/routerpc/log.go b/lnrpc/routerpc/log.go new file mode 100644 index 00000000..7421ad39 --- /dev/null +++ b/lnrpc/routerpc/log.go @@ -0,0 +1,45 @@ +package routerpc + +import ( + "github.com/btcsuite/btclog" + "github.com/lightningnetwork/lnd/build" +) + +// log is a logger that is initialized with no output filters. This +// means the package will not perform any logging by default until the caller +// requests it. +var log btclog.Logger + +// The default amount of logging is none. +func init() { + UseLogger(build.NewSubLogger("RRPC", nil)) +} + +// DisableLog disables all library log output. Logging output is disabled +// by default until UseLogger is called. +func DisableLog() { + UseLogger(btclog.Disabled) +} + +// UseLogger uses a specified Logger to output package logging info. +// This should be used in preference to SetLogWriter if the caller is also +// using btclog. +func UseLogger(logger btclog.Logger) { + log = logger +} + +// logClosure is used to provide a closure over expensive logging operations so +// don't have to be performed when the logging level doesn't warrant it. +type logClosure func() string + +// String invokes the underlying function and returns the result. +func (c logClosure) String() string { + return c() +} + +// newLogClosure returns a new closure over a function that returns a string +// which itself provides a Stringer interface so that it can be used with the +// logging system. +func newLogClosure(c func() string) logClosure { + return logClosure(c) +} diff --git a/lnrpc/routerrpc/router.pb.go b/lnrpc/routerrpc/router.pb.go new file mode 100644 index 00000000..cd7bcfe4 --- /dev/null +++ b/lnrpc/routerrpc/router.pb.go @@ -0,0 +1,441 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: routerrpc/router.proto + +package routerrpc + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +import ( + context "golang.org/x/net/context" + grpc "google.golang.org/grpc" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package + +type PaymentRequest struct { + // * + // A serialized BOLT-11 payment request that contains all information + // required to dispatch the payment. If the pay req is invalid, or expired, + // an error will be returned. + PayReq string `protobuf:"bytes,1,opt,name=pay_req,json=payReq,proto3" json:"pay_req,omitempty"` + // * + // An absolute limit on the highest fee we should pay when looking for a route + // to the destination. Routes with fees higher than this will be ignored, if + // there are no routes with a fee below this amount, an error will be + // returned. + FeeLimitSat int64 `protobuf:"varint,2,opt,name=fee_limit_sat,json=feeLimitSat,proto3" json:"fee_limit_sat,omitempty"` + // * + // An absolute limit on the cumulative CLTV value along the route for this + // payment. Routes with total CLTV values higher than this will be ignored, + // if there are no routes with a CLTV value below this amount, an error will + // be returned. + CltvLimit int32 `protobuf:"varint,3,opt,name=cltv_limit,json=cltvLimit,proto3" json:"cltv_limit,omitempty"` + // * + // An upper limit on the amount of time we should spend when attempting to + // fulfill the payment. This is expressed in seconds. If we cannot make a + // successful payment within this time frame, an error will be returned. + TimeoutSeconds int32 `protobuf:"varint,4,opt,name=timeout_seconds,json=timeoutSeconds,proto3" json:"timeout_seconds,omitempty"` + // * + // The channel id of the channel that must be taken to the first hop. If zero, + // any channel may be used. + OutgoingChannelId int64 `protobuf:"varint,5,opt,name=outgoing_channel_id,json=outgoingChannelId,proto3" json:"outgoing_channel_id,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *PaymentRequest) Reset() { *m = PaymentRequest{} } +func (m *PaymentRequest) String() string { return proto.CompactTextString(m) } +func (*PaymentRequest) ProtoMessage() {} +func (*PaymentRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_router_e218e7c710fe8172, []int{0} +} +func (m *PaymentRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_PaymentRequest.Unmarshal(m, b) +} +func (m *PaymentRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_PaymentRequest.Marshal(b, m, deterministic) +} +func (dst *PaymentRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_PaymentRequest.Merge(dst, src) +} +func (m *PaymentRequest) XXX_Size() int { + return xxx_messageInfo_PaymentRequest.Size(m) +} +func (m *PaymentRequest) XXX_DiscardUnknown() { + xxx_messageInfo_PaymentRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_PaymentRequest proto.InternalMessageInfo + +func (m *PaymentRequest) GetPayReq() string { + if m != nil { + return m.PayReq + } + return "" +} + +func (m *PaymentRequest) GetFeeLimitSat() int64 { + if m != nil { + return m.FeeLimitSat + } + return 0 +} + +func (m *PaymentRequest) GetCltvLimit() int32 { + if m != nil { + return m.CltvLimit + } + return 0 +} + +func (m *PaymentRequest) GetTimeoutSeconds() int32 { + if m != nil { + return m.TimeoutSeconds + } + return 0 +} + +func (m *PaymentRequest) GetOutgoingChannelId() int64 { + if m != nil { + return m.OutgoingChannelId + } + return 0 +} + +type PaymentResponse struct { + // * + // The payment hash that we paid to. Provided so callers are able to map + // responses (which may be streaming) back to their original requests. + PayHash []byte `protobuf:"bytes,1,opt,name=pay_hash,json=payHash,proto3" json:"pay_hash,omitempty"` + // * + // The pre-image of the payment successfully completed. + PreImage []byte `protobuf:"bytes,2,opt,name=pre_image,json=preImage,proto3" json:"pre_image,omitempty"` + // * + // If not an empty string, then a string representation of the payment error. + PaymentErr string `protobuf:"bytes,3,opt,name=payment_err,json=paymentErr,proto3" json:"payment_err,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *PaymentResponse) Reset() { *m = PaymentResponse{} } +func (m *PaymentResponse) String() string { return proto.CompactTextString(m) } +func (*PaymentResponse) ProtoMessage() {} +func (*PaymentResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_router_e218e7c710fe8172, []int{1} +} +func (m *PaymentResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_PaymentResponse.Unmarshal(m, b) +} +func (m *PaymentResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_PaymentResponse.Marshal(b, m, deterministic) +} +func (dst *PaymentResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_PaymentResponse.Merge(dst, src) +} +func (m *PaymentResponse) XXX_Size() int { + return xxx_messageInfo_PaymentResponse.Size(m) +} +func (m *PaymentResponse) XXX_DiscardUnknown() { + xxx_messageInfo_PaymentResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_PaymentResponse proto.InternalMessageInfo + +func (m *PaymentResponse) GetPayHash() []byte { + if m != nil { + return m.PayHash + } + return nil +} + +func (m *PaymentResponse) GetPreImage() []byte { + if m != nil { + return m.PreImage + } + return nil +} + +func (m *PaymentResponse) GetPaymentErr() string { + if m != nil { + return m.PaymentErr + } + return "" +} + +type RouteFeeRequest struct { + // * + // The destination once wishes to obtain a routing fee quote to. + Dest []byte `protobuf:"bytes,1,opt,name=dest,proto3" json:"dest,omitempty"` + // * + // The amount one wishes to send to the target destination. + AmtSat int64 `protobuf:"varint,2,opt,name=amt_sat,json=amtSat,proto3" json:"amt_sat,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *RouteFeeRequest) Reset() { *m = RouteFeeRequest{} } +func (m *RouteFeeRequest) String() string { return proto.CompactTextString(m) } +func (*RouteFeeRequest) ProtoMessage() {} +func (*RouteFeeRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_router_e218e7c710fe8172, []int{2} +} +func (m *RouteFeeRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_RouteFeeRequest.Unmarshal(m, b) +} +func (m *RouteFeeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_RouteFeeRequest.Marshal(b, m, deterministic) +} +func (dst *RouteFeeRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_RouteFeeRequest.Merge(dst, src) +} +func (m *RouteFeeRequest) XXX_Size() int { + return xxx_messageInfo_RouteFeeRequest.Size(m) +} +func (m *RouteFeeRequest) XXX_DiscardUnknown() { + xxx_messageInfo_RouteFeeRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_RouteFeeRequest proto.InternalMessageInfo + +func (m *RouteFeeRequest) GetDest() []byte { + if m != nil { + return m.Dest + } + return nil +} + +func (m *RouteFeeRequest) GetAmtSat() int64 { + if m != nil { + return m.AmtSat + } + return 0 +} + +type RouteFeeResponse struct { + // * + // A lower bound of the estimated fee to the target destination within the + // network, expressed in milli-satoshis. + RoutingFeeMsat int64 `protobuf:"varint,1,opt,name=routing_fee_msat,json=routingFeeMsat,proto3" json:"routing_fee_msat,omitempty"` + // * + // An estimate of the worst case time delay that can occur. Note that callers + // will still need to factor in the final CLTV delta of the last hop into this + // value. + TimeLockDelay int64 `protobuf:"varint,2,opt,name=time_lock_delay,json=timeLockDelay,proto3" json:"time_lock_delay,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *RouteFeeResponse) Reset() { *m = RouteFeeResponse{} } +func (m *RouteFeeResponse) String() string { return proto.CompactTextString(m) } +func (*RouteFeeResponse) ProtoMessage() {} +func (*RouteFeeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_router_e218e7c710fe8172, []int{3} +} +func (m *RouteFeeResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_RouteFeeResponse.Unmarshal(m, b) +} +func (m *RouteFeeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_RouteFeeResponse.Marshal(b, m, deterministic) +} +func (dst *RouteFeeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_RouteFeeResponse.Merge(dst, src) +} +func (m *RouteFeeResponse) XXX_Size() int { + return xxx_messageInfo_RouteFeeResponse.Size(m) +} +func (m *RouteFeeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_RouteFeeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_RouteFeeResponse proto.InternalMessageInfo + +func (m *RouteFeeResponse) GetRoutingFeeMsat() int64 { + if m != nil { + return m.RoutingFeeMsat + } + return 0 +} + +func (m *RouteFeeResponse) GetTimeLockDelay() int64 { + if m != nil { + return m.TimeLockDelay + } + return 0 +} + +func init() { + proto.RegisterType((*PaymentRequest)(nil), "routerrpc.PaymentRequest") + proto.RegisterType((*PaymentResponse)(nil), "routerrpc.PaymentResponse") + proto.RegisterType((*RouteFeeRequest)(nil), "routerrpc.RouteFeeRequest") + proto.RegisterType((*RouteFeeResponse)(nil), "routerrpc.RouteFeeResponse") +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// RouterClient is the client API for Router service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type RouterClient interface { + // * + // SendPayment attempts to route a payment described by the passed + // PaymentRequest to the final destination. If we are unable to route the + // payment, or cannot find a route that satisfies the constraints in the + // PaymentRequest, then an error will be returned. Otherwise, the payment + // pre-image, along with the final route will be returned. + SendPayment(ctx context.Context, in *PaymentRequest, opts ...grpc.CallOption) (*PaymentResponse, error) + // * + // EstimateRouteFee allows callers to obtain a lower bound w.r.t how much it + // may cost to send an HTLC to the target end destination. + EstimateRouteFee(ctx context.Context, in *RouteFeeRequest, opts ...grpc.CallOption) (*RouteFeeResponse, error) +} + +type routerClient struct { + cc *grpc.ClientConn +} + +func NewRouterClient(cc *grpc.ClientConn) RouterClient { + return &routerClient{cc} +} + +func (c *routerClient) SendPayment(ctx context.Context, in *PaymentRequest, opts ...grpc.CallOption) (*PaymentResponse, error) { + out := new(PaymentResponse) + err := c.cc.Invoke(ctx, "/routerrpc.Router/SendPayment", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *routerClient) EstimateRouteFee(ctx context.Context, in *RouteFeeRequest, opts ...grpc.CallOption) (*RouteFeeResponse, error) { + out := new(RouteFeeResponse) + err := c.cc.Invoke(ctx, "/routerrpc.Router/EstimateRouteFee", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// RouterServer is the server API for Router service. +type RouterServer interface { + // * + // SendPayment attempts to route a payment described by the passed + // PaymentRequest to the final destination. If we are unable to route the + // payment, or cannot find a route that satisfies the constraints in the + // PaymentRequest, then an error will be returned. Otherwise, the payment + // pre-image, along with the final route will be returned. + SendPayment(context.Context, *PaymentRequest) (*PaymentResponse, error) + // * + // EstimateRouteFee allows callers to obtain a lower bound w.r.t how much it + // may cost to send an HTLC to the target end destination. + EstimateRouteFee(context.Context, *RouteFeeRequest) (*RouteFeeResponse, error) +} + +func RegisterRouterServer(s *grpc.Server, srv RouterServer) { + s.RegisterService(&_Router_serviceDesc, srv) +} + +func _Router_SendPayment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PaymentRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RouterServer).SendPayment(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/routerrpc.Router/SendPayment", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RouterServer).SendPayment(ctx, req.(*PaymentRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Router_EstimateRouteFee_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RouteFeeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RouterServer).EstimateRouteFee(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/routerrpc.Router/EstimateRouteFee", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RouterServer).EstimateRouteFee(ctx, req.(*RouteFeeRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Router_serviceDesc = grpc.ServiceDesc{ + ServiceName: "routerrpc.Router", + HandlerType: (*RouterServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SendPayment", + Handler: _Router_SendPayment_Handler, + }, + { + MethodName: "EstimateRouteFee", + Handler: _Router_EstimateRouteFee_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "routerrpc/router.proto", +} + +func init() { proto.RegisterFile("routerrpc/router.proto", fileDescriptor_router_e218e7c710fe8172) } + +var fileDescriptor_router_e218e7c710fe8172 = []byte{ + // 409 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0xdf, 0x6e, 0xd3, 0x30, + 0x14, 0xc6, 0x15, 0xb6, 0x85, 0xe5, 0x74, 0x6b, 0x8b, 0x91, 0x20, 0xeb, 0x84, 0xa8, 0x72, 0x01, + 0xb9, 0x0a, 0x12, 0xdc, 0x73, 0xc3, 0x36, 0x31, 0x31, 0x24, 0xe4, 0x3e, 0x80, 0x65, 0x92, 0xb3, + 0x26, 0x34, 0x8e, 0x5d, 0xdb, 0x41, 0xca, 0xb3, 0xf0, 0x3c, 0xbc, 0x17, 0xb2, 0xe3, 0x96, 0x82, + 0x7a, 0xe7, 0x7c, 0xe7, 0xef, 0xf7, 0x3b, 0x81, 0x17, 0x5a, 0xf6, 0x16, 0xb5, 0x56, 0xe5, 0xbb, + 0xf1, 0x55, 0x28, 0x2d, 0xad, 0x24, 0xc9, 0x5e, 0xcf, 0x7e, 0x47, 0x30, 0xfd, 0xc6, 0x07, 0x81, + 0x9d, 0xa5, 0xb8, 0xed, 0xd1, 0x58, 0xf2, 0x12, 0x9e, 0x2a, 0x3e, 0x30, 0x8d, 0xdb, 0x34, 0x5a, + 0x46, 0x79, 0x42, 0x63, 0xc5, 0x07, 0x8a, 0x5b, 0x92, 0xc1, 0xe5, 0x23, 0x22, 0x6b, 0x1b, 0xd1, + 0x58, 0x66, 0xb8, 0x4d, 0x9f, 0x2c, 0xa3, 0xfc, 0x84, 0x4e, 0x1e, 0x11, 0x1f, 0x9c, 0xb6, 0xe2, + 0x96, 0xbc, 0x02, 0x28, 0x5b, 0xfb, 0x73, 0x4c, 0x4a, 0x4f, 0x96, 0x51, 0x7e, 0x46, 0x13, 0xa7, + 0xf8, 0x0c, 0xf2, 0x16, 0x66, 0xb6, 0x11, 0x28, 0x7b, 0xcb, 0x0c, 0x96, 0xb2, 0xab, 0x4c, 0x7a, + 0xea, 0x73, 0xa6, 0x41, 0x5e, 0x8d, 0x2a, 0x29, 0xe0, 0xb9, 0xec, 0xed, 0x5a, 0x36, 0xdd, 0x9a, + 0x95, 0x35, 0xef, 0x3a, 0x6c, 0x59, 0x53, 0xa5, 0x67, 0x7e, 0xe2, 0xb3, 0x5d, 0xe8, 0xd3, 0x18, + 0xb9, 0xaf, 0xb2, 0x1f, 0x30, 0xdb, 0xdb, 0x30, 0x4a, 0x76, 0x06, 0xc9, 0x15, 0x9c, 0x3b, 0x1f, + 0x35, 0x37, 0xb5, 0x37, 0x72, 0x41, 0x9d, 0xaf, 0xcf, 0xdc, 0xd4, 0xe4, 0x1a, 0x12, 0xa5, 0x91, + 0x35, 0x82, 0xaf, 0xd1, 0xbb, 0xb8, 0xa0, 0xe7, 0x4a, 0xe3, 0xbd, 0xfb, 0x26, 0xaf, 0x61, 0xa2, + 0xc6, 0x56, 0x0c, 0xb5, 0xf6, 0x1e, 0x12, 0x0a, 0x41, 0xba, 0xd5, 0x3a, 0xfb, 0x08, 0x33, 0xea, + 0x00, 0xde, 0x21, 0xee, 0x98, 0x11, 0x38, 0xad, 0xd0, 0xd8, 0x30, 0xc7, 0xbf, 0x1d, 0x47, 0x2e, + 0x0e, 0x41, 0xc5, 0x5c, 0x38, 0x46, 0x59, 0x05, 0xf3, 0xbf, 0xf5, 0x61, 0xd9, 0x1c, 0xe6, 0xee, + 0x28, 0xce, 0xae, 0x63, 0x2c, 0x5c, 0x55, 0xe4, 0xab, 0xa6, 0x41, 0xbf, 0x43, 0xfc, 0x6a, 0xb8, + 0x25, 0x6f, 0x46, 0x84, 0xac, 0x95, 0xe5, 0x86, 0x55, 0xd8, 0xf2, 0x21, 0xb4, 0xbf, 0x74, 0xf2, + 0x83, 0x2c, 0x37, 0x37, 0x4e, 0x7c, 0xff, 0x2b, 0x82, 0xd8, 0x8f, 0xd1, 0xe4, 0x06, 0x26, 0x2b, + 0xec, 0xaa, 0x00, 0x88, 0x5c, 0x15, 0xfb, 0xfb, 0x17, 0xff, 0xde, 0x7e, 0xb1, 0x38, 0x16, 0x0a, + 0x2b, 0x7e, 0x81, 0xf9, 0xad, 0xb1, 0x8d, 0xe0, 0x16, 0x77, 0xeb, 0x93, 0xc3, 0xfc, 0xff, 0x98, + 0x2c, 0xae, 0x8f, 0xc6, 0xc6, 0x66, 0xdf, 0x63, 0xff, 0x27, 0x7e, 0xf8, 0x13, 0x00, 0x00, 0xff, + 0xff, 0x95, 0xc2, 0xf8, 0xec, 0xa3, 0x02, 0x00, 0x00, +} diff --git a/lnrpc/routerrpc/router.proto b/lnrpc/routerrpc/router.proto new file mode 100644 index 00000000..4ab4af29 --- /dev/null +++ b/lnrpc/routerrpc/router.proto @@ -0,0 +1,103 @@ +syntax = "proto3"; + +package routerrpc; + +message PaymentRequest { + /** + A serialized BOLT-11 payment request that contains all information + required to dispatch the payment. If the pay req is invalid, or expired, + an error will be returned. + */ + string pay_req = 1; + + /** + An absolute limit on the highest fee we should pay when looking for a route + to the destination. Routes with fees higher than this will be ignored, if + there are no routes with a fee below this amount, an error will be + returned. + */ + int64 fee_limit_sat = 2; + + /** + An absolute limit on the cumulative CLTV value along the route for this + payment. Routes with total CLTV values higher than this will be ignored, + if there are no routes with a CLTV value below this amount, an error will + be returned. + */ + int32 cltv_limit = 3; + + /** + An upper limit on the amount of time we should spend when attempting to + fulfill the payment. This is expressed in seconds. If we cannot make a + successful payment within this time frame, an error will be returned. + */ + int32 timeout_seconds = 4; + + /** + The channel id of the channel that must be taken to the first hop. If zero, + any channel may be used. + */ + int64 outgoing_channel_id = 5; +} + +message PaymentResponse { + /** + The payment hash that we paid to. Provided so callers are able to map + responses (which may be streaming) back to their original requests. + */ + bytes pay_hash = 1; + + /** + The pre-image of the payment successfully completed. + */ + bytes pre_image = 2; + + /** + If not an empty string, then a string representation of the payment error. + */ + string payment_err = 3; +} + +message RouteFeeRequest { + /** + The destination once wishes to obtain a routing fee quote to. + */ + bytes dest = 1; + + /** + The amount one wishes to send to the target destination. + */ + int64 amt_sat = 2; +} + +message RouteFeeResponse { + /** + A lower bound of the estimated fee to the target destination within the + network, expressed in milli-satoshis. + */ + int64 routing_fee_msat = 1; + + /** + An estimate of the worst case time delay that can occur. Note that callers + will still need to factor in the final CLTV delta of the last hop into this + value. + */ + int64 time_lock_delay = 2; +} + +service Router { + /** + SendPayment attempts to route a payment described by the passed + PaymentRequest to the final destination. If we are unable to route the + payment, or cannot find a route that satisfies the constraints in the + PaymentRequest, then an error will be returned. Otherwise, the payment + pre-image, along with the final route will be returned. + */ + rpc SendPayment(PaymentRequest) returns (PaymentResponse); + + /** + EstimateRouteFee allows callers to obtain a lower bound w.r.t how much it + may cost to send an HTLC to the target end destination. + */ + rpc EstimateRouteFee(RouteFeeRequest) returns (RouteFeeResponse); +}