Esempio n. 1
0
        /// <summary>	Executes the push market action. </summary>
        ///
        /// <remarks>	Paul, 19/02/2015. </remarks>
        ///
        /// <param name="ctx">      The context. </param>
        /// <param name="dummy">	The dummy. </param>
        ///
        /// <returns>	A Task. </returns>
        Task OnPushMarket(RequestContext ctx, IDummy dummy)
        {
            if (ConfirmDaemon(ctx, dummy))
            {
                MarketRow market = JsonSerializer.DeserializeFromString <MarketRow>(ctx.Request.Body);
                dummy.m_database.UpdateMarketInDatabase(market);
                ctx.Respond <bool>(true);
            }
            else
            {
                ctx.Respond <bool>(false);
            }

            return(null);
        }
Esempio n. 2
0
        /// <summary>	Executes the submit address action. </summary>
        ///
        /// <remarks>	Paul, 19/02/2015. </remarks>
        ///
        /// <param name="ctx">      The context. </param>
        /// <param name="dummy">	The dummy. </param>
        ///
        /// <returns>	A Task. </returns>
        async Task OnSubmitAddress(RequestContext ctx, IDummy dummy)
        {
            // intercept the response and stick it in the site database so we can handle forwarding future queries
            string symbolPair       = RestHelpers.GetPostArg <string, ApiExceptionMissingParameter>(ctx, WebForms.kSymbolPair);
            uint   referralUser     = RestHelpers.GetPostArg <uint>(ctx, WebForms.kReferralId);
            string receivingAddress = RestHelpers.GetPostArg <string, ApiExceptionMissingParameter>(ctx, WebForms.kReceivingAddress);

            // do this at the site level, because we need to prevent this from occuring across nodes
            if (dummy.m_database.IsAnyDepositAddress(receivingAddress))
            {
                throw new ApiExceptionInvalidAddress("<internal deposit address>");
            }

            // forward the post on
            string response = await ForwardPostSpecific(ctx, dummy);

            if (response != null)
            {
                // get the juicy data out
                SubmitAddressResponse data = JsonSerializer.DeserializeFromString <SubmitAddressResponse>(response);

                // pull the market out of the request
                MarketRow m = dummy.m_database.GetMarket(symbolPair);

                // stick it in the master database
                dummy.m_database.InsertSenderToDeposit(data.receiving_address, data.deposit_address, m.symbol_pair, referralUser, true);

                if (referralUser > 0)
                {
                    // track referrals
                    string depositAddress;

                    if (data.memo != null)
                    {
                        depositAddress = data.memo;
                    }
                    else
                    {
                        depositAddress = data.deposit_address;
                    }

                    dummy.m_database.InsertReferralAddress(depositAddress, referralUser);
                }
            }
        }
Esempio n. 3
0
        /// <summary>	Executes the get market action. </summary>
        ///
        /// <remarks>	Paul, 28/02/2015. </remarks>
        ///
        /// <exception cref="ApiExceptionUnknownMarket">	Thrown when an API exception unknown market
        ///                                                 error condition occurs. </exception>
        ///
        /// <param name="ctx">      The context. </param>
        /// <param name="dummy">	The dummy. </param>
        ///
        /// <returns>	A Task. </returns>
        Task OnGetMarket(RequestContext ctx, IDummy dummy)
        {
            string symbolPair = RestHelpers.GetPostArg <string, ApiExceptionMissingParameter>(ctx, WebForms.kSymbolPair);

            MarketRow market = m_Database.GetMarket(symbolPair);

            if (market == null)            // || !market.visible)
            {
                throw new ApiExceptionUnknownMarket(symbolPair);
            }
            else
            {
                //ctx.Respond<MarketRow>(market);
                m_api.SendCorsResponse <MarketRow>(ctx, market);
            }

            return(null);
        }
Esempio n. 4
0
        /// <summary>	Executes the push transactions action. </summary>
        ///
        /// <remarks>	Paul, 19/02/2015. </remarks>
        ///
        /// <param name="ctx">      The context. </param>
        /// <param name="dummy">	The dummy. </param>
        ///
        /// <returns>	A Task. </returns>
        async Task OnPushTransactions(RequestContext ctx, IDummy dummy)
        {
            if (ConfirmDaemon(ctx, dummy))
            {
                string allTrans = ctx.Request.Body;
                if (ctx.Request.m_Truncated)
                {
                    allTrans += await ctx.Request.GetBody(kMb);
                }

                List <TransactionsRow> newTrans = JsonSerializer.DeserializeFromString <List <TransactionsRow> >(allTrans);

                OnPushTransactions(newTrans, dummy.m_database);

                ctx.Respond <bool>(true);
            }
            else
            {
                ctx.Respond <bool>(false);
            }
        }
Esempio n. 5
0
 /// <summary>	Executes the get all markets action. </summary>
 ///
 /// <remarks>	Paul, 28/02/2015. </remarks>
 ///
 /// <param name="ctx">      The context. </param>
 /// <param name="dummy">	The dummy. </param>
 ///
 /// <returns>	A Task. </returns>
 Task OnGetAllMarkets(RequestContext ctx, IDummy dummy)
 {
     //ctx.Respond<List<MarketRow>>(GetVisisbleMarkets(m_Database.GetAllMarkets()).ToList());
     m_api.SendCorsResponse <List <MarketRow> >(ctx, GetVisisbleMarkets(m_Database.GetAllMarkets()).ToList());
     return(null);
 }