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"` Stauts 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 }