chainrpc

package
v0.15.5-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package chainrpc is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
var ChainNotifier_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "chainrpc.ChainNotifier",
	HandlerType: (*ChainNotifierServer)(nil),
	Methods:     []grpc.MethodDesc{},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "RegisterConfirmationsNtfn",
			Handler:       _ChainNotifier_RegisterConfirmationsNtfn_Handler,
			ServerStreams: true,
		},
		{
			StreamName:    "RegisterSpendNtfn",
			Handler:       _ChainNotifier_RegisterSpendNtfn_Handler,
			ServerStreams: true,
		},
		{
			StreamName:    "RegisterBlockEpochNtfn",
			Handler:       _ChainNotifier_RegisterBlockEpochNtfn_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "chainrpc/chainnotifier.proto",
}

ChainNotifier_ServiceDesc is the grpc.ServiceDesc for ChainNotifier service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

View Source
var File_chainrpc_chainnotifier_proto protoreflect.FileDescriptor

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.

func RegisterChainNotifierHandler

func RegisterChainNotifierHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterChainNotifierHandler registers the http handlers for service ChainNotifier to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterChainNotifierHandlerClient

func RegisterChainNotifierHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ChainNotifierClient) error

RegisterChainNotifierHandlerClient registers the http handlers for service ChainNotifier to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ChainNotifierClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ChainNotifierClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "ChainNotifierClient" to call the correct interceptors.

func RegisterChainNotifierHandlerFromEndpoint

func RegisterChainNotifierHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterChainNotifierHandlerFromEndpoint is same as RegisterChainNotifierHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterChainNotifierHandlerServer

func RegisterChainNotifierHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ChainNotifierServer) error

RegisterChainNotifierHandlerServer registers the http handlers for service ChainNotifier to "mux". UnaryRPC :call ChainNotifierServer 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 RegisterChainNotifierHandlerFromEndpoint instead.

func RegisterChainNotifierJSONCallbacks

func RegisterChainNotifierJSONCallbacks(registry map[string]func(ctx context.Context,
	conn *grpc.ClientConn, reqJSON string, callback func(string, error)))

func RegisterChainNotifierServer

func RegisterChainNotifierServer(s grpc.ServiceRegistrar, srv ChainNotifierServer)

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

Types

type BlockEpoch

type BlockEpoch struct {

	// The hash of the block.
	Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"`
	// The height of the block.
	Height uint32 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"`
	// contains filtered or unexported fields
}

func (*BlockEpoch) Descriptor deprecated

func (*BlockEpoch) Descriptor() ([]byte, []int)

Deprecated: Use BlockEpoch.ProtoReflect.Descriptor instead.

func (*BlockEpoch) GetHash

func (x *BlockEpoch) GetHash() []byte

func (*BlockEpoch) GetHeight

func (x *BlockEpoch) GetHeight() uint32

func (*BlockEpoch) ProtoMessage

func (*BlockEpoch) ProtoMessage()

func (*BlockEpoch) ProtoReflect

func (x *BlockEpoch) ProtoReflect() protoreflect.Message

func (*BlockEpoch) Reset

func (x *BlockEpoch) Reset()

func (*BlockEpoch) String

func (x *BlockEpoch) String() string

type ChainNotifierClient

type ChainNotifierClient interface {
	//
	//RegisterConfirmationsNtfn is a synchronous response-streaming RPC that
	//registers an intent for a client to be notified once a confirmation request
	//has reached its required number of confirmations on-chain.
	//
	//A confirmation request must have a valid output script. It is also possible
	//to give a transaction ID. If the transaction ID is not set, a notification
	//is sent once the output script confirms. If the transaction ID is also set,
	//a notification is sent once the output script confirms in the given
	//transaction.
	RegisterConfirmationsNtfn(ctx context.Context, in *ConfRequest, opts ...grpc.CallOption) (ChainNotifier_RegisterConfirmationsNtfnClient, error)
	//
	//RegisterSpendNtfn is a synchronous response-streaming RPC that registers an
	//intent for a client to be notification once a spend request has been spent
	//by a transaction that has confirmed on-chain.
	//
	//A client can specify whether the spend request should be for a particular
	//outpoint  or for an output script by specifying a zero outpoint.
	RegisterSpendNtfn(ctx context.Context, in *SpendRequest, opts ...grpc.CallOption) (ChainNotifier_RegisterSpendNtfnClient, error)
	//
	//RegisterBlockEpochNtfn is a synchronous response-streaming RPC that
	//registers an intent for a client to be notified of blocks in the chain. The
	//stream will return a hash and height tuple of a block for each new/stale
	//block in the chain. It is the client's responsibility to determine whether
	//the tuple returned is for a new or stale block in the chain.
	//
	//A client can also request a historical backlog of blocks from a particular
	//point. This allows clients to be idempotent by ensuring that they do not
	//missing processing a single block within the chain.
	RegisterBlockEpochNtfn(ctx context.Context, in *BlockEpoch, opts ...grpc.CallOption) (ChainNotifier_RegisterBlockEpochNtfnClient, error)
}

