diff --git a/lnrpc/neutrinorpc/driver.go b/lnrpc/neutrinorpc/driver.go new file mode 100644 index 000000000..9bfe7ccd1 --- /dev/null +++ b/lnrpc/neutrinorpc/driver.go @@ -0,0 +1,55 @@ +//go:build neutrinorpc +// +build neutrinorpc + +package neutrinorpc + +import ( + "fmt" + + "github.com/lightningnetwork/lnd/lnrpc" +) + +// createNewSubServer is a helper method that will create the new sub server +// given the main config dispatcher method. If we're unable to find the config +// that is meant for us in the config dispatcher, then we'll exit with an +// error. +func createNewSubServer(configRegistry lnrpc.SubServerConfigDispatcher) ( + *Server, lnrpc.MacaroonPerms, error) { + + // We'll attempt to look up the config that we expect, according to our + // subServerName name. If we can't find this, then we'll exit with an + // error, as we're unable to properly initialize ourselves without this + // config. + subServerConf, ok := configRegistry.FetchConfig(subServerName) + if !ok { + return nil, nil, fmt.Errorf("unable to find config for "+ + "subserver type %s", subServerName) + } + + // Now that we've found an object mapping to our service name, we'll + // ensure that it's the type we need. + config, ok := subServerConf.(*Config) + if !ok { + return nil, nil, fmt.Errorf("wrong type of config for "+ + "subserver %s, expected %T got %T", subServerName, + &Config{}, subServerConf) + } + + return New(config) +} + +func init() { + subServer := &lnrpc.SubServerDriver{ + SubServerName: subServerName, + NewGrpcHandler: func() lnrpc.GrpcHandler { + return &ServerShell{} + }, + } + + // If the build tag is active, then we'll register ourselves as a + // sub-RPC server within the global lnrpc package namespace. + if err := lnrpc.RegisterSubServer(subServer); err != nil { + panic(fmt.Sprintf("failed to register sub server driver "+ + "'%s': %v", subServerName, err)) + } +} diff --git a/lnrpc/neutrinorpc/neutrino.pb.go b/lnrpc/neutrinorpc/neutrino.pb.go new file mode 100644 index 000000000..7395197ce --- /dev/null +++ b/lnrpc/neutrinorpc/neutrino.pb.go @@ -0,0 +1,1343 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v3.6.1 +// source: neutrinorpc/neutrino.proto + +package neutrinorpc + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type StatusRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *StatusRequest) Reset() { + *x = StatusRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StatusRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StatusRequest) ProtoMessage() {} + +func (x *StatusRequest) ProtoReflect() protoreflect.Message { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StatusRequest.ProtoReflect.Descriptor instead. +func (*StatusRequest) Descriptor() ([]byte, []int) { + return file_neutrinorpc_neutrino_proto_rawDescGZIP(), []int{0} +} + +type StatusResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Indicates whether the neutrino backend is active or not. + Active bool `protobuf:"varint,1,opt,name=active,proto3" json:"active,omitempty"` + // Is fully synced. + Synced bool `protobuf:"varint,2,opt,name=synced,proto3" json:"synced,omitempty"` + // Best block height. + BlockHeight int32 `protobuf:"varint,3,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` + // Best block hash. + BlockHash string `protobuf:"bytes,4,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"` + // Connected peers. + Peers []string `protobuf:"bytes,5,rep,name=peers,proto3" json:"peers,omitempty"` +} + +func (x *StatusResponse) Reset() { + *x = StatusResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StatusResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StatusResponse) ProtoMessage() {} + +func (x *StatusResponse) ProtoReflect() protoreflect.Message { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StatusResponse.ProtoReflect.Descriptor instead. +func (*StatusResponse) Descriptor() ([]byte, []int) { + return file_neutrinorpc_neutrino_proto_rawDescGZIP(), []int{1} +} + +func (x *StatusResponse) GetActive() bool { + if x != nil { + return x.Active + } + return false +} + +func (x *StatusResponse) GetSynced() bool { + if x != nil { + return x.Synced + } + return false +} + +func (x *StatusResponse) GetBlockHeight() int32 { + if x != nil { + return x.BlockHeight + } + return 0 +} + +func (x *StatusResponse) GetBlockHash() string { + if x != nil { + return x.BlockHash + } + return "" +} + +func (x *StatusResponse) GetPeers() []string { + if x != nil { + return x.Peers + } + return nil +} + +type AddPeerRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Peer to add. + PeerAddrs string `protobuf:"bytes,1,opt,name=peer_addrs,json=peerAddrs,proto3" json:"peer_addrs,omitempty"` +} + +func (x *AddPeerRequest) Reset() { + *x = AddPeerRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddPeerRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddPeerRequest) ProtoMessage() {} + +func (x *AddPeerRequest) ProtoReflect() protoreflect.Message { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddPeerRequest.ProtoReflect.Descriptor instead. +func (*AddPeerRequest) Descriptor() ([]byte, []int) { + return file_neutrinorpc_neutrino_proto_rawDescGZIP(), []int{2} +} + +func (x *AddPeerRequest) GetPeerAddrs() string { + if x != nil { + return x.PeerAddrs + } + return "" +} + +type AddPeerResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *AddPeerResponse) Reset() { + *x = AddPeerResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddPeerResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddPeerResponse) ProtoMessage() {} + +func (x *AddPeerResponse) ProtoReflect() protoreflect.Message { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddPeerResponse.ProtoReflect.Descriptor instead. +func (*AddPeerResponse) Descriptor() ([]byte, []int) { + return file_neutrinorpc_neutrino_proto_rawDescGZIP(), []int{3} +} + +type DisconnectPeerRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Peer to disconnect. + PeerAddrs string `protobuf:"bytes,1,opt,name=peer_addrs,json=peerAddrs,proto3" json:"peer_addrs,omitempty"` +} + +func (x *DisconnectPeerRequest) Reset() { + *x = DisconnectPeerRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DisconnectPeerRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DisconnectPeerRequest) ProtoMessage() {} + +func (x *DisconnectPeerRequest) ProtoReflect() protoreflect.Message { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DisconnectPeerRequest.ProtoReflect.Descriptor instead. +func (*DisconnectPeerRequest) Descriptor() ([]byte, []int) { + return file_neutrinorpc_neutrino_proto_rawDescGZIP(), []int{4} +} + +func (x *DisconnectPeerRequest) GetPeerAddrs() string { + if x != nil { + return x.PeerAddrs + } + return "" +} + +type DisconnectPeerResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *DisconnectPeerResponse) Reset() { + *x = DisconnectPeerResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DisconnectPeerResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DisconnectPeerResponse) ProtoMessage() {} + +func (x *DisconnectPeerResponse) ProtoReflect() protoreflect.Message { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DisconnectPeerResponse.ProtoReflect.Descriptor instead. +func (*DisconnectPeerResponse) Descriptor() ([]byte, []int) { + return file_neutrinorpc_neutrino_proto_rawDescGZIP(), []int{5} +} + +type IsBannedRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Peer to lookup. + PeerAddrs string `protobuf:"bytes,1,opt,name=peer_addrs,json=peerAddrs,proto3" json:"peer_addrs,omitempty"` +} + +func (x *IsBannedRequest) Reset() { + *x = IsBannedRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IsBannedRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IsBannedRequest) ProtoMessage() {} + +func (x *IsBannedRequest) ProtoReflect() protoreflect.Message { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use IsBannedRequest.ProtoReflect.Descriptor instead. +func (*IsBannedRequest) Descriptor() ([]byte, []int) { + return file_neutrinorpc_neutrino_proto_rawDescGZIP(), []int{6} +} + +func (x *IsBannedRequest) GetPeerAddrs() string { + if x != nil { + return x.PeerAddrs + } + return "" +} + +type IsBannedResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Banned bool `protobuf:"varint,1,opt,name=banned,proto3" json:"banned,omitempty"` +} + +func (x *IsBannedResponse) Reset() { + *x = IsBannedResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IsBannedResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IsBannedResponse) ProtoMessage() {} + +func (x *IsBannedResponse) ProtoReflect() protoreflect.Message { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use IsBannedResponse.ProtoReflect.Descriptor instead. +func (*IsBannedResponse) Descriptor() ([]byte, []int) { + return file_neutrinorpc_neutrino_proto_rawDescGZIP(), []int{7} +} + +func (x *IsBannedResponse) GetBanned() bool { + if x != nil { + return x.Banned + } + return false +} + +type GetBlockHeaderRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Block hash in hex notation. + Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` +} + +func (x *GetBlockHeaderRequest) Reset() { + *x = GetBlockHeaderRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetBlockHeaderRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetBlockHeaderRequest) ProtoMessage() {} + +func (x *GetBlockHeaderRequest) ProtoReflect() protoreflect.Message { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetBlockHeaderRequest.ProtoReflect.Descriptor instead. +func (*GetBlockHeaderRequest) Descriptor() ([]byte, []int) { + return file_neutrinorpc_neutrino_proto_rawDescGZIP(), []int{8} +} + +func (x *GetBlockHeaderRequest) GetHash() string { + if x != nil { + return x.Hash + } + return "" +} + +type GetBlockHeaderResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The block hash (same as provided). + Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` + // The number of confirmations. + Confirmations int64 `protobuf:"varint,2,opt,name=confirmations,proto3" json:"confirmations,omitempty"` + // The block size excluding witness data. + StrippedSize int64 `protobuf:"varint,3,opt,name=stripped_size,json=strippedSize,proto3" json:"stripped_size,omitempty"` + // The block size (bytes). + Size int64 `protobuf:"varint,4,opt,name=size,proto3" json:"size,omitempty"` + // The block weight as defined in BIP 141. + Weight int64 `protobuf:"varint,5,opt,name=weight,proto3" json:"weight,omitempty"` + // The block height or index. + Height int32 `protobuf:"varint,6,opt,name=height,proto3" json:"height,omitempty"` + // The block version. + Version int32 `protobuf:"varint,7,opt,name=version,proto3" json:"version,omitempty"` + // The block version. + VersionHex string `protobuf:"bytes,8,opt,name=version_hex,json=versionHex,proto3" json:"version_hex,omitempty"` + // The merkle root. + Merkleroot string `protobuf:"bytes,9,opt,name=merkleroot,proto3" json:"merkleroot,omitempty"` + // The block time in seconds since epoch (Jan 1 1970 GMT). + Time int64 `protobuf:"varint,10,opt,name=time,proto3" json:"time,omitempty"` + // The nonce. + Nonce uint32 `protobuf:"varint,11,opt,name=nonce,proto3" json:"nonce,omitempty"` + // The bits in hex notation. + Bits string `protobuf:"bytes,12,opt,name=bits,proto3" json:"bits,omitempty"` + // The number of transactions in the block. + Ntx int32 `protobuf:"varint,13,opt,name=ntx,proto3" json:"ntx,omitempty"` + // The hash of the previous block. + PreviousBlockHash string `protobuf:"bytes,14,opt,name=previous_block_hash,json=previousBlockHash,proto3" json:"previous_block_hash,omitempty"` + // The raw hex of the block. + RawHex []byte `protobuf:"bytes,15,opt,name=raw_hex,json=rawHex,proto3" json:"raw_hex,omitempty"` +} + +func (x *GetBlockHeaderResponse) Reset() { + *x = GetBlockHeaderResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetBlockHeaderResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetBlockHeaderResponse) ProtoMessage() {} + +func (x *GetBlockHeaderResponse) ProtoReflect() protoreflect.Message { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetBlockHeaderResponse.ProtoReflect.Descriptor instead. +func (*GetBlockHeaderResponse) Descriptor() ([]byte, []int) { + return file_neutrinorpc_neutrino_proto_rawDescGZIP(), []int{9} +} + +func (x *GetBlockHeaderResponse) GetHash() string { + if x != nil { + return x.Hash + } + return "" +} + +func (x *GetBlockHeaderResponse) GetConfirmations() int64 { + if x != nil { + return x.Confirmations + } + return 0 +} + +func (x *GetBlockHeaderResponse) GetStrippedSize() int64 { + if x != nil { + return x.StrippedSize + } + return 0 +} + +func (x *GetBlockHeaderResponse) GetSize() int64 { + if x != nil { + return x.Size + } + return 0 +} + +func (x *GetBlockHeaderResponse) GetWeight() int64 { + if x != nil { + return x.Weight + } + return 0 +} + +func (x *GetBlockHeaderResponse) GetHeight() int32 { + if x != nil { + return x.Height + } + return 0 +} + +func (x *GetBlockHeaderResponse) GetVersion() int32 { + if x != nil { + return x.Version + } + return 0 +} + +func (x *GetBlockHeaderResponse) GetVersionHex() string { + if x != nil { + return x.VersionHex + } + return "" +} + +func (x *GetBlockHeaderResponse) GetMerkleroot() string { + if x != nil { + return x.Merkleroot + } + return "" +} + +func (x *GetBlockHeaderResponse) GetTime() int64 { + if x != nil { + return x.Time + } + return 0 +} + +func (x *GetBlockHeaderResponse) GetNonce() uint32 { + if x != nil { + return x.Nonce + } + return 0 +} + +func (x *GetBlockHeaderResponse) GetBits() string { + if x != nil { + return x.Bits + } + return "" +} + +func (x *GetBlockHeaderResponse) GetNtx() int32 { + if x != nil { + return x.Ntx + } + return 0 +} + +func (x *GetBlockHeaderResponse) GetPreviousBlockHash() string { + if x != nil { + return x.PreviousBlockHash + } + return "" +} + +func (x *GetBlockHeaderResponse) GetRawHex() []byte { + if x != nil { + return x.RawHex + } + return nil +} + +type GetBlockRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Block hash in hex notation. + Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` +} + +func (x *GetBlockRequest) Reset() { + *x = GetBlockRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetBlockRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetBlockRequest) ProtoMessage() {} + +func (x *GetBlockRequest) ProtoReflect() protoreflect.Message { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetBlockRequest.ProtoReflect.Descriptor instead. +func (*GetBlockRequest) Descriptor() ([]byte, []int) { + return file_neutrinorpc_neutrino_proto_rawDescGZIP(), []int{10} +} + +func (x *GetBlockRequest) GetHash() string { + if x != nil { + return x.Hash + } + return "" +} + +type GetBlockResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The block hash (same as provided). + Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` + // The number of confirmations. + Confirmations int64 `protobuf:"varint,2,opt,name=confirmations,proto3" json:"confirmations,omitempty"` + // The block size excluding witness data. + StrippedSize int64 `protobuf:"varint,3,opt,name=stripped_size,json=strippedSize,proto3" json:"stripped_size,omitempty"` + // The block size (bytes). + Size int64 `protobuf:"varint,4,opt,name=size,proto3" json:"size,omitempty"` + // The block weight as defined in BIP 141. + Weight int64 `protobuf:"varint,5,opt,name=weight,proto3" json:"weight,omitempty"` + // The block height or index. + Height int32 `protobuf:"varint,6,opt,name=height,proto3" json:"height,omitempty"` + // The block version. + Version int32 `protobuf:"varint,7,opt,name=version,proto3" json:"version,omitempty"` + // The block version. + VersionHex string `protobuf:"bytes,8,opt,name=version_hex,json=versionHex,proto3" json:"version_hex,omitempty"` + // The merkle root. + Merkleroot string `protobuf:"bytes,9,opt,name=merkleroot,proto3" json:"merkleroot,omitempty"` + // List of transaction ids. + Tx []string `protobuf:"bytes,10,rep,name=tx,proto3" json:"tx,omitempty"` + // The block time in seconds since epoch (Jan 1 1970 GMT). + Time int64 `protobuf:"varint,11,opt,name=time,proto3" json:"time,omitempty"` + // The nonce. + Nonce uint32 `protobuf:"varint,12,opt,name=nonce,proto3" json:"nonce,omitempty"` + // The bits in hex notation. + Bits string `protobuf:"bytes,13,opt,name=bits,proto3" json:"bits,omitempty"` + // The number of transactions in the block. + Ntx int32 `protobuf:"varint,14,opt,name=ntx,proto3" json:"ntx,omitempty"` + // The hash of the previous block. + PreviousBlockHash string `protobuf:"bytes,15,opt,name=previous_block_hash,json=previousBlockHash,proto3" json:"previous_block_hash,omitempty"` + // The raw hex of the block. + RawHex []byte `protobuf:"bytes,16,opt,name=raw_hex,json=rawHex,proto3" json:"raw_hex,omitempty"` +} + +func (x *GetBlockResponse) Reset() { + *x = GetBlockResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetBlockResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetBlockResponse) ProtoMessage() {} + +func (x *GetBlockResponse) ProtoReflect() protoreflect.Message { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetBlockResponse.ProtoReflect.Descriptor instead. +func (*GetBlockResponse) Descriptor() ([]byte, []int) { + return file_neutrinorpc_neutrino_proto_rawDescGZIP(), []int{11} +} + +func (x *GetBlockResponse) GetHash() string { + if x != nil { + return x.Hash + } + return "" +} + +func (x *GetBlockResponse) GetConfirmations() int64 { + if x != nil { + return x.Confirmations + } + return 0 +} + +func (x *GetBlockResponse) GetStrippedSize() int64 { + if x != nil { + return x.StrippedSize + } + return 0 +} + +func (x *GetBlockResponse) GetSize() int64 { + if x != nil { + return x.Size + } + return 0 +} + +func (x *GetBlockResponse) GetWeight() int64 { + if x != nil { + return x.Weight + } + return 0 +} + +func (x *GetBlockResponse) GetHeight() int32 { + if x != nil { + return x.Height + } + return 0 +} + +func (x *GetBlockResponse) GetVersion() int32 { + if x != nil { + return x.Version + } + return 0 +} + +func (x *GetBlockResponse) GetVersionHex() string { + if x != nil { + return x.VersionHex + } + return "" +} + +func (x *GetBlockResponse) GetMerkleroot() string { + if x != nil { + return x.Merkleroot + } + return "" +} + +func (x *GetBlockResponse) GetTx() []string { + if x != nil { + return x.Tx + } + return nil +} + +func (x *GetBlockResponse) GetTime() int64 { + if x != nil { + return x.Time + } + return 0 +} + +func (x *GetBlockResponse) GetNonce() uint32 { + if x != nil { + return x.Nonce + } + return 0 +} + +func (x *GetBlockResponse) GetBits() string { + if x != nil { + return x.Bits + } + return "" +} + +func (x *GetBlockResponse) GetNtx() int32 { + if x != nil { + return x.Ntx + } + return 0 +} + +func (x *GetBlockResponse) GetPreviousBlockHash() string { + if x != nil { + return x.PreviousBlockHash + } + return "" +} + +func (x *GetBlockResponse) GetRawHex() []byte { + if x != nil { + return x.RawHex + } + return nil +} + +type GetCFilterRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Block hash in hex notation. + Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` +} + +func (x *GetCFilterRequest) Reset() { + *x = GetCFilterRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetCFilterRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetCFilterRequest) ProtoMessage() {} + +func (x *GetCFilterRequest) ProtoReflect() protoreflect.Message { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetCFilterRequest.ProtoReflect.Descriptor instead. +func (*GetCFilterRequest) Descriptor() ([]byte, []int) { + return file_neutrinorpc_neutrino_proto_rawDescGZIP(), []int{12} +} + +func (x *GetCFilterRequest) GetHash() string { + if x != nil { + return x.Hash + } + return "" +} + +type GetCFilterResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // GCS filter. + Filter []byte `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"` +} + +func (x *GetCFilterResponse) Reset() { + *x = GetCFilterResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetCFilterResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetCFilterResponse) ProtoMessage() {} + +func (x *GetCFilterResponse) ProtoReflect() protoreflect.Message { + mi := &file_neutrinorpc_neutrino_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetCFilterResponse.ProtoReflect.Descriptor instead. +func (*GetCFilterResponse) Descriptor() ([]byte, []int) { + return file_neutrinorpc_neutrino_proto_rawDescGZIP(), []int{13} +} + +func (x *GetCFilterResponse) GetFilter() []byte { + if x != nil { + return x.Filter + } + return nil +} + +var File_neutrinorpc_neutrino_proto protoreflect.FileDescriptor + +var file_neutrinorpc_neutrino_proto_rawDesc = []byte{ + 0x0a, 0x1a, 0x6e, 0x65, 0x75, 0x74, 0x72, 0x69, 0x6e, 0x6f, 0x72, 0x70, 0x63, 0x2f, 0x6e, 0x65, + 0x75, 0x74, 0x72, 0x69, 0x6e, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x6e, 0x65, + 0x75, 0x74, 0x72, 0x69, 0x6e, 0x6f, 0x72, 0x70, 0x63, 0x22, 0x0f, 0x0a, 0x0d, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x98, 0x01, 0x0a, 0x0e, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, + 0x06, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x61, + 0x63, 0x74, 0x69, 0x76, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x79, 0x6e, 0x63, 0x65, 0x64, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x73, 0x79, 0x6e, 0x63, 0x65, 0x64, 0x12, 0x21, 0x0a, + 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, + 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x12, + 0x14, 0x0a, 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, + 0x70, 0x65, 0x65, 0x72, 0x73, 0x22, 0x2f, 0x0a, 0x0e, 0x41, 0x64, 0x64, 0x50, 0x65, 0x65, 0x72, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x65, 0x65, 0x72, 0x5f, + 0x61, 0x64, 0x64, 0x72, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x65, 0x65, + 0x72, 0x41, 0x64, 0x64, 0x72, 0x73, 0x22, 0x11, 0x0a, 0x0f, 0x41, 0x64, 0x64, 0x50, 0x65, 0x65, + 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x36, 0x0a, 0x15, 0x44, 0x69, 0x73, + 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x50, 0x65, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x73, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x65, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, + 0x73, 0x22, 0x18, 0x0a, 0x16, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x50, + 0x65, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x30, 0x0a, 0x0f, 0x49, + 0x73, 0x42, 0x61, 0x6e, 0x6e, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, + 0x0a, 0x0a, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x73, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x70, 0x65, 0x65, 0x72, 0x41, 0x64, 0x64, 0x72, 0x73, 0x22, 0x2a, 0x0a, + 0x10, 0x49, 0x73, 0x42, 0x61, 0x6e, 0x6e, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x61, 0x6e, 0x6e, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x06, 0x62, 0x61, 0x6e, 0x6e, 0x65, 0x64, 0x22, 0x2b, 0x0a, 0x15, 0x47, 0x65, 0x74, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x22, 0xaf, 0x03, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x68, 0x61, 0x73, 0x68, 0x12, 0x24, 0x0a, 0x0d, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x63, 0x6f, + 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x23, 0x0a, 0x0d, 0x73, + 0x74, 0x72, 0x69, 0x70, 0x70, 0x65, 0x64, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x03, 0x52, 0x0c, 0x73, 0x74, 0x72, 0x69, 0x70, 0x70, 0x65, 0x64, 0x53, 0x69, 0x7a, 0x65, + 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, + 0x73, 0x69, 0x7a, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x16, 0x0a, 0x06, + 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x68, 0x65, + 0x69, 0x67, 0x68, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, + 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1f, + 0x0a, 0x0b, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x68, 0x65, 0x78, 0x18, 0x08, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0a, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x48, 0x65, 0x78, 0x12, + 0x1e, 0x0a, 0x0a, 0x6d, 0x65, 0x72, 0x6b, 0x6c, 0x65, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x09, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6d, 0x65, 0x72, 0x6b, 0x6c, 0x65, 0x72, 0x6f, 0x6f, 0x74, 0x12, + 0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x74, + 0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x6f, 0x6e, 0x63, 0x65, 0x18, 0x0b, 0x20, 0x01, + 0x28, 0x0d, 0x52, 0x05, 0x6e, 0x6f, 0x6e, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x69, 0x74, + 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x62, 0x69, 0x74, 0x73, 0x12, 0x10, 0x0a, + 0x03, 0x6e, 0x74, 0x78, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6e, 0x74, 0x78, 0x12, + 0x2e, 0x0a, 0x13, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x5f, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x70, 0x72, + 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x12, + 0x17, 0x0a, 0x07, 0x72, 0x61, 0x77, 0x5f, 0x68, 0x65, 0x78, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x06, 0x72, 0x61, 0x77, 0x48, 0x65, 0x78, 0x22, 0x25, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x68, + 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x22, + 0xb9, 0x03, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x12, 0x24, 0x0a, 0x0d, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x0d, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x23, + 0x0a, 0x0d, 0x73, 0x74, 0x72, 0x69, 0x70, 0x70, 0x65, 0x64, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x73, 0x74, 0x72, 0x69, 0x70, 0x70, 0x65, 0x64, 0x53, + 0x69, 0x7a, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x77, 0x65, 0x69, 0x67, 0x68, + 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, + 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x68, 0x65, 0x78, + 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x48, + 0x65, 0x78, 0x12, 0x1e, 0x0a, 0x0a, 0x6d, 0x65, 0x72, 0x6b, 0x6c, 0x65, 0x72, 0x6f, 0x6f, 0x74, + 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6d, 0x65, 0x72, 0x6b, 0x6c, 0x65, 0x72, 0x6f, + 0x6f, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x78, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x09, 0x52, 0x02, + 0x74, 0x78, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x6f, 0x6e, 0x63, 0x65, 0x18, + 0x0c, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x6e, 0x6f, 0x6e, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, + 0x62, 0x69, 0x74, 0x73, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x62, 0x69, 0x74, 0x73, + 0x12, 0x10, 0x0a, 0x03, 0x6e, 0x74, 0x78, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6e, + 0x74, 0x78, 0x12, 0x2e, 0x0a, 0x13, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x5f, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x11, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, + 0x73, 0x68, 0x12, 0x17, 0x0a, 0x07, 0x72, 0x61, 0x77, 0x5f, 0x68, 0x65, 0x78, 0x18, 0x10, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x06, 0x72, 0x61, 0x77, 0x48, 0x65, 0x78, 0x22, 0x27, 0x0a, 0x11, 0x47, + 0x65, 0x74, 0x43, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x68, 0x61, 0x73, 0x68, 0x22, 0x2c, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x43, 0x46, 0x69, 0x6c, 0x74, + 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x66, 0x69, + 0x6c, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x66, 0x69, 0x6c, 0x74, + 0x65, 0x72, 0x32, 0xad, 0x04, 0x0a, 0x0b, 0x4e, 0x65, 0x75, 0x74, 0x72, 0x69, 0x6e, 0x6f, 0x4b, + 0x69, 0x74, 0x12, 0x41, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1a, 0x2e, 0x6e, + 0x65, 0x75, 0x74, 0x72, 0x69, 0x6e, 0x6f, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x6e, 0x65, 0x75, 0x74, 0x72, + 0x69, 0x6e, 0x6f, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x44, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x50, 0x65, 0x65, 0x72, + 0x12, 0x1b, 0x2e, 0x6e, 0x65, 0x75, 0x74, 0x72, 0x69, 0x6e, 0x6f, 0x72, 0x70, 0x63, 0x2e, 0x41, + 0x64, 0x64, 0x50, 0x65, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, + 0x6e, 0x65, 0x75, 0x74, 0x72, 0x69, 0x6e, 0x6f, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x64, 0x64, 0x50, + 0x65, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x59, 0x0a, 0x0e, 0x44, + 0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x50, 0x65, 0x65, 0x72, 0x12, 0x22, 0x2e, + 0x6e, 0x65, 0x75, 0x74, 0x72, 0x69, 0x6e, 0x6f, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x69, 0x73, 0x63, + 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x50, 0x65, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x23, 0x2e, 0x6e, 0x65, 0x75, 0x74, 0x72, 0x69, 0x6e, 0x6f, 0x72, 0x70, 0x63, 0x2e, + 0x44, 0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x50, 0x65, 0x65, 0x72, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x47, 0x0a, 0x08, 0x49, 0x73, 0x42, 0x61, 0x6e, 0x6e, + 0x65, 0x64, 0x12, 0x1c, 0x2e, 0x6e, 0x65, 0x75, 0x74, 0x72, 0x69, 0x6e, 0x6f, 0x72, 0x70, 0x63, + 0x2e, 0x49, 0x73, 0x42, 0x61, 0x6e, 0x6e, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x1d, 0x2e, 0x6e, 0x65, 0x75, 0x74, 0x72, 0x69, 0x6e, 0x6f, 0x72, 0x70, 0x63, 0x2e, 0x49, + 0x73, 0x42, 0x61, 0x6e, 0x6e, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x59, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x12, 0x22, 0x2e, 0x6e, 0x65, 0x75, 0x74, 0x72, 0x69, 0x6e, 0x6f, 0x72, 0x70, 0x63, 0x2e, + 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x6e, 0x65, 0x75, 0x74, 0x72, 0x69, 0x6e, 0x6f, + 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x61, 0x64, + 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x47, 0x0a, 0x08, 0x47, 0x65, + 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x1c, 0x2e, 0x6e, 0x65, 0x75, 0x74, 0x72, 0x69, 0x6e, + 0x6f, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x6e, 0x65, 0x75, 0x74, 0x72, 0x69, 0x6e, 0x6f, 0x72, + 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x4d, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x43, 0x46, 0x69, 0x6c, 0x74, 0x65, + 0x72, 0x12, 0x1e, 0x2e, 0x6e, 0x65, 0x75, 0x74, 0x72, 0x69, 0x6e, 0x6f, 0x72, 0x70, 0x63, 0x2e, + 0x47, 0x65, 0x74, 0x43, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x1f, 0x2e, 0x6e, 0x65, 0x75, 0x74, 0x72, 0x69, 0x6e, 0x6f, 0x72, 0x70, 0x63, 0x2e, + 0x47, 0x65, 0x74, 0x43, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x6e, 0x69, 0x6e, 0x67, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, + 0x6b, 0x2f, 0x6c, 0x6e, 0x64, 0x2f, 0x6c, 0x6e, 0x72, 0x70, 0x63, 0x2f, 0x6e, 0x65, 0x75, 0x74, + 0x72, 0x69, 0x6e, 0x6f, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_neutrinorpc_neutrino_proto_rawDescOnce sync.Once + file_neutrinorpc_neutrino_proto_rawDescData = file_neutrinorpc_neutrino_proto_rawDesc +) + +func file_neutrinorpc_neutrino_proto_rawDescGZIP() []byte { + file_neutrinorpc_neutrino_proto_rawDescOnce.Do(func() { + file_neutrinorpc_neutrino_proto_rawDescData = protoimpl.X.CompressGZIP(file_neutrinorpc_neutrino_proto_rawDescData) + }) + return file_neutrinorpc_neutrino_proto_rawDescData +} + +var file_neutrinorpc_neutrino_proto_msgTypes = make([]protoimpl.MessageInfo, 14) +var file_neutrinorpc_neutrino_proto_goTypes = []interface{}{ + (*StatusRequest)(nil), // 0: neutrinorpc.StatusRequest + (*StatusResponse)(nil), // 1: neutrinorpc.StatusResponse + (*AddPeerRequest)(nil), // 2: neutrinorpc.AddPeerRequest + (*AddPeerResponse)(nil), // 3: neutrinorpc.AddPeerResponse + (*DisconnectPeerRequest)(nil), // 4: neutrinorpc.DisconnectPeerRequest + (*DisconnectPeerResponse)(nil), // 5: neutrinorpc.DisconnectPeerResponse + (*IsBannedRequest)(nil), // 6: neutrinorpc.IsBannedRequest + (*IsBannedResponse)(nil), // 7: neutrinorpc.IsBannedResponse + (*GetBlockHeaderRequest)(nil), // 8: neutrinorpc.GetBlockHeaderRequest + (*GetBlockHeaderResponse)(nil), // 9: neutrinorpc.GetBlockHeaderResponse + (*GetBlockRequest)(nil), // 10: neutrinorpc.GetBlockRequest + (*GetBlockResponse)(nil), // 11: neutrinorpc.GetBlockResponse + (*GetCFilterRequest)(nil), // 12: neutrinorpc.GetCFilterRequest + (*GetCFilterResponse)(nil), // 13: neutrinorpc.GetCFilterResponse +} +var file_neutrinorpc_neutrino_proto_depIdxs = []int32{ + 0, // 0: neutrinorpc.NeutrinoKit.Status:input_type -> neutrinorpc.StatusRequest + 2, // 1: neutrinorpc.NeutrinoKit.AddPeer:input_type -> neutrinorpc.AddPeerRequest + 4, // 2: neutrinorpc.NeutrinoKit.DisconnectPeer:input_type -> neutrinorpc.DisconnectPeerRequest + 6, // 3: neutrinorpc.NeutrinoKit.IsBanned:input_type -> neutrinorpc.IsBannedRequest + 8, // 4: neutrinorpc.NeutrinoKit.GetBlockHeader:input_type -> neutrinorpc.GetBlockHeaderRequest + 10, // 5: neutrinorpc.NeutrinoKit.GetBlock:input_type -> neutrinorpc.GetBlockRequest + 12, // 6: neutrinorpc.NeutrinoKit.GetCFilter:input_type -> neutrinorpc.GetCFilterRequest + 1, // 7: neutrinorpc.NeutrinoKit.Status:output_type -> neutrinorpc.StatusResponse + 3, // 8: neutrinorpc.NeutrinoKit.AddPeer:output_type -> neutrinorpc.AddPeerResponse + 5, // 9: neutrinorpc.NeutrinoKit.DisconnectPeer:output_type -> neutrinorpc.DisconnectPeerResponse + 7, // 10: neutrinorpc.NeutrinoKit.IsBanned:output_type -> neutrinorpc.IsBannedResponse + 9, // 11: neutrinorpc.NeutrinoKit.GetBlockHeader:output_type -> neutrinorpc.GetBlockHeaderResponse + 11, // 12: neutrinorpc.NeutrinoKit.GetBlock:output_type -> neutrinorpc.GetBlockResponse + 13, // 13: neutrinorpc.NeutrinoKit.GetCFilter:output_type -> neutrinorpc.GetCFilterResponse + 7, // [7:14] is the sub-list for method output_type + 0, // [0:7] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_neutrinorpc_neutrino_proto_init() } +func file_neutrinorpc_neutrino_proto_init() { + if File_neutrinorpc_neutrino_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_neutrinorpc_neutrino_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StatusRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_neutrinorpc_neutrino_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StatusResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_neutrinorpc_neutrino_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AddPeerRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_neutrinorpc_neutrino_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AddPeerResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_neutrinorpc_neutrino_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DisconnectPeerRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_neutrinorpc_neutrino_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DisconnectPeerResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_neutrinorpc_neutrino_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IsBannedRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_neutrinorpc_neutrino_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IsBannedResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_neutrinorpc_neutrino_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetBlockHeaderRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_neutrinorpc_neutrino_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetBlockHeaderResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_neutrinorpc_neutrino_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetBlockRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_neutrinorpc_neutrino_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetBlockResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_neutrinorpc_neutrino_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetCFilterRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_neutrinorpc_neutrino_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetCFilterResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_neutrinorpc_neutrino_proto_rawDesc, + NumEnums: 0, + NumMessages: 14, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_neutrinorpc_neutrino_proto_goTypes, + DependencyIndexes: file_neutrinorpc_neutrino_proto_depIdxs, + MessageInfos: file_neutrinorpc_neutrino_proto_msgTypes, + }.Build() + File_neutrinorpc_neutrino_proto = out.File + file_neutrinorpc_neutrino_proto_rawDesc = nil + file_neutrinorpc_neutrino_proto_goTypes = nil + file_neutrinorpc_neutrino_proto_depIdxs = nil +} diff --git a/lnrpc/neutrinorpc/neutrino.pb.gw.go b/lnrpc/neutrinorpc/neutrino.pb.gw.go new file mode 100644 index 000000000..7c10a3a03 --- /dev/null +++ b/lnrpc/neutrinorpc/neutrino.pb.gw.go @@ -0,0 +1,693 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: neutrinorpc/neutrino.proto + +/* +Package neutrinorpc is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package neutrinorpc + +import ( + "context" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = metadata.Join + +func request_NeutrinoKit_Status_0(ctx context.Context, marshaler runtime.Marshaler, client NeutrinoKitClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq StatusRequest + var metadata runtime.ServerMetadata + + msg, err := client.Status(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_NeutrinoKit_Status_0(ctx context.Context, marshaler runtime.Marshaler, server NeutrinoKitServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq StatusRequest + var metadata runtime.ServerMetadata + + msg, err := server.Status(ctx, &protoReq) + return msg, metadata, err + +} + +func request_NeutrinoKit_AddPeer_0(ctx context.Context, marshaler runtime.Marshaler, client NeutrinoKitClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq AddPeerRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.AddPeer(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_NeutrinoKit_AddPeer_0(ctx context.Context, marshaler runtime.Marshaler, server NeutrinoKitServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq AddPeerRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.AddPeer(ctx, &protoReq) + return msg, metadata, err + +} + +func request_NeutrinoKit_DisconnectPeer_0(ctx context.Context, marshaler runtime.Marshaler, client NeutrinoKitClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DisconnectPeerRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.DisconnectPeer(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_NeutrinoKit_DisconnectPeer_0(ctx context.Context, marshaler runtime.Marshaler, server NeutrinoKitServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq DisconnectPeerRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.DisconnectPeer(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_NeutrinoKit_IsBanned_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_NeutrinoKit_IsBanned_0(ctx context.Context, marshaler runtime.Marshaler, client NeutrinoKitClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq IsBannedRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_NeutrinoKit_IsBanned_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.IsBanned(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_NeutrinoKit_IsBanned_0(ctx context.Context, marshaler runtime.Marshaler, server NeutrinoKitServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq IsBannedRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_NeutrinoKit_IsBanned_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.IsBanned(ctx, &protoReq) + return msg, metadata, err + +} + +func request_NeutrinoKit_GetBlockHeader_0(ctx context.Context, marshaler runtime.Marshaler, client NeutrinoKitClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetBlockHeaderRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["hash"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash") + } + + protoReq.Hash, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err) + } + + msg, err := client.GetBlockHeader(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_NeutrinoKit_GetBlockHeader_0(ctx context.Context, marshaler runtime.Marshaler, server NeutrinoKitServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetBlockHeaderRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["hash"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash") + } + + protoReq.Hash, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err) + } + + msg, err := server.GetBlockHeader(ctx, &protoReq) + return msg, metadata, err + +} + +func request_NeutrinoKit_GetBlock_0(ctx context.Context, marshaler runtime.Marshaler, client NeutrinoKitClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetBlockRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["hash"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash") + } + + protoReq.Hash, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err) + } + + msg, err := client.GetBlock(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_NeutrinoKit_GetBlock_0(ctx context.Context, marshaler runtime.Marshaler, server NeutrinoKitServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetBlockRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["hash"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash") + } + + protoReq.Hash, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err) + } + + msg, err := server.GetBlock(ctx, &protoReq) + return msg, metadata, err + +} + +func request_NeutrinoKit_GetCFilter_0(ctx context.Context, marshaler runtime.Marshaler, client NeutrinoKitClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetCFilterRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["hash"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash") + } + + protoReq.Hash, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err) + } + + msg, err := client.GetCFilter(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_NeutrinoKit_GetCFilter_0(ctx context.Context, marshaler runtime.Marshaler, server NeutrinoKitServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetCFilterRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["hash"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash") + } + + protoReq.Hash, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err) + } + + msg, err := server.GetCFilter(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterNeutrinoKitHandlerServer registers the http handlers for service NeutrinoKit to "mux". +// UnaryRPC :call NeutrinoKitServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterNeutrinoKitHandlerFromEndpoint instead. +func RegisterNeutrinoKitHandlerServer(ctx context.Context, mux *runtime.ServeMux, server NeutrinoKitServer) error { + + mux.Handle("GET", pattern_NeutrinoKit_Status_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/neutrinorpc.NeutrinoKit/Status", runtime.WithHTTPPathPattern("/v2/neutrino/status")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_NeutrinoKit_Status_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_NeutrinoKit_Status_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_NeutrinoKit_AddPeer_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/neutrinorpc.NeutrinoKit/AddPeer", runtime.WithHTTPPathPattern("/v2/neutrino/addpeer")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_NeutrinoKit_AddPeer_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_NeutrinoKit_AddPeer_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_NeutrinoKit_DisconnectPeer_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/neutrinorpc.NeutrinoKit/DisconnectPeer", runtime.WithHTTPPathPattern("/v2/neutrino/disconnect")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_NeutrinoKit_DisconnectPeer_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_NeutrinoKit_DisconnectPeer_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_NeutrinoKit_IsBanned_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/neutrinorpc.NeutrinoKit/IsBanned", runtime.WithHTTPPathPattern("/v2/neutrino/isbanned")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_NeutrinoKit_IsBanned_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_NeutrinoKit_IsBanned_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_NeutrinoKit_GetBlockHeader_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/neutrinorpc.NeutrinoKit/GetBlockHeader", runtime.WithHTTPPathPattern("/v2/neutrino/blockheader/{hash}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_NeutrinoKit_GetBlockHeader_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_NeutrinoKit_GetBlockHeader_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_NeutrinoKit_GetBlock_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/neutrinorpc.NeutrinoKit/GetBlock", runtime.WithHTTPPathPattern("/v2/neutrino/block/{hash}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_NeutrinoKit_GetBlock_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_NeutrinoKit_GetBlock_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_NeutrinoKit_GetCFilter_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/neutrinorpc.NeutrinoKit/GetCFilter", runtime.WithHTTPPathPattern("/v2/neutrino/cfilter/{hash}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_NeutrinoKit_GetCFilter_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_NeutrinoKit_GetCFilter_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterNeutrinoKitHandlerFromEndpoint is same as RegisterNeutrinoKitHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterNeutrinoKitHandlerFromEndpoint(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.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterNeutrinoKitHandler(ctx, mux, conn) +} + +// RegisterNeutrinoKitHandler registers the http handlers for service NeutrinoKit to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterNeutrinoKitHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterNeutrinoKitHandlerClient(ctx, mux, NewNeutrinoKitClient(conn)) +} + +// RegisterNeutrinoKitHandlerClient registers the http handlers for service NeutrinoKit +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "NeutrinoKitClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "NeutrinoKitClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "NeutrinoKitClient" to call the correct interceptors. +func RegisterNeutrinoKitHandlerClient(ctx context.Context, mux *runtime.ServeMux, client NeutrinoKitClient) error { + + mux.Handle("GET", pattern_NeutrinoKit_Status_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, "/neutrinorpc.NeutrinoKit/Status", runtime.WithHTTPPathPattern("/v2/neutrino/status")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_NeutrinoKit_Status_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_NeutrinoKit_Status_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_NeutrinoKit_AddPeer_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, "/neutrinorpc.NeutrinoKit/AddPeer", runtime.WithHTTPPathPattern("/v2/neutrino/addpeer")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_NeutrinoKit_AddPeer_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_NeutrinoKit_AddPeer_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_NeutrinoKit_DisconnectPeer_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, "/neutrinorpc.NeutrinoKit/DisconnectPeer", runtime.WithHTTPPathPattern("/v2/neutrino/disconnect")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_NeutrinoKit_DisconnectPeer_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_NeutrinoKit_DisconnectPeer_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_NeutrinoKit_IsBanned_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, "/neutrinorpc.NeutrinoKit/IsBanned", runtime.WithHTTPPathPattern("/v2/neutrino/isbanned")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_NeutrinoKit_IsBanned_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_NeutrinoKit_IsBanned_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_NeutrinoKit_GetBlockHeader_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, "/neutrinorpc.NeutrinoKit/GetBlockHeader", runtime.WithHTTPPathPattern("/v2/neutrino/blockheader/{hash}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_NeutrinoKit_GetBlockHeader_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_NeutrinoKit_GetBlockHeader_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_NeutrinoKit_GetBlock_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, "/neutrinorpc.NeutrinoKit/GetBlock", runtime.WithHTTPPathPattern("/v2/neutrino/block/{hash}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_NeutrinoKit_GetBlock_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_NeutrinoKit_GetBlock_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_NeutrinoKit_GetCFilter_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, "/neutrinorpc.NeutrinoKit/GetCFilter", runtime.WithHTTPPathPattern("/v2/neutrino/cfilter/{hash}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_NeutrinoKit_GetCFilter_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_NeutrinoKit_GetCFilter_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_NeutrinoKit_Status_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "neutrino", "status"}, "")) + + pattern_NeutrinoKit_AddPeer_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "neutrino", "addpeer"}, "")) + + pattern_NeutrinoKit_DisconnectPeer_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "neutrino", "disconnect"}, "")) + + pattern_NeutrinoKit_IsBanned_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v2", "neutrino", "isbanned"}, "")) + + pattern_NeutrinoKit_GetBlockHeader_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v2", "neutrino", "blockheader", "hash"}, "")) + + pattern_NeutrinoKit_GetBlock_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v2", "neutrino", "block", "hash"}, "")) + + pattern_NeutrinoKit_GetCFilter_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v2", "neutrino", "cfilter", "hash"}, "")) +) + +var ( + forward_NeutrinoKit_Status_0 = runtime.ForwardResponseMessage + + forward_NeutrinoKit_AddPeer_0 = runtime.ForwardResponseMessage + + forward_NeutrinoKit_DisconnectPeer_0 = runtime.ForwardResponseMessage + + forward_NeutrinoKit_IsBanned_0 = runtime.ForwardResponseMessage + + forward_NeutrinoKit_GetBlockHeader_0 = runtime.ForwardResponseMessage + + forward_NeutrinoKit_GetBlock_0 = runtime.ForwardResponseMessage + + forward_NeutrinoKit_GetCFilter_0 = runtime.ForwardResponseMessage +) diff --git a/lnrpc/neutrinorpc/neutrino.proto b/lnrpc/neutrinorpc/neutrino.proto new file mode 100644 index 000000000..388714813 --- /dev/null +++ b/lnrpc/neutrinorpc/neutrino.proto @@ -0,0 +1,210 @@ +syntax = "proto3"; + +package neutrinorpc; + +option go_package = "github.com/lightningnetwork/lnd/lnrpc/neutrinorpc"; + +// NeutrinoKit is a service that can be used to get information about the +// current state of the neutrino instance, fetch blocks and add/remove peers. +service NeutrinoKit { + /* + Status returns the status of the light client neutrino instance, + along with height and hash of the best block, and a list of connected + peers. + */ + rpc Status (StatusRequest) returns (StatusResponse); + + /* + AddPeer adds a new peer that has already been connected to the server. + */ + rpc AddPeer (AddPeerRequest) returns (AddPeerResponse); + + /* + DisconnectPeer disconnects a peer by target address. Both outbound and + inbound nodes will be searched for the target node. An error message will + be returned if the peer was not found. + */ + rpc DisconnectPeer (DisconnectPeerRequest) returns (DisconnectPeerResponse); + + /* + IsBanned returns true if the peer is banned, otherwise false. + */ + rpc IsBanned (IsBannedRequest) returns (IsBannedResponse); + + /* + GetBlockHeader returns a block header with a particular block hash. + */ + rpc GetBlockHeader (GetBlockHeaderRequest) returns (GetBlockHeaderResponse); + + /* + GetBlock returns a block with a particular block hash. + */ + rpc GetBlock (GetBlockRequest) returns (GetBlockResponse); + + /* + GetCFilter returns a compact filter from a block. + */ + rpc GetCFilter (GetCFilterRequest) returns (GetCFilterResponse); +} + +message StatusRequest { +} + +message StatusResponse { + // Indicates whether the neutrino backend is active or not. + bool active = 1; + + // Is fully synced. + bool synced = 2; + + // Best block height. + int32 block_height = 3; + + // Best block hash. + string block_hash = 4; + + // Connected peers. + repeated string peers = 5; +} + +message AddPeerRequest { + // Peer to add. + string peer_addrs = 1; +} + +message AddPeerResponse { +} + +message DisconnectPeerRequest { + // Peer to disconnect. + string peer_addrs = 1; +} + +message DisconnectPeerResponse { +} + +message IsBannedRequest { + // Peer to lookup. + string peer_addrs = 1; +} + +message IsBannedResponse { + bool banned = 1; +} + +message GetBlockHeaderRequest { + // Block hash in hex notation. + string hash = 1; +} + +message GetBlockHeaderResponse { + // The block hash (same as provided). + string hash = 1; + + // The number of confirmations. + int64 confirmations = 2; + + // The block size excluding witness data. + int64 stripped_size = 3; + + // The block size (bytes). + int64 size = 4; + + // The block weight as defined in BIP 141. + int64 weight = 5; + + // The block height or index. + int32 height = 6; + + // The block version. + int32 version = 7; + + // The block version. + string version_hex = 8; + + // The merkle root. + string merkleroot = 9; + + // The block time in seconds since epoch (Jan 1 1970 GMT). + int64 time = 10; + + // The nonce. + uint32 nonce = 11; + + // The bits in hex notation. + string bits = 12; + + // The number of transactions in the block. + int32 ntx = 13; + + // The hash of the previous block. + string previous_block_hash = 14; + + // The raw hex of the block. + bytes raw_hex = 15; +} + +message GetBlockRequest { + // Block hash in hex notation. + string hash = 1; +} + +message GetBlockResponse { + // The block hash (same as provided). + string hash = 1; + + // The number of confirmations. + int64 confirmations = 2; + + // The block size excluding witness data. + int64 stripped_size = 3; + + // The block size (bytes). + int64 size = 4; + + // The block weight as defined in BIP 141. + int64 weight = 5; + + // The block height or index. + int32 height = 6; + + // The block version. + int32 version = 7; + + // The block version. + string version_hex = 8; + + // The merkle root. + string merkleroot = 9; + + // List of transaction ids. + repeated string tx = 10; + + // The block time in seconds since epoch (Jan 1 1970 GMT). + int64 time = 11; + + // The nonce. + uint32 nonce = 12; + + // The bits in hex notation. + string bits = 13; + + // The number of transactions in the block. + int32 ntx = 14; + + // The hash of the previous block. + string previous_block_hash = 15; + + // The raw hex of the block. + bytes raw_hex = 16; +} + +message GetCFilterRequest { + // Block hash in hex notation. + string hash = 1; +} + +message GetCFilterResponse { + // GCS filter. + bytes filter = 1; +} \ No newline at end of file diff --git a/lnrpc/neutrinorpc/neutrino.swagger.json b/lnrpc/neutrinorpc/neutrino.swagger.json new file mode 100644 index 000000000..5be08ef01 --- /dev/null +++ b/lnrpc/neutrinorpc/neutrino.swagger.json @@ -0,0 +1,497 @@ +{ + "swagger": "2.0", + "info": { + "title": "neutrinorpc/neutrino.proto", + "version": "version not set" + }, + "tags": [ + { + "name": "NeutrinoKit" + } + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": { + "/v2/neutrino/addpeer": { + "post": { + "summary": "AddPeer adds a new peer that has already been connected to the server.", + "operationId": "NeutrinoKit_AddPeer", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/neutrinorpcAddPeerResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/neutrinorpcAddPeerRequest" + } + } + ], + "tags": [ + "NeutrinoKit" + ] + } + }, + "/v2/neutrino/block/{hash}": { + "get": { + "summary": "GetBlock returns a block with a particular block hash.", + "operationId": "NeutrinoKit_GetBlock", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/neutrinorpcGetBlockResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "hash", + "description": "Block hash in hex notation.", + "in": "path", + "required": true, + "type": "string" + } + ], + "tags": [ + "NeutrinoKit" + ] + } + }, + "/v2/neutrino/blockheader/{hash}": { + "get": { + "summary": "GetBlockHeader returns a block header with a particular block hash.", + "operationId": "NeutrinoKit_GetBlockHeader", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/neutrinorpcGetBlockHeaderResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "hash", + "description": "Block hash in hex notation.", + "in": "path", + "required": true, + "type": "string" + } + ], + "tags": [ + "NeutrinoKit" + ] + } + }, + "/v2/neutrino/cfilter/{hash}": { + "get": { + "summary": "GetCFilter returns a compact filter from a block.", + "operationId": "NeutrinoKit_GetCFilter", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/neutrinorpcGetCFilterResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "hash", + "description": "Block hash in hex notation.", + "in": "path", + "required": true, + "type": "string" + } + ], + "tags": [ + "NeutrinoKit" + ] + } + }, + "/v2/neutrino/disconnect": { + "post": { + "summary": "DisconnectPeer disconnects a peer by target address. Both outbound and\ninbound nodes will be searched for the target node. An error message will\nbe returned if the peer was not found.", + "operationId": "NeutrinoKit_DisconnectPeer", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/neutrinorpcDisconnectPeerResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/neutrinorpcDisconnectPeerRequest" + } + } + ], + "tags": [ + "NeutrinoKit" + ] + } + }, + "/v2/neutrino/isbanned": { + "get": { + "summary": "IsBanned returns true if the peer is banned, otherwise false.", + "operationId": "NeutrinoKit_IsBanned", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/neutrinorpcIsBannedResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "peer_addrs", + "description": "Peer to lookup.", + "in": "query", + "required": false, + "type": "string" + } + ], + "tags": [ + "NeutrinoKit" + ] + } + }, + "/v2/neutrino/status": { + "get": { + "summary": "Status returns the status of the light client neutrino instance,\nalong with height and hash of the best block, and a list of connected\npeers.", + "operationId": "NeutrinoKit_Status", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/neutrinorpcStatusResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "tags": [ + "NeutrinoKit" + ] + } + } + }, + "definitions": { + "neutrinorpcAddPeerRequest": { + "type": "object", + "properties": { + "peer_addrs": { + "type": "string", + "description": "Peer to add." + } + } + }, + "neutrinorpcAddPeerResponse": { + "type": "object" + }, + "neutrinorpcDisconnectPeerRequest": { + "type": "object", + "properties": { + "peer_addrs": { + "type": "string", + "description": "Peer to disconnect." + } + } + }, + "neutrinorpcDisconnectPeerResponse": { + "type": "object" + }, + "neutrinorpcGetBlockHeaderResponse": { + "type": "object", + "properties": { + "hash": { + "type": "string", + "description": "The block hash (same as provided)." + }, + "confirmations": { + "type": "string", + "format": "int64", + "description": "The number of confirmations." + }, + "stripped_size": { + "type": "string", + "format": "int64", + "description": "The block size excluding witness data." + }, + "size": { + "type": "string", + "format": "int64", + "description": "The block size (bytes)." + }, + "weight": { + "type": "string", + "format": "int64", + "description": "The block weight as defined in BIP 141." + }, + "height": { + "type": "integer", + "format": "int32", + "description": "The block height or index." + }, + "version": { + "type": "integer", + "format": "int32", + "description": "The block version." + }, + "version_hex": { + "type": "string", + "description": "The block version." + }, + "merkleroot": { + "type": "string", + "description": "The merkle root." + }, + "time": { + "type": "string", + "format": "int64", + "description": "The block time in seconds since epoch (Jan 1 1970 GMT)." + }, + "nonce": { + "type": "integer", + "format": "int64", + "description": "The nonce." + }, + "bits": { + "type": "string", + "description": "The bits in hex notation." + }, + "ntx": { + "type": "integer", + "format": "int32", + "description": "The number of transactions in the block." + }, + "previous_block_hash": { + "type": "string", + "description": "The hash of the previous block." + }, + "raw_hex": { + "type": "string", + "format": "byte", + "description": "The raw hex of the block." + } + } + }, + "neutrinorpcGetBlockResponse": { + "type": "object", + "properties": { + "hash": { + "type": "string", + "description": "The block hash (same as provided)." + }, + "confirmations": { + "type": "string", + "format": "int64", + "description": "The number of confirmations." + }, + "stripped_size": { + "type": "string", + "format": "int64", + "description": "The block size excluding witness data." + }, + "size": { + "type": "string", + "format": "int64", + "description": "The block size (bytes)." + }, + "weight": { + "type": "string", + "format": "int64", + "description": "The block weight as defined in BIP 141." + }, + "height": { + "type": "integer", + "format": "int32", + "description": "The block height or index." + }, + "version": { + "type": "integer", + "format": "int32", + "description": "The block version." + }, + "version_hex": { + "type": "string", + "description": "The block version." + }, + "merkleroot": { + "type": "string", + "description": "The merkle root." + }, + "tx": { + "type": "array", + "items": { + "type": "string" + }, + "description": "List of transaction ids." + }, + "time": { + "type": "string", + "format": "int64", + "description": "The block time in seconds since epoch (Jan 1 1970 GMT)." + }, + "nonce": { + "type": "integer", + "format": "int64", + "description": "The nonce." + }, + "bits": { + "type": "string", + "description": "The bits in hex notation." + }, + "ntx": { + "type": "integer", + "format": "int32", + "description": "The number of transactions in the block." + }, + "previous_block_hash": { + "type": "string", + "description": "The hash of the previous block." + }, + "raw_hex": { + "type": "string", + "format": "byte", + "description": "The raw hex of the block." + } + } + }, + "neutrinorpcGetCFilterResponse": { + "type": "object", + "properties": { + "filter": { + "type": "string", + "format": "byte", + "description": "GCS filter." + } + } + }, + "neutrinorpcIsBannedResponse": { + "type": "object", + "properties": { + "banned": { + "type": "boolean" + } + } + }, + "neutrinorpcStatusResponse": { + "type": "object", + "properties": { + "active": { + "type": "boolean", + "description": "Indicates whether the neutrino backend is active or not." + }, + "synced": { + "type": "boolean", + "description": "Is fully synced." + }, + "block_height": { + "type": "integer", + "format": "int32", + "description": "Best block height." + }, + "block_hash": { + "type": "string", + "description": "Best block hash." + }, + "peers": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Connected peers." + } + } + }, + "protobufAny": { + "type": "object", + "properties": { + "type_url": { + "type": "string" + }, + "value": { + "type": "string", + "format": "byte" + } + } + }, + "rpcStatus": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + }, + "details": { + "type": "array", + "items": { + "$ref": "#/definitions/protobufAny" + } + } + } + } + } +} diff --git a/lnrpc/neutrinorpc/neutrino.yaml b/lnrpc/neutrinorpc/neutrino.yaml new file mode 100644 index 000000000..d8547b7e5 --- /dev/null +++ b/lnrpc/neutrinorpc/neutrino.yaml @@ -0,0 +1,21 @@ +type: google.api.Service +config_version: 3 + +http: + rules: + - selector: neutrinorpc.NeutrinoKit.Status + get: "/v2/neutrino/status" + - selector: neutrinorpc.NeutrinoKit.AddPeer + post: "/v2/neutrino/addpeer" + body: "*" + - selector: neutrinorpc.NeutrinoKit.DisconnectPeer + post: "/v2/neutrino/disconnect" + body: "*" + - selector: neutrinorpc.NeutrinoKit.IsBanned + get: "/v2/neutrino/isbanned" + - selector: neutrinorpc.NeutrinoKit.GetBlock + get: "/v2/neutrino/block/{hash}" + - selector: neutrinorpc.NeutrinoKit.GetBlockHeader + get: "/v2/neutrino/blockheader/{hash}" + - selector: neutrinorpc.NeutrinoKit.GetCFilter + get: "/v2/neutrino/cfilter/{hash}" \ No newline at end of file diff --git a/lnrpc/neutrinorpc/neutrino_grpc.pb.go b/lnrpc/neutrinorpc/neutrino_grpc.pb.go new file mode 100644 index 000000000..2003cfb52 --- /dev/null +++ b/lnrpc/neutrinorpc/neutrino_grpc.pb.go @@ -0,0 +1,353 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package neutrinorpc + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// NeutrinoKitClient is the client API for NeutrinoKit service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type NeutrinoKitClient interface { + // + //Status returns the status of the light client neutrino instance, + //along with height and hash of the best block, and a list of connected + //peers. + Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error) + // + //AddPeer adds a new peer that has already been connected to the server. + AddPeer(ctx context.Context, in *AddPeerRequest, opts ...grpc.CallOption) (*AddPeerResponse, error) + // + //DisconnectPeer disconnects a peer by target address. Both outbound and + //inbound nodes will be searched for the target node. An error message will + //be returned if the peer was not found. + DisconnectPeer(ctx context.Context, in *DisconnectPeerRequest, opts ...grpc.CallOption) (*DisconnectPeerResponse, error) + // + //IsBanned returns true if the peer is banned, otherwise false. + IsBanned(ctx context.Context, in *IsBannedRequest, opts ...grpc.CallOption) (*IsBannedResponse, error) + // + //GetBlockHeader returns a block header with a particular block hash. + GetBlockHeader(ctx context.Context, in *GetBlockHeaderRequest, opts ...grpc.CallOption) (*GetBlockHeaderResponse, error) + // + //GetBlock returns a block with a particular block hash. + GetBlock(ctx context.Context, in *GetBlockRequest, opts ...grpc.CallOption) (*GetBlockResponse, error) + // + //GetCFilter returns a compact filter from a block. + GetCFilter(ctx context.Context, in *GetCFilterRequest, opts ...grpc.CallOption) (*GetCFilterResponse, error) +} + +type neutrinoKitClient struct { + cc grpc.ClientConnInterface +} + +func NewNeutrinoKitClient(cc grpc.ClientConnInterface) NeutrinoKitClient { + return &neutrinoKitClient{cc} +} + +func (c *neutrinoKitClient) Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error) { + out := new(StatusResponse) + err := c.cc.Invoke(ctx, "/neutrinorpc.NeutrinoKit/Status", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *neutrinoKitClient) AddPeer(ctx context.Context, in *AddPeerRequest, opts ...grpc.CallOption) (*AddPeerResponse, error) { + out := new(AddPeerResponse) + err := c.cc.Invoke(ctx, "/neutrinorpc.NeutrinoKit/AddPeer", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *neutrinoKitClient) DisconnectPeer(ctx context.Context, in *DisconnectPeerRequest, opts ...grpc.CallOption) (*DisconnectPeerResponse, error) { + out := new(DisconnectPeerResponse) + err := c.cc.Invoke(ctx, "/neutrinorpc.NeutrinoKit/DisconnectPeer", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *neutrinoKitClient) IsBanned(ctx context.Context, in *IsBannedRequest, opts ...grpc.CallOption) (*IsBannedResponse, error) { + out := new(IsBannedResponse) + err := c.cc.Invoke(ctx, "/neutrinorpc.NeutrinoKit/IsBanned", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *neutrinoKitClient) GetBlockHeader(ctx context.Context, in *GetBlockHeaderRequest, opts ...grpc.CallOption) (*GetBlockHeaderResponse, error) { + out := new(GetBlockHeaderResponse) + err := c.cc.Invoke(ctx, "/neutrinorpc.NeutrinoKit/GetBlockHeader", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *neutrinoKitClient) GetBlock(ctx context.Context, in *GetBlockRequest, opts ...grpc.CallOption) (*GetBlockResponse, error) { + out := new(GetBlockResponse) + err := c.cc.Invoke(ctx, "/neutrinorpc.NeutrinoKit/GetBlock", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *neutrinoKitClient) GetCFilter(ctx context.Context, in *GetCFilterRequest, opts ...grpc.CallOption) (*GetCFilterResponse, error) { + out := new(GetCFilterResponse) + err := c.cc.Invoke(ctx, "/neutrinorpc.NeutrinoKit/GetCFilter", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// NeutrinoKitServer is the server API for NeutrinoKit service. +// All implementations must embed UnimplementedNeutrinoKitServer +// for forward compatibility +type NeutrinoKitServer interface { + // + //Status returns the status of the light client neutrino instance, + //along with height and hash of the best block, and a list of connected + //peers. + Status(context.Context, *StatusRequest) (*StatusResponse, error) + // + //AddPeer adds a new peer that has already been connected to the server. + AddPeer(context.Context, *AddPeerRequest) (*AddPeerResponse, error) + // + //DisconnectPeer disconnects a peer by target address. Both outbound and + //inbound nodes will be searched for the target node. An error message will + //be returned if the peer was not found. + DisconnectPeer(context.Context, *DisconnectPeerRequest) (*DisconnectPeerResponse, error) + // + //IsBanned returns true if the peer is banned, otherwise false. + IsBanned(context.Context, *IsBannedRequest) (*IsBannedResponse, error) + // + //GetBlockHeader returns a block header with a particular block hash. + GetBlockHeader(context.Context, *GetBlockHeaderRequest) (*GetBlockHeaderResponse, error) + // + //GetBlock returns a block with a particular block hash. + GetBlock(context.Context, *GetBlockRequest) (*GetBlockResponse, error) + // + //GetCFilter returns a compact filter from a block. + GetCFilter(context.Context, *GetCFilterRequest) (*GetCFilterResponse, error) + mustEmbedUnimplementedNeutrinoKitServer() +} + +// UnimplementedNeutrinoKitServer must be embedded to have forward compatible implementations. +type UnimplementedNeutrinoKitServer struct { +} + +func (UnimplementedNeutrinoKitServer) Status(context.Context, *StatusRequest) (*StatusResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Status not implemented") +} +func (UnimplementedNeutrinoKitServer) AddPeer(context.Context, *AddPeerRequest) (*AddPeerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddPeer not implemented") +} +func (UnimplementedNeutrinoKitServer) DisconnectPeer(context.Context, *DisconnectPeerRequest) (*DisconnectPeerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DisconnectPeer not implemented") +} +func (UnimplementedNeutrinoKitServer) IsBanned(context.Context, *IsBannedRequest) (*IsBannedResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method IsBanned not implemented") +} +func (UnimplementedNeutrinoKitServer) GetBlockHeader(context.Context, *GetBlockHeaderRequest) (*GetBlockHeaderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetBlockHeader not implemented") +} +func (UnimplementedNeutrinoKitServer) GetBlock(context.Context, *GetBlockRequest) (*GetBlockResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetBlock not implemented") +} +func (UnimplementedNeutrinoKitServer) GetCFilter(context.Context, *GetCFilterRequest) (*GetCFilterResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetCFilter not implemented") +} +func (UnimplementedNeutrinoKitServer) mustEmbedUnimplementedNeutrinoKitServer() {} + +// UnsafeNeutrinoKitServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to NeutrinoKitServer will +// result in compilation errors. +type UnsafeNeutrinoKitServer interface { + mustEmbedUnimplementedNeutrinoKitServer() +} + +func RegisterNeutrinoKitServer(s grpc.ServiceRegistrar, srv NeutrinoKitServer) { + s.RegisterService(&NeutrinoKit_ServiceDesc, srv) +} + +func _NeutrinoKit_Status_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StatusRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(NeutrinoKitServer).Status(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/neutrinorpc.NeutrinoKit/Status", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(NeutrinoKitServer).Status(ctx, req.(*StatusRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _NeutrinoKit_AddPeer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AddPeerRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(NeutrinoKitServer).AddPeer(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/neutrinorpc.NeutrinoKit/AddPeer", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(NeutrinoKitServer).AddPeer(ctx, req.(*AddPeerRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _NeutrinoKit_DisconnectPeer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DisconnectPeerRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(NeutrinoKitServer).DisconnectPeer(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/neutrinorpc.NeutrinoKit/DisconnectPeer", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(NeutrinoKitServer).DisconnectPeer(ctx, req.(*DisconnectPeerRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _NeutrinoKit_IsBanned_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(IsBannedRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(NeutrinoKitServer).IsBanned(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/neutrinorpc.NeutrinoKit/IsBanned", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(NeutrinoKitServer).IsBanned(ctx, req.(*IsBannedRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _NeutrinoKit_GetBlockHeader_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetBlockHeaderRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(NeutrinoKitServer).GetBlockHeader(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/neutrinorpc.NeutrinoKit/GetBlockHeader", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(NeutrinoKitServer).GetBlockHeader(ctx, req.(*GetBlockHeaderRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _NeutrinoKit_GetBlock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetBlockRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(NeutrinoKitServer).GetBlock(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/neutrinorpc.NeutrinoKit/GetBlock", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(NeutrinoKitServer).GetBlock(ctx, req.(*GetBlockRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _NeutrinoKit_GetCFilter_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetCFilterRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(NeutrinoKitServer).GetCFilter(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/neutrinorpc.NeutrinoKit/GetCFilter", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(NeutrinoKitServer).GetCFilter(ctx, req.(*GetCFilterRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// NeutrinoKit_ServiceDesc is the grpc.ServiceDesc for NeutrinoKit service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var NeutrinoKit_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "neutrinorpc.NeutrinoKit", + HandlerType: (*NeutrinoKitServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Status", + Handler: _NeutrinoKit_Status_Handler, + }, + { + MethodName: "AddPeer", + Handler: _NeutrinoKit_AddPeer_Handler, + }, + { + MethodName: "DisconnectPeer", + Handler: _NeutrinoKit_DisconnectPeer_Handler, + }, + { + MethodName: "IsBanned", + Handler: _NeutrinoKit_IsBanned_Handler, + }, + { + MethodName: "GetBlockHeader", + Handler: _NeutrinoKit_GetBlockHeader_Handler, + }, + { + MethodName: "GetBlock", + Handler: _NeutrinoKit_GetBlock_Handler, + }, + { + MethodName: "GetCFilter", + Handler: _NeutrinoKit_GetCFilter_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "neutrinorpc/neutrino.proto", +} diff --git a/lnrpc/neutrinorpc/neutrino_server.go b/lnrpc/neutrinorpc/neutrino_server.go new file mode 100644 index 000000000..fdfbe64c5 --- /dev/null +++ b/lnrpc/neutrinorpc/neutrino_server.go @@ -0,0 +1,425 @@ +//go:build neutrinorpc +// +build neutrinorpc + +package neutrinorpc + +import ( + "context" + "errors" + "fmt" + + "google.golang.org/grpc" + "gopkg.in/macaroon-bakery.v2/bakery" + + "github.com/btcsuite/btcd/chaincfg/chainhash" + + "github.com/btcsuite/btcd/blockchain" + "github.com/btcsuite/btcd/wire" + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + + "github.com/lightningnetwork/lnd/lnrpc" +) + +const ( + // subServerName is the name of the sub rpc server. We'll use this name + // to register ourselves, and we also require that the main + // SubServerConfigDispatcher instance recognize it as the name of our + // RPC service. + subServerName = "NeutrinoKitRPC" +) + +var ( + // macPermissions maps RPC calls to the permissions they require. + macPermissions = map[string][]bakery.Op{ + "/neutrinorpc.NeutrinoKit/Status": {{ + Entity: "info", + Action: "read", + }}, + "/neutrinorpc.NeutrinoKit/AddPeer": {{ + Entity: "peers", + Action: "write", + }}, + "/neutrinorpc.NeutrinoKit/DisconnectPeer": {{ + Entity: "peers", + Action: "write", + }}, + "/neutrinorpc.NeutrinoKit/IsBanned": {{ + Entity: "info", + Action: "read", + }}, + "/neutrinorpc.NeutrinoKit/GetBlock": {{ + Entity: "onchain", + Action: "read", + }}, + "/neutrinorpc.NeutrinoKit/GetBlockHeader": {{ + Entity: "onchain", + Action: "read", + }}, + "/neutrinorpc.NeutrinoKit/GetCFilter": {{ + Entity: "onchain", + Action: "read", + }}, + } + + // ErrNeutrinoNotActive is an error returned when there is no running + // neutrino light client instance. + ErrNeutrinoNotActive = errors.New("no active neutrino instance") +) + +// ServerShell is a shell struct holding a reference to the actual sub-server. +// It is used to register the gRPC sub-server with the root server before we +// have the necessary dependencies to populate the actual sub-server. +type ServerShell struct { + NeutrinoKitServer +} + +// Server is a sub-server of the main RPC server: the neutrino RPC. This sub +// RPC server allows external callers to access the status of the neutrino +// currently active within lnd, as well as configuring it at runtime. +type Server struct { + // Required by the grpc-gateway/v2 library for forward compatibility. + // Must be after the atomically used variables to not break struct + // alignment. + UnimplementedNeutrinoKitServer + + cfg *Config +} + +// A compile time check to ensure that NeutrinoKit fully implements the +// NeutrinoServer gRPC service. +var _ NeutrinoKitServer = (*Server)(nil) + +// New returns a new instance of the neutrinorpc Neutrino sub-server. We also +// return the set of permissions for the macaroons that we may create within +// this method. If the macaroons we need aren't found in the filepath, then +// we'll create them on start up. If we're unable to locate, or create the +// macaroons we need, then we'll return with an error. +func New(cfg *Config) (*Server, lnrpc.MacaroonPerms, error) { + // We don't create any new macaroons for this subserver, instead reuse + // existing onchain/offchain permissions. + server := &Server{ + cfg: cfg, + } + + return server, macPermissions, nil +} + +// Start launches any helper goroutines required for the Server to function. +// +// NOTE: This is part of the lnrpc.SubServer interface. +func (s *Server) Start() error { + return nil +} + +// Stop signals any active goroutines for a graceful closure. +// +// NOTE: This is part of the lnrpc.SubServer interface. +func (s *Server) Stop() error { + return nil +} + +// Name returns a unique string representation of the sub-server. This can be +// used to identify the sub-server and also de-duplicate them. +// +// NOTE: This is part of the lnrpc.SubServer interface. +func (s *Server) Name() string { + return subServerName +} + +// RegisterWithRootServer will be called by the root gRPC server to direct a +// sub RPC server to register itself with the main gRPC root server. Until this +// is called, each sub-server won't be able to have +// requests routed towards it. +// +// NOTE: This is part of the lnrpc.GrpcHandler interface. +func (r *ServerShell) RegisterWithRootServer(grpcServer *grpc.Server) error { + // We make sure that we register it with the main gRPC server to ensure + // all our methods are routed properly. + RegisterNeutrinoKitServer(grpcServer, r) + + log.Debugf("Neutrino RPC server successfully register with root " + + "gRPC server") + + return nil +} + +// RegisterWithRestServer will be called by the root REST mux to direct a sub +// RPC server to register itself with the main REST mux server. Until this is +// called, each sub-server won't be able to have requests routed towards it. +// +// NOTE: This is part of the lnrpc.GrpcHandler interface. +func (r *ServerShell) RegisterWithRestServer(ctx context.Context, + mux *runtime.ServeMux, dest string, opts []grpc.DialOption) error { + + // We make sure that we register it with the main REST server to ensure + // all our methods are routed properly. + err := RegisterNeutrinoKitHandlerFromEndpoint(ctx, mux, dest, opts) + if err != nil { + log.Errorf("Could not register Neutrino REST server "+ + "with root REST server: %v", err) + return err + } + + log.Debugf("Neutrino REST server successfully registered with " + + "root REST server") + return nil +} + +// CreateSubServer populates the subserver's dependencies using the passed +// SubServerConfigDispatcher. This method should fully initialize the +// sub-server instance, making it ready for action. It returns the macaroon +// permissions that the sub-server wishes to pass on to the root server for all +// methods routed towards it. +// +// NOTE: This is part of the lnrpc.GrpcHandler interface. +func (r *ServerShell) CreateSubServer(configRegistry lnrpc.SubServerConfigDispatcher) ( + lnrpc.SubServer, lnrpc.MacaroonPerms, error) { + + subServer, macPermissions, err := createNewSubServer(configRegistry) + if err != nil { + return nil, nil, err + } + + r.NeutrinoKitServer = subServer + return subServer, macPermissions, nil +} + +// Status returns the current status, best block height and connected peers +// of the neutrino node. +// +// NOTE: Part of the NeutrinoServer interface. +func (s *Server) Status(ctx context.Context, + in *StatusRequest) (*StatusResponse, error) { + + if s.cfg.NeutrinoCS == nil { + return &StatusResponse{}, nil + } + + bestBlock, err := s.cfg.NeutrinoCS.BestBlock() + if err != nil { + return &StatusResponse{}, + fmt.Errorf("could not get best block: %v", err) + } + + peers := s.cfg.NeutrinoCS.Peers() + var Peers = make([]string, len(peers)) + for i, p := range peers { + Peers[i] = p.Addr() + } + + return &StatusResponse{ + Active: s.cfg.NeutrinoCS != nil, + BlockHeight: bestBlock.Height, + BlockHash: bestBlock.Hash.String(), + Synced: s.cfg.NeutrinoCS.IsCurrent(), + Peers: Peers, + }, nil +} + +// AddPeer adds a new peer that has already been connected to the server. +// +// NOTE: Part of the NeutrinoKitServer interface. +func (s *Server) AddPeer(ctx context.Context, + in *AddPeerRequest) (*AddPeerResponse, error) { + + if s.cfg.NeutrinoCS == nil { + return &AddPeerResponse{}, ErrNeutrinoNotActive + } + + peer := s.cfg.NeutrinoCS.PeerByAddr(in.PeerAddrs) + if peer == nil { + return &AddPeerResponse{}, + fmt.Errorf("could not found peer: %s", in.PeerAddrs) + } + s.cfg.NeutrinoCS.AddPeer(peer) + + return &AddPeerResponse{}, nil +} + +// DisconnectPeer disconnects a peer by target address. Both outbound and +// inbound nodes will be searched for the target node. An error message will +// be returned if the peer was not found. +// +// NOTE: Part of the NeutrinoKitServer interface. +func (s *Server) DisconnectPeer(ctx context.Context, + in *DisconnectPeerRequest) (*DisconnectPeerResponse, error) { + + if s.cfg.NeutrinoCS == nil { + return &DisconnectPeerResponse{}, ErrNeutrinoNotActive + } + + peer := s.cfg.NeutrinoCS.PeerByAddr(in.PeerAddrs) + if peer == nil { + return &DisconnectPeerResponse{}, + fmt.Errorf("could not found peer: %s", in.PeerAddrs) + } + + err := s.cfg.NeutrinoCS.DisconnectNodeByAddr(peer.Addr()) + if err != nil { + return &DisconnectPeerResponse{}, err + } + + return &DisconnectPeerResponse{}, nil +} + +// IsBanned returns true if the peer is banned, otherwise false. +// +// NOTE: Part of the NeutrinoKitServer interface. +func (s *Server) IsBanned(ctx context.Context, + in *IsBannedRequest) (*IsBannedResponse, error) { + + if s.cfg.NeutrinoCS == nil { + return &IsBannedResponse{}, ErrNeutrinoNotActive + } + + return &IsBannedResponse{ + Banned: s.cfg.NeutrinoCS.IsBanned(in.PeerAddrs), + }, nil +} + +// GetBlockHeader returns a block header with a particular block hash. If the +// block header is found in the cache, it will be returned immediately. +// Otherwise a block will be requested from the network, one peer at a time, +// until one answers. +// +// NOTE: Part of the NeutrinoKitServer interface. +func (s *Server) GetBlockHeader(ctx context.Context, + in *GetBlockHeaderRequest) (*GetBlockHeaderResponse, error) { + + if s.cfg.NeutrinoCS == nil { + return &GetBlockHeaderResponse{}, ErrNeutrinoNotActive + } + + var hash chainhash.Hash + if err := chainhash.Decode(&hash, in.Hash); err != nil { + return &GetBlockHeaderResponse{}, err + } + + resp, err := s.getBlock(hash) + if err != nil { + return &GetBlockHeaderResponse{}, err + } + + return &GetBlockHeaderResponse{ + Hash: resp.Hash, + Confirmations: resp.Confirmations, + StrippedSize: resp.StrippedSize, + Size: resp.Size, + Weight: resp.Weight, + Height: resp.Height, + Version: resp.Version, + VersionHex: resp.VersionHex, + Merkleroot: resp.Merkleroot, + Time: resp.Time, + Nonce: resp.Nonce, + Bits: resp.Bits, + Ntx: resp.Ntx, + PreviousBlockHash: resp.PreviousBlockHash, + RawHex: resp.RawHex, + }, nil +} + +// GetBlock returns a block with a particular block hash. If the block is +// found in the cache, it will be returned immediately. Otherwise a block will +// be requested from the network, one peer at a time, until one answers. +// +// NOTE: Part of the NeutrinoKitServer interface. +func (s *Server) GetBlock(ctx context.Context, + in *GetBlockRequest) (*GetBlockResponse, error) { + + if s.cfg.NeutrinoCS == nil { + return &GetBlockResponse{}, ErrNeutrinoNotActive + } + + var hash chainhash.Hash + if err := chainhash.Decode(&hash, in.Hash); err != nil { + return &GetBlockResponse{}, err + } + + return s.getBlock(hash) +} + +// GetCFilter returns a compact filter of a particular block. +// If found, only regular filters will be returned. +// +// NOTE: Part of the NeutrinoKitServer interface. +func (s *Server) GetCFilter(ctx context.Context, + in *GetCFilterRequest) (*GetCFilterResponse, error) { + + if s.cfg.NeutrinoCS == nil { + return &GetCFilterResponse{}, ErrNeutrinoNotActive + } + + var hash chainhash.Hash + if err := chainhash.Decode(&hash, in.Hash); err != nil { + return &GetCFilterResponse{}, err + } + + // GetCFilter returns a compact filter from the database. If it is missing, + // it requests the compact filter from the network. + filter, err := s.cfg.NeutrinoCS.GetCFilter(hash, wire.GCSFilterRegular) + if err != nil { + return &GetCFilterResponse{}, err + } + + filterlBytes, err := filter.Bytes() + if err != nil { + return &GetCFilterResponse{}, err + } + + return &GetCFilterResponse{Filter: filterlBytes}, nil +} + +func (s *Server) getBlock(hash chainhash.Hash) (*GetBlockResponse, error) { + block, err := s.cfg.NeutrinoCS.GetBlock(hash) + if err != nil { + return &GetBlockResponse{}, err + } + + header, _, err := s.cfg.NeutrinoCS.BlockHeaders.FetchHeader(&hash) + if err != nil { + return &GetBlockResponse{}, err + } + + blockData, err := block.Bytes() + if err != nil { + return &GetBlockResponse{}, err + } + + strippedData, err := block.BytesNoWitness() + if err != nil { + return &GetBlockResponse{}, err + } + + bestBlock, err := s.cfg.NeutrinoCS.BestBlock() + if err != nil { + return &GetBlockResponse{}, err + } + + // Convert txids to a string array. + transactions := block.Transactions() + tx := make([]string, len(transactions)) + for i := range transactions { + tx[i] = transactions[i].Hash().String() + } + + return &GetBlockResponse{ + Hash: block.Hash().String(), + Confirmations: int64(1 + bestBlock.Height - block.Height()), + StrippedSize: int64(len(strippedData)), + Size: int64(len(blockData)), + Weight: blockchain.GetBlockWeight(block), + Height: block.Height(), + Version: header.Version, + VersionHex: fmt.Sprintf("%0x", header.Version), + Merkleroot: header.MerkleRoot.String(), + Tx: tx, + Time: header.Timestamp.Unix(), + Nonce: header.Nonce, + // Format bits as a hex. + Bits: fmt.Sprintf("%0x", header.Bits), + Ntx: int32(len(block.Transactions())), + PreviousBlockHash: header.PrevBlock.String(), + RawHex: blockData, + }, nil +} diff --git a/lnrpc/neutrinorpc/neutrinokit.pb.json.go b/lnrpc/neutrinorpc/neutrinokit.pb.json.go new file mode 100644 index 000000000..2b9e2664e --- /dev/null +++ b/lnrpc/neutrinorpc/neutrinokit.pb.json.go @@ -0,0 +1,200 @@ +// Code generated by falafel 0.9.1. DO NOT EDIT. +// source: neutrino.proto + +// +build js + +package neutrinorpc + +import ( + "context" + + gateway "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "google.golang.org/grpc" + "google.golang.org/protobuf/encoding/protojson" +) + +func RegisterNeutrinoKitJSONCallbacks(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["neutrinorpc.NeutrinoKit.Status"] = func(ctx context.Context, + conn *grpc.ClientConn, reqJSON string, callback func(string, error)) { + + req := &StatusRequest{} + err := marshaler.Unmarshal([]byte(reqJSON), req) + if err != nil { + callback("", err) + return + } + + client := NewNeutrinoKitClient(conn) + resp, err := client.Status(ctx, req) + if err != nil { + callback("", err) + return + } + + respBytes, err := marshaler.Marshal(resp) + if err != nil { + callback("", err) + return + } + callback(string(respBytes), nil) + } + + registry["neutrinorpc.NeutrinoKit.AddPeer"] = func(ctx context.Context, + conn *grpc.ClientConn, reqJSON string, callback func(string, error)) { + + req := &AddPeerRequest{} + err := marshaler.Unmarshal([]byte(reqJSON), req) + if err != nil { + callback("", err) + return + } + + client := NewNeutrinoKitClient(conn) + resp, err := client.AddPeer(ctx, req) + if err != nil { + callback("", err) + return + } + + respBytes, err := marshaler.Marshal(resp) + if err != nil { + callback("", err) + return + } + callback(string(respBytes), nil) + } + + registry["neutrinorpc.NeutrinoKit.DisconnectPeer"] = func(ctx context.Context, + conn *grpc.ClientConn, reqJSON string, callback func(string, error)) { + + req := &DisconnectPeerRequest{} + err := marshaler.Unmarshal([]byte(reqJSON), req) + if err != nil { + callback("", err) + return + } + + client := NewNeutrinoKitClient(conn) + resp, err := client.DisconnectPeer(ctx, req) + if err != nil { + callback("", err) + return + } + + respBytes, err := marshaler.Marshal(resp) + if err != nil { + callback("", err) + return + } + callback(string(respBytes), nil) + } + + registry["neutrinorpc.NeutrinoKit.IsBanned"] = func(ctx context.Context, + conn *grpc.ClientConn, reqJSON string, callback func(string, error)) { + + req := &IsBannedRequest{} + err := marshaler.Unmarshal([]byte(reqJSON), req) + if err != nil { + callback("", err) + return + } + + client := NewNeutrinoKitClient(conn) + resp, err := client.IsBanned(ctx, req) + if err != nil { + callback("", err) + return + } + + respBytes, err := marshaler.Marshal(resp) + if err != nil { + callback("", err) + return + } + callback(string(respBytes), nil) + } + + registry["neutrinorpc.NeutrinoKit.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 := NewNeutrinoKitClient(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["neutrinorpc.NeutrinoKit.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 := NewNeutrinoKitClient(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["neutrinorpc.NeutrinoKit.GetCFilter"] = func(ctx context.Context, + conn *grpc.ClientConn, reqJSON string, callback func(string, error)) { + + req := &GetCFilterRequest{} + err := marshaler.Unmarshal([]byte(reqJSON), req) + if err != nil { + callback("", err) + return + } + + client := NewNeutrinoKitClient(conn) + resp, err := client.GetCFilter(ctx, req) + if err != nil { + callback("", err) + return + } + + respBytes, err := marshaler.Marshal(resp) + if err != nil { + callback("", err) + return + } + callback(string(respBytes), nil) + } +}