model

package
v1.24.2 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: GPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OrderApiTypeEpusdt      = "epusdt"       // epusdt
	OrderApiTypeEpusdtOrder = "epusdt_order" // epusdt create-order
	OrderApiTypeEpay        = "epay"         // 彩虹易支付
	OrderApiTypeAdmin       = "admin"        // 管理后台
)
View Source
const (
	WaStatusEnable  uint8 = 1
	WaStatusDisable uint8 = 0
	WaOtherEnable   uint8 = 1
	WaOtherDisable  uint8 = 0
)

Variables

View Source
var Db *gorm.DB

Functions

func AddrCaseSens added in v1.23.0

func AddrCaseSens(t TradeType) bool

func AuthToken added in v1.23.0

func AuthToken() string

func AutoMigrate added in v1.9.26

func AutoMigrate() error

func CalcTradeExpiredAt added in v1.22.1

func CalcTradeExpiredAt(sec int64) time.Time

CalcTradeExpiredAt 计算订单过期时间 最小180,最大3600,默认1200

func CheckoutList added in v1.24.0

func CheckoutList() map[string]Checkout

func CheckoutUrl added in v1.24.0

func CheckoutUrl(host, id string) string

func Close added in v1.23.0

func Close()

func CoingeckoRate added in v1.23.0

func CoingeckoRate() error

func ConfInit added in v1.23.0

func ConfInit()

func Endpoint added in v1.23.0

func Endpoint(net Network) string

func FillDefaultConf added in v1.23.5

func FillDefaultConf()

func GetAllAlias added in v1.23.0

func GetAllAlias() map[string]string

func GetAllNetwork added in v1.24.1

func GetAllNetwork() map[string]string

func GetAllTradeConfig added in v1.23.2

func GetAllTradeConfig() map[string]TradeTypeConf

func GetAtomicity added in v1.23.0

func GetAtomicity(t TradeType) (decimal.Decimal, int32)

func GetC added in v1.23.0

func GetC(k ConfKey) string

GetC 从缓存获取配置,适用于高频读取,依赖 RefreshC 刷新缓存

func GetContractDecimal added in v1.23.0

func GetContractDecimal(addr string) int32

func GetInstallInfo added in v1.23.0

func GetInstallInfo() gin.H

func GetK added in v1.13.29

func GetK(k ConfKey) string

func GetLookbackHour added in v1.24.0

func GetLookbackHour() time.Duration

func GetOrderRate added in v1.23.2

func GetOrderRate(token Crypto, fiat Fiat, syntax string) (decimal.Decimal, error)

func GetSupportCrypto added in v1.23.0

func GetSupportCrypto() map[Crypto]CoinId

func GetSupportFiat added in v1.23.0

func GetSupportFiat() map[Fiat]struct{}

func GetTradeDecimal added in v1.23.0

func GetTradeDecimal(t TradeType) int32

func GetTronGridApiKeys added in v1.23.4

func GetTronGridApiKeys() []string

func GetTxUrl added in v1.23.0

func GetTxUrl(t TradeType, hash string) string

func GetVs added in v1.23.0

func GetVs(keys []ConfKey) map[ConfKey]string

func Init

func Init(db, dsn string) error

func InstallLock added in v1.23.0

func InstallLock()

func IsAmountValid added in v1.23.0

func IsAmountValid(t TradeType, d decimal.Decimal) bool

func IsInstalled added in v1.23.0

func IsInstalled() bool

func IsNeedNotifyByTxid

func IsNeedNotifyByTxid(txid string) bool

func IsSupportedTradeType added in v1.23.0

func IsSupportedTradeType(t TradeType) bool

func ParseFloatRate added in v1.23.0

func ParseFloatRate(syntax string, rawVal float64) float64

func RefreshC added in v1.23.0

func RefreshC()

func RegisterCheckout added in v1.24.0

func RegisterCheckout(name string, checkout Checkout)

RegisterCheckout 注册收银台模板

func SetK added in v1.13.29

