2025-10-16 18:54:27 +08:00
|
|
|
|
package msg
|
|
|
|
|
|
|
2025-11-13 17:08:38 +08:00
|
|
|
|
import "math/big"
|
2025-10-16 18:54:27 +08:00
|
|
|
|
|
2025-10-27 16:27:33 +08:00
|
|
|
|
// =============================== type0 ===============================
|
2025-10-16 18:54:27 +08:00
|
|
|
|
// 接收的充值消息
|
|
|
|
|
|
type TopupMsg_req struct {
|
2025-10-31 13:46:58 +08:00
|
|
|
|
QueueId string `json:"queue_id"`
|
2025-10-16 18:54:27 +08:00
|
|
|
|
Chain string `json:"chain"` // 链名称
|
|
|
|
|
|
Symbol string `json:"symbol"` // 币种
|
|
|
|
|
|
Address string `json:"address"`
|
|
|
|
|
|
Timestamp uint64 `json:"timestamp"`
|
|
|
|
|
|
Sign string `json:"sign"`
|
2025-11-13 17:08:38 +08:00
|
|
|
|
Status int `json:"status,omitempty"` // 1监听中,2停止监听
|
2025-10-16 18:54:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 返回充值结果消息
|
|
|
|
|
|
type TopupMsg_resp struct {
|
2025-10-31 13:46:58 +08:00
|
|
|
|
QueueId string `json:"queue_id"`
|
2025-11-13 17:08:38 +08:00
|
|
|
|
Chain string `json:"chain"` // 链名称
|
|
|
|
|
|
Symbol string `json:"symbol"` // 币种
|
|
|
|
|
|
FromAddress string `json:"from_address,omitempty"` // 充值来源地址
|
|
|
|
|
|
Address string `json:"address"` // 充值目标地址
|
|
|
|
|
|
TxHash string `json:"tx_hash,omitempty"`
|
|
|
|
|
|
Amount float64 `json:"amount,omitempty"`
|
|
|
|
|
|
BlockHeight uint64 `json:"block_height,omitempty"` // 区块高度
|
|
|
|
|
|
Status int `json:"status"` // 0失败,1成功,2待定,3sign校验失败
|
2025-10-16 18:54:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-27 16:27:33 +08:00
|
|
|
|
// =============================== type1 ===============================
|
2025-10-16 18:54:27 +08:00
|
|
|
|
// 接收的提现消息
|
|
|
|
|
|
type WithdrawMsg_req struct {
|
|
|
|
|
|
QueueId string `json:"queue_id"`
|
2025-11-13 17:08:38 +08:00
|
|
|
|
Chain string `json:"chain"` // 链名称
|
|
|
|
|
|
Symbol string `json:"symbol"` // 币种
|
2025-10-16 18:54:27 +08:00
|
|
|
|
FromAddress string `json:"from_address"` // 我们提供的地址
|
|
|
|
|
|
ToAddress string `json:"to_address"` // 用户要提现到的地址
|
|
|
|
|
|
Amount float64 `json:"amount"`
|
2025-11-13 17:08:38 +08:00
|
|
|
|
Fee float64 `json:"fee"`
|
2025-10-16 18:54:27 +08:00
|
|
|
|
Timestamp uint64 `json:"timestamp"`
|
|
|
|
|
|
Sign string `json:"sign"`
|
2025-10-31 13:46:58 +08:00
|
|
|
|
Status int `json:"status,omitempty"`
|
2025-10-16 18:54:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 返回提现结果消息
|
|
|
|
|
|
type WithdrawMsg_resp struct {
|
2025-10-21 14:25:15 +08:00
|
|
|
|
QueueId string `json:"queue_id"`
|
2025-11-13 17:08:38 +08:00
|
|
|
|
Chain string `json:"chain"` // 链名称
|
|
|
|
|
|
Symbol string `json:"symbol"` // 币种
|
2025-10-21 14:25:15 +08:00
|
|
|
|
FromAddress string `json:"from_address"` // 来源地址
|
|
|
|
|
|
ToAddress string `json:"to_address"` // 目标地址
|
2025-11-13 17:08:38 +08:00
|
|
|
|
TxHash string `json:"tx_hash,omitempty"`
|
|
|
|
|
|
Amount float64 `json:"amount,omitempty"`
|
|
|
|
|
|
Fee float64 `json:"fee,omitempty"`
|
|
|
|
|
|
BlockHeight uint64 `json:"block_height,omitempty"` // 区块高度
|
|
|
|
|
|
Status int `json:"status"` // 0失败,1成功,3sign校验失败
|
2025-10-16 18:54:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-27 16:27:33 +08:00
|
|
|
|
// =============================== type2 ===============================
|
2025-10-16 18:54:27 +08:00
|
|
|
|
type PayMsg_req struct {
|
2025-11-14 17:43:25 +08:00
|
|
|
|
QueueId string `json:"queue_id"`
|
|
|
|
|
|
Chain string `json:"chain"` // 链名称
|
|
|
|
|
|
Symbol string `json:"symbol"` // 币种
|
|
|
|
|
|
FromAddress string `json:"from_address"` // 我们提供的地址
|
|
|
|
|
|
ToAddress string `json:"to_address"` // 用户要提现到的地址
|
|
|
|
|
|
Amount float64 `json:"amount"`
|
|
|
|
|
|
Fee float64 `json:"fee"`
|
|
|
|
|
|
Timestamp uint64 `json:"timestamp"`
|
|
|
|
|
|
Sign string `json:"sign"`
|
|
|
|
|
|
Status int `json:"status,omitempty"`
|
2025-10-16 18:54:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type PayMsg_resp struct {
|
2025-11-14 17:43:25 +08:00
|
|
|
|
QueueId string `json:"queue_id"`
|
|
|
|
|
|
Chain string `json:"chain"` // 链名称
|
|
|
|
|
|
Symbol string `json:"symbol"` // 币种
|
|
|
|
|
|
FromAddress string `json:"from_address"` // 来源地址
|
|
|
|
|
|
ToAddress string `json:"to_address"` // 目标地址
|
2025-11-13 17:08:38 +08:00
|
|
|
|
TxHash string `json:"tx_hash,omitempty"`
|
2025-11-14 17:43:25 +08:00
|
|
|
|
Amount float64 `json:"amount,omitempty"`
|
|
|
|
|
|
Fee float64 `json:"fee,omitempty"`
|
|
|
|
|
|
BlockHeight uint64 `json:"block_height,omitempty"` // 区块高度
|
|
|
|
|
|
Status int `json:"status"` // 0失败,1成功,3sign校验失败
|
2025-10-16 18:54:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-14 17:43:25 +08:00
|
|
|
|
// type PayMsg_req struct {
|
|
|
|
|
|
// QueueId string `json:"queue_id"`
|
|
|
|
|
|
// Chain string `json:"chain"`
|
|
|
|
|
|
// Symbol string `json:"symbol"`
|
|
|
|
|
|
// FromAddress string `json:"from_address"`
|
|
|
|
|
|
// TotalAmount float64 `json:"total_amount"`
|
|
|
|
|
|
// TotalFee float64 `json:"total_fee"`
|
|
|
|
|
|
// Timestamp uint64 `json:"timestamp"`
|
|
|
|
|
|
// Sign string `json:"sign"`
|
|
|
|
|
|
// Transactions map[string]PayData `json:"transactions"` // {"to_address": PayData_req{}, ...}
|
|
|
|
|
|
// Status int `json:"status,omitempty"`
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// type PayMsg_resp struct {
|
|
|
|
|
|
// QueueId string `json:"queue_id"`
|
|
|
|
|
|
// Chain string `json:"chain"`
|
|
|
|
|
|
// Symbol string `json:"symbol"`
|
|
|
|
|
|
// FromAddress string `json:"from_address"`
|
|
|
|
|
|
// PayStatus int `json:"pay_status"` // 1至少有一笔转账成功,3sign校验失败,4钱包余额不足
|
|
|
|
|
|
// Transactions map[string]PayData `json:"transactions"` // {"to_address": PayData_resp{}, ...}
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// type PayData struct {
|
|
|
|
|
|
// QueueId string `json:"queue_id,omitempty"`
|
|
|
|
|
|
// Chain string `json:"chain,omitempty"`
|
|
|
|
|
|
// Symbol string `json:"symbol,omitempty"`
|
|
|
|
|
|
// TxHash string `json:"tx_hash,omitempty"`
|
|
|
|
|
|
// ToAddress string `json:"to_address"`
|
|
|
|
|
|
// Amount float64 `json:"amount"`
|
|
|
|
|
|
// Fee float64 `json:"fee"`
|
|
|
|
|
|
// BlockHeight uint64 `json:"block_height,omitempty"`
|
|
|
|
|
|
// Status int `json:"status,omitempty"` // 0失败,1成功, 2待确认
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
2025-10-27 16:27:33 +08:00
|
|
|
|
// =============================== type3 ===============================
|
|
|
|
|
|
// 接收到的删除监听地址消息
|
|
|
|
|
|
type RemoveListenMsg_req struct {
|
2025-10-31 13:46:58 +08:00
|
|
|
|
QueueId string `json:"queue_id"`
|
2025-10-27 16:27:33 +08:00
|
|
|
|
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"`
|
2025-11-13 17:08:38 +08:00
|
|
|
|
Stauts int `json:"status,omitempty"`
|
2025-10-27 16:27:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 返回收到的删除监听地址消息
|
|
|
|
|
|
type RemoveListenMsg_resp struct {
|
2025-10-31 13:46:58 +08:00
|
|
|
|
QueueId string `json:"queue_id"`
|
2025-10-27 16:27:33 +08:00
|
|
|
|
MsgType int `json:"msg_type"`
|
|
|
|
|
|
Chain string `json:"chain"`
|
|
|
|
|
|
Symbol string `json:"symbol"`
|
|
|
|
|
|
Address string `json:"address"`
|
|
|
|
|
|
Status int `json:"status"` // 0失败 1成功
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-13 17:08:38 +08:00
|
|
|
|
// =============================== ChainServer -> ListenServer ===============================
|
|
|
|
|
|
// 节点服务响应
|
|
|
|
|
|
type ChainServer_resp struct {
|
|
|
|
|
|
QueueId string
|
|
|
|
|
|
MsgType int
|
|
|
|
|
|
Chain string
|
|
|
|
|
|
Symbol string
|
|
|
|
|
|
Status int // 遵循constant模块定义
|
2025-10-16 18:54:27 +08:00
|
|
|
|
}
|
2025-10-31 13:46:58 +08:00
|
|
|
|
|
2025-11-13 17:08:38 +08:00
|
|
|
|
// =============================== 其他 ===============================
|
2025-10-31 13:46:58 +08:00
|
|
|
|
type Transaction struct {
|
2025-11-13 17:08:38 +08:00
|
|
|
|
QueueId string `json:"queue_id,omitempty"` // 交易对应的QueueId
|
|
|
|
|
|
// 交易对应的消息类型,0充值 1提现 2支付
|
|
|
|
|
|
// 充值:tx.to_address = msg.Address
|
|
|
|
|
|
// 提现/支付:tx.to_address = msg.ToAddress && tx.from_address = msg.FromAddress && tx.value = msg.Amount
|
|
|
|
|
|
// 同时还要通过msg确认属于哪种类型,即上述3个条件是否都存在于某个msg钟
|
|
|
|
|
|
TxType int `json:"tx_type,omitempty"`
|
|
|
|
|
|
Chain string `json:"chain"`
|
|
|
|
|
|
Symbol string `json:"symbol"`
|
|
|
|
|
|
From string `json:"from"`
|
|
|
|
|
|
To string `json:"to"`
|
|
|
|
|
|
TxHash string `json:"tx_hash,omitempty"`
|
|
|
|
|
|
Height uint64 `json:"height,omitempty"`
|
|
|
|
|
|
Amount *big.Int `json:"amount"`
|
|
|
|
|
|
GasUsed *big.Int `json:"gas_used,omitempty"` // 转账实际产生的eth消耗
|
|
|
|
|
|
FreezeFee *big.Int `json:"freeze_fee,omitempty"` // erc20转账冻结的usdt,只有提现才会修改
|
|
|
|
|
|
Status int `json:"status"` // 交易状态,1成功,0失败, 2待确认
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type TransferResult struct {
|
|
|
|
|
|
QueueId string
|
|
|
|
|
|
MsgType int // 1提现,2支付
|
|
|
|
|
|
Chain string
|
|
|
|
|
|
Symbol string
|
|
|
|
|
|
FromAddress string
|
|
|
|
|
|
ToAddress string
|
|
|
|
|
|
Amount float64
|
|
|
|
|
|
Status int
|
2025-10-31 13:46:58 +08:00
|
|
|
|
}
|
2025-11-14 17:43:25 +08:00
|
|
|
|
|
|
|
|
|
|
type UpdateReqState struct {
|
|
|
|
|
|
QueueId string
|
|
|
|
|
|
MsgType int
|
|
|
|
|
|
Status int
|
|
|
|
|
|
}
|