當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ITransaction.ValidateSignatures方法代碼示例

本文整理匯總了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
}
開發者ID:conseweb,項目名稱:factoid,代碼行數:48,代碼來源:scblock.go

示例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
}
開發者ID:msgilligan,項目名稱:Testing,代碼行數:23,代碼來源:AssetState.go

示例3: ValidateSignatures

func (w *SCWallet) ValidateSignatures(trans fct.ITransaction) error {
	if trans == nil {
		return fmt.Errorf("Missing Transaction")
	}
	return trans.ValidateSignatures()
}
開發者ID:Kalipsol,項目名稱:factomd,代碼行數:6,代碼來源:scwallet.go


注:本文中的github.com/FactomProject/factoid.ITransaction.ValidateSignatures方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。