lnrpc: add cursory REST support to the RPC server

This commit adds a REST interface to the existing gRPC server by
employing a simple http proxy auto-generated from the existing protobuf
files. Currently full-support for any streaming RPC’s are currently
untested. In addition to auto-generating a REST proxy server, a
swagger.json is also generated which allows for gRPC-like native
objects with higher-level clients, and also for auto-generated
documentation.

Due to limitations with accepting raw byte strings as parameters, some
RPC’s have been modified to take both raw-bytes and string arguments.
Additionally a new RPC has been added ‘NewWitnessAddress’ since the
proxy doesn’t currently support enum-based arguments.

Currently the proxy server is embedded within the daemon as an active
HTTP server, however we may want to package the proxy server as a
separate binary in the future. Similarly, we may want to add additional
configuration information which controls the optional inclusion of the
REST proxy.

Atm, just like the current gRPC interface, the REST API is fully
unauthenticated. Before moving to an initial alpha release after making
the necessary changes to meet the spec drafted in Milan, authentication
of the RPC interfaces will be addressed.
This commit is contained in:
Olaoluwa Osuntokun 2016-10-15 14:38:47 -07:00
parent bea555e61d
commit 566cd86a1d
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
8 changed files with 2667 additions and 293 deletions

34
glide.lock generated
View File

@ -1,13 +1,14 @@
hash: 3047655dd4d303e49360573568bb046155e047519243c0ed8b1f8be2fcaf02de
updated: 2016-09-20T16:28:15.627923101-07:00
hash: db69bdd1de1bff79275a16649b87f5c5769a7ce6e889a9babf96dea470d931bf
updated: 2016-10-15T14:19:38.70874686-07:00
imports:
- name: github.com/awalterschulze/gographviz
version: 761fd5fbb34e4c2c138c280395b65b48e4ff5a53
version: d4d8514752339899250316f88a7907468e8eca7e
subpackages:
- ast
- parser
- scanner
- token
- errors
- lexer
- name: github.com/BitfuryLightning/tools
version: b36ae00916b800503504455f7afeb3159bd5ee35
subpackages:
@ -55,11 +56,20 @@ imports:
subpackages:
- spew
- name: github.com/golang/protobuf
version: 1f49d83d9aa00e6ce4fc8258c71cc7786aec968a
version: 98fa357170587e470c5f27d3c3ea0947b71eb455
subpackages:
- proto
- jsonpb
- protoc-gen-go/descriptor
- name: github.com/grpc-ecosystem/grpc-gateway
version: a8f25bd1ab549f8b87afd48aa9181221e9d439bb
subpackages:
- runtime
- third_party/googleapis/google/api
- utilities
- runtime/internal
- name: github.com/howeyc/gopass
version: 26c6e1184fd5255fa5f5289d0b789a4819c203a4
version: f5387c492211eb133053880d23dfae62aa14123d
- name: github.com/lightningnetwork/lightning-onion
version: 81647ffa2c5e17c0447d359e1963a54e18be85c4
- name: github.com/roasbeef/btcd
@ -84,7 +94,7 @@ imports:
- txsort
- base58
- name: github.com/roasbeef/btcwallet
version: 1fd2d6224698e14591d06f2a10b24e86494cc19f
version: 7acd18a96697b180b631631108f1a15448de369f
subpackages:
- chain
- waddrmgr
@ -104,7 +114,7 @@ imports:
- name: github.com/urfave/cli
version: a14d7d367bc02b1f57d88de97926727f2d936387
- name: golang.org/x/crypto
version: 6ab629be5e31660579425a738ba8870beb5b7404
version: 5f31782cfb2b6373211f8f9fbf31283fa234b570
subpackages:
- hkdf
- nacl/secretbox
@ -115,7 +125,7 @@ imports:
- pbkdf2
- ssh/terminal
- name: golang.org/x/net
version: f4fe4abe3c785295ddf81c7f1823bcd3bad391b6
version: 8b4af36cd21a1f85a7484b49feb7c79363106d8e
subpackages:
- context
- http2
@ -125,17 +135,17 @@ imports:
- lex/httplex
- internal/timeseries
- name: golang.org/x/sys
version: 8f0908ab3b2457e2e15403d3697c9ef5cb4b57a9
version: 9bb9f0998d48b31547d975974935ae9b48c7a03c
subpackages:
- unix
- name: google.golang.org/grpc
version: 0032a855ba5c8a3c8e0d71c2deef354b70af1584
version: b1a2821ca5a4fd6b6e48ddfbb7d6d7584d839d21
subpackages:
- grpclog
- codes
- metadata
- credentials
- internal
- metadata
- naming
- transport
- peer

View File

@ -57,3 +57,5 @@ import:
- package: google.golang.org/grpc
version: ^1.0.0
- package: github.com/lightningnetwork/lightning-onion
- package: github.com/grpc-ecosystem/grpc-gateway
version: ^1.1.0

28
lnd.go
View File

@ -1,6 +1,7 @@
package main
import (
"context"
"encoding/hex"
"fmt"
"io/ioutil"
@ -14,11 +15,13 @@ import (
"google.golang.org/grpc"
proxy "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/lightningnetwork/lnd/chainntnfs/btcdnotify"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwallet/btcwallet"
"github.com/roasbeef/btcrpcclient"
)
@ -175,8 +178,9 @@ func lndMain() error {
grpcServer := grpc.NewServer(opts...)
lnrpc.RegisterLightningServer(grpcServer, server.rpcServer)
// Finally, start the grpc server listening for HTTP/2 connections.
lis, err := net.Listen("tcp", fmt.Sprintf("localhost:%d", loadedConfig.RPCPort))
// Next, Start the grpc server listening for HTTP/2 connections.
grpcEndpoint := fmt.Sprintf("localhost:%d", loadedConfig.RPCPort)
lis, err := net.Listen("tcp", grpcEndpoint)
if err != nil {
fmt.Printf("failed to listen: %v", err)
return err
@ -186,6 +190,26 @@ func lndMain() error {
grpcServer.Serve(lis)
}()
// Finally, start the REST proxy for our gRPC server above.
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
defer cancel()
mux := proxy.NewServeMux()
swaggerPattern := proxy.MustPattern(proxy.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "swagger"}, ""))
// TODO(roasbeef): accept path to swagger file as command-line option
mux.Handle("GET", swaggerPattern, func(w http.ResponseWriter, r *http.Request, p map[string]string) {
http.ServeFile(w, r, "lnrpc/rpc.swagger.json")
})
proxyOpts := []grpc.DialOption{grpc.WithInsecure()}
err = lnrpc.RegisterLightningHandlerFromEndpoint(ctx, mux, grpcEndpoint, proxyOpts)
if err != nil {
return err
}
go func() {
rpcsLog.Infof("gRPC proxy started")
http.ListenAndServe(":8080", mux)
}()
// Wait for shutdown signal from either a graceful server stop or from
// the interrupt handler.
<-shutdownChannel

View File

@ -1,3 +1,24 @@
#!/bin/sh
protoc -I . rpc.proto --go_out=plugins=grpc:.
# Generate the protos.
protoc -I/usr/local/include -I. \
-I$GOPATH/src \
-I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
--go_out=Mgoogle/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api,plugins=grpc:. \
rpc.proto
# Generate the REST reverse prozxy.
protoc -I/usr/local/include -I. \
-I$GOPATH/src \
-I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
--grpc-gateway_out=logtostderr=true:. \
rpc.proto
# Finally, generate the swagger file which describes the REST API in detail.
protoc -I/usr/local/include -I. \
-I$GOPATH/src \
-I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
--swagger_out=logtostderr=true:. \
rpc.proto

File diff suppressed because it is too large Load Diff

953
lnrpc/rpc.pb.gw.go Normal file
View File

@ -0,0 +1,953 @@
// Code generated by protoc-gen-grpc-gateway
// source: rpc.proto
// DO NOT EDIT!
/*
Package lnrpc is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package lnrpc
import (
"io"
"net/http"
"github.com/golang/protobuf/proto"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/utilities"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
)
var _ codes.Code
var _ io.Reader
var _ = runtime.String
var _ = utilities.NewDoubleArray
var (
filter_Lightning_WalletBalance_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
func request_Lightning_WalletBalance_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq WalletBalanceRequest
var metadata runtime.ServerMetadata
if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_Lightning_WalletBalance_0); err != nil {
return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.WalletBalance(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func request_Lightning_ChannelBalance_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ChannelBalanceRequest
var metadata runtime.ServerMetadata
msg, err := client.ChannelBalance(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func request_Lightning_GetTransactions_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetTransactionsRequest
var metadata runtime.ServerMetadata
msg, err := client.GetTransactions(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func request_Lightning_SendCoins_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq SendCoinsRequest
var metadata runtime.ServerMetadata
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.SendCoins(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func request_Lightning_NewWitnessAddress_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq NewWitnessAddressRequest
var metadata runtime.ServerMetadata
msg, err := client.NewWitnessAddress(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func request_Lightning_ConnectPeer_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ConnectPeerRequest
var metadata runtime.ServerMetadata
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.ConnectPeer(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func request_Lightning_ListPeers_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ListPeersRequest
var metadata runtime.ServerMetadata
msg, err := client.ListPeers(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func request_Lightning_GetInfo_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetInfoRequest
var metadata runtime.ServerMetadata
msg, err := client.GetInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
var (
filter_Lightning_PendingChannels_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
func request_Lightning_PendingChannels_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq PendingChannelRequest
var metadata runtime.ServerMetadata
if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_Lightning_PendingChannels_0); err != nil {
return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.PendingChannels(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func request_Lightning_ListChannels_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ListChannelsRequest
var metadata runtime.ServerMetadata
msg, err := client.ListChannels(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func request_Lightning_OpenChannel_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (Lightning_OpenChannelClient, runtime.ServerMetadata, error) {
var protoReq OpenChannelRequest
var metadata runtime.ServerMetadata
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
}
stream, err := client.OpenChannel(ctx, &protoReq)
if err != nil {
return nil, metadata, err
}
header, err := stream.Header()
if err != nil {
return nil, metadata, err
}
metadata.HeaderMD = header
return stream, metadata, nil
}
var (
filter_Lightning_CloseChannel_0 = &utilities.DoubleArray{Encoding: map[string]int{"channel_point": 0, "funding_txid": 1, "output_index": 2, "force": 3}, Base: []int{1, 1, 1, 2, 3, 0, 0, 0}, Check: []int{0, 1, 2, 2, 1, 3, 4, 5}}
)
func request_Lightning_CloseChannel_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (Lightning_CloseChannelClient, runtime.ServerMetadata, error) {
var protoReq CloseChannelRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["channel_point.funding_txid"]
if !ok {
return nil, metadata, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_point.funding_txid")
}
err = runtime.PopulateFieldFromPath(&protoReq, "channel_point.funding_txid", val)
if err != nil {
return nil, metadata, err
}
val, ok = pathParams["channel_point.output_index"]
if !ok {
return nil, metadata, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_point.output_index")
}
err = runtime.PopulateFieldFromPath(&protoReq, "channel_point.output_index", val)
if err != nil {
return nil, metadata, err
}
val, ok = pathParams["force"]
if !ok {
return nil, metadata, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "force")
}
protoReq.Force, err = runtime.Bool(val)
if err != nil {
return nil, metadata, err
}
if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_Lightning_CloseChannel_0); err != nil {
return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
}
stream, err := client.CloseChannel(ctx, &protoReq)
if err != nil {
return nil, metadata, err
}
header, err := stream.Header()
if err != nil {
return nil, metadata, err
}
metadata.HeaderMD = header
return stream, metadata, nil
}
func request_Lightning_SendPayment_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (Lightning_SendPaymentClient, runtime.ServerMetadata, error) {
var metadata runtime.ServerMetadata
stream, err := client.SendPayment(ctx)
if err != nil {
grpclog.Printf("Failed to start streaming: %v", err)
return nil, metadata, err
}
dec := marshaler.NewDecoder(req.Body)
handleSend := func() error {
var protoReq SendRequest
err = dec.Decode(&protoReq)
if err == io.EOF {
return err
}
if err != nil {
grpclog.Printf("Failed to decode request: %v", err)
return err
}
if err = stream.Send(&protoReq); err != nil {
grpclog.Printf("Failed to send request: %v", err)
return err
}
return nil
}
if err := handleSend(); err != nil {
if cerr := stream.CloseSend(); cerr != nil {
grpclog.Printf("Failed to terminate client stream: %v", cerr)
}
if err == io.EOF {
return stream, metadata, nil
}
return nil, metadata, err
}
go func() {
for {
if err := handleSend(); err != nil {
break
}
}
if err := stream.CloseSend(); err != nil {
grpclog.Printf("Failed to terminate client stream: %v", err)
}
}()
header, err := stream.Header()
if err != nil {
grpclog.Printf("Failed to get header from client: %v", err)
return nil, metadata, err
}
metadata.HeaderMD = header
return stream, metadata, nil
}
func request_Lightning_AddInvoice_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq Invoice
var metadata runtime.ServerMetadata
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.AddInvoice(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func request_Lightning_ListInvoices_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ListInvoiceRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["pending_only"]
if !ok {
return nil, metadata, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "pending_only")
}
protoReq.PendingOnly, err = runtime.Bool(val)
if err != nil {
return nil, metadata, err
}
msg, err := client.ListInvoices(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
var (
filter_Lightning_LookupInvoice_0 = &utilities.DoubleArray{Encoding: map[string]int{"r_hash_str": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
)
func request_Lightning_LookupInvoice_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq PaymentHash
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["r_hash_str"]
if !ok {
return nil, metadata, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "r_hash_str")
}
protoReq.RHashStr, err = runtime.String(val)
if err != nil {
return nil, metadata, err
}
if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_Lightning_LookupInvoice_0); err != nil {
return nil, metadata, grpc.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.LookupInvoice(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func request_Lightning_SubscribeInvoices_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (Lightning_SubscribeInvoicesClient, runtime.ServerMetadata, error) {
var protoReq InvoiceSubscription
var metadata runtime.ServerMetadata
stream, err := client.SubscribeInvoices(ctx, &protoReq)
if err != nil {
return nil, metadata, err
}
header, err := stream.Header()
if err != nil {
return nil, metadata, err
}
metadata.HeaderMD = header
return stream, metadata, nil
}
// RegisterLightningHandlerFromEndpoint is same as RegisterLightningHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterLightningHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
conn, err := grpc.Dial(endpoint, opts...)
if err != nil {
return err
}
defer func() {
if err != nil {
if cerr := conn.Close(); cerr != nil {
grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
}
return
}
go func() {
<-ctx.Done()
if cerr := conn.Close(); cerr != nil {
grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
}
}()
}()
return RegisterLightningHandler(ctx, mux, conn)
}
// RegisterLightningHandler registers the http handlers for service Lightning to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterLightningHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
client := NewLightningClient(conn)
mux.Handle("GET", pattern_Lightning_WalletBalance_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, req)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
}
resp, md, err := request_Lightning_WalletBalance_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
return
}
forward_Lightning_WalletBalance_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Lightning_ChannelBalance_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, req)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
}
resp, md, err := request_Lightning_ChannelBalance_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
return
}
forward_Lightning_ChannelBalance_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Lightning_GetTransactions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, req)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
}
resp, md, err := request_Lightning_GetTransactions_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
return
}
forward_Lightning_GetTransactions_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_Lightning_SendCoins_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, req)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
}
resp, md, err := request_Lightning_SendCoins_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
return
}
forward_Lightning_SendCoins_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Lightning_NewWitnessAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, req)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
}
resp, md, err := request_Lightning_NewWitnessAddress_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
return
}
forward_Lightning_NewWitnessAddress_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_Lightning_ConnectPeer_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, req)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
}
resp, md, err := request_Lightning_ConnectPeer_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
return
}
forward_Lightning_ConnectPeer_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Lightning_ListPeers_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, req)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
}
resp, md, err := request_Lightning_ListPeers_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
return
}
forward_Lightning_ListPeers_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Lightning_GetInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, req)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
}
resp, md, err := request_Lightning_GetInfo_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
return
}
forward_Lightning_GetInfo_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Lightning_PendingChannels_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, req)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
}
resp, md, err := request_Lightning_PendingChannels_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
return
}
forward_Lightning_PendingChannels_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Lightning_ListChannels_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, req)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
}
resp, md, err := request_Lightning_ListChannels_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
return
}
forward_Lightning_ListChannels_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_Lightning_OpenChannel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, req)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
}
resp, md, err := request_Lightning_OpenChannel_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
return
}
forward_Lightning_OpenChannel_0(ctx, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...)
})
mux.Handle("DELETE", pattern_Lightning_CloseChannel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, req)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
}
resp, md, err := request_Lightning_CloseChannel_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
return
}
forward_Lightning_CloseChannel_0(ctx, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_Lightning_SendPayment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, req)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
}
resp, md, err := request_Lightning_SendPayment_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
return
}
forward_Lightning_SendPayment_0(ctx, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_Lightning_AddInvoice_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, req)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
}
resp, md, err := request_Lightning_AddInvoice_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
return
}
forward_Lightning_AddInvoice_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Lightning_ListInvoices_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, req)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
}
resp, md, err := request_Lightning_ListInvoices_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
return
}
forward_Lightning_ListInvoices_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Lightning_LookupInvoice_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, req)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
}
resp, md, err := request_Lightning_LookupInvoice_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
return
}
forward_Lightning_LookupInvoice_0(ctx, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Lightning_SubscribeInvoices_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, req)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
}
resp, md, err := request_Lightning_SubscribeInvoices_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, outboundMarshaler, w, req, err)
return
}
forward_Lightning_SubscribeInvoices_0(ctx, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_Lightning_WalletBalance_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "balance", "blockchain"}, ""))
pattern_Lightning_ChannelBalance_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "balance", "channels"}, ""))
pattern_Lightning_GetTransactions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "transactions"}, ""))
pattern_Lightning_SendCoins_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "transactions"}, ""))
pattern_Lightning_NewWitnessAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "newaddress"}, ""))
pattern_Lightning_ConnectPeer_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "peers"}, ""))
pattern_Lightning_ListPeers_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "peers"}, ""))
pattern_Lightning_GetInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getinfo"}, ""))
pattern_Lightning_PendingChannels_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "channels", "pending"}, ""))
pattern_Lightning_ListChannels_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "channels"}, ""))
pattern_Lightning_OpenChannel_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "channels"}, ""))
pattern_Lightning_CloseChannel_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"v1", "channels", "channel_point.funding_txid", "channel_point.output_index", "force"}, ""))
pattern_Lightning_SendPayment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "channels", "transactions"}, ""))
pattern_Lightning_AddInvoice_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "invoices"}, ""))
pattern_Lightning_ListInvoices_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "invoices", "pending_only"}, ""))
pattern_Lightning_LookupInvoice_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"v1", "invoices", "r_hash_str"}, ""))
pattern_Lightning_SubscribeInvoices_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "invoices", "subscribe"}, ""))
)
var (
forward_Lightning_WalletBalance_0 = runtime.ForwardResponseMessage
forward_Lightning_ChannelBalance_0 = runtime.ForwardResponseMessage
forward_Lightning_GetTransactions_0 = runtime.ForwardResponseMessage
forward_Lightning_SendCoins_0 = runtime.ForwardResponseMessage
forward_Lightning_NewWitnessAddress_0 = runtime.ForwardResponseMessage
forward_Lightning_ConnectPeer_0 = runtime.ForwardResponseMessage
forward_Lightning_ListPeers_0 = runtime.ForwardResponseMessage
forward_Lightning_GetInfo_0 = runtime.ForwardResponseMessage
forward_Lightning_PendingChannels_0 = runtime.ForwardResponseMessage
forward_Lightning_ListChannels_0 = runtime.ForwardResponseMessage
forward_Lightning_OpenChannel_0 = runtime.ForwardResponseStream
forward_Lightning_CloseChannel_0 = runtime.ForwardResponseStream
forward_Lightning_SendPayment_0 = runtime.ForwardResponseStream
forward_Lightning_AddInvoice_0 = runtime.ForwardResponseMessage
forward_Lightning_ListInvoices_0 = runtime.ForwardResponseMessage
forward_Lightning_LookupInvoice_0 = runtime.ForwardResponseMessage
forward_Lightning_SubscribeInvoices_0 = runtime.ForwardResponseStream
)

View File

@ -1,34 +1,131 @@
syntax = "proto3";
import "google/api/annotations.proto";
package lnrpc;
service Lightning {
rpc WalletBalance(WalletBalanceRequest) returns (WalletBalanceResponse);
rpc ChannelBalance(ChannelBalanceRequest) returns (ChannelBalanceResponse);
rpc WalletBalance(WalletBalanceRequest) returns (WalletBalanceResponse) {
option (google.api.http) = {
get: "/v1/balance/blockchain"
};
}
rpc ChannelBalance(ChannelBalanceRequest) returns (ChannelBalanceResponse) {
option (google.api.http) = {
get: "/v1/balance/channels"
};
}
rpc GetTransactions(GetTransactionsRequest) returns (TransactionDetails) {
option (google.api.http) = {
get: "/v1/transactions"
};
}
rpc SendCoins(SendCoinsRequest) returns (SendCoinsResponse) {
option (google.api.http) = {
post: "/v1/transactions"
body: "*"
};
}
rpc SubscribeTransactions(GetTransactionsRequest) returns (stream Transaction);
rpc SendMany(SendManyRequest) returns (SendManyResponse);
rpc SendCoins(SendCoinsRequest) returns (SendCoinsResponse);
rpc NewAddress(NewAddressRequest) returns (NewAddressResponse);
rpc NewWitnessAddress(NewWitnessAddressRequest) returns (NewAddressResponse) {
option (google.api.http) = {
get: "/v1/newaddress"
};
}
rpc ConnectPeer(ConnectPeerRequest) returns (ConnectPeerResponse);
rpc ListPeers(ListPeersRequest) returns (ListPeersResponse);
rpc GetInfo(GetInfoRequest) returns (GetInfoResponse);
rpc ConnectPeer(ConnectPeerRequest) returns (ConnectPeerResponse) {
option (google.api.http) = {
post: "/v1/peers"
body: "*"
};
}
rpc ListPeers(ListPeersRequest) returns (ListPeersResponse) {
option (google.api.http) = {
get: "/v1/peers"
};
}
rpc GetInfo(GetInfoRequest) returns (GetInfoResponse) {
option (google.api.http) = {
get: "/v1/getinfo"
};
}
rpc OpenChannel(OpenChannelRequest) returns (stream OpenStatusUpdate);
rpc CloseChannel(CloseChannelRequest) returns (stream CloseStatusUpdate);
// TODO(roasbeef): merge with below with bool?
rpc PendingChannels(PendingChannelRequest) returns (PendingChannelResponse) {
option (google.api.http) = {
get: "/v1/channels/pending"
};
}
rpc ListChannels(ListChannelsRequest) returns (ListChannelsResponse) {
option (google.api.http) = {
get: "/v1/channels"
};
}
rpc OpenChannel(OpenChannelRequest) returns (stream OpenStatusUpdate) {
option (google.api.http) = {
post: "/v1/channels"
body: "*"
};
}
rpc CloseChannel(CloseChannelRequest) returns (stream CloseStatusUpdate) {
option (google.api.http) = {
delete: "/v1/channels/{channel_point.funding_txid}/{channel_point.output_index}/{force}"
};
}
rpc PendingChannels(PendingChannelRequest) returns (PendingChannelResponse);
rpc ListChannels(ListChannelsRequest) returns (ListChannelsResponse);
rpc SendPayment(stream SendRequest) returns (stream SendResponse) {
option (google.api.http) = {
post: "/v1/channels/transactions"
body: "*"
};
}
rpc SendPayment(stream SendRequest) returns (stream SendResponse);
rpc AddInvoice(Invoice) returns (AddInvoiceResponse);
rpc LookupInvoice(PaymentHash) returns (Invoice);
rpc ListInvoices(ListInvoiceRequest) returns (ListInvoiceResponse);
rpc AddInvoice(Invoice) returns (AddInvoiceResponse) {
option (google.api.http) = {
post: "/v1/invoices"
body: "*"
};
}
rpc ListInvoices(ListInvoiceRequest) returns (ListInvoiceResponse) {
option (google.api.http) = {
get: "/v1/invoices/{pending_only}"
};
}
rpc LookupInvoice(PaymentHash) returns (Invoice) {
option (google.api.http) = {
get: "/v1/invoices/{r_hash_str}"
};
}
rpc SubscribeInvoices(InvoiceSubscription) returns (stream Invoice) {
option (google.api.http) = {
get: "/v1/invoices/subscribe"
};
}
rpc ShowRoutingTable(ShowRoutingTableRequest) returns (ShowRoutingTableResponse);
}
message Transaction {
string tx_hash = 1;
double amount = 2;
int32 num_confirmations = 3;
string block_hash = 4;
int32 block_height = 5;
int64 time_stamp = 6;
int64 total_fees = 7;
}
message GetTransactionsRequest {
}
message TransactionDetails {
repeated Transaction transactions = 1;
}
message SendRequest {
bytes dest = 1;
int64 amt = 2;
@ -36,13 +133,14 @@ message SendRequest {
bool fast_send = 4;
}
message SendResponse{
message SendResponse {
// TODO(roasbeef): info about route? stats?
}
message ChannelPoint {
bytes funding_txid = 1;
uint32 output_index = 2;
string funding_txid_str = 2;
uint32 output_index = 3;
}
message LightningAddress {
@ -71,9 +169,9 @@ message NewAddressRequest {
NESTED_PUBKEY_HASH = 1;
PUBKEY_HASH = 2;
}
AddressType type = 1;
}
message NewWitnessAddressRequest {}
message NewAddressResponse {
string address = 1;
}
@ -267,7 +365,8 @@ message AddInvoiceResponse {
bytes r_hash = 1;
}
message PaymentHash {
bytes r_hash = 1;
string r_hash_str = 1;
bytes r_hash = 2;
}
message ListInvoiceRequest {
bool pending_only = 1;
@ -275,3 +374,5 @@ message ListInvoiceRequest {
message ListInvoiceResponse {
repeated Invoice invoices = 1;
}
message InvoiceSubscription {}

981
lnrpc/rpc.swagger.json Normal file
View File

@ -0,0 +1,981 @@
{
"swagger": "2.0",
"info": {
"title": "rpc.proto",
"version": "version not set"
},
"schemes": [
"http",
"https"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/v1/balance/blockchain": {
"get": {
"operationId": "WalletBalance",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/lnrpcWalletBalanceResponse"
}
}
},
"tags": [
"Lightning"
]
}
},
"/v1/balance/channels": {
"get": {
"operationId": "ChannelBalance",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/lnrpcChannelBalanceResponse"
}
}
},
"tags": [
"Lightning"
]
}
},
"/v1/channels": {
"get": {
"operationId": "ListChannels",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/lnrpcListChannelsResponse"
}
}
},
"tags": [
"Lightning"
]
},
"post": {
"operationId": "OpenChannel",
"responses": {
"200": {
"description": "(streaming responses)",
"schema": {
"$ref": "#/definitions/lnrpcOpenStatusUpdate"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/lnrpcOpenChannelRequest"
}
}
],
"tags": [
"Lightning"
]
}
},
"/v1/channels/pending": {
"get": {
"operationId": "PendingChannels",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/lnrpcPendingChannelResponse"
}
}
},
"tags": [
"Lightning"
]
}
},
"/v1/channels/transactions": {
"post": {
"operationId": "SendPayment",
"responses": {
"200": {
"description": "(streaming responses)",
"schema": {
"$ref": "#/definitions/lnrpcSendResponse"
}
}
},
"parameters": [
{
"name": "body",
"description": "(streaming inputs)",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/lnrpcSendRequest"
}
}
],
"tags": [
"Lightning"
]
}
},
"/v1/channels/{channel_point.funding_txid}/{channel_point.output_index}/{force}": {
"delete": {
"summary": "TODO(roasbeef): merge with below with bool?",
"operationId": "CloseChannel",
"responses": {
"200": {
"description": "(streaming responses)",
"schema": {
"$ref": "#/definitions/lnrpcCloseStatusUpdate"
}
}
},
"parameters": [
{
"name": "channel_point.funding_txid",
"in": "path",
"required": true,
"type": "string",
"format": "byte"
},
{
"name": "channel_point.output_index",
"in": "path",
"required": true,
"type": "integer",
"format": "int64"
},
{
"name": "force",
"in": "path",
"required": true,
"type": "boolean",
"format": "boolean"
}
],
"tags": [
"Lightning"
]
}
},
"/v1/getinfo": {
"get": {
"operationId": "GetInfo",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/lnrpcGetInfoResponse"
}
}
},
"tags": [
"Lightning"
]
}
},
"/v1/invoices": {
"post": {
"operationId": "AddInvoice",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/lnrpcAddInvoiceResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/lnrpcInvoice"
}
}
],
"tags": [
"Lightning"
]
}
},
"/v1/invoices/subscribe": {
"get": {
"operationId": "SubscribeInvoices",
"responses": {
"200": {
"description": "(streaming responses)",
"schema": {
"$ref": "#/definitions/lnrpcInvoice"
}
}
},
"tags": [
"Lightning"
]
}
},
"/v1/invoices/{pending_only}": {
"get": {
"operationId": "ListInvoices",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/lnrpcListInvoiceResponse"
}
}
},
"parameters": [
{
"name": "pending_only",
"in": "path",
"required": true,
"type": "boolean",
"format": "boolean"
}
],
"tags": [
"Lightning"
]
}
},
"/v1/invoices/{r_hash_str}": {
"get": {
"operationId": "LookupInvoice",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/lnrpcInvoice"
}
}
},
"parameters": [
{
"name": "r_hash_str",
"in": "path",
"required": true,
"type": "string",
"format": "string"
}
],
"tags": [
"Lightning"
]
}
},
"/v1/newaddress": {
"get": {
"operationId": "NewWitnessAddress",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/lnrpcNewAddressResponse"
}
}
},
"tags": [
"Lightning"
]
}
},
"/v1/peers": {
"get": {
"operationId": "ListPeers",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/lnrpcListPeersResponse"
}
}
},
"tags": [
"Lightning"
]
},
"post": {
"operationId": "ConnectPeer",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/lnrpcConnectPeerResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/lnrpcConnectPeerRequest"
}
}
],
"tags": [
"Lightning"
]
}
},
"/v1/transactions": {
"get": {
"operationId": "GetTransactions",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/lnrpcTransactionDetails"
}
}
},
"tags": [
"Lightning"
]
},
"post": {
"operationId": "SendCoins",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/lnrpcSendCoinsResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/lnrpcSendCoinsRequest"
}
}
],
"tags": [
"Lightning"
]
}
}
},
"definitions": {
"PendingChannelResponsePendingChannel": {
"type": "object",
"properties": {
"capacity": {
"type": "string",
"format": "int64"
},
"channel_point": {
"type": "string",
"format": "string"
},
"closing_txid": {
"type": "string",
"format": "string"
},
"lightning_id": {
"type": "string",
"format": "string"
},
"local_balance": {
"type": "string",
"format": "int64"
},
"peer_id": {
"type": "integer",
"format": "int32"
},
"remote_balance": {
"type": "string",
"format": "int64"
},
"status": {
"$ref": "#/definitions/lnrpcChannelStatus"
}
}
},
"lnrpcActiveChannel": {
"type": "object",
"properties": {
"capacity": {
"type": "string",
"format": "int64"
},
"channel_point": {
"type": "string",
"format": "string"
},
"local_balance": {
"type": "string",
"format": "int64"
},
"num_updates": {
"type": "string",
"format": "uint64"
},
"pending_htlcs": {
"type": "array",
"items": {
"$ref": "#/definitions/lnrpcHTLC"
}
},
"remote_balance": {
"type": "string",
"format": "int64"
},
"remote_pubkey": {
"type": "string",
"format": "string"
},
"unsettled_balance": {
"type": "string",
"format": "int64"
}
}
},
"lnrpcAddInvoiceResponse": {
"type": "object",
"properties": {
"r_hash": {
"type": "string",
"format": "byte"
}
}
},
"lnrpcChannelBalanceRequest": {
"type": "object"
},
"lnrpcChannelBalanceResponse": {
"type": "object",
"properties": {
"balance": {
"type": "string",
"format": "int64"
}
}
},
"lnrpcChannelCloseUpdate": {
"type": "object",
"properties": {
"closing_txid": {
"type": "string",
"format": "byte"
},
"success": {
"type": "boolean",
"format": "boolean"
}
}
},
"lnrpcChannelOpenUpdate": {
"type": "object",
"properties": {
"channel_point": {
"$ref": "#/definitions/lnrpcChannelPoint"
}
}
},
"lnrpcChannelPoint": {
"type": "object",
"properties": {
"funding_txid": {
"type": "string",
"format": "byte"
},
"funding_txid_str": {
"type": "string",
"format": "string"
},
"output_index": {
"type": "integer",
"format": "int64"
}
}
},
"lnrpcChannelStatus": {
"type": "string",
"enum": [
"ALL",
"OPENING",
"CLOSING"
],
"default": "ALL"
},
"lnrpcCloseChannelRequest": {
"type": "object",
"properties": {
"channel_point": {
"$ref": "#/definitions/lnrpcChannelPoint"
},
"force": {
"type": "boolean",
"format": "boolean"
},
"time_limit": {
"type": "string",
"format": "int64"
}
}
},
"lnrpcCloseStatusUpdate": {
"type": "object",
"properties": {
"chan_close": {
"$ref": "#/definitions/lnrpcChannelCloseUpdate"
},
"close_pending": {
"$ref": "#/definitions/lnrpcPendingUpdate"
},
"confirmation": {
"$ref": "#/definitions/lnrpcConfirmationUpdate"
}
}
},
"lnrpcConfirmationUpdate": {
"type": "object",
"properties": {
"block_height": {
"type": "integer",
"format": "int32"
},
"block_sha": {
"type": "string",
"format": "byte"
},
"num_confs_left": {
"type": "integer",
"format": "int64"
}
}
},
"lnrpcConnectPeerRequest": {
"type": "object",
"properties": {
"addr": {
"$ref": "#/definitions/lnrpcLightningAddress"
}
}
},
"lnrpcConnectPeerResponse": {
"type": "object",
"properties": {
"peer_id": {
"type": "integer",
"format": "int32"
}
}
},
"lnrpcGetInfoRequest": {
"type": "object"
},
"lnrpcGetInfoResponse": {
"type": "object",
"properties": {
"identity_address": {
"type": "string",
"format": "string"
},
"identity_pubkey": {
"type": "string",
"format": "string"
},
"lightning_id": {
"type": "string",
"format": "string"
},
"num_active_channels": {
"type": "integer",
"format": "int64"
},
"num_peers": {
"type": "integer",
"format": "int64"
},
"num_pending_channels": {
"type": "integer",
"format": "int64"
}
}
},
"lnrpcGetTransactionsRequest": {
"type": "object"
},
"lnrpcHTLC": {
"type": "object",
"properties": {
"amount": {
"type": "string",
"format": "int64"
},
"expiration_height": {
"type": "integer",
"format": "int64"
},
"hash_lock": {
"type": "string",
"format": "byte"
},
"incoming": {
"type": "boolean",
"format": "boolean"
},
"revocation_delay": {
"type": "integer",
"format": "int64"
}
}
},
"lnrpcInvoice": {
"type": "object",
"properties": {
"memo": {
"type": "string",
"format": "string"
},
"r_hash": {
"type": "string",
"format": "byte"
},
"r_preimage": {
"type": "string",
"format": "byte"
},
"receipt": {
"type": "string",
"format": "byte"
},
"settled": {
"type": "boolean",
"format": "boolean"
},
"value": {
"type": "string",
"format": "int64"
}
}
},
"lnrpcInvoiceSubscription": {
"type": "object"
},
"lnrpcLightningAddress": {
"type": "object",
"properties": {
"host": {
"type": "string",
"format": "string"
},
"pubKeyHash": {
"type": "string",
"format": "string"
}
}
},
"lnrpcListChannelsRequest": {
"type": "object"
},
"lnrpcListChannelsResponse": {
"type": "object",
"properties": {
"channels": {
"type": "array",
"items": {
"$ref": "#/definitions/lnrpcActiveChannel"
}
}
}
},
"lnrpcListInvoiceRequest": {
"type": "object",
"properties": {
"pending_only": {
"type": "boolean",
"format": "boolean"
}
}
},
"lnrpcListInvoiceResponse": {
"type": "object",
"properties": {
"invoices": {
"type": "array",
"items": {
"$ref": "#/definitions/lnrpcInvoice"
}
}
}
},
"lnrpcListPeersRequest": {
"type": "object"
},
"lnrpcListPeersResponse": {
"type": "object",
"properties": {
"peers": {
"type": "array",
"items": {
"$ref": "#/definitions/lnrpcPeer"
}
}
}
},
"lnrpcNewAddressResponse": {
"type": "object",
"properties": {
"address": {
"type": "string",
"format": "string"
}
}
},
"lnrpcNewWitnessAddressRequest": {
"type": "object"
},
"lnrpcOpenChannelRequest": {
"type": "object",
"properties": {
"commission_size": {
"type": "string",
"format": "int64"
},
"local_funding_amount": {
"type": "string",
"format": "int64"
},
"num_confs": {
"type": "integer",
"format": "int64"
},
"remote_funding_amount": {
"type": "string",
"format": "int64"
},
"target_node": {
"type": "string",
"format": "byte"
},
"target_peer_id": {
"type": "integer",
"format": "int32"
}
}
},
"lnrpcOpenStatusUpdate": {
"type": "object",
"properties": {
"chan_open": {
"$ref": "#/definitions/lnrpcChannelOpenUpdate"
},
"chan_pending": {
"$ref": "#/definitions/lnrpcPendingUpdate"
},
"confirmation": {
"$ref": "#/definitions/lnrpcConfirmationUpdate"
}
}
},
"lnrpcPaymentHash": {
"type": "object",
"properties": {
"r_hash": {
"type": "string",
"format": "byte"
},
"r_hash_str": {
"type": "string",
"format": "string"
}
}
},
"lnrpcPeer": {
"type": "object",
"properties": {
"address": {
"type": "string",
"format": "string"
},
"bytes_recv": {
"type": "string",
"format": "uint64"
},
"bytes_sent": {
"type": "string",
"format": "uint64"
},
"inbound": {
"type": "boolean",
"format": "boolean"
},
"lightning_id": {
"type": "string",
"format": "string"
},
"peer_id": {
"type": "integer",
"format": "int32"
},
"sat_recv": {
"type": "string",
"format": "int64"
},
"sat_sent": {
"type": "string",
"format": "int64"
}
}
},
"lnrpcPendingChannelRequest": {
"type": "object",
"properties": {
"status": {
"$ref": "#/definitions/lnrpcChannelStatus"
}
}
},
"lnrpcPendingChannelResponse": {
"type": "object",
"properties": {
"pending_channels": {
"type": "array",
"items": {
"$ref": "#/definitions/PendingChannelResponsePendingChannel"
}
}
}
},
"lnrpcPendingUpdate": {
"type": "object",
"properties": {
"txid": {
"type": "string",
"format": "byte"
}
}
},
"lnrpcSendCoinsRequest": {
"type": "object",
"properties": {
"addr": {
"type": "string",
"format": "string"
},
"amount": {
"type": "string",
"format": "int64"
}
}
},
"lnrpcSendCoinsResponse": {
"type": "object",
"properties": {
"txid": {
"type": "string",
"format": "string"
}
}
},
"lnrpcSendRequest": {
"type": "object",
"properties": {
"amt": {
"type": "string",
"format": "int64"
},
"dest": {
"type": "string",
"format": "byte"
},
"fast_send": {
"type": "boolean",
"format": "boolean"
},
"payment_hash": {
"type": "string",
"format": "byte"
}
}
},
"lnrpcSendResponse": {
"type": "object"
},
"lnrpcTransaction": {
"type": "object",
"properties": {
"amount": {
"type": "number",
"format": "double"
},
"block_hash": {
"type": "string",
"format": "string"
},
"block_height": {
"type": "integer",
"format": "int32"
},
"num_confirmations": {
"type": "integer",
"format": "int32"
},
"time_stamp": {
"type": "string",
"format": "int64"
},
"total_fees": {
"type": "string",
"format": "int64"
},
"tx_hash": {
"type": "string",
"format": "string"
}
}
},
"lnrpcTransactionDetails": {
"type": "object",
"properties": {
"transactions": {
"type": "array",
"items": {
"$ref": "#/definitions/lnrpcTransaction"
}
}
}
},
"lnrpcWalletBalanceRequest": {
"type": "object",
"properties": {
"witness_only": {
"type": "boolean",
"format": "boolean"
}
}
},
"lnrpcWalletBalanceResponse": {
"type": "object",
"properties": {
"balance": {
"type": "number",
"format": "double"
}
}
}
}
}