126 lines
4.2 KiB
Go
126 lines
4.2 KiB
Go
|
|
package msg
|
|||
|
|
|
|||
|
|
import "time"
|
|||
|
|
|
|||
|
|
// 配置文件结构
|
|||
|
|
type Config struct {
|
|||
|
|
RMQConfig RMQConfig `json:"rmq_config"`
|
|||
|
|
ETHConfig ETHConfig `json:"eth_config"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
type RMQConfig struct {
|
|||
|
|
SubAddr string `json:"sub_addr"` // 监听地址
|
|||
|
|
PayConfig QueueConfig `json:"pay"` // 支付
|
|||
|
|
TopUpConfig QueueConfig `json:"topup"` // 充值
|
|||
|
|
WithdrawConfig QueueConfig `json:"withdraw"` // 提现
|
|||
|
|
PayRespConfig QueueConfig `json:"pay_resp"` // 支付回复
|
|||
|
|
TopUpRespConfig QueueConfig `json:"topup_resp"` // 充值回复
|
|||
|
|
WithdrawRespConfig QueueConfig `json:"withdraw_resp"` // 提现回复
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
type QueueConfig struct {
|
|||
|
|
QueueName string `json:"queue"`
|
|||
|
|
ExchangeName string `json:"exchange"`
|
|||
|
|
Routing []string `json:"routing"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
type ETHConfig struct {
|
|||
|
|
RpcURL string `json:"rpcUrl"` // rpc连接地址
|
|||
|
|
WsURL string `json:"wsUrl"` // websocket连接地址
|
|||
|
|
ConfirmHeight uint64 `json:"confirmHeight"` // 确认所需区块数
|
|||
|
|
DbConfig DbConfig `json:"dbConfig"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Config 数据库配置
|
|||
|
|
type DbConfig struct {
|
|||
|
|
User string `json:"user"`
|
|||
|
|
Password string `json:"password"`
|
|||
|
|
Host string `json:"host"`
|
|||
|
|
Port int `json:"port"`
|
|||
|
|
Database string `json:"database"`
|
|||
|
|
MaxOpenConns int `json:"maxOpenConns"` // 最大打开连接数
|
|||
|
|
MaxIdleConns int `json:"maxIdleCoons"` // 最大空闲连接数
|
|||
|
|
ConnMaxLife time.Duration `json:"connMaxLife"` // 连接最大存活时间
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// =======================================================================
|
|||
|
|
// 接收的充值消息
|
|||
|
|
type TopupMsg_req struct {
|
|||
|
|
Chain string `json:"chain"` // 链名称
|
|||
|
|
Symbol string `json:"symbol"` // 币种
|
|||
|
|
Address string `json:"address"`
|
|||
|
|
Timestamp uint64 `json:"timestamp"`
|
|||
|
|
Sign string `json:"sign"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 返回充值结果消息
|
|||
|
|
type TopupMsg_resp struct {
|
|||
|
|
Address string `json:"address"`
|
|||
|
|
Status int `json:"status"`
|
|||
|
|
Chain string `json:"chain"` // 链名称
|
|||
|
|
Symbol string `json:"symbol"` // 币种
|
|||
|
|
Amount float64 `json:"amount"`
|
|||
|
|
TxHash string `json:"tx_hash"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 接收的提现消息
|
|||
|
|
type WithdrawMsg_req struct {
|
|||
|
|
QueueId string `json:"queue_id"`
|
|||
|
|
FromAddress string `json:"from_address"` // 我们提供的地址
|
|||
|
|
ToAddress string `json:"to_address"` // 用户要提现到的地址
|
|||
|
|
Amount float64 `json:"amount"`
|
|||
|
|
Chain string `json:"chain"` // 链名称
|
|||
|
|
Symbol string `json:"symbol"` // 币种
|
|||
|
|
Timestamp uint64 `json:"timestamp"`
|
|||
|
|
Sign string `json:"sign"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 返回提现结果消息
|
|||
|
|
type WithdrawMsg_resp struct {
|
|||
|
|
QueueId string `json:"queue_id"`
|
|||
|
|
Status int `json:"status"`
|
|||
|
|
Amount float64 `json:"amount"`
|
|||
|
|
Chain string `json:"chain"` // 链名称
|
|||
|
|
Symbol string `json:"symbol"` // 币种
|
|||
|
|
TxHash string `json:"tx_hash"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 接收到的支付消息
|
|||
|
|
type PayMsg_req struct {
|
|||
|
|
QueueId string `json:"queue_id"`
|
|||
|
|
FromAddress string `json:"from_address"` // 我们提供的地址
|
|||
|
|
ToAddress string `json:"to_address"` // 卖家地址
|
|||
|
|
Amount float64 `json:"amount"`
|
|||
|
|
Chain string `json:"chain"` // 链名称
|
|||
|
|
Symbol string `json:"symbol"` // 币种
|
|||
|
|
OrderId string `json:"order_id"` // 订单号
|
|||
|
|
Timestamp uint64 `json:"timestamp"`
|
|||
|
|
Sign string `json:"sign"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 返回支付结果消息
|
|||
|
|
type PayMsg_resp struct {
|
|||
|
|
QueueId string `json:"queue_id"`
|
|||
|
|
Status int `json:"status"`
|
|||
|
|
Amount float64 `json:"amount"`
|
|||
|
|
Chain string `json:"chain"` // 链名称
|
|||
|
|
Symbol string `json:"symbol"` // 币种
|
|||
|
|
OrderId string `json:"order_id"` // 订单号
|
|||
|
|
TxHash string `json:"tx_hash"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 节点通用消息结构
|
|||
|
|
type Tx_msg struct {
|
|||
|
|
TxType int `json:"tx_type"` // 转账类型:0充值,1提现,2支付
|
|||
|
|
Tx Tx `json:"tx"`
|
|||
|
|
}
|
|||
|
|
type Tx struct {
|
|||
|
|
From string `json:"from"` // 充值/提现/支付的来源地址
|
|||
|
|
To string `json:"to"` // 充值/提现/支付的目标地址
|
|||
|
|
Height uint64 `json:"height"` // 区块高度
|
|||
|
|
TxHash string `json:"tx_hash"` // 交易哈希
|
|||
|
|
Symbol string `json:"symbol"` // 币种
|
|||
|
|
Value float64 `json:"value"` // 数量,单位是币
|
|||
|
|
Status int `json:"status"` // 交易状态,1成功,0失败, 2待确认
|
|||
|
|
}
|