ChainNotifierClient is the client API for ChainNotifier 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 ChainNotifierServer

type ChainNotifierServer interface {
	//
	//RegisterConfirmationsNtfn is a synchronous response-streaming RPC that
	//registers an intent for a client to be notified once a confirmation request
	//has reached its required number of confirmations on-chain.
	//
	//A confirmation request must have a valid output script. It is also possible
	//to give a transaction ID. If the transaction ID is not set, a notification
	//is sent once the output script confirms. If the transaction ID is also set,
	//a notification is sent once the output script confirms in the given
	//transaction.
	RegisterConfirmationsNtfn(*ConfRequest, ChainNotifier_RegisterConfirmationsNtfnServer) error
	//
	//RegisterSpendNtfn is a synchronous response-streaming RPC that registers an
	//intent for a client to be notification once a spend request has been spent
	//by a transaction that has confirmed on-chain.
	//
	//A client can specify whether the spend request should be for a particular
	//outpoint  or for an output script by specifying a zero outpoint.
	RegisterSpendNtfn(*SpendRequest, ChainNotifier_RegisterSpendNtfnServer) error
	//
	//RegisterBlockEpochNtfn is a synchronous response-streaming RPC that
	//registers an intent for a client to be notified of blocks in the chain. The
	//stream will return a hash and height tuple of a block for each new/stale
	//block in the chain. It is the client's responsibility to determine whether
	//the tuple returned is for a new or stale block in the chain.
	//
	//A client can also request a historical backlog of blocks from a particular
	//point. This allows clients to be idempotent by ensuring that they do not
	//missing processing a single block within the chain.
	RegisterBlockEpochNtfn(*BlockEpoch, ChainNotifier_RegisterBlockEpochNtfnServer) error
	// contains filtered or unexported methods
}

ChainNotifierServer is the server API for ChainNotifier service. All implementations must embed UnimplementedChainNotifierServer for forward compatibility

type ChainNotifier_RegisterBlockEpochNtfnClient

type ChainNotifier_RegisterBlockEpochNtfnClient interface {
	Recv() (*BlockEpoch, error)
	grpc.ClientStream
}

type ChainNotifier_RegisterBlockEpochNtfnServer

type ChainNotifier_RegisterBlockEpochNtfnServer interface {
	Send(*BlockEpoch) error
	grpc.ServerStream
}

type ChainNotifier_RegisterConfirmationsNtfnClient

type ChainNotifier_RegisterConfirmationsNtfnClient interface {
	Recv() (*ConfEvent, error)
	grpc.ClientStream
}

type ChainNotifier_RegisterConfirmationsNtfnServer

type ChainNotifier_RegisterConfirmationsNtfnServer interface {
	Send(*ConfEvent) error
	grpc.ServerStream
}

type ChainNotifier_RegisterSpendNtfnClient

type ChainNotifier_RegisterSpendNtfnClient interface {
	Recv() (*SpendEvent, error)
	grpc.ClientStream
}

type ChainNotifier_RegisterSpendNtfnServer

type ChainNotifier_RegisterSpendNtfnServer interface {
	Send(*SpendEvent) error
	grpc.ServerStream
}

type ConfDetails

type ConfDetails struct {

	// The raw bytes of the confirmed transaction.
	RawTx []byte `protobuf:"bytes,1,opt,name=raw_tx,json=rawTx,proto3" json:"raw_tx,omitempty"`
	// The hash of the block in which the confirmed transaction was included in.
	BlockHash []byte `protobuf:"bytes,2,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"`
	// The height of the block in which the confirmed transaction was included
	// in.
	BlockHeight uint32 `protobuf:"varint,3,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"`
	// The index of the confirmed transaction within the transaction.
	TxIndex uint32 `protobuf:"varint,4,opt,name=tx_index,json=txIndex,proto3" json:"tx_index,omitempty"`
	// contains filtered or unexported fields
}

