170 lines
6.0 KiB
Go
170 lines
6.0 KiB
Go
package msg
|
||
|
||
import "time"
|
||
|
||
// 配置文件结构
|
||
type Config struct {
|
||
SQLite3 SQLite3 `json:"sqlite3"`
|
||
RMQConfig RMQConfig `json:"rmq_config"`
|
||
ETHConfig ETHConfig `json:"eth_config"`
|
||
TRONConfig TRONConfig `json:"tron_config"`
|
||
}
|
||
|
||
type SQLite3 struct {
|
||
MsgPath string `json:"msg_path"`
|
||
}
|
||
|
||
type RMQConfig struct {
|
||
SubAddr string `json:"sub_addr"` // 监听地址
|
||
PayConfig QueueConfig `json:"pay"` // 支付
|
||
TopUpConfig QueueConfig `json:"topup"` // 充值
|
||
WithdrawConfig QueueConfig `json:"withdraw"` // 提现
|
||
RemoveConfig QueueConfig `json:"remove"` // 移除监听
|
||
PayRespConfig QueueConfig `json:"pay_resp"` // 支付回复
|
||
TopUpRespConfig QueueConfig `json:"topup_resp"` // 充值回复
|
||
WithdrawRespConfig QueueConfig `json:"withdraw_resp"` // 提现回复
|
||
RemoveRespConfig QueueConfig `json:"remove_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"`
|
||
}
|
||
|
||
type TRONConfig struct {
|
||
RpcUrl string `json:"rpcUrl"`
|
||
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"` // 连接最大存活时间
|
||
}
|
||
|
||
// =============================== type0 ===============================
|
||
// 接收的充值消息
|
||
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"`
|
||
BlockHeight uint64 `json:"block_height"` // 区块高度
|
||
}
|
||
|
||
// =============================== type1 ===============================
|
||
// 接收的提现消息
|
||
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"`
|
||
Chain string `json:"chain"` // 链名称
|
||
Symbol string `json:"symbol"` // 币种
|
||
Status int `json:"status"`
|
||
Amount float64 `json:"amount"`
|
||
TxHash string `json:"tx_hash"`
|
||
FromAddress string `json:"from_address"` // 来源地址
|
||
ToAddress string `json:"to_address"` // 目标地址
|
||
BlockHeight uint64 `json:"block_height"` // 区块高度
|
||
}
|
||
|
||
// =============================== type2 ===============================
|
||
// 接收到的支付消息
|
||
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"`
|
||
FromAddress string `json:"from_address"` // 来源地址
|
||
ToAddress string `json:"to_address"` // 目标地址
|
||
BlockHeight uint64 `json:"block_height"` // 区块高度
|
||
}
|
||
|
||
// =============================== type3 ===============================
|
||
// 接收到的删除监听地址消息
|
||
type RemoveListenMsg_req struct {
|
||
MsgType int `json:"msg_type"`
|
||
Chain string `json:"chain"`
|
||
Symbol string `json:"symbol"`
|
||
Address string `json:"address"`
|
||
Timestamp uint64 `json:"timestamp"`
|
||
Sign string `json:"sign"`
|
||
}
|
||
|
||
// 返回收到的删除监听地址消息
|
||
type RemoveListenMsg_resp struct {
|
||
MsgType int `json:"msg_type"`
|
||
Chain string `json:"chain"`
|
||
Symbol string `json:"symbol"`
|
||
Address string `json:"address"`
|
||
Status int `json:"status"` // 0失败 1成功
|
||
}
|
||
|
||
// =====================================================================
|
||
// 节点通用消息结构
|
||
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待确认
|
||
}
|