Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalcFixedFee ¶
func CalcFixedFee(ct *rlwe.Ciphertext, rate float64) (fee *rlwe.Ciphertext)
CalcFixedFee 计算固定费率的手续费 ... 返回加了手续费的密文
func CalcRatedFee ¶
func CalcRatedFee(ct *rlwe.Ciphertext, rate float64) (fee *rlwe.Ciphertext)
CalcRatedFee 计算按比例计算的手续费
Types ¶
type Transaction ¶
type Transaction struct { // ConfirmingPhase 可能是 // "unconfirmed", "waiting", "processing", // "rejected", "confirmed", "failed" ConfirmingPhase string `json:"confirmingPhase"` UUID uuid.UUID `json:"uuid"` Sender uuid.UUID `json:"sender"` Receipt uuid.UUID `json:"receipt"` CTSender []byte `json:"ctSender"` CTReceipt []byte `json:"ctReceipt"` SigCTSender []byte `json:"sigCtSender"` CTSenderSignedBy uuid.UUID `json:"ctSenderSignedBy"` SigCTReceipt []byte `json:"sigCTReceipt"` CTReceiptSignedBy uuid.UUID `json:"ctReceiptSignedBy"` TimeStamp int64 `json:"timestamp"` //unix时间戳 IsValid bool `json:"isValid"` }
Transaction 是单笔转账的抽象, 一个 Transaction 包含了转账的发起者、接收者、金额、时间戳等信息。具体如下: sender, receipt, CT{Sender,Receipt}SignedBy: []byte, UUID CTSender,CTReceipt: []byte <- rlwe.CipherText.MarshalBinary() sig(略): []byte,签名,只会有三种可能的签名方:CA、发送者和接受者
func (Transaction) CopyToJSONStruct ¶
func (t Transaction) CopyToJSONStruct() (res *TransactionJSON)
func (Transaction) GetReceiptCT ¶
func (t Transaction) GetReceiptCT() (ct *rlwe.Ciphertext, err error)
func (Transaction) GetSenderCT ¶
func (t Transaction) GetSenderCT() (ct *rlwe.Ciphertext, err error)
func (Transaction) MarshalToJSON ¶
func (t Transaction) MarshalToJSON() (res []byte, err error)
type TransactionJSON ¶
type TransactionJSON struct { // ConfirmingPhase 可能是 // "unconfirmed", "waiting", "processing", // "rejected", "confirmed", "failed" ConfirmingPhase string `json:"confirmingPhase"` UUID uuid.UUID `json:"uuid"` Sender uuid.UUID `json:"sender"` Receipt uuid.UUID `json:"receipt"` CTSender string `json:"ctSender"` CTReceipt string `json:"ctReceipt"` SigCTSender string `json:"sigCtSender"` CTSenderSignedBy uuid.UUID `json:"ctSenderSignedBy"` SigCTReceipt string `json:"sigCTReceipt"` CTReceiptSignedBy uuid.UUID `json:"ctReceiptSignedBy"` TimeStamp int64 `json:"timestamp"` //unix时间戳 IsValid bool `json:"isValid"` }
TransactionJSON 结构题和 Transaction 一样,只是为了 json 序列化。 不同的是,其将所有的 []byte 类型都变换为了 string 类型。
func (TransactionJSON) CopyToStruct ¶
func (tj TransactionJSON) CopyToStruct() (res *Transaction, err error)
Click to show internal directories.
Click to hide internal directories.