func (*ConfDetails) Descriptor deprecated

func (*ConfDetails) Descriptor() ([]byte, []int)

Deprecated: Use ConfDetails.ProtoReflect.Descriptor instead.

func (*ConfDetails) GetBlockHash

func (x *ConfDetails) GetBlockHash() []byte

func (*ConfDetails) GetBlockHeight

func (x *ConfDetails) GetBlockHeight() uint32

func (*ConfDetails) GetRawTx

func (x *ConfDetails) GetRawTx() []byte

func (*ConfDetails) GetTxIndex

func (x *ConfDetails) GetTxIndex() uint32

func (*ConfDetails) ProtoMessage

func (*ConfDetails) ProtoMessage()

func (*ConfDetails) ProtoReflect

func (x *ConfDetails) ProtoReflect() protoreflect.Message

func (*ConfDetails) Reset

func (x *ConfDetails) Reset()

func (*ConfDetails) String

func (x *ConfDetails) String() string

type ConfEvent

type ConfEvent struct {

	// Types that are assignable to Event:
	//	*ConfEvent_Conf
	//	*ConfEvent_Reorg
	Event isConfEvent_Event `protobuf_oneof:"event"`
	// contains filtered or unexported fields
}

func (*ConfEvent) Descriptor deprecated

func (*ConfEvent) Descriptor() ([]byte, []int)

Deprecated: Use ConfEvent.ProtoReflect.Descriptor instead.

func (*ConfEvent) GetConf

func (x *ConfEvent) GetConf() *ConfDetails

func (*ConfEvent) GetEvent

func (m *ConfEvent) GetEvent() isConfEvent_Event

func (*ConfEvent) GetReorg

func (x *ConfEvent) GetReorg() *Reorg

func (*ConfEvent) ProtoMessage

func (*ConfEvent) ProtoMessage()

func (*ConfEvent) ProtoReflect

func (x *ConfEvent) ProtoReflect() protoreflect.Message

func (*ConfEvent) Reset

func (x *ConfEvent) Reset()

func (*ConfEvent) String

func (x *ConfEvent) String() string

type ConfEvent_Conf

type ConfEvent_Conf struct {
	//
	//An event that includes the confirmation details of the request
	//(txid/ouput script).
	Conf *ConfDetails `protobuf:"bytes,1,opt,name=conf,proto3,oneof"`
}

type ConfEvent_Reorg

type ConfEvent_Reorg struct {
	//
	//An event send when the transaction of the request is reorged out of the
	//chain.
	Reorg *Reorg `protobuf:"bytes,2,opt,name=reorg,proto3,oneof"`
}

type ConfRequest

type ConfRequest struct {

	//
	//The transaction hash for which we should request a confirmation notification
	//for. If set to a hash of all zeros, then the confirmation notification will
	//be requested for the script instead.
	Txid []byte `protobuf:"bytes,1,opt,name=txid,proto3" json:"txid,omitempty"`
	//
	//An output script within a transaction with the hash above which will be used
	//by light clients to match block filters. If the transaction hash is set to a
	//hash of all zeros, then a confirmation notification will be requested for
	//this script instead.
	Script []byte `protobuf:"bytes,2,opt,name=script,proto3" json:"script,omitempty"`
	//
	//The number of desired confirmations the transaction/output script should
	//reach before dispatching a confirmation notification.
	NumConfs uint32 `protobuf:"varint,3,opt,name=num_confs,json=numConfs,proto3" json:"num_confs,omitempty"`
	//
	//The earliest height in the chain for which the transaction/output script
	//could have been included in a block. This should in most cases be set to the
	//broadcast height of the transaction/output script.
	HeightHint uint32 `protobuf:"varint,4,opt,name=height_hint,json=heightHint,proto3" json:"height_hint,omitempty"`
	// contains filtered or unexported fields
}

func (*ConfRequest) Descriptor deprecated

func (*ConfRequest) Descriptor() ([]byte, []int)

Deprecated: Use ConfRequest.ProtoReflect.Descriptor instead.

func (*ConfRequest) GetHeightHint

func (x *ConfRequest) GetHeightHint() uint32

func (*ConfRequest) GetNumConfs

func (x *ConfRequest) GetNumConfs() uint32

