priceoraclerpc

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2025 License: MIT Imports: 23 Imported by: 1

Documentation

Overview

Package priceoraclerpc is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
var (
	TransactionType_name = map[int32]string{
		0: "PURCHASE",
		1: "SALE",
	}
	TransactionType_value = map[string]int32{
		"PURCHASE": 0,
		"SALE":     1,
	}
)

Enum value maps for TransactionType.

View Source
var File_priceoraclerpc_price_oracle_proto protoreflect.FileDescriptor
View Source
var PriceOracle_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "priceoraclerpc.PriceOracle",
	HandlerType: (*PriceOracleServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "QueryAssetRates",
			Handler:    _PriceOracle_QueryAssetRates_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "priceoraclerpc/price_oracle.proto",
}

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

Functions

func IsAssetBtc

func IsAssetBtc(assetSpecifier *AssetSpecifier) bool

IsAssetBtc is a helper function that returns true if the given asset specifier represents BTC, and false otherwise.

func MarshalAssetRates added in v0.5.0

func MarshalAssetRates(assetRate rfqmsg.AssetRate) lfn.Result[*AssetRates]

MarshalAssetRates converts an asset rate to an RPC AssetRates. The OK result has a pointer type so that it is nil if there is an error. NOTE: The payment asset is assumed to be BTC.

func RegisterPriceOracleHandler

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

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

func RegisterPriceOracleHandlerClient

func RegisterPriceOracleHandlerClient(ctx context.Context, mux *runtime.ServeMux, client PriceOracleClient) error

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

func RegisterPriceOracleHandlerFromEndpoint

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

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

func RegisterPriceOracleHandlerServer

func RegisterPriceOracleHandlerServer(ctx context.Context, mux *runtime.ServeMux, server PriceOracleServer) error

RegisterPriceOracleHandlerServer registers the http handlers for service PriceOracle to "mux". UnaryRPC :call PriceOracleServer 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 RegisterPriceOracleHandlerFromEndpoint instead.

func RegisterPriceOracleJSONCallbacks

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

func RegisterPriceOracleServer

func RegisterPriceOracleServer(s grpc.ServiceRegistrar, srv PriceOracleServer)

func UnmarshalFixedPoint added in v0.5.0

func UnmarshalFixedPoint(fp *FixedPoint) (*rfqmath.BigIntFixedPoint, error)

UnmarshalFixedPoint converts an RPC FixedPoint to a BigIntFixedPoint.

Types

type AssetRates added in v0.5.0

type AssetRates struct {

	// subjectAssetRate is the number of subject asset units per BTC represented
	// as a fixed-point number. This field is also commonly referred to as the
	// subject asset to BTC (conversion) rate. When the subject asset is BTC,
	// this field should be set to 100 billion, as one BTC is equivalent to 100
	// billion msats.
	SubjectAssetRate *FixedPoint `protobuf:"bytes,1,opt,name=subjectAssetRate,proto3" json:"subjectAssetRate,omitempty"`
	// paymentAssetRate is the number of payment asset units per BTC represented
	// as a fixed-point number. This field is also commonly referred to as the
	// payment asset to BTC (conversion) rate. When the payment asset is BTC,
	// this field should be set to 100 billion, as one BTC is equivalent to 100
	// billion msats.
	PaymentAssetRate *FixedPoint `protobuf:"bytes,2,opt,name=paymentAssetRate,proto3" json:"paymentAssetRate,omitempty"`
	// expiry_timestamp is the Unix timestamp in seconds after which the asset
	// rates are no longer valid.
	ExpiryTimestamp uint64 `protobuf:"varint,3,opt,name=expiry_timestamp,json=expiryTimestamp,proto3" json:"expiry_timestamp,omitempty"`
	// contains filtered or unexported fields
}

AssetRates represents the exchange rates for subject and payment assets relative to BTC, expressed as fixed-point numbers. It includes the rates for both assets and an expiration timestamp indicating when the rates are no longer valid.

func (*AssetRates) Descriptor deprecated added in v0.5.0

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

