btckeys

package
v0.0.0-...-51cb76d Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2021 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package btckeys is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	HardenedKeyStart = hd.HardenedKeyStart
)

Variables

View Source
var (
	ErrInvalidMOfNValue        = errors.New("invalid m and n value")
	ErrInvalidPublicKeyString  = errors.New("invalid public key string")
	ErrInvalidPublicKeysNumber = errors.New("wrong number of public keys")
)
View Source
var BtcKeys_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "btckeys.BtcKeys",
	HandlerType: (*BtcKeysServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "DeriveBech32AddressFromXpub",
			Handler:    _BtcKeys_DeriveBech32AddressFromXpub_Handler,
		},
		{
			MethodName: "GetMultiSigAddress",
			Handler:    _BtcKeys_GetMultiSigAddress_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "btckeys.proto",
}

BtcKeys_ServiceDesc is the grpc.ServiceDesc for BtcKeys 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 (
	ErrInvalidPath = errors.New("invalid derivation path")
)
View Source
var File_btckeys_proto protoreflect.FileDescriptor
View Source
var HardenedSymbol = map[string]bool{
	"'": true,
	"h": true,
	"H": true,
}

Functions

func GenerateMultiSigAddress

func GenerateMultiSigAddress(publicKeyStrings []string, flagM int, flagN int) (multiSigAddress string, redeemScriptString string, err error)

This will generate P2SH multisig address from compressed pubkeys even if uncompressed pubkeys were provided to shorten the redeemscript length

func IsCompressedPublicKeyString

func IsCompressedPublicKeyString(publicKeyString string) bool

func NewMOfNRedeemScript

func NewMOfNRedeemScript(publicKeys [][]byte, m int, n int) ([]byte, error)

func RegisterBtcKeysHandler

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

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

func RegisterBtcKeysHandlerClient

func RegisterBtcKeysHandlerClient(ctx context.Context, mux *runtime.ServeMux, client BtcKeysClient) error

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

func RegisterBtcKeysHandlerFromEndpoint

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

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

func RegisterBtcKeysHandlerServer

func RegisterBtcKeysHandlerServer(ctx context.Context, mux *runtime.ServeMux, server BtcKeysServer) error

RegisterBtcKeysHandlerServer registers the http handlers for service BtcKeys to "mux". UnaryRPC :call BtcKeysServer 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 RegisterBtcKeysHandlerFromEndpoint instead.

func RegisterBtcKeysServer

func RegisterBtcKeysServer(s grpc.ServiceRegistrar, srv BtcKeysServer)

Types

type Address

type Address struct {
	Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
	// contains filtered or unexported fields
}

func (*Address) Descriptor deprecated

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

Deprecated: Use Address.ProtoReflect.Descriptor instead.

func (*Address) GetAddress

func (x *Address) GetAddress() string

func (*Address) ProtoMessage

func (*Address) ProtoMessage()

func (*Address) ProtoReflect

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

func (*Address) Reset

func (x *Address) Reset()

func (*Address) String

func (x *Address) String() string

type BtcKeysClient

type BtcKeysClient interface {
	DeriveBech32AddressFromXpub(ctx context.Context, in *DerivationRequest, opts ...grpc.CallOption) (*Address, error)
	GetMultiSigAddress(ctx context.Context, in *MultiSigRequest, opts ...grpc.CallOption) (*MultiSigResponse, error)
}

BtcKeysClient is the client API for BtcKeys 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.

func NewBtcKeysClient

func NewBtcKeysClient(cc grpc.ClientConnInterface) BtcKeysClient

type BtcKeysServer

type BtcKeysServer interface {
	DeriveBech32AddressFromXpub(context.Context, *DerivationRequest) (*Address, error)
	GetMultiSigAddress(context.Context, *MultiSigRequest) (*MultiSigResponse, error)
	// contains filtered or unexported methods
}

BtcKeysServer is the server API for BtcKeys service. All implementations must embed UnimplementedBtcKeysServer for forward compatibility

type DerivationRequest