func (*ConfRequest) GetScript

func (x *ConfRequest) GetScript() []byte

func (*ConfRequest) GetTxid

func (x *ConfRequest) GetTxid() []byte

func (*ConfRequest) ProtoMessage

func (*ConfRequest) ProtoMessage()

func (*ConfRequest) ProtoReflect

func (x *ConfRequest) ProtoReflect() protoreflect.Message

func (*ConfRequest) Reset

func (x *ConfRequest) Reset()

func (*ConfRequest) String

func (x *ConfRequest) String() string

type Config

type Config struct{}

Config is empty for non-chainrpc builds.

type Outpoint

type Outpoint struct {

	// The hash of the transaction.
	Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"`
	// The index of the output within the transaction.
	Index uint32 `protobuf:"varint,2,opt,name=index,proto3" json:"index,omitempty"`
	// contains filtered or unexported fields
}

func (*Outpoint) Descriptor deprecated

func (*Outpoint) Descriptor() ([]byte, []int)

Deprecated: Use Outpoint.ProtoReflect.Descriptor instead.

func (*Outpoint) GetHash

func (x *Outpoint) GetHash() []byte

func (*Outpoint) GetIndex

func (x *Outpoint) GetIndex() uint32

func (*Outpoint) ProtoMessage

func (*Outpoint) ProtoMessage()

func (*Outpoint) ProtoReflect

func (x *Outpoint) ProtoReflect() protoreflect.Message

func (*Outpoint) Reset

func (x *Outpoint) Reset()

func (*Outpoint) String

func (x *Outpoint) String() string

type Reorg

type Reorg struct {
	// contains filtered or unexported fields
}

func (*Reorg) Descriptor deprecated

func (*Reorg) Descriptor() ([]byte, []int)

Deprecated: Use Reorg.ProtoReflect.Descriptor instead.

func (*Reorg) ProtoMessage

func (*Reorg) ProtoMessage()

func (*Reorg) ProtoReflect

func (x *Reorg) ProtoReflect() protoreflect.Message

func (*Reorg) Reset

func (x *Reorg) Reset()

func (*Reorg) String

func (x *Reorg) String() string

type SpendDetails

type SpendDetails struct {

	// The outpoint was that spent.
	SpendingOutpoint *Outpoint `protobuf:"bytes,1,opt,name=spending_outpoint,json=spendingOutpoint,proto3" json:"spending_outpoint,omitempty"`
	// The raw bytes of the spending transaction.
	RawSpendingTx []byte `protobuf:"bytes,2,opt,name=raw_spending_tx,json=rawSpendingTx,proto3" json:"raw_spending_tx,omitempty"`
	// The hash of the spending transaction.
	SpendingTxHash []byte `protobuf:"bytes,3,opt,name=spending_tx_hash,json=spendingTxHash,proto3" json:"spending_tx_hash,omitempty"`
	// The input of the spending transaction that fulfilled the spend request.
	SpendingInputIndex uint32 `protobuf:"varint,4,opt,name=spending_input_index,json=spendingInputIndex,proto3" json:"spending_input_index,omitempty"`
	// The height at which the spending transaction was included in a block.
	SpendingHeight uint32 `protobuf:"varint,5,opt,name=spending_height,json=spendingHeight,proto3" json:"spending_height,omitempty"`
	// contains filtered or unexported fields
}

func (*SpendDetails) Descriptor deprecated

func (*SpendDetails) Descriptor() ([]byte, []int)

Deprecated: Use SpendDetails.ProtoReflect.Descriptor instead.

func (*SpendDetails) GetRawSpendingTx

func (x *SpendDetails) GetRawSpendingTx() []byte

func (*SpendDetails) GetSpendingHeight

func (x *SpendDetails) GetSpendingHeight() uint32

func (*SpendDetails) GetSpendingInputIndex

func (x *SpendDetails) GetSpendingInputIndex() uint32

func (*SpendDetails) GetSpendingOutpoint

func (x *SpendDetails) GetSpendingOutpoint() *Outpoint

func (*SpendDetails) GetSpendingTxHash

func (x *SpendDetails) GetSpendingTxHash() []byte

func (*SpendDetails) ProtoMessage

func (*SpendDetails) ProtoMessage()

func (*SpendDetails) ProtoReflect

func (x *SpendDetails) ProtoReflect() protoreflect.Message

func (*SpendDetails) Reset

func (x *SpendDetails) Reset()

