ui/offering.go
func (h *Handler) setOfferingHash(logger log.Logger, offering *data.Offering,
	template *data.Template, agent *data.Account) error {
	handleErr := func(err error) error {
		logger.Error(err.Error())
		return ErrInternal
	}
	msg := offer.OfferingMessage(agent, template, offering)

	msgBytes, err := json.Marshal(msg)
	if err != nil {
		return handleErr(err)
	}

	agentKey, err := h.decryptKeyFunc(agent.PrivateKey, h.pwdStorage.Get())
	if err != nil {
		return handleErr(err)
	}

	packed, err := messages.PackWithSignature(msgBytes, agentKey)
	if err != nil {
		return handleErr(err)
	}

	offering.RawMsg = data.FromBytes(packed)

	hashBytes := common.BytesToHash(crypto.Keccak256(packed))

	offering.Hash = data.HexFromBytes(hashBytes.Bytes())

	return nil
}
func (h *Handler) setOfferingHash(logger log.Logger, offering *data.Offering,
	template *data.Template, agent *data.Account) error {
	handleErr := func(err error) error {
		logger.Error(err.Error())
		return ErrInternal
	}
	msg := offer.OfferingMessage(agent, template, offering)

	msgBytes, err := json.Marshal(msg)
	if err != nil {
		return handleErr(err)
	}

	agentKey, err := h.decryptKeyFunc(agent.PrivateKey, h.pwdStorage.Get())
	if err != nil {
		return handleErr(err)
	}

	packed, err := messages.PackWithSignature(msgBytes, agentKey)
	if err != nil {
		return handleErr(err)
	}

	offering.RawMsg = data.FromBytes(packed)

	hashBytes := common.BytesToHash(crypto.Keccak256(packed))

	offering.Hash = data.HexFromBytes(hashBytes.Bytes())

	return nil
}
func ( h * Handler ) setOfferingHash ( logger log . Logger , offering * data . Offering , template * data . Template , agent * data . Account ) error { handleErr := func ( err error ) error { logger . Error ( err . Error ( ) ) return ErrInternal } msg := offer . OfferingMessage ( agent , template , offering ) msgBytes , err := json . Marshal ( msg ) if err != nil { return handleErr ( err ) } agentKey , err := h . decryptKeyFunc ( agent . PrivateKey , h . pwdStorage . Get ( ) ) if err != nil { return handleErr ( err ) } packed , err := messages . PackWithSignature ( msgBytes , agentKey ) if err != nil { return handleErr ( err ) } offering . RawMsg = data . FromBytes ( packed ) hashBytes := common . BytesToHash ( crypto . Keccak256 ( packed ) ) offering . Hash = data . HexFromBytes ( hashBytes . Bytes ( ) ) return nil }
// setOfferingHash computes and sets values for raw msg and hash fields.
setOfferingHash computes and sets values for raw msg and hash fields .