Deprecated: Use AssetRates.ProtoReflect.Descriptor instead.

func (*AssetRates) GetExpiryTimestamp added in v0.5.0

func (x *AssetRates) GetExpiryTimestamp() uint64

func (*AssetRates) GetPaymentAssetRate added in v0.5.0

func (x *AssetRates) GetPaymentAssetRate() *FixedPoint

func (*AssetRates) GetSubjectAssetRate added in v0.5.0

func (x *AssetRates) GetSubjectAssetRate() *FixedPoint

func (*AssetRates) ProtoMessage added in v0.5.0

func (*AssetRates) ProtoMessage()

func (*AssetRates) ProtoReflect added in v0.5.0

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

func (*AssetRates) Reset added in v0.5.0

func (x *AssetRates) Reset()

func (*AssetRates) String added in v0.5.0

func (x *AssetRates) String() string

type AssetSpecifier

type AssetSpecifier struct {

	// Types that are assignable to Id:
	//
	//	*AssetSpecifier_AssetId
	//	*AssetSpecifier_AssetIdStr
	//	*AssetSpecifier_GroupKey
	//	*AssetSpecifier_GroupKeyStr
	Id isAssetSpecifier_Id `protobuf_oneof:"id"`
	// contains filtered or unexported fields
}

AssetSpecifier is a union type for specifying an asset by either its asset ID or group key.

func (*AssetSpecifier) Descriptor deprecated

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

Deprecated: Use AssetSpecifier.ProtoReflect.Descriptor instead.

func (*AssetSpecifier) GetAssetId

func (x *AssetSpecifier) GetAssetId() []byte

func (*AssetSpecifier) GetAssetIdStr

func (x *AssetSpecifier) GetAssetIdStr() string

func (*AssetSpecifier) GetGroupKey

func (x *AssetSpecifier) GetGroupKey() []byte

func (*AssetSpecifier) GetGroupKeyStr

func (x *AssetSpecifier) GetGroupKeyStr() string

func (*AssetSpecifier) GetId

func (m *AssetSpecifier) GetId() isAssetSpecifier_Id

func (*AssetSpecifier) ProtoMessage

func (*AssetSpecifier) ProtoMessage()

func (*AssetSpecifier) ProtoReflect

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

func (*AssetSpecifier) Reset

func (x *AssetSpecifier) Reset()

func (*AssetSpecifier) String

func (x *AssetSpecifier) String() string

type AssetSpecifier_AssetId

type AssetSpecifier_AssetId struct {
	// The 32-byte asset ID specified as raw bytes (gRPC only).
	AssetId []byte `protobuf:"bytes,1,opt,name=asset_id,json=assetId,proto3,oneof"`
}

type AssetSpecifier_AssetIdStr

type AssetSpecifier_AssetIdStr struct {
	// The 32-byte asset ID encoded as a hex string (use this for REST).
	AssetIdStr string `protobuf:"bytes,2,opt,name=asset_id_str,json=assetIdStr,proto3,oneof"`
}

type AssetSpecifier_GroupKey

type AssetSpecifier_GroupKey struct {
	// The 32-byte asset group key specified as raw bytes (gRPC only).
	GroupKey []byte `protobuf:"bytes,3,opt,name=group_key,json=groupKey,proto3,oneof"`
}

type AssetSpecifier_GroupKeyStr

type AssetSpecifier_GroupKeyStr struct {
	// The 32-byte asset group key encoded as hex string (use this for
	// REST).
	GroupKeyStr string `protobuf:"bytes,4,opt,name=group_key_str,json=groupKeyStr,proto3,oneof"`
}

type FixedPoint added in v0.5.0

type FixedPoint struct {

	// The coefficient is the fractional value scaled-up as an integer. This
	// integer is represented as a string as it may be too large to fit in a
	// uint64.
	Coefficient string `protobuf:"bytes,1,opt,name=coefficient,proto3" json:"coefficient,omitempty"`
	// The scale is the component that determines how many decimal places
	// the coefficient should be divided by to obtain the fractional value.
	Scale uint32 `protobuf:"varint,2,opt,name=scale,proto3" json:"scale,omitempty"`
	// contains filtered or unexported fields
}

FixedPoint is a scaled integer representation of a fractional number.

This type consists of two integer fields: a coefficient and a scale. Using this format enables precise and consistent representation of fractional numbers while avoiding floating-point data types, which are prone to precision errors.

The relationship between the fractional representation and its fixed-point representation is expressed as: ``` V = F_c / (10^F_s) ``` where:

* `V` is the fractional value.

  • `F_c` is the coefficient component of the fixed-point representation. It is the scaled-up fractional value represented as an integer.

  • `F_s` is the scale component. It is an integer specifying how many decimal places `F_c` should be divided by to obtain the fractional representation.

func MarshalBigIntFixedPoint added in v0.5.0

func MarshalBigIntFixedPoint(fp rfqmath.BigIntFixedPoint) (*FixedPoint, error)

MarshalBigIntFixedPoint converts a BigIntFixedPoint to an RPC FixedPoint.

func (*FixedPoint) Descriptor deprecated added in v0.5.0

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

Deprecated: Use FixedPoint.ProtoReflect.Descriptor instead.

func (*FixedPoint) GetCoefficient added in v0.5.0

func (x *FixedPoint) GetCoefficient() string

func (*FixedPoint) GetScale added in v0.5.0

func (x *FixedPoint) GetScale() uint32

func (*FixedPoint) ProtoMessage added in v0.5.0

func (*FixedPoint) ProtoMessage()

func (*FixedPoint) ProtoReflect added in v0.5.0

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

func (*FixedPoint) Reset added in v0.5.0

func (x *FixedPoint) Reset()

func (*FixedPoint) String added in v0.5.0

func (x *FixedPoint) String() string

type PriceOracleClient

type PriceOracleClient interface {
	// QueryAssetRates retrieves the exchange rate between a tap asset and BTC for
	// a specified transaction type, subject asset, and payment asset. The asset
	// rate represents the number of tap asset units per BTC.
	QueryAssetRates(ctx context.Context, in *QueryAssetRatesRequest, opts ...grpc.CallOption) (*QueryAssetRatesResponse, error)
}

PriceOracleClient is the client API for PriceOracle service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkgo.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

type PriceOracleServer

type PriceOracleServer interface {
	// QueryAssetRates retrieves the exchange rate between a tap asset and BTC for
	// a specified transaction type, subject asset, and payment asset. The asset
	// rate represents the number of tap asset units per BTC.
	QueryAssetRates(context.Context, *QueryAssetRatesRequest) (*QueryAssetRatesResponse, error)
	// contains filtered or unexported methods
}

PriceOracleServer is the server API for PriceOracle service. All implementations must embed UnimplementedPriceOracleServer for forward compatibility

type QueryAssetRatesErrResponse added in v0.5.0

type QueryAssetRatesErrResponse struct {

	// error is the error message.
	Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
	// code is the error code.
	Code uint32 `protobuf:"varint,2,opt,name=code,proto3" json:"code,omitempty"`
	// contains filtered or unexported fields
}

QueryAssetRatesErrResponse is the error response to a QueryAssetRates call.

func (*QueryAssetRatesErrResponse) Descriptor deprecated added in v0.5.0

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

Deprecated: Use QueryAssetRatesErrResponse.ProtoReflect.Descriptor instead.

func (*QueryAssetRatesErrResponse) GetCode added in v0.5.0

func (x *QueryAssetRatesErrResponse) GetCode() uint32

func (*QueryAssetRatesErrResponse) GetMessage added in v0.5.0

func (x *QueryAssetRatesErrResponse) GetMessage() string

func (*QueryAssetRatesErrResponse) ProtoMessage added in v0.5.0

func (*QueryAssetRatesErrResponse) ProtoMessage()

func (*QueryAssetRatesErrResponse) ProtoReflect added in v0.5.0

func (*QueryAssetRatesErrResponse) Reset added in v0.5.0