func (*SpendDetails) String

func (x *SpendDetails) String() string

type SpendEvent

type SpendEvent struct {

	// Types that are assignable to Event:
	//	*SpendEvent_Spend
	//	*SpendEvent_Reorg
	Event isSpendEvent_Event `protobuf_oneof:"event"`
	// contains filtered or unexported fields
}

func (*SpendEvent) Descriptor deprecated

func (*SpendEvent) Descriptor() ([]byte, []int)

Deprecated: Use SpendEvent.ProtoReflect.Descriptor instead.

func (*SpendEvent) GetEvent

func (m *SpendEvent) GetEvent() isSpendEvent_Event

func (*SpendEvent) GetReorg

func (x *SpendEvent) GetReorg() *Reorg

func (*SpendEvent) GetSpend

func (x *SpendEvent) GetSpend() *SpendDetails

func (*SpendEvent) ProtoMessage

func (*SpendEvent) ProtoMessage()

func (*SpendEvent) ProtoReflect

func (x *SpendEvent) ProtoReflect() protoreflect.Message

func (*SpendEvent) Reset

func (x *SpendEvent) Reset()

func (*SpendEvent) String

func (x *SpendEvent) String() string

type SpendEvent_Reorg

type SpendEvent_Reorg struct {
	//
	//An event sent when the spending transaction of the request was
	//reorged out of the chain.
	Reorg *Reorg `protobuf:"bytes,2,opt,name=reorg,proto3,oneof"`
}

type SpendEvent_Spend

type SpendEvent_Spend struct {
	//
	//An event that includes the details of the spending transaction of the
	//request (outpoint/output script).
	Spend *SpendDetails `protobuf:"bytes,1,opt,name=spend,proto3,oneof"`
}

type SpendRequest

type SpendRequest struct {

	//
	//The outpoint for which we should request a spend notification for. If set to
	//a zero outpoint, then the spend notification will be requested for the
	//script instead. A zero or nil outpoint is not supported for Taproot spends
	//because the output script cannot reliably be computed from the witness alone
	//and the spent output script is not always available in the rescan context.
	//So an outpoint must _always_ be specified when registering a spend
	//notification for a Taproot output.
	Outpoint *Outpoint `protobuf:"bytes,1,opt,name=outpoint,proto3" json:"outpoint,omitempty"`
	//
	//The output script for the outpoint above. This will be used by light clients
	//to match block filters. If the outpoint is set to a zero outpoint, then a
	//spend notification will be requested for this script instead.
	Script []byte `protobuf:"bytes,2,opt,name=script,proto3" json:"script,omitempty"`
	//
	//The earliest height in the chain for which the outpoint/output script could
	//have been spent. This should in most cases be set to the broadcast height of
	//the outpoint/output script.
	HeightHint uint32 `protobuf:"varint,3,opt,name=height_hint,json=heightHint,proto3" json:"height_hint,omitempty"`
	// contains filtered or unexported fields
}

func (*SpendRequest) Descriptor deprecated

func (*SpendRequest) Descriptor() ([]byte, []int)

Deprecated: Use SpendRequest.ProtoReflect.Descriptor instead.

func (*SpendRequest) GetHeightHint

func (x *SpendRequest) GetHeightHint() uint32

func (*SpendRequest) GetOutpoint

func (x *SpendRequest) GetOutpoint() *Outpoint

func (*SpendRequest) GetScript

func (x *SpendRequest) GetScript() []byte

func (*SpendRequest) ProtoMessage

func (*SpendRequest) ProtoMessage()

func (*SpendRequest) ProtoReflect

func (x *SpendRequest) ProtoReflect() protoreflect.Message

func (*SpendRequest) Reset

func (x *SpendRequest) Reset()

func (*SpendRequest) String

func (x *SpendRequest) String() string

type UnimplementedChainNotifierServer

type UnimplementedChainNotifierServer struct {
}

UnimplementedChainNotifierServer must be embedded to have forward compatible implementations.

func (UnimplementedChainNotifierServer) RegisterBlockEpochNtfn

func (UnimplementedChainNotifierServer) RegisterConfirmationsNtfn

func (UnimplementedChainNotifierServer) RegisterSpendNtfn

type UnsafeChainNotifierServer

type UnsafeChainNotifierServer interface {
	// contains filtered or unexported methods
}

UnsafeChainNotifierServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to ChainNotifierServer will result in compilation errors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL