// ParseStake parses and performs sanity checks on the payload of a stake transaction.
ParseStake parses and performs sanity checks on the payload of a stake transaction.
// ParseStake parses and performs sanity checks on the payload of a stake transaction .
func ParseStake(payload []byte) (Stake, error) {
	var stake Stake
	if len(payload) != 9 {
		return stake, errors.New("stake: payload must be exactly 9 bytes")
	}
	stake.Opcode = payload[0]
	if stake.Opcode > sys.WithdrawReward {
		return stake, errors.New("stake: opcode must be 0, 1, or 2")
	}
	stake.Amount = binary.LittleEndian.Uint64(payload[1:9])
	if stake.Amount == 0 {
		return stake, errors.New("stake: amount must be greater than zero")
	}
	if stake.Opcode == sys.WithdrawReward && stake.Amount < sys.MinimumRewardWithdraw {
		return stake, errors.Errorf(
			"stake: must withdraw a reward of a minimum of %d PERLs, but requested to withdraw %d PERLs",
			sys.MinimumRewardWithdraw, stake.Amount,
		)
	}
	return stake, nil
}
func ParseStake ( payload [ ] byte ) ( Stake , error ) { var stake Stake if len ( payload ) != 9 { return stake , errors . New ( " " ) } stake . Opcode = payload [ 0 ] if stake . Opcode > sys . WithdrawReward { return stake , errors . New ( " " ) } stake . Amount = binary . LittleEndian . Uint64 ( payload [ 1 : 9 ] ) if stake . Amount == 0 { return stake , errors . New ( " " ) } if stake . Opcode == sys . WithdrawReward && stake . Amount < sys . MinimumRewardWithdraw { return stake , errors . Errorf ( " " , sys . MinimumRewardWithdraw , stake . Amount , ) } return stake , nil }
ParseStake parses and performs sanity checks on the payload of a stake transaction.
ParseStake parses and performs sanity checks on the payload of a stake transaction .