mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-19 05:45:21 +01:00
58317e66d3
Update the falafel version.
124 lines
2.7 KiB
Go
124 lines
2.7 KiB
Go
// Code generated by falafel 0.9.2. DO NOT EDIT.
|
|
// source: chainkit.proto
|
|
|
|
package chainrpc
|
|
|
|
import (
|
|
"context"
|
|
|
|
gateway "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/protobuf/encoding/protojson"
|
|
)
|
|
|
|
func RegisterChainKitJSONCallbacks(registry map[string]func(ctx context.Context,
|
|
conn *grpc.ClientConn, reqJSON string, callback func(string, error))) {
|
|
|
|
marshaler := &gateway.JSONPb{
|
|
MarshalOptions: protojson.MarshalOptions{
|
|
UseProtoNames: true,
|
|
EmitUnpopulated: true,
|
|
},
|
|
}
|
|
|
|
registry["chainrpc.ChainKit.GetBlock"] = func(ctx context.Context,
|
|
conn *grpc.ClientConn, reqJSON string, callback func(string, error)) {
|
|
|
|
req := &GetBlockRequest{}
|
|
err := marshaler.Unmarshal([]byte(reqJSON), req)
|
|
if err != nil {
|
|
callback("", err)
|
|
return
|
|
}
|
|
|
|
client := NewChainKitClient(conn)
|
|
resp, err := client.GetBlock(ctx, req)
|
|
if err != nil {
|
|
callback("", err)
|
|
return
|
|
}
|
|
|
|
respBytes, err := marshaler.Marshal(resp)
|
|
if err != nil {
|
|
callback("", err)
|
|
return
|
|
}
|
|
callback(string(respBytes), nil)
|
|
}
|
|
|
|
registry["chainrpc.ChainKit.GetBlockHeader"] = func(ctx context.Context,
|
|
conn *grpc.ClientConn, reqJSON string, callback func(string, error)) {
|
|
|
|
req := &GetBlockHeaderRequest{}
|
|
err := marshaler.Unmarshal([]byte(reqJSON), req)
|
|
if err != nil {
|
|
callback("", err)
|
|
return
|
|
}
|
|
|
|
client := NewChainKitClient(conn)
|
|
resp, err := client.GetBlockHeader(ctx, req)
|
|
if err != nil {
|
|
callback("", err)
|
|
return
|
|
}
|
|
|
|
respBytes, err := marshaler.Marshal(resp)
|
|
if err != nil {
|
|
callback("", err)
|
|
return
|
|
}
|
|
callback(string(respBytes), nil)
|
|
}
|
|
|
|
registry["chainrpc.ChainKit.GetBestBlock"] = func(ctx context.Context,
|
|
conn *grpc.ClientConn, reqJSON string, callback func(string, error)) {
|
|
|
|
req := &GetBestBlockRequest{}
|
|
err := marshaler.Unmarshal([]byte(reqJSON), req)
|
|
if err != nil {
|
|
callback("", err)
|
|
return
|
|
}
|
|
|
|
client := NewChainKitClient(conn)
|
|
resp, err := client.GetBestBlock(ctx, req)
|
|
if err != nil {
|
|
callback("", err)
|
|
return
|
|
}
|
|
|
|
respBytes, err := marshaler.Marshal(resp)
|
|
if err != nil {
|
|
callback("", err)
|
|
return
|
|
}
|
|
callback(string(respBytes), nil)
|
|
}
|
|
|
|
registry["chainrpc.ChainKit.GetBlockHash"] = func(ctx context.Context,
|
|
conn *grpc.ClientConn, reqJSON string, callback func(string, error)) {
|
|
|
|
req := &GetBlockHashRequest{}
|
|
err := marshaler.Unmarshal([]byte(reqJSON), req)
|
|
if err != nil {
|
|
callback("", err)
|
|
return
|
|
}
|
|
|
|
client := NewChainKitClient(conn)
|
|
resp, err := client.GetBlockHash(ctx, req)
|
|
if err != nil {
|
|
callback("", err)
|
|
return
|
|
}
|
|
|
|
respBytes, err := marshaler.Marshal(resp)
|
|
if err != nil {
|
|
callback("", err)
|
|
return
|
|
}
|
|
callback(string(respBytes), nil)
|
|
}
|
|
}
|