func (tx *SignedTransaction) Digest(chain string) ([]byte, error) {
	var msgBuffer bytes.Buffer

	// Write the chain ID.
	rawChainID, err := hex.DecodeString(chain)
	if err != nil {
		return nil, errors.Wrapf(err, "failed to decode chain ID: %v", chain)
	}

	if _, err := msgBuffer.Write(rawChainID); err != nil {
		return nil, errors.Wrap(err, "failed to write chain ID")
	}

	// Write the serialized transaction.
	rawTx, err := tx.Serialize()
	if err != nil {
		return nil, err
	}

	if _, err := msgBuffer.Write(rawTx); err != nil {
		return nil, errors.Wrap(err, "failed to write serialized transaction")
	}

	// Compute the digest.
	digest := sha256.Sum256(msgBuffer.Bytes())
	return digest[:], nil
}
//Digest function that returns a digest from a serialized transaction
Digest function that returns a digest from a serialized transaction
// Digest function that returns a digest from a serialized transaction
func (tx *SignedTransaction) Digest(chain string) ([]byte, error) {
	var msgBuffer bytes.Buffer
	rawChainID, err := hex.DecodeString(chain)
	if err != nil {
		return nil, errors.Wrapf(err, "failed to decode chain ID: %v", chain)
	}
	if _, err := msgBuffer.Write(rawChainID); err != nil {
		return nil, errors.Wrap(err, "failed to write chain ID")
	}
	rawTx, err := tx.Serialize()
	if err != nil {
		return nil, err
	}
	if _, err := msgBuffer.Write(rawTx); err != nil {
		return nil, errors.Wrap(err, "failed to write serialized transaction")
	}
	digest := sha256.Sum256(msgBuffer.Bytes())
	return digest[:], nil
}
func ( tx * SignedTransaction ) Digest ( chain string ) ( [ ] byte , error ) { var msgBuffer bytes . Buffer rawChainID , err := hex . DecodeString ( chain ) if err != nil { return nil , errors . Wrapf ( err , " " , chain ) } if _ , err := msgBuffer . Write ( rawChainID ) ; err != nil { return nil , errors . Wrap ( err , " " ) } rawTx , err := tx . Serialize ( ) if err != nil { return nil , err } if _ , err := msgBuffer . Write ( rawTx ) ; err != nil { return nil , errors . Wrap ( err , " " ) } digest := sha256 . Sum256 ( msgBuffer . Bytes ( ) ) return digest [ : ] , nil }
Digest function that returns a digest from a serialized transaction
Digest function that returns a digest from a serialized transaction
// Write the chain ID. // Write the serialized transaction. // Compute the digest.