Exemple #1
0
        public override (bool, int) Validate(Transaction transaction, FeatureData featureData)
        {
            var error = ReceiverError.None;

            if (!(featureData is Receiver receiverData) || !receiverData.Valid)
            {
                error = ReceiverError.InvalidReceiverData;
                goto end;
            }

            var receivers = receiverData.Receivers;

            if (receivers.Count > MaxReceivers)
            {
                error = ReceiverError.TooManyReceivers;
                goto end;
            }

            if (receivers.Count == 0)
            {
                error = ReceiverError.InvalidReceiver;
                goto end;
            }

            var receiversList = new HashSet <long>();

            foreach (var receiverAccountId in receivers)
            {
                if (!CurrentChain.FeatureAccountExists(receiverAccountId))
                {
                    error = ReceiverError.InvalidReceiver;
                    goto end;
                }

                if (receiversList.Contains(receiverAccountId))
                {
                    error = ReceiverError.InvalidReceiver;
                    goto end;
                }

                receiversList.Add(receiverAccountId);
            }

end:

            return(error == ReceiverError.None, (int)error);
        }