Files
m2pool_payment/internal/msg/msg.go
2025-11-18 11:10:16 +08:00

189 lines
7.3 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package msg
import "math/big"
// =============================== type0 ===============================
// 接收的充值消息
type TopupMsg_req struct {
QueueId string `json:"queue_id"`
Chain string `json:"chain"` // 链名称
Symbol string `json:"symbol"` // 币种
Address string `json:"address"`
Timestamp uint64 `json:"timestamp"`
Sign string `json:"sign"`
Status int `json:"status,omitempty"` // 1监听中2停止监听
}
// 返回充值结果消息
type TopupMsg_resp struct {
QueueId string `json:"queue_id"`
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校验失败
}
// =============================== type1 ===============================
// 接收的提现消息
type WithdrawMsg_req struct {
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"`
}
// 返回提现结果消息
type WithdrawMsg_resp struct {
QueueId string `json:"queue_id"`
Chain string `json:"chain"` // 链名称
Symbol string `json:"symbol"` // 币种
FromAddress string `json:"from_address"` // 来源地址
ToAddress string `json:"to_address"` // 目标地址
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校验失败
}
// =============================== type2 ===============================
type PayMsg_req struct {
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"`
}
type PayMsg_resp struct {
QueueId string `json:"queue_id"`
Chain string `json:"chain"` // 链名称
Symbol string `json:"symbol"` // 币种
FromAddress string `json:"from_address"` // 来源地址
ToAddress string `json:"to_address"` // 目标地址
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校验失败
}
// 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待确认
// }
// =============================== type3 ===============================
// 接收到的删除监听地址消息
type RemoveListenMsg_req struct {
QueueId string `json:"queue_id"`
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"`
Status int `json:"status,omitempty"`
}
// 返回收到的删除监听地址消息
type RemoveListenMsg_resp struct {
QueueId string `json:"queue_id"`
MsgType int `json:"msg_type"`
Chain string `json:"chain"`
Symbol string `json:"symbol"`
Address string `json:"address"`
Status int `json:"status"` // 0失败 1成功
}
// =============================== ChainServer -> ListenServer ===============================
// 节点服务响应
type ChainServer_resp struct {
QueueId string
MsgType int
Chain string
Symbol string
Status int // 遵循constant模块定义
}
// =============================== 其他 ===============================
type Transaction struct {
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
}
type UpdateReqState struct {
QueueId string
MsgType int
Status int
}