func (x *QueryAssetRatesErrResponse) Reset()

func (*QueryAssetRatesErrResponse) String added in v0.5.0

func (x *QueryAssetRatesErrResponse) String() string

type QueryAssetRatesOkResponse added in v0.5.0

type QueryAssetRatesOkResponse struct {

	// asset_rates is the asset exchange rates for the transaction.
	AssetRates *AssetRates `protobuf:"bytes,1,opt,name=asset_rates,json=assetRates,proto3" json:"asset_rates,omitempty"`
	// contains filtered or unexported fields
}

QueryAssetRatesOkResponse is the successful response to a QueryAssetRates call.

func (*QueryAssetRatesOkResponse) Descriptor deprecated added in v0.5.0

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

Deprecated: Use QueryAssetRatesOkResponse.ProtoReflect.Descriptor instead.

func (*QueryAssetRatesOkResponse) GetAssetRates added in v0.5.0

func (x *QueryAssetRatesOkResponse) GetAssetRates() *AssetRates

func (*QueryAssetRatesOkResponse) ProtoMessage added in v0.5.0

func (*QueryAssetRatesOkResponse) ProtoMessage()

func (*QueryAssetRatesOkResponse) ProtoReflect added in v0.5.0

func (*QueryAssetRatesOkResponse) Reset added in v0.5.0

func (x *QueryAssetRatesOkResponse) Reset()

func (*QueryAssetRatesOkResponse) String added in v0.5.0

func (x *QueryAssetRatesOkResponse) String() string

type QueryAssetRatesRequest added in v0.5.0

type QueryAssetRatesRequest struct {

	// transaction_type indicates whether the transaction is a purchase or a
	// sale.
	TransactionType TransactionType `` /* 143-byte string literal not displayed */
	// subject_asset is the asset to be priced for purchase or sale.
	SubjectAsset *AssetSpecifier `protobuf:"bytes,2,opt,name=subject_asset,json=subjectAsset,proto3" json:"subject_asset,omitempty"`
	// subject_asset_max_amount is the maximum amount of the subject asset that
	// could be involved in the transaction.
	SubjectAssetMaxAmount uint64 `` /* 129-byte string literal not displayed */
	// payment_asset is the asset used for purchasing or receiving from a sale.
	//
	// NOTE: An asset ID of all zeros indicates that the payment asset is BTC.
	// In this case, the asset rate will be given as milli-satoshi per asset
	// unit
	PaymentAsset *AssetSpecifier `protobuf:"bytes,4,opt,name=payment_asset,json=paymentAsset,proto3" json:"payment_asset,omitempty"`
	// payment_asset_max_amount is the maximum amount of the payment asset that
	// could be involved in the transaction. This field is optional. If set to
	// zero, it is considered unset.
	PaymentAssetMaxAmount uint64 `` /* 129-byte string literal not displayed */
	// asset_rates_hint is an optional suggestion of asset rates for the
	// transaction, intended to provide guidance on expected pricing.
	AssetRatesHint *AssetRates `protobuf:"bytes,6,opt,name=asset_rates_hint,json=assetRatesHint,proto3" json:"asset_rates_hint,omitempty"`
	// contains filtered or unexported fields
}

QueryAssetRatesRequest specifies the parameters for querying asset exchange rates in a transaction. It includes the transaction type, details about the subject and payment assets, and an optional hint for expected asset rates.

func (*QueryAssetRatesRequest) Descriptor deprecated added in v0.5.0

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

Deprecated: Use QueryAssetRatesRequest.ProtoReflect.Descriptor instead.

func (*QueryAssetRatesRequest) GetAssetRatesHint added in v0.5.0

func (x *QueryAssetRatesRequest) GetAssetRatesHint() *AssetRates

func (*QueryAssetRatesRequest) GetPaymentAsset added in v0.5.0

func (x *QueryAssetRatesRequest) GetPaymentAsset() *AssetSpecifier

func (*QueryAssetRatesRequest) GetPaymentAssetMaxAmount added in v0.5.0

func (x *QueryAssetRatesRequest) GetPaymentAssetMaxAmount() uint64