func SetK(k ConfKey, v string)

Types

type Addr added in v1.24.0

type Addr struct {
	Address   string // 对外前端收款地址
	MatchAddr string // 对内订单校验地址
}

type AutoTimeAt added in v1.23.0

type AutoTimeAt struct {
	CreatedAt *Datetime `gorm:"column:created_at;not null;comment:记录创建时间;index" json:"created_at"`
	UpdatedAt *Datetime `gorm:"column:updated_at;not null;comment:最后更新时间" json:"updated_at"`
}

type Checkout added in v1.24.0

type Checkout struct {
	Name   string `json:"name"`
	Author string `json:"author"`
	Desc   string `json:"desc"`
	Link   string `json:"link"`
}

type CoinId added in v1.23.0

type CoinId string

type Conf added in v1.23.0

type Conf struct {
	K ConfKey `gorm:"column:k;type:varchar(32);not null;primaryKey" json:"key"`
	V string  `gorm:"column:v;type:varchar(512);not null" json:"val"`
}

func (Conf) TableName added in v1.23.0

func (c Conf) TableName() string

type ConfKey added in v1.23.0

type ConfKey string
const (
	AdminUsername ConfKey = "admin_username"
	AdminPassword ConfKey = "admin_password"
	AdminSecure   ConfKey = "admin_secure"
	AdminSecret   ConfKey = "admin_secret"
	AdminLoginIP  ConfKey = "admin_login_ip"
	AdminLoginAt  ConfKey = "admin_login_at"

	ApiAuthToken ConfKey = "api_auth_token" // API 对接令牌
	ApiAppUri    ConfKey = "api_app_uri"    // API 对接地址(收银台地址)

	AtomUSDT ConfKey = "atom_usdt"
	AtomUSDC ConfKey = "atom_usdc"
	AtomTRX  ConfKey = "atom_trx"
	AtomBNB  ConfKey = "atom_bnb"
	AtomETH  ConfKey = "atom_eth"
	AtomGRAM ConfKey = "atom_gram"

	MonitorMinAmount    ConfKey = "monitor_min_amount" // 监控最小金额,低于此金额的入账不进行通知
	PaymentMinAmount    ConfKey = "payment_min_amount"
	PaymentMaxAmount    ConfKey = "payment_max_amount"
	PaymentTimeout      ConfKey = "payment_timeout"       // 订单支付超时时间,单位秒
	PaymentCheckout     ConfKey = "payment_checkout"      // 收银台模板
	PaymentMatchMode    ConfKey = "payment_match_mode"    // 订单金额匹配模式
	PaymentSupportUrl   ConfKey = "payment_support_url"   // 订单支付客服链接
	PaymentLookbackHour ConfKey = "payment_lookback_hour" // 订单回溯时间
	PaymentNetworkSort  ConfKey = "payment_network_sort"  // 收银台网络顺序,逗号分隔

	RpcEndpointPlasma         ConfKey = "rpc_endpoint_plasma"            // Plasma RPC节点
	RpcEndpointBsc            ConfKey = "rpc_endpoint_bsc"               // BSC RPC节点
	RpcEndpointSolana         ConfKey = "rpc_endpoint_solana"            // Solana RPC节点
	RpcEndpointXlayer         ConfKey = "rpc_endpoint_xlayer"            // Xlayer RPC节点
	RpcEndpointPolygon        ConfKey = "rpc_endpoint_polygon"           // Polygon RPC节点
	RpcEndpointArbitrum       ConfKey = "rpc_endpoint_arbitrum"          // Arbitrum RPC节点
	RpcEndpointEthereum       ConfKey = "rpc_endpoint_ethereum"          // Ethereum RPC节点
	RpcEndpointBase           ConfKey = "rpc_endpoint_base"              // Base RPC节点
	RpcEndpointAptos          ConfKey = "rpc_endpoint_aptos"             // APTOS RPC节点
	RpcEndpointTron           ConfKey = "rpc_endpoint_tron"              // TRON RPC节点
	RpcEndpointTronGridApiKey ConfKey = "rpc_endpoint_tron_grid_api_key" // TRON RPC节点 TronGrid Api Key
	RpcGlobalConfigUrlTon     ConfKey = "rpc_global_config_url_ton"      // Ton Global Config Url

	RateSyncCoingeckoApiUrl ConfKey = "rate_sync_coingecko_api_url" // 汇率同步 Coingecko Api URL
	RateSyncCoingeckoApiKey ConfKey = "rate_sync_coingecko_api_key" // 汇率同步 Coingecko Api Key
	RateSyncInterval        ConfKey = "rate_sync_interval"          // 汇率同步间隔,单位秒
	RateSyncHistoryDays     ConfKey = "rate_sync_history_days"      // 历史汇率保存天数

	NotifyMaxRetry     ConfKey = "notify_max_retry"      // 最大重试次数,订单回调失败
	BlockHeightMaxDiff ConfKey = "block_height_max_diff" // 区块高度最大差值,超过此值则以当前区块高度为准,重新开始扫描
	BlockOffsetConfirm ConfKey = "block_offset_confirm"  // 区块偏移确认数,扫描时以当前区块高度减去此偏移量为准,避免重链导致的订单回调失败

	MqttHost        ConfKey = "mqtt_host"
	MqttPort        ConfKey = "mqtt_port"
	MqttUser        ConfKey = "mqtt_user"
	MqttPass        ConfKey = "mqtt_pass"
	MqttPublishQos  ConfKey = "mqtt_publish_qos"
	MqttTopicPrefix ConfKey = "mqtt_topic_prefix" // 消息发布 Topic 路径前缀
	MqttNetworks    ConfKey = "mqtt_networks"     // 需要持续监控的区块网络

	NotifierParams  ConfKey = "notifier_params"  // 通知参数 (token, chat_id, email
	NotifierChannel ConfKey = "notifier_channel" // 通知渠道 (telegram, wechat, email

	SystemInstallLock ConfKey = "system_install_lock" // 系统安装锁
	HomeRedirectUrl   ConfKey = "home_redirect_url"
)

