private bool ValidateBuyOrder(TradeOrderBlock block, TransactionInfoEx transaction) { int sell_token_precision = FindTokenPrecision(block.SellTokenCode); if (sell_token_precision < 0) { return(false); } int buy_token_precision = FindTokenPrecision(block.BuyTokenCode); if (buy_token_precision < 0) { return(false); } if (transaction.Amount != block.TradeAmount * block.Price) { return(false); } var serviceblock = _serviceAccount.GetLastServiceBlock(); //decimal real_price = Math.Round(block.Price / (decimal)Math.Pow(10, sell_token_precision), sell_token_precision); //decimal real_trade_amount = Math.Round(block.TradeAmount / (decimal)Math.Pow(10, buy_token_precision), buy_token_precision); //long sell_amount = (long) (real_price * real_trade_amount * (decimal)Math.Pow(10, sell_token_precision)); decimal balance_change = block.TradeAmount * block.Price; decimal reference_fee = serviceblock.TradeFee; if (block.CoverAnotherTradersFee) { reference_fee = serviceblock.TradeFee * 2; } if (block.AnotherTraderWillCoverFee) { reference_fee = 0; } if (block.SellTokenCode == LyraGlobal.LYRA_TICKER_CODE) { balance_change += reference_fee; } if (transaction.TotalBalanceChange != balance_change) { return(false); } return(true); }
//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); }