链上交易数据结构
ccxt库中,链上交易(Transaction)的数据结构如下:
{
'info': { ... }, // the JSON response from the exchange as is
'id': '123456', // exchange-specific transaction id, string
'txid': '0x68bfb29821c50ca35ef3762f887fd3211e4405aba1a94e448a4f218b850358f0',
'timestamp': 1534081184515, // timestamp in milliseconds
'datetime': '2018-08-12T13:39:44.515Z', // ISO8601 string of the timestamp
'addressFrom': '0x38b1F8644ED1Dbd5DcAedb3610301Bf5fa640D6f', // sender
'address': '0x02b0a9b7b4cDe774af0f8e47cb4f1c2ccdEa0806', // "from" or "to"
'addressTo': '0x304C68D441EF7EB0E2c056E836E8293BD28F8129', // receiver
'tagFrom', '0xabcdef', // "tag" or "memo" or "payment_id" associated with the sender
'tag': '0xabcdef' // "tag" or "memo" or "payment_id" associated with the address
'tagTo': '0xhijgklmn', // "tag" or "memo" or "payment_id" associated with the receiver
'type': 'deposit', // or 'withdrawal', string
'amount': 1.2345, // float (does not include the fee)
'currency': 'ETH', // a common unified currency code, string
'status': 'pending', // 'ok', 'failed', 'canceled', string
'updated': undefined, // UTC timestamp of most recent status change in ms
'comment': 'a comment or message defined by the user if any',
'fee': { // the entire fee structure may be undefined
'currency': 'ETH', // a unified fee currency code
'cost': 0.1234, // float
'rate': undefined, // approximately, fee['cost'] / amount, float
},
}
补充说明:
- 如果交易所没有设置交易的方向(买入/卖出), addressFrom 或 addressTo 的值可能为undefined/None/null
- address字段的含义是交易所相关的。有些情况下该字段的值表示发送方的地址,有时则可能表示接收方的地址。
- update字段表示最近的资金操作的状态变化,以毫秒计算的UTC时间戳。
- 取决于交易所的支持与否,fee字段的内容可能缺失
- comment字段的值可能是undefined/None/null,否则表示用户创建链上交易时传入的消息或备注
- 处理标签(tag)和地址(address)时需要谨慎,标签不是用户任意指定的字符串,不能在 标签中发送用户消息和评论。标签的目的是正确定位你的钱包。因此应当遵循交易所的要求。