type DerivationRequest struct {
	Xpub string `protobuf:"bytes,1,opt,name=xpub,proto3" json:"xpub,omitempty"`
	Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"`
	// contains filtered or unexported fields
}

func (*DerivationRequest) Descriptor deprecated

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

Deprecated: Use DerivationRequest.ProtoReflect.Descriptor instead.

func (*DerivationRequest) GetPath

func (x *DerivationRequest) GetPath() string

func (*DerivationRequest) GetXpub

func (x *DerivationRequest) GetXpub() string

func (*DerivationRequest) ProtoMessage

func (*DerivationRequest) ProtoMessage()

func (*DerivationRequest) ProtoReflect

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

func (*DerivationRequest) Reset

func (x *DerivationRequest) Reset()

func (*DerivationRequest) String

func (x *DerivationRequest) String() string

type ExtendedKey

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

func NewKeyFromString

func NewKeyFromString(xpubOrxprv string) (*ExtendedKey, error)

Generate ExtendedKet from xpub or xprv string, both allowed

func (*ExtendedKey) Derive

func (exkey *ExtendedKey) Derive(path string) (*ExtendedKey, error)

Derive method transfers path to indexes and call derive in order to get final child ExtendedKey Hardened derivation in path for xpub will fail.

func (*ExtendedKey) P2WPKHAddress

func (exkey *ExtendedKey) P2WPKHAddress() (address string, err error)

Generate bech32 address from ExtendedKey

type MultiSigRequest

type MultiSigRequest struct {
	Pubkeys []string `protobuf:"bytes,1,rep,name=pubkeys,proto3" json:"pubkeys,omitempty"`
	M       uint64   `protobuf:"varint,2,opt,name=m,proto3" json:"m,omitempty"`
	N       uint64   `protobuf:"varint,3,opt,name=n,proto3" json:"n,omitempty"`
	// contains filtered or unexported fields
}

func (*MultiSigRequest) Descriptor deprecated

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

Deprecated: Use MultiSigRequest.ProtoReflect.Descriptor instead.

func (*MultiSigRequest) GetM

func (x *MultiSigRequest) GetM() uint64

func (*MultiSigRequest) GetN

func (x *MultiSigRequest) GetN() uint64

func (*MultiSigRequest) GetPubkeys

func (x *MultiSigRequest) GetPubkeys() []string

func (*MultiSigRequest) ProtoMessage

func (*MultiSigRequest) ProtoMessage()

func (*MultiSigRequest) ProtoReflect

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

func (*MultiSigRequest) Reset

func (x *MultiSigRequest) Reset()

func (*MultiSigRequest) String

func (x *MultiSigRequest) String() string

type MultiSigResponse

type MultiSigResponse struct {
	Address      string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
	Redeemscript string `protobuf:"bytes,2,opt,name=redeemscript,proto3" json:"redeemscript,omitempty"`
	// contains filtered or unexported fields
}

func (*MultiSigResponse) Descriptor deprecated

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

Deprecated: Use MultiSigResponse.ProtoReflect.Descriptor instead.

func (*MultiSigResponse) GetAddress

func (x *MultiSigResponse) GetAddress() string

func (*MultiSigResponse) GetRedeemscript

func (x *MultiSigResponse) GetRedeemscript() string

func (*MultiSigResponse) ProtoMessage

func (*MultiSigResponse) ProtoMessage()

func (*MultiSigResponse) ProtoReflect

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

func (*MultiSigResponse) Reset

func (x *MultiSigResponse) Reset()

func (*MultiSigResponse) String

func (x *MultiSigResponse) String() string

type UnimplementedBtcKeysServer

type UnimplementedBtcKeysServer struct {
}

UnimplementedBtcKeysServer must be embedded to have forward compatible implementations.

func (UnimplementedBtcKeysServer) DeriveBech32AddressFromXpub

func (UnimplementedBtcKeysServer) DeriveBech32AddressFromXpub(context.Context, *DerivationRequest) (*Address, error)

func (UnimplementedBtcKeysServer) GetMultiSigAddress

type UnsafeBtcKeysServer

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

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

Jump to

Keyboard shortcuts

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