/// <summary> Handles the command. </summary> /// /// <remarks> Paul, 26/02/2015. </remarks> /// /// <param name="l"> The BitsharesLedgerEntry to process. </param> /// <param name="handler"> The handler. </param> /// <param name="market"> The market. </param> /// /// <returns> true if it succeeds, false if it fails. </returns> public bool HandleCommand(BitsharesLedgerEntry l, MarketBase handler, MarketRow market, string trxid) { if (m_adminUsernames.Contains(l.from_account)) { try { string[] parts = l.memo.Split(' '); if (l.memo.StartsWith(kSetPricesMemoStart)) { HandlePriceSetting(parts, l, handler, market); return(true); } else if (l.memo.StartsWith(kWithdrawMemo)) { // process withdrawal if (parts[0] == kWithdrawMemo) { // make sure we didn't already process this transaction! if (!m_dataAccess.IsWithdrawalProcessed(trxid)) { decimal amount = decimal.Parse(parts[1]); CurrenciesRow type = CurrencyHelpers.FromSymbol(parts[2], m_allCurrencies); string to; string txid; if (!CurrencyHelpers.IsBitsharesAsset(type)) { to = m_dataAccess.GetStats().bitcoin_withdraw_address; Debug.Assert(to != null); txid = m_bitcoin.SendToAddress(to, amount); } else { to = l.from_account; BitsharesTransactionResponse response = m_bitshares.WalletTransfer(amount, CurrencyHelpers.ToBitsharesSymbol(type), m_bitsharesAccount, to); txid = response.record_id; } // log in DB m_dataAccess.InsertWithdrawal(trxid, txid, type.ToString(), amount, to, DateTime.UtcNow); } return(true); } } } catch (Exception e) { LogGeneralException(e.ToString()); } } return(false); }
public void FromSymbol() { List <string> symbols = new List <string>(); for (int i = 0; i < (int)CurrencyTypesDep.max; i++) { CurrencyTypesDep type = (CurrencyTypesDep)i; symbols.Add(type.ToString()); } foreach (string s in symbols) { string old = CurrencyHelpersDep.FromSymbol(s).ToString(); string n = CurrencyHelpers.FromSymbol(s, m_currencies).ToString(); Assert.AreEqual(old, n); } }
public CurrenciesRow GetQuote(Dictionary <string, CurrenciesRow> currencyMap) { return(CurrencyHelpers.FromSymbol(symbol_pair.Split('_')[1], currencyMap)); }
public void UnknownAsset() { Assert.Throws(typeof(ArgumentException), () => CurrencyHelpersDep.FromSymbol("ldss")); Assert.Throws(typeof(KeyNotFoundException), () => CurrencyHelpers.FromSymbol("ldss", m_currencies)); }