func (*QueryAssetRatesRequest) GetSubjectAsset added in v0.5.0

func (x *QueryAssetRatesRequest) GetSubjectAsset() *AssetSpecifier

func (*QueryAssetRatesRequest) GetSubjectAssetMaxAmount added in v0.5.0

func (x *QueryAssetRatesRequest) GetSubjectAssetMaxAmount() uint64

func (*QueryAssetRatesRequest) GetTransactionType added in v0.5.0

func (x *QueryAssetRatesRequest) GetTransactionType() TransactionType

func (*QueryAssetRatesRequest) ProtoMessage added in v0.5.0

func (*QueryAssetRatesRequest) ProtoMessage()

func (*QueryAssetRatesRequest) ProtoReflect added in v0.5.0

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

func (*QueryAssetRatesRequest) Reset added in v0.5.0

func (x *QueryAssetRatesRequest) Reset()

func (*QueryAssetRatesRequest) String added in v0.5.0

func (x *QueryAssetRatesRequest) String() string

type QueryAssetRatesResponse added in v0.5.0

type QueryAssetRatesResponse struct {

	// Types that are assignable to Result:
	//
	//	*QueryAssetRatesResponse_Ok
	//	*QueryAssetRatesResponse_Error
	Result isQueryAssetRatesResponse_Result `protobuf_oneof:"result"`
	// contains filtered or unexported fields
}

QueryAssetRatesResponse is the response from a QueryAssetRates RPC call.

func (*QueryAssetRatesResponse) Descriptor deprecated added in v0.5.0

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

Deprecated: Use QueryAssetRatesResponse.ProtoReflect.Descriptor instead.

func (*QueryAssetRatesResponse) GetError added in v0.5.0

func (*QueryAssetRatesResponse) GetOk added in v0.5.0

func (*QueryAssetRatesResponse) GetResult added in v0.5.0

func (m *QueryAssetRatesResponse) GetResult() isQueryAssetRatesResponse_Result

func (*QueryAssetRatesResponse) ProtoMessage added in v0.5.0

func (*QueryAssetRatesResponse) ProtoMessage()

func (*QueryAssetRatesResponse) ProtoReflect added in v0.5.0

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

func (*QueryAssetRatesResponse) Reset added in v0.5.0

func (x *QueryAssetRatesResponse) Reset()

func (*QueryAssetRatesResponse) String added in v0.5.0

func (x *QueryAssetRatesResponse) String() string

type QueryAssetRatesResponse_Error added in v0.5.0

type QueryAssetRatesResponse_Error struct {
	// error is the error response to the query.
	Error *QueryAssetRatesErrResponse `protobuf:"bytes,2,opt,name=error,proto3,oneof"`
}

type QueryAssetRatesResponse_Ok added in v0.5.0

type QueryAssetRatesResponse_Ok struct {
	// ok is the successful response to the query.
	Ok *QueryAssetRatesOkResponse `protobuf:"bytes,1,opt,name=ok,proto3,oneof"`
}

type TransactionType

type TransactionType int32

TransactionType is an enum representing the type of transaction.

const (
	// PURCHASE indicates a purchase transaction.
	TransactionType_PURCHASE TransactionType = 0
	// SALE indicates a sale transaction.
	TransactionType_SALE TransactionType = 1
)

func (TransactionType) Descriptor

func (TransactionType) Enum

func (x TransactionType) Enum() *TransactionType

func (TransactionType) EnumDescriptor deprecated

func (TransactionType) EnumDescriptor() ([]byte, []int)

Deprecated: Use TransactionType.Descriptor instead.

func (TransactionType) Number

func (TransactionType) String

func (x TransactionType) String() string

func (TransactionType) Type

type UnimplementedPriceOracleServer

type UnimplementedPriceOracleServer struct {
}

UnimplementedPriceOracleServer must be embedded to have forward compatible implementations.

func (UnimplementedPriceOracleServer) QueryAssetRates added in v0.5.0

type UnsafePriceOracleServer

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

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