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


Golang ITransaction.ValidateSignatures方法代碼示例

本文整理匯總了Golang中github.com/FactomProject/factomd/common/interfaces.ITransaction.ValidateSignatures方法的典型用法代碼示例。如果您正苦於以下問題:Golang ITransaction.ValidateSignatures方法的具體用法?Golang ITransaction.ValidateSignatures怎麽用?Golang ITransaction.ValidateSignatures使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/FactomProject/factomd/common/interfaces.ITransaction的用法示例。


在下文中一共展示了ITransaction.ValidateSignatures方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: SignFactoidTransaction

func SignFactoidTransaction(n uint64, tx interfaces.ITransaction) {
	tx.AddAuthorization(NewFactoidRCDAddress(n))
	data, err := tx.MarshalBinarySig()
	if err != nil {
		panic(err)
	}

	sig := factoid.NewSingleSignatureBlock(NewPrivKey(n), data)

	//str, err := sig.JSONString()

	//fmt.Printf("sig, err - %v, %v\n", str, err)

	tx.SetSignatureBlock(0, sig)

	err = tx.Validate(1)
	if err != nil {
		panic(err)
	}

	err = tx.ValidateSignatures()
	if err != nil {
		panic(err)
	}
}
開發者ID:jjdevbiz,項目名稱:factomd,代碼行數:25,代碼來源:fBlock.go

示例2: ValidateTransaction

func (b FBlock) ValidateTransaction(index int, trans interfaces.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 := 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",
			primitives.ConvertDecimalToString(tin),
			primitives.ConvertDecimalToString(tout),
			primitives.ConvertDecimalToString(tec),
			primitives.ConvertDecimalToString(fee))
	}
	return nil
}
開發者ID:FactomProject,項目名稱:factomd,代碼行數:48,代碼來源:fblock.go

示例3: ValidateSignatures

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


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