blockchain

package
v1.799.2 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: Apache-2.0, MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoPayment = errors.New("blockchain: no payment function registered for chain type")

ErrNoPayment is returned when MakePayment is called for a chain type whose payment function hasn't been registered (e.g. an EVM chain without the luxfi/cevm sub-module wired in).

View Source
var ErrNoTokenTransfer = errors.New("blockchain: no ERC-20 token transfer registered (import github.com/hanzoai/cloud/clients/commerce/luxfi/cevm)")

ErrNoTokenTransfer is returned when TransferToken is called without a registered implementation (the luxfi/cevm sub-module not imported).

Functions

func GetUserOrderByWallet

func GetUserOrderByWallet(db *datastore.Datastore, walletId string) (*user.User, *order.Order, *wallet.Wallet, error)

GetUserOrderByWallet returns the (user, order, wallet) triple associated with walletId. Chain-agnostic — used by Bitcoin pay task in-tree and by the Ethereum pay task in the luxfi/cevm sub-module.

func MakeBitcoinPayment

func MakeBitcoinPayment(ctx context.Context, from wallet.Account, to string, amount, feePerByte currency.Cents, password []byte) (string, error)

func MakePayment

func MakePayment(ctx context.Context, from wallet.Account, to string, amount, fee currency.Cents, password []byte) (string, error)

func RegisterPayment

func RegisterPayment(typ blockchains.Type, fn PaymentFn)

RegisterPayment wires a payment function for a chain type. Later registrations override earlier ones; callers should register once at init time.

func RegisterTokenTransfer

func RegisterTokenTransfer(fn TokenTransferFn)

RegisterTokenTransfer wires the ERC-20 transfer implementation. Call once at init time; later registrations override earlier ones.

func TokenTransferRegistered

func TokenTransferRegistered() bool

TokenTransferRegistered reports whether an implementation is wired. Callers can use this to fail fast (or skip) before attempting an on-chain payout.

func TransferToken

func TransferToken(ctx context.Context, t TokenTransfer) (string, error)

TransferToken validates the request and dispatches to the registered EVM implementation. It is the single entry point for treasury ERC-20 transfers.

Types

type PaymentFn

type PaymentFn func(ctx context.Context, from wallet.Account, to string, amount, fee currency.Cents, password []byte) (string, error)

PaymentFn is the per-chain payment dispatcher. EVM payment support ships in github.com/hanzoai/cloud/clients/commerce/luxfi/cevm and registers itself on import; consumers who don't need EVM never link geth.

type TokenTransfer

type TokenTransfer struct {
	ChainID      int64    // EVM chain id (e.g. 36900 Hanzo)
	RPCURL       string   // JSON-RPC endpoint (e.g. https://rpc.hanzo.network)
	TokenAddress string   // ERC-20 contract address (0x…)
	TreasuryKey  string   // hex private key (with or without 0x); from KMS, never persisted
	To           string   // recipient address (0x…)
	AmountWei    *big.Int // amount in the token's base units
	GasLimit     uint64   // 0 → implementation default
}

TokenTransfer describes a treasury-signed ERC-20 transfer on an EVM chain.

All on-chain parameters (RPC endpoint, token contract, treasury key) are supplied by the caller, which sources them from KMS (KMSSecret CRD → k8s Secret → env). TreasuryKey is used in-memory only by the registered implementation; it is never persisted and never logged.

type TokenTransferFn

type TokenTransferFn func(ctx context.Context, t TokenTransfer) (txHash string, err error)

TokenTransferFn signs and submits an ERC-20 transfer, returning the tx hash.

Jump to

Keyboard shortcuts

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