Пример #1
0
        protected bool ValidateRenewalDate(TransactionBlock block, TransactionBlock previousBlock)
        {
            if (previousBlock == null)
            {
                return(true);
            }

            var trs = block.GetTransaction(previousBlock);

            if (trs.Amount <= 0)
            {
                return(true);
            }

            var token = _accountCollection.FindTokenGenesisBlock(null, trs.TokenCode);

            if (token != null)
            {
                if (token.RenewalDate < DateTime.Now)
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #2
0
        //protected virtual APIResultCodes ValidateFee(TransactionBlock block)
        //{
        //    if (block.Fee == 0 && block.FeeType != AuthorizationFeeTypes.NoFee)
        //        return APIResultCodes.InvalidFeeAmount;

        //    return APIResultCodes.Success;
        //}

        protected virtual APIResultCodes ValidateNonFungible(TransactionBlock send_or_receice_block, TransactionBlock previousBlock)
        {
            TransactionInfoEx transaction = send_or_receice_block.GetTransaction(previousBlock);

            if (transaction.TokenCode == LyraGlobal.LYRA_TICKER_CODE)
            {
                return(APIResultCodes.Success);
            }

            var token_block = _accountCollection.FindTokenGenesisBlock(null, transaction.TokenCode);

            if (token_block == null)
            {
                return(APIResultCodes.TokenGenesisBlockNotFound);
            }

            if (!token_block.IsNonFungible)
            {
                return(APIResultCodes.Success);
            }

            //INonFungibleToken non_fungible_token = send_block.GetNonFungibleTransaction(previousBlock);

            if (send_or_receice_block.NonFungibleToken == null)
            {
                return(APIResultCodes.MissingNonFungibleToken);
            }

            if (send_or_receice_block.NonFungibleToken.Denomination != transaction.Amount)
            {
                return(APIResultCodes.InvalidNonFungibleAmount);
            }

            if (send_or_receice_block.NonFungibleToken.TokenCode != transaction.TokenCode)
            {
                return(APIResultCodes.InvalidNonFungibleTokenCode);
            }

            if (!send_or_receice_block.NonFungibleToken.VerifySignature(token_block.NonFungibleKey))
            {
                return(APIResultCodes.NonFungibleSignatureVerificationFailed);
            }

            return(APIResultCodes.Success);
        }