utils

package
v0.0.0-...-1e441f3 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidPublicAddressFormat is returned when a public address contains
	// characters that are not valid hexadecimal digits (0-9, a-f, A-F).
	ErrInvalidPublicAddressFormat = errors.New("public address must be a valid hex string")

	// ErrInvalidPublicAddressLength is returned when a public address is not
	// exactly 64 characters long.
	ErrInvalidPublicAddressLength = errors.New("public address must be 64 characters long")
)

Functions

func EncryptRequestSourceWithWalletID

func EncryptRequestSourceWithWalletID(requestSource models.BridgeRequestSource, walletID string) (string, error)

EncryptRequestSourceWithWalletID encrypts the request source metadata using the wallet's Curve25519 public key

func ExtractOrigin

func ExtractOrigin(rawURL string) string

func GenerateSelfSignedCertificate

func GenerateSelfSignedCertificate() ([]byte, []byte, error)

GenerateSelfSignedCertificate generates a self-signed X.509 certificate and private key

Types

type HttpRes

type HttpRes struct {
	Message    string `json:"message,omitempty" example:"status ok"`
	StatusCode int    `json:"statusCode,omitempty" example:"200"`
}

func HttpResError

func HttpResError(errMsg string, statusCode int) (int, HttpRes)

func HttpResOk

func HttpResOk() HttpRes

type PublicAddress

type PublicAddress string

PublicAddress represents a 64-character hexadecimal public address. It must contain only valid hex characters (0-9, a-f, A-F) and be exactly 64 characters in length.

func NewPublicAddressFromString

func NewPublicAddressFromString(a string) (PublicAddress, error)

NewPublicAddressFromString creates a new PublicAddress from a string. The input string is trimmed of leading and trailing whitespace for validation, but the original string (with whitespace) is returned if valid. It returns an error if the address is invalid (wrong length or contains non-hexadecimal characters).

func (PublicAddress) String

func (a PublicAddress) String() string

String returns the string representation of the PublicAddress.

func (PublicAddress) Validate

func (a PublicAddress) Validate() error

Validate checks if the PublicAddress is valid. It returns ErrInvalidPublicAddressLength if the address is not exactly 64 characters long, or ErrInvalidPublicAddressFormat if it contains non-hexadecimal characters.

type RealIPExtractor

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

func NewRealIPExtractor

func NewRealIPExtractor(trustedRanges []string) (*RealIPExtractor, error)

NewRealIPExtractor creates a new realIPExtractor with the given trusted ranges.

func (*RealIPExtractor) Extract

func (e *RealIPExtractor) Extract(request *http.Request) string

Jump to

Keyboard shortcuts

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