本文整理匯總了Golang中github.com/FactomProject/factoid.ITransaction.ValidateSignatures方法的典型用法代碼示例。如果您正苦於以下問題:Golang ITransaction.ValidateSignatures方法的具體用法?Golang ITransaction.ValidateSignatures怎麽用?Golang ITransaction.ValidateSignatures使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/FactomProject/factoid.ITransaction
的用法示例。
在下文中一共展示了ITransaction.ValidateSignatures方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ValidateTransaction
func (b FBlock) ValidateTransaction(index int, trans fct.ITransaction) error {
// Calculate the fee due.
{
err := trans.Validate(index)
if err != nil {
return err
}
}
//Ignore coinbase transaction's signatures
if len(b.Transactions) > 0 {
err := trans.ValidateSignatures()
if err != nil {
return err
}
}
fee, err := trans.CalculateFee(b.ExchRate)
if err != nil {
return err
}
tin, err := trans.TotalInputs()
if err != nil {
return err
}
tout, err := trans.TotalOutputs()
if err != nil {
return err
}
tec, err := trans.TotalECs()
if err != nil {
return err
}
sum, err := fct.ValidateAmounts(tout, tec, fee)
if err != nil {
return err
}
if tin < sum {
return fmt.Errorf("The inputs %s do not cover the outputs %s,\n"+
"the Entry Credit outputs %s, and the required fee %s",
strings.TrimSpace(fct.ConvertDecimal(tin)),
strings.TrimSpace(fct.ConvertDecimal(tout)),
strings.TrimSpace(fct.ConvertDecimal(tec)),
strings.TrimSpace(fct.ConvertDecimal(fee)))
}
return nil
}
示例2: Validate
// Returns an error message about what is wrong with the transaction if it is
// invalid, otherwise you are good to go.
func (fs *AssetState) Validate(trans fct.ITransaction) error {
if err := trans.ValidateSignatures(); err != nil {
return err
}
var sums = make(map[fct.IAddress]uint64, 10)
for _, input := range trans.GetInputs() {
bal, err := fct.ValidateAmounts(
sums[input.GetAddress()], // Will be zero the first time around
input.GetAmount()) // Get this amount, check against bounds
if err != nil {
return err
}
if bal > fs.GetBalance(input.GetAddress()) {
return fmt.Errorf("Not enough funds in input addresses for the transaction")
}
sums[input.GetAddress()] = bal
}
return nil
}
示例3: ValidateSignatures
func (w *SCWallet) ValidateSignatures(trans fct.ITransaction) error {
if trans == nil {
return fmt.Errorf("Missing Transaction")
}
return trans.ValidateSignatures()
}