func GetTradeAtomKey added in v1.23.0

func GetTradeAtomKey(t TradeType) (ConfKey, bool)

type Crypto added in v1.23.0

type Crypto string
const (
	USDT Crypto = "USDT"
	USDC Crypto = "USDC"
	TRX  Crypto = "TRX"
	BNB  Crypto = "BNB"
	ETH  Crypto = "ETH"
	GRAM Crypto = "GRAM" // 其实就是 Ton
)

func GetCrypto added in v1.23.0

func GetCrypto(t TradeType) (Crypto, error)

type Datetime added in v1.23.0

type Datetime time.Time

func (*Datetime) Before added in v1.23.0

func (d *Datetime) Before(u time.Time) bool

func (*Datetime) Format added in v1.23.0

func (d *Datetime) Format(layout string) string

func (*Datetime) MarshalJSON added in v1.23.0

func (d *Datetime) MarshalJSON() ([]byte, error)

func (*Datetime) Scan added in v1.23.0

func (d *Datetime) Scan(v interface{}) error

func (*Datetime) String added in v1.23.0

func (d *Datetime) String() string

func (*Datetime) Time added in v1.23.0

func (d *Datetime) Time() time.Time

func (Datetime) Value added in v1.23.0

func (d Datetime) Value() (driver.Value, error)

func (*Datetime) Year added in v1.23.0

func (d *Datetime) Year() string

type Fiat added in v1.23.0

type Fiat string
const (
	CNY Fiat = "CNY"
	USD Fiat = "USD"
	JPY Fiat = "JPY"
	EUR Fiat = "EUR"
	GBP Fiat = "GBP"
)

type Id added in v1.23.0

type Id struct {
	ID int64 `gorm:"column:id;primaryKey;autoIncrement;not null;comment:主键ID" json:"id"`
}

type MatchMode added in v1.23.0

type MatchMode string
const (
	Classic   MatchMode = "classic"    // 经典模式,精确匹配
	HasPrefix MatchMode = "has_prefix" // 前缀匹配,允许多付
	RoundOff  MatchMode = "round_off"  // 数值修约,四舍五入,允许容错
)

type MethodItem added in v1.24.0

type MethodItem struct {
	Amount          string `json:"amount"`
	ActualAmount    string `json:"actual_amount"`
	Fiat            string `json:"fiat"`
	ExchangeRate    string `json:"exchange_rate"`
	Currency        string `json:"currency"`
	Network         string `json:"network"`
	TokenNetName    string `json:"token_net_name"`
	TokenCustomName string `json:"token_custom_name"`
	IsPopular       bool   `json:"is_popular"`
}

type Network added in v1.23.0

type Network string

type NotifyRecord

type NotifyRecord struct {
	Id
	Txid string `gorm:"type:varchar(128);uniqueIndex;not null;comment:交易哈希"`
	AutoTimeAt
}

func (NotifyRecord) TableName

func (nr NotifyRecord) TableName() string

type Order added in v1.23.0

type Order struct {
	Id
	OrderId           string     `gorm:"column:order_id;type:varchar(128);not null;index;comment:商户ID" json:"order_id"`
	TradeId           string     `gorm:"column:trade_id;type:varchar(128);not null;uniqueIndex;comment:本地ID" json:"trade_id"`
	TradeType         TradeType  `gorm:"column:trade_type;type:varchar(20);not null;index;comment:交易类型" json:"trade_type"`
	Fiat              Fiat       `gorm:"column:fiat;type:varchar(16);not null;index;default:CNY;comment:法定货币" json:"fiat"`
	Crypto            Crypto     `gorm:"column:crypto;type:varchar(16);not null;index;default:USDT;comment:加密货币" json:"crypto"`
	CurrencyLimit     string     `gorm:"column:currency_limit;type:varchar(255);not null;default:'';comment:限定币种" json:"currency_limit"`
	Rate              string     `gorm:"column:rate;type:varchar(10);not null;comment:交易汇率" json:"rate"`
	Amount            string     `gorm:"column:amount;type:varchar(32);not null;default:0.00;comment:交易数额" json:"amount"`
	Money             string     `gorm:"column:money;type:varchar(32);not null;default:0.00;comment:交易金额" json:"money"`
	Address           string     `gorm:"column:address;type:varchar(128);index;not null;comment:收款地址" json:"address"`
	FromAddress       string     `gorm:"column:from_address;type:varchar(128);not null;default:'';comment:支付地址" json:"from_address"`
	MatchAddress      string     `gorm:"column:match_address;type:varchar(128);not null;default:'';comment:校验地址" json:"match_address"`
	AddressLocked     bool       `gorm:"column:address_locked;not null;default:false;comment:地址锁定 1:独占 0:共享" json:"address_locked"`
	Status            int        `gorm:"column:status;not null;default:1;index;index:idx_order_notify_retry,priority:1;comment:交易状态" json:"status"`
	Name              string     `gorm:"column:name;type:varchar(64);not null;default:'';comment:商品名称" json:"name"`
	ApiType           string     `gorm:"column:api_type;type:varchar(20);not null;default:'epusdt';comment:API类型" json:"api_type"`
	ReturnUrl         string     `gorm:"column:return_url;type:varchar(255);not null;default:'';comment:同步地址" json:"return_url"`
	NotifyUrl         string     `gorm:"column:notify_url;type:varchar(255);not null;default:'';comment:异步地址" json:"notify_url"`
	NotifyNum         int        `gorm:"column:notify_num;not null;default:0;index:idx_order_notify_retry,priority:3;comment:回调次数" json:"notify_num"`
	NotifyState       int        `` /* 148-byte string literal not displayed */
	RefHash           string     `gorm:"column:ref_hash;type:varchar(128);not null;default:'';index;comment:交易哈希" json:"ref_hash"`
	RefBlockNum       int        `gorm:"column:ref_block_num;not null;default:0;comment:区块索引" json:"ref_block_num"`
	ExpiredAt         time.Time  `gorm:"column:expired_at;not null;comment:失效时间" json:"expired_at"`
	ConfirmedAt       *time.Time `gorm:"column:confirmed_at;not null;comment:交易确认时间" json:"confirmed_at"`
	ClientFingerprint string     `gorm:"column:client_fingerprint;type:varchar(64);not null;default:'';comment:'客户端指纹'" json:"-"`
	AutoTimeAt
}

func BuildOrder added in v1.23.0

func BuildOrder(p OrderParams, trade Trade) (Order, error)

func BuildPendingOrder added in v1.23.2

func BuildPendingOrder(p OrderParams) (Order, error)

BuildPendingOrder 创建待支付订单(不锁定地址和汇率)

func GetNotifyFailedTradeOrders

func GetNotifyFailedTradeOrders() ([]Order, error)

func GetOrderByStatus added in v1.19.1

func GetOrderByStatus(Status int) []Order

func GetTradeOrder

func GetTradeOrder(tradeId string) (Order, bool)

func RebuildOrder added in v1.23.0

func RebuildOrder(t Order, p OrderParams) (Order, error)

func StartBuildOrder added in v1.23.4

func StartBuildOrder(p OrderParams) (Order, error)

func (*Order) BuildNotifyParams added in v1.24.0

func (o *Order) BuildNotifyParams() string

func (*Order) CanReselectPayment added in v1.24.0

func (o *Order) CanReselectPayment() bool

CanReselectPayment 判断订单是否支持重选交易类型

func (*Order) FingerprintBound added in v1.24.1

func (o *Order) FingerprintBound() bool

func (*Order) GetMethods added in v1.24.0

func (o *Order) GetMethods(crypto Crypto) []MethodItem

func (*Order) GetStatusEmoji added in v1.23.0

func (o *Order) GetStatusEmoji() string

func (*Order) GetStatusLabel added in v1.23.0

func (o *Order) GetStatusLabel() string

func (*Order) GetTxUrl added in v1.23.0

func (o *Order) GetTxUrl() string

func (*Order) MarkConfirming added in v1.23.0

func (o *Order) MarkConfirming(blockNum int, from, hash string, at time.Time, amount decimal.Decimal) error

func (*Order) MatchFingerprint added in v1.24.1

func (o *Order) MatchFingerprint(fingerprint string) bool

func (*Order) Network added in v1.24.0

func (o *Order) Network() any

func (*Order) RedirectUrl added in v1.24.0

func (o *Order) RedirectUrl() string

func (*Order) SetCanceled added in v1.23.0

func (o *Order) SetCanceled() error

func (*Order) SetExpired added in v1.23.0

func (o *Order) SetExpired()

func (*Order) SetFailed added in v1.23.0

func (o *Order) SetFailed()

func (*Order) SetNotifyState added in v1.23.0

func (o *Order) SetNotifyState(state int) error

func (*Order) SetSuccess added in v1.23.0

func (o *Order) SetSuccess()

func (*Order) TableName added in v1.23.0

func (o *Order) TableName() string

type OrderParams added in v1.23.0

type OrderParams struct {
	Money             decimal.Decimal `json:"money"`              // 交易金额 (单位:法币)s
	ApiType           string          `json:"api_type"`           // 支付 API 类型
	Address           string          `json:"address"`            // 收款地址
	OrderId           string          `json:"order_id"`           // 商户订单 ID
	TradeType         TradeType       `json:"trade_type"`         // 交易类型
	RedirectUrl       string          `json:"redirect_url"`       // 成功跳转地址
	NotifyUrl         string          `json:"notify_url"`         // 异步通知地址
	Name              string          `json:"name"`               // 商品名称
	Timeout           int64           `json:"timeout"`            // 订单超时时间(秒)
	Rate              string          `json:"rate"`               // 强制指定汇率
	Fiat              Fiat            `json:"fiat"`               // 法币类型
	CurrencyLimit     string          `json:"currency_limit"`     // 限定币种
	AddressLocked     bool            `json:"address_locked"`     // 地址独占锁定
	ClientFingerprint string          `json:"client_fingerprint"` //  客户端指纹
}

type Range added in v1.23.0

type Range struct {
	MinAmount decimal.Decimal
	MaxAmount decimal.Decimal
}

type Rate added in v1.23.0

type Rate struct {
	Id
	Rate    string  `gorm:"column:rate;type:varchar(32);not null;comment:订单汇率" json:"rate"`
	Fiat    string  `gorm:"column:fiat;type:varchar(16);not null;comment:法币" json:"fiat"`
	Crypto  string  `gorm:"column:crypto;type:varchar(16);not null;comment:加密货币" json:"crypto"`
	RawRate float64 `gorm:"column:raw_rate;type:decimal(10,4);not null;comment:基准汇率" json:"raw_rate"`
	Syntax  string  `gorm:"column:syntax;type:varchar(32);not null;default:'';comment:浮动语法" json:"syntax"`
	AutoTimeAt
}

func (*Rate) BeforeCreate added in v1.23.0

func (r *Rate) BeforeCreate(*gorm.DB) error

func (*Rate) TableName added in v1.23.0

func (r *Rate) TableName() string

type Trade added in v1.23.0

type Trade struct {
	Wallet Wallet
	Crypto Crypto
	Rate   decimal.Decimal
	Amount string
}

func BuildTrade added in v1.23.0

func BuildTrade(p OrderParams) (Trade, error)

type TradeType added in v1.20.4

type TradeType string
const (
	OrderNotifyStateSucc = 1 // 回调成功
	OrderNotifyStateFail = 0 // 回调失败

	OrderStatusWaiting    = 1 // 等待支付
	OrderStatusSuccess    = 2 // 交易确认成功
	OrderStatusExpired    = 3 // 订单过期
	OrderStatusCanceled   = 4 // 订单取消
	OrderStatusConfirming = 5 // 等待交易确认
	OrderStatusFailed     = 6 // 交易确认失败

	BscBnb      TradeType = "bsc.bnb"
	EthereumEth TradeType = "ethereum.eth"
	TronTrx     TradeType = "tron.trx"
	TonGram     TradeType = "ton.gram"

	UsdtTrc20    TradeType = "usdt.trc20"
	UsdcTrc20    TradeType = "usdc.trc20"
	UsdtPolygon  TradeType = "usdt.polygon"
	UsdcPolygon  TradeType = "usdc.polygon"
	UsdtArbitrum TradeType = "usdt.arbitrum"
	UsdcArbitrum TradeType = "usdc.arbitrum"
	UsdtErc20    TradeType = "usdt.erc20"
	UsdcErc20    TradeType = "usdc.erc20"
	UsdtBep20    TradeType = "usdt.bep20"
	UsdcBep20    TradeType = "usdc.bep20"
	UsdtXlayer   TradeType = "usdt.xlayer"
	UsdcXlayer   TradeType = "usdc.xlayer"
	UsdcBase     TradeType = "usdc.base"
	UsdtSolana   TradeType = "usdt.solana"
	UsdcSolana   TradeType = "usdc.solana"
	UsdtAptos    TradeType = "usdt.aptos"
	UsdcAptos    TradeType = "usdc.aptos"
	UsdtPlasma   TradeType = "usdt.plasma"
	UsdtTon      TradeType = "usdt.ton"
)

func GetContractTrade added in v1.23.0

func GetContractTrade(addr string) (TradeType, bool)

func GetNetworkTrades added in v1.23.0

func GetNetworkTrades(n Network) []TradeType

func GetTradeTypeByCurrencyAndNetwork added in v1.23.2

func GetTradeTypeByCurrencyAndNetwork(currency, network string) (TradeType, error)

type TradeTypeConf added in v1.23.0

type TradeTypeConf struct {
	Alias        string  // 类型别名,主要用户前端展示
	NetworkName  string  // 网络名称,用于前端展示
	Network      Network // 所属区块链网络
	Crypto       Crypto  // 币种类型
	Native       bool    // 是否原生币
	Contract     string  // 合约地址,原生币为空
	Decimal      int32   // 小数位
	AmountRange  Range   // 合法数额范围;这里特指则扫块时[数额范围],目前偷懒全部写死一个大概合理的范围,后面有问题再说...
	ExplorerFmt  string  // 区块浏览器交易链接格式化字符串,%s 位置替换为交易哈希
	EndpointKey  ConfKey // RPC 端点配置键
	AddrCaseSens bool    // 钱包地址是否大小写敏感,如果为 false 则会统一转为小写比较
}

type TronResource added in v1.23.0

type TronResource struct {
	ID           string
	Type         core.Transaction_Contract_ContractType
	Balance      int64
	FromAddress  string
	RecvAddress  string
	Timestamp    time.Time
	ResourceCode core.ResourceCode
}

type TronTransfer added in v1.23.0

type TronTransfer struct {
	Network     string
	TxHash      string
	Amount      decimal.Decimal
	FromAddress string
	RecvAddress string
	Timestamp   time.Time
	TradeType   TradeType
	BlockNum    int
}

type Wallet added in v1.23.0

type Wallet struct {
	Id
	Name        string `gorm:"column:name;type:varchar(32);not null;default:-';comment:名称" json:"name"`
	Status      uint8  `gorm:"column:status;not null;default:1;comment:地址状态" json:"status"`
	Address     string `gorm:"column:address;type:varchar(128);not null;index;comment:钱包地址" json:"address"`
	MatchAddr   string `gorm:"column:match_addr;type:varchar(128);not null;uniqueIndex:idx_address;comment:匹配地址" json:"match_addr"`
	TradeType   string `gorm:"column:trade_type;type:varchar(20);not null;uniqueIndex:idx_address;comment:交易类型" json:"trade_type"`
	OtherNotify uint8  `gorm:"column:other_notify;not null;default:0;comment:其它通知" json:"other_notify"`
	Remark      string `gorm:"column:remark;type:varchar(255);not null;default:'';comment:备注" json:"remark"`
	AutoTimeAt
}

func CalcTradeAmount

func CalcTradeAmount(wallets []Wallet, rate decimal.Decimal, p OrderParams) (Wallet, string, error)

CalcTradeAmount 计算当前实际可用的交易金额

func GetAvailableWallets added in v1.24.0

func GetAvailableWallets(t TradeType) []Wallet

func LockTradeAddress added in v1.23.4

func LockTradeAddress(wallets []Wallet, t TradeType) (Wallet, string, error)

LockTradeAddress 检测交易地址,独占使用

func NewWallet added in v1.24.0

func NewWallet(address string, tradeType TradeType) (Wallet, error)

func (*Wallet) Delete added in v1.23.0

func (wa *Wallet) Delete()

func (*Wallet) GetMatchAddr added in v1.24.0

func (wa *Wallet) GetMatchAddr() string

func (*Wallet) GetNetwork added in v1.23.0

func (wa *Wallet) GetNetwork() Network

func (*Wallet) GetPaymentAddr added in v1.24.0

func (wa *Wallet) GetPaymentAddr() string

func (*Wallet) GetTokenContract added in v1.23.0

func (wa *Wallet) GetTokenContract() string

func (*Wallet) GetTokenDecimals added in v1.23.0

func (wa *Wallet) GetTokenDecimals() int32

func (*Wallet) SetOtherNotify added in v1.23.0

func (wa *Wallet) SetOtherNotify(notify uint8)

func (*Wallet) SetStatus added in v1.23.0

func (wa *Wallet) SetStatus(status uint8)

func (*Wallet) TableName added in v1.23.0

func (wa *Wallet) TableName() string

func (*Wallet) Validate added in v1.24.0

func (wa *Wallet) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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