diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index f70c3dc22df8..5f8e743505a7 100755 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -23,6 +23,7 @@ QT_TS = \ QT_FORMS_UI = \ qt/forms/addressbookpage.ui \ qt/forms/askpassphrasedialog.ui \ + qt/forms/bittrextradingtab.ui \ qt/forms/coincontroldialog.ui \ qt/forms/obfuscationconfig.ui \ qt/forms/editaddressdialog.ui \ @@ -47,6 +48,7 @@ QT_MOC_CPP = \ qt/moc_bitcoinamountfield.cpp \ qt/moc_bitcoingui.cpp \ qt/moc_bitcoinunits.cpp \ + qt/moc_bittrextradingtab.cpp \ qt/moc_clientmodel.cpp \ qt/moc_coincontroldialog.cpp \ qt/moc_coincontroltreewidget.cpp \ @@ -113,6 +115,7 @@ BITCOIN_QT_H = \ qt/bitcoinamountfield.h \ qt/bitcoingui.h \ qt/bitcoinunits.h \ + qt/bittrextradingtab.h \ qt/clientmodel.h \ qt/coincontroldialog.h \ qt/coincontroltreewidget.h \ @@ -208,6 +211,7 @@ RES_ICONS = \ qt/res/icons/remove.png \ qt/res/icons/send.png \ qt/res/icons/synced.png \ + qt/res/icons/trade.png \ qt/res/icons/transaction0.png \ qt/res/icons/transaction2.png \ qt/res/icons/transaction_conflicted.png \ @@ -249,6 +253,7 @@ BITCOIN_QT_CPP += \ qt/addressbookpage.cpp \ qt/addresstablemodel.cpp \ qt/askpassphrasedialog.cpp \ + qt/bittrextradingtab.cpp \ qt/coincontroldialog.cpp \ qt/coincontroltreewidget.cpp \ qt/obfuscationconfig.cpp \ diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 1879981b36c6..f6cf283106f2 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -7,6 +7,7 @@ #include "bitcoingui.h" #include "bitcoinunits.h" +#include "bittrextradingtab.h" #include "clientmodel.h" #include "guiconstants.h" #include "guiutil.h" @@ -315,6 +316,13 @@ void BitcoinGUI::createActions(const NetworkStyle *networkStyle) #endif tabGroup->addAction(historyAction); + bittrexTradingAction = new QAction(QIcon(":/icons/trade"), tr("&Trade"), this); + bittrexTradingAction->setStatusTip(tr("Buy/Sell at Bittrex")); + bittrexTradingAction->setToolTip(bittrexTradingAction->statusTip()); + bittrexTradingAction->setCheckable(true); + bittrexTradingAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5)); + tabGroup->addAction(bittrexTradingAction); + #ifdef ENABLE_WALLET // These showNormalIfMinimized are needed because Send Coins and Receive Coins // can be triggered from the tray menu, and need to show the GUI to be useful. @@ -326,6 +334,8 @@ void BitcoinGUI::createActions(const NetworkStyle *networkStyle) connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage())); connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage())); + connect(bittrexTradingAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); + connect(bittrexTradingAction, SIGNAL(triggered()), this, SLOT(gotoBittrexTradingTab())); #endif // ENABLE_WALLET quitAction = new QAction(QIcon(":/icons/quit"), tr("E&xit"), this); @@ -479,6 +489,7 @@ void BitcoinGUI::createToolBars() toolbar->addAction(sendCoinsAction); toolbar->addAction(receiveCoinsAction); toolbar->addAction(historyAction); + toolbar->addAction(bittrexTradingAction); toolbar->setMovable(false); // remove unused icon in upper left corner overviewAction->setChecked(true); @@ -705,6 +716,12 @@ void BitcoinGUI::gotoSendCoinsPage(QString addr) if (walletFrame) walletFrame->gotoSendCoinsPage(addr); } +void BitcoinGUI::gotoBittrexTradingTab() +{ + bittrexTradingAction->setChecked(true); + if (walletFrame) walletFrame->gotoBittrexTradingTab(); +} + void BitcoinGUI::gotoSignMessageTab(QString addr) { if (walletFrame) walletFrame->gotoSignMessageTab(addr); diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 2d1ebdd33bd1..f23108aa6b2b 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -94,6 +94,7 @@ class BitcoinGUI : public QMainWindow QAction *sendCoinsAction; QAction *usedSendingAddressesAction; QAction *usedReceivingAddressesAction; + QAction *bittrexTradingAction; QAction *signMessageAction; QAction *verifyMessageAction; QAction *aboutAction; @@ -192,6 +193,8 @@ private slots: void gotoReceiveCoinsPage(); /** Switch to send coins page */ void gotoSendCoinsPage(QString addr = ""); + /** Switch to manage names page */ + void gotoBittrexTradingTab(); /** Show Sign/Verify Message dialog and switch to sign message tab */ void gotoSignMessageTab(QString addr = ""); diff --git a/src/qt/bittrextradingtab.cpp b/src/qt/bittrextradingtab.cpp new file mode 100644 index 000000000000..107479485b24 --- /dev/null +++ b/src/qt/bittrextradingtab.cpp @@ -0,0 +1,1387 @@ +#include "bittrextradingtab.h" +#include "ui_bittrextradingtab.h" +#include "walletmodel.h" +#include "guiutil.h" +#include "base58.h" +#include "main.h" +#include "wallet.h" +#include "ui_interface.h" +#include "util.h" + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace std; + + +BittrexTradingTab::BittrexTradingTab(QWidget *parent) : + QWidget(parent), + ui(new Ui::BittrexTradingTab), + model(0) +{ + ui->setupUi(this); + + timerid = 0; + // qDebug() << "Expected this"; + + InitTrading(); + + ui->BtcAvailableLabel->setTextFormat(Qt::RichText); + ui->DNETAvailableLabel->setTextFormat(Qt::RichText); + ui->BuyCostLabel->setTextFormat(Qt::RichText); + ui->SellCostLabel->setTextFormat(Qt::RichText); + ui->BittrexBTCLabel->setTextFormat(Qt::RichText); + ui->BittrexDNETLabel->setTextFormat(Qt::RichText); + ui->CSDumpLabel->setTextFormat(Qt::RichText); + ui->CSTotalLabel->setTextFormat(Qt::RichText); + ui->CSReceiveLabel->setTextFormat(Qt::RichText); + + //Set tabs to inactive + ui->TradingTabWidget->setTabEnabled(0,false); + ui->TradingTabWidget->setTabEnabled(1,false); + ui->TradingTabWidget->setTabEnabled(3,false); + ui->TradingTabWidget->setTabEnabled(4,false); + ui->TradingTabWidget->setTabEnabled(5,false); + + // Listen for keypress + connect(ui->PasswordInput, SIGNAL(returnPressed()),ui->LoadKeys,SIGNAL(clicked())); + + /*OrderBook Table Init*/ + CreateOrderBookTables(*ui->BidsTable,QStringList() << "SUM(BTC)" << "TOTAL(BTC)" << "DNET(SIZE)" << "BID(BTC)"); + CreateOrderBookTables(*ui->AsksTable,QStringList() << "ASK(BTC)" << "DNET(SIZE)" << "TOTAL(BTC)" << "SUM(BTC)"); + /*OrderBook Table Init*/ + + /*Market History Table Init*/ + ui->MarketHistoryTable->setColumnCount(5); + ui->MarketHistoryTable->verticalHeader()->setVisible(false); + ui->MarketHistoryTable->setHorizontalHeaderLabels(QStringList()<<"DATE"<<"BUY/SELL"<<"BID/ASK"<<"TOTAL UNITS(DNET)"<<"TOTAL COST(BTC"); + ui->MarketHistoryTable->setRowCount(0); + int Cellwidth = ui->MarketHistoryTable->width() / 5; + ui->MarketHistoryTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); + ui->MarketHistoryTable->horizontalHeader()->resizeSection(1,Cellwidth); + ui->MarketHistoryTable->horizontalHeader()->resizeSection(2,Cellwidth); + ui->MarketHistoryTable->horizontalHeader()->resizeSection(3,Cellwidth); + ui->MarketHistoryTable->horizontalHeader()->resizeSection(4,Cellwidth); + ui->MarketHistoryTable->horizontalHeader()->resizeSection(5,Cellwidth); + ui->MarketHistoryTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); + ui->MarketHistoryTable->horizontalHeader()->setStyleSheet("QHeaderView::section, QHeaderView::section * {font-weight :bold;}"); + /*Market History Table Init*/ + + /*Account History Table Init*/ + ui->TradeHistoryTable->setColumnCount(9); + ui->TradeHistoryTable->verticalHeader()->setVisible(false); + ui->TradeHistoryTable->setHorizontalHeaderLabels(QStringList() << "Date Time" << "Exchange" << "OrderType" << "Limit" << "QTY" << "QTY_Rem" << "Price" << "PricePerUnit" << "Closed"); + ui->TradeHistoryTable->setRowCount(0); + Cellwidth = ui->TradeHistoryTable->width() / 9; + ui->TradeHistoryTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(1,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(2,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(3,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(4,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(5,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(6,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(7,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(8,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(9,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); + ui->TradeHistoryTable->horizontalHeader()->setStyleSheet("QHeaderView::section, QHeaderView::section * {font-weight :bold;}"); + /*Account History Table Init*/ + + /*Open Orders Table*/ + ui->OpenOrdersTable->setColumnCount(10); + ui->OpenOrdersTable->verticalHeader()->setVisible(false); + ui->OpenOrdersTable->setHorizontalHeaderLabels(QStringList() << "OrderId" << "Date Time" << "Exchange" << "OrderType" << "Limit" << "QTY" << "QTY_Rem" << "Price" << "PricePerUnit" << "Cancel Order"); + ui->OpenOrdersTable->setRowCount(0); + Cellwidth = ui->TradeHistoryTable->width() / 9; + ui->OpenOrdersTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(2,Cellwidth); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(3,Cellwidth); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(4,Cellwidth); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(5,Cellwidth); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(6,Cellwidth); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(7,Cellwidth); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(8,Cellwidth); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(9,Cellwidth); + ui->OpenOrdersTable->setColumnHidden(0,true); + ui->OpenOrdersTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); + ui->OpenOrdersTable->horizontalHeader()->setStyleSheet("QHeaderView::section, QHeaderView::section * {font-weight :bold;}"); + + connect (ui->OpenOrdersTable, SIGNAL(cellClicked(int,int)), this, SLOT(CancelOrderSlot(int, int))); + /*Open Orders Table*/ +} + +BittrexTradingTab::~BittrexTradingTab() +{ + delete ui; +} + +void BittrexTradingTab::InitTrading(){ + //todo - add internet connection/socket error checking. + + //Get default exchange info for the qlabels + UpdaterFunction(); + qDebug() << "Updater called"; + if(this->timerid == 0) + { + //Timer is not set,lets create one. + this->timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(UpdaterFunction())); + this->timer->start(5000); + this->timerid = this->timer->timerId(); + } +} + +void BittrexTradingTab::UpdaterFunction(){ + //DNETst get the main exchange info in order to populate qLabels in maindialog. then get data + //required for the current tab. + + int Retval = SetExchangeInfoTextLabels(); + + if (Retval == 0){ + ActionsOnSwitch(-1); + } +} + +QString BittrexTradingTab::GetMarketSummary(){ + + QString Response = sendRequest("https://bittrex.com/api/v1.1/public/GetMarketSummary?market=BTC-DNET"); + return Response; +} + +QString BittrexTradingTab::GetOrderBook(){ + + QString Response = sendRequest("https://bittrex.com/api/v1.1/public/getorderbook?market=BTC-DNET&type=both&depth=50"); + return Response; +} + +QString BittrexTradingTab::GetMarketHistory(){ + QString Response = sendRequest("https://bittrex.com/api/v1.1/public/getmarkethistory?market=BTC-DNET&count=100"); + return Response; +} + +QString BittrexTradingTab::CancelOrder(QString OrderId){ + + QString URL = "https://bittrex.com/api/v1.1/market/cancel?apikey="; + URL += this->ApiKey; + URL += "&nonce=12345434&uuid="; + URL += OrderId; + + QString Response = sendRequest(URL); + return Response; +} + +QString BittrexTradingTab::BuyDNET(QString OrderType, double Quantity, double Rate){ + + QString str = ""; + QString URL = "https://bittrex.com/api/v1.1/market/"; + URL += OrderType; + URL += "?apikey="; + URL += this->ApiKey; + URL += "&nonce=12345434&market=BTC-DNET&quantity="; + URL += str.number(Quantity,'i',8); + URL += "&rate="; + URL += str.number(Rate,'i',8); + + QString Response = sendRequest(URL); + return Response; +} + +QString BittrexTradingTab::SellDNET(QString OrderType, double Quantity, double Rate){ + + QString str = ""; + QString URL = "https://bittrex.com/api/v1.1/market/"; + URL += OrderType; + URL += "?apikey="; + URL += this->ApiKey; + URL += "&nonce=12345434&market=BTC-DNET&quantity="; + URL += str.number(Quantity,'i',8); + URL += "&rate="; + URL += str.number(Rate,'i',8); + + QString Response = sendRequest(URL); + return Response; +} + +QString BittrexTradingTab::Withdraw(double Amount, QString Address, QString Coin){ + + QString str = ""; + QString URL = "https://bittrex.com/api/v1.1/account/withdraw?apikey="; + URL += this->ApiKey; + URL += "¤cy="; + URL += Coin; + URL += "&quantity="; + URL += str.number(Amount,'i',8); + URL += "&address="; + URL += Address; + URL += "&nonce=12345434"; + + QString Response = sendRequest(URL); + return Response; +} + +QString BittrexTradingTab::GetOpenOrders(){ + QString URL = "https://bittrex.com/api/v1.1/market/getopenorders?apikey="; + URL += this->ApiKey; + URL += "&nonce=12345434&market=BTC-DNET"; + + QString Response = sendRequest(URL); + return Response; +} + +QString BittrexTradingTab::GetBalance(QString Currency){ + + QString URL = "https://bittrex.com/api/v1.1/account/getbalance?apikey="; + URL += this->ApiKey; + URL += "&nonce=12345434¤cy="; + URL += Currency; + + QString Response = sendRequest(URL); + return Response; +} + +QString BittrexTradingTab::GetDepositAddress(){ + + QString URL = "https://bittrex.com/api/v1.1/account/getdepositaddress?apikey="; + URL += this->ApiKey; + URL += "&nonce=12345434¤cy=DNET"; + + QString Response = sendRequest(URL); + return Response; +} + +QString BittrexTradingTab::GetAccountHistory(){ + + QString URL = "https://bittrex.com/api/v1.1/account/getorderhistory?apikey="; + URL += this->ApiKey; + URL += "&nonce=12345434&market=BTC-DNET&count=10"; + + QString Response = sendRequest(URL); + return Response; +} + +int BittrexTradingTab::SetExchangeInfoTextLabels(){ + //Get the current exchange information + information for the current open tab if required. + QString str = ""; + QString Response = GetMarketSummary(); + + //Set the labels, parse the json result to get values. + QJsonObject obj = GetResultObjectFromJSONArray(Response); + + //set labels to richtext to use css. + ui->Bid->setTextFormat(Qt::RichText); + ui->Ask->setTextFormat(Qt::RichText); + ui->volumet->setTextFormat(Qt::RichText); + ui->volumebtc->setTextFormat(Qt::RichText); + + ui->Ask->setText("Ask: " + str.number(obj["Ask"].toDouble(),'i',8) + " BTC"); + + ui->Bid->setText("Bid: " + str.number(obj["Bid"].toDouble(),'i',8) + " BTC"); + + ui->volumet->setText("DNET Volume: " + str.number(obj["Volume"].toDouble(),'i',8) + " DNET"); + + ui->volumebtc->setText("BTC Volume: " + str.number(obj["BaseVolume"].toDouble(),'i',8) + " BTC"); + + obj.empty(); + + return 0; +} + +void BittrexTradingTab::CreateOrderBookTables(QTableWidget& Table,QStringList TableHeader){ + + Table.setColumnCount(4); + Table.verticalHeader()->setVisible(false); + + Table.setHorizontalHeaderLabels(TableHeader); + + int Cellwidth = Table.width() / 4; + + Table.horizontalHeader()->resizeSection(1,Cellwidth); // column 1, width 50 + Table.horizontalHeader()->resizeSection(2,Cellwidth); + Table.horizontalHeader()->resizeSection(3,Cellwidth); + Table.horizontalHeader()->resizeSection(4,Cellwidth); + + Table.setRowCount(0); + + Table.horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); + Table.horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); + Table.horizontalHeader()->setStyleSheet("QHeaderView::section, QHeaderView::section * { font-weight :bold;}"); +} + +void BittrexTradingTab::DisplayBalance(QLabel &BalanceLabel,QLabel &Available, QLabel &Pending, QString Currency,QString Response){ + + QString str; + + BalanceLabel.setTextFormat(Qt::RichText); + Available.setTextFormat(Qt::RichText); + Pending.setTextFormat(Qt::RichText); + + //Set the labels, parse the json result to get values. + QJsonObject ResultObject = GetResultObjectFromJSONObject(Response); + + BalanceLabel.setText("" + str.number( ResultObject["Balance"].toDouble(),'i',8) + " " + Currency); + Available.setText("" + str.number( ResultObject["Available"].toDouble(),'i',8) + " " +Currency); + Pending.setText("" + str.number( ResultObject["Pending"].toDouble(),'i',8) + " " +Currency); +} + +void BittrexTradingTab::DisplayBalance(QLabel &BalanceLabel, QString Response){ + + QString str; + + //Set the labels, parse the json result to get values. + QJsonObject ResultObject = GetResultObjectFromJSONObject(Response); + + BalanceLabel.setText("" + str.number(ResultObject["Available"].toDouble(),'i',8) + ""); +} + +void BittrexTradingTab::DisplayBalance(QLabel &BalanceLabel, QLabel &BalanceLabel2, QString Response, QString Response2){ + + QString str; + QString str2; + + //Set the labels, parse the json result to get values. + QJsonObject ResultObject = GetResultObjectFromJSONObject(Response); + QJsonObject ResultObject2 = GetResultObjectFromJSONObject(Response2); + + BalanceLabel.setText("" + str.number(ResultObject["Available"].toDouble(),'i',8) + ""); + BalanceLabel2.setText("" + str2.number(ResultObject2["Available"].toDouble(),'i',8) + ""); +} + +void BittrexTradingTab::ParseAndPopulateOpenOrdersTable(QString Response){ + + int itteration = 0, RowCount = 0; + + QJsonArray jsonArray = GetResultArrayFromJSONObject(Response); + QJsonObject obj; + + ui->OpenOrdersTable->setRowCount(0); + + Q_FOREACH (const QJsonValue & value, jsonArray) + { + QString str = ""; + obj = value.toObject(); + + RowCount = ui->OpenOrdersTable->rowCount(); + + ui->OpenOrdersTable->insertRow(RowCount); + ui->OpenOrdersTable->setItem(itteration, 0, new QTableWidgetItem(obj["OrderUuid"].toString())); + ui->OpenOrdersTable->setItem(itteration, 1, new QTableWidgetItem(BittrexTimeStampToReadable(obj["Opened"].toString()))); + ui->OpenOrdersTable->setItem(itteration, 2, new QTableWidgetItem(obj["Exchange"].toString())); + ui->OpenOrdersTable->setItem(itteration, 3, new QTableWidgetItem(obj["OrderType"].toString())); + ui->OpenOrdersTable->setItem(itteration, 4, new QTableWidgetItem(str.number(obj["Limit"].toDouble(),'i',8))); + ui->OpenOrdersTable->setItem(itteration, 5, new QTableWidgetItem(str.number(obj["Quantity"].toDouble(),'i',8))); + ui->OpenOrdersTable->setItem(itteration, 6, new QTableWidgetItem(str.number(obj["QuantityRemaining"].toDouble(),'i',8))); + ui->OpenOrdersTable->setItem(itteration, 7, new QTableWidgetItem(str.number(obj["Price"].toDouble(),'i',8))); + ui->OpenOrdersTable->setItem(itteration, 8, new QTableWidgetItem(str.number(obj["PricePerUnit"].toDouble(),'i',8))); + ui->OpenOrdersTable->setItem(itteration, 9, new QTableWidgetItem(tr("Cancel Order"))); + + //Handle the cancel link in open orders table + QTableWidgetItem* CancelCell; + CancelCell= ui->OpenOrdersTable->item(itteration, 9); //Set the wtablewidget item to the cancel cell item. + CancelCell->setForeground(QColor::fromRgb(255,0,0)); //make this item red. + CancelCell->setTextAlignment(Qt::AlignCenter); + itteration++; + } + obj.empty(); +} + +void BittrexTradingTab::CancelOrderSlot(int row, int col){ + + QString OrderId = ui->OpenOrdersTable->model()->data(ui->OpenOrdersTable->model()->index(row,0)).toString(); + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this,"Cancel Order","Are you sure you want to cancel the order?",QMessageBox::Yes|QMessageBox::No); + + if (reply == QMessageBox::Yes) { + + QString Response = CancelOrder(OrderId); + + QJsonDocument jsonResponse = QJsonDocument::fromJson(Response.toUtf8()); + QJsonObject ResponseObject = jsonResponse.object(); + + if (ResponseObject["success"].toBool() == false){ + + QMessageBox::information(this,"Failed To Cancel Order",ResponseObject["message"].toString()); + + }else if (ResponseObject["success"].toBool() == true){ + ui->OpenOrdersTable->model()->removeRow(row); + QMessageBox::information(this,"Success","You're order was cancelled."); + } + } else { + qDebug() << "Do Nothing"; + } +} + +void BittrexTradingTab::ParseAndPopulateAccountHistoryTable(QString Response){ + + int itteration = 0, RowCount = 0; + + QJsonArray jsonArray = GetResultArrayFromJSONObject(Response); + QJsonObject obj; + + ui->TradeHistoryTable->setRowCount(0); + + Q_FOREACH (const QJsonValue & value, jsonArray) + { + QString str = ""; + obj = value.toObject(); + + RowCount = ui->TradeHistoryTable->rowCount(); + + ui->TradeHistoryTable->insertRow(RowCount); + ui->TradeHistoryTable->setItem(itteration, 0, new QTableWidgetItem(BittrexTimeStampToReadable(obj["TimeStamp"].toString()))); + ui->TradeHistoryTable->setItem(itteration, 1, new QTableWidgetItem(obj["Exchange"].toString())); + ui->TradeHistoryTable->setItem(itteration, 2, new QTableWidgetItem(obj["OrderType"].toString())); + ui->TradeHistoryTable->setItem(itteration, 3, new QTableWidgetItem(str.number(obj["Limit"].toDouble(),'i',8))); + ui->TradeHistoryTable->setItem(itteration, 4, new QTableWidgetItem(str.number(obj["Quantity"].toDouble(),'i',8))); + ui->TradeHistoryTable->setItem(itteration, 5, new QTableWidgetItem(str.number(obj["QuantityRemaining"].toDouble(),'i',8))); + ui->TradeHistoryTable->setItem(itteration, 6, new QTableWidgetItem(str.number(obj["Price"].toDouble(),'i',8))); + ui->TradeHistoryTable->setItem(itteration, 7, new QTableWidgetItem(str.number(obj["PricePerUnit"].toDouble(),'i',8))); + ui->TradeHistoryTable->setItem(itteration, 8, new QTableWidgetItem(obj["Closed"].toString())); + itteration++; + } + + obj.empty(); +} + +void BittrexTradingTab::ParseAndPopulateOrderBookTables(QString OrderBook){ + + QString str; + QJsonObject obj; + QJsonObject ResultObject = GetResultObjectFromJSONObject(OrderBook); + + int BuyItteration = 0,SellItteration = 0, BidRows = 0, AskRows = 0; + + QJsonArray BuyArray = ResultObject.value("buy").toArray(); //get buy/sell object from result object + QJsonArray SellArray = ResultObject.value("sell").toArray(); //get buy/sell object from result object + + double DNETSupply = 0; + double DNETDemand = 0; + double BtcSupply = 0; + double BtcDemand = 0; + + ui->AsksTable->setRowCount(0); + + Q_FOREACH (const QJsonValue & value, SellArray) + { + obj = value.toObject(); + + double x = obj["Rate"].toDouble(); //would like to use int64 here + double y = obj["Quantity"].toDouble(); + double a = (x * y); + + DNETSupply += y; + BtcSupply += a; + + AskRows = ui->AsksTable->rowCount(); + ui->AsksTable->insertRow(AskRows); + ui->AsksTable->setItem(SellItteration, 0, new QTableWidgetItem(str.number(x,'i',8))); + ui->AsksTable->setItem(SellItteration, 1, new QTableWidgetItem(str.number(y,'i',8))); + ui->AsksTable->setItem(SellItteration, 2, new QTableWidgetItem(str.number(a,'i',8))); + ui->AsksTable->setItem(SellItteration, 3, new QTableWidgetItem(str.number(BtcSupply,'i',8))); + SellItteration++; + } + + ui->BidsTable->setRowCount(0); + + Q_FOREACH(const QJsonValue & value, BuyArray) + { + obj = value.toObject(); + + double x = obj["Rate"].toDouble(); //would like to use int64 here + double y = obj["Quantity"].toDouble(); + double a = (x * y); + + DNETDemand += y; + BtcDemand += a; + + BidRows = ui->BidsTable->rowCount(); + ui->BidsTable->insertRow(BidRows); + ui->BidsTable->setItem(BuyItteration, 0, new QTableWidgetItem(str.number(BtcDemand,'i',8))); + ui->BidsTable->setItem(BuyItteration, 1, new QTableWidgetItem(str.number(a,'i',8))); + ui->BidsTable->setItem(BuyItteration, 2, new QTableWidgetItem(str.number(y,'i',8))); + ui->BidsTable->setItem(BuyItteration, 3, new QTableWidgetItem(str.number(x,'i',8))); + BuyItteration++; + } + + ui->DNETSupply->setText("Supply: " + str.number(DNETSupply,'i',8) + " DNET"); + ui->BtcSupply->setText("" + str.number(BtcSupply,'i',8) + " BTC"); + ui->AsksCount->setText("Ask's : " + str.number(ui->AsksTable->rowCount()) + ""); + + ui->DNETDemand->setText("Demand: " + str.number(DNETDemand,'i',8) + " DNET"); + ui->BtcDemand->setText("" + str.number(BtcDemand,'i',8) + " BTC"); + ui->BidsCount->setText("Bid's : " + str.number(ui->BidsTable->rowCount()) + ""); + obj.empty(); +} + +void BittrexTradingTab::ParseAndPopulateMarketHistoryTable(QString Response){ + + int itteration = 0, RowCount = 0; + QJsonArray jsonArray = GetResultArrayFromJSONObject(Response); + QJsonObject obj; + + ui->MarketHistoryTable->setRowCount(0); + + Q_FOREACH (const QJsonValue & value, jsonArray) + { + QString str = ""; + obj = value.toObject(); + + RowCount = ui->MarketHistoryTable->rowCount(); + + ui->MarketHistoryTable->insertRow(RowCount); + ui->MarketHistoryTable->setItem(itteration, 0, new QTableWidgetItem(BittrexTimeStampToReadable(obj["TimeStamp"].toString()))); + ui->MarketHistoryTable->setItem(itteration, 1, new QTableWidgetItem(obj["OrderType"].toString())); + ui->MarketHistoryTable->setItem(itteration, 2, new QTableWidgetItem(str.number(obj["Price"].toDouble(),'i',8))); + ui->MarketHistoryTable->setItem(itteration, 3, new QTableWidgetItem(str.number(obj["Quantity"].toDouble(),'i',8))); + ui->MarketHistoryTable->setItem(itteration, 4, new QTableWidgetItem(str.number(obj["Total"].toDouble(),'i',8))); + ui->MarketHistoryTable->item(itteration,1)->setBackgroundColor((obj["OrderType"] == QStringLiteral("BUY")) ? (QColor (150, 191, 70,255)) : ( QColor (201, 119, 153,255))); + itteration++; + } + obj.empty(); +} + +void BittrexTradingTab::ActionsOnSwitch(int index = -1){ + + QString Response = ""; + QString Response2 = ""; + QString Response3 = ""; + + if(index == -1){ + index = ui->TradingTabWidget->currentIndex(); + } + + switch (index){ + case 0: //buy tab is active + + Response = GetBalance("BTC"); + Response2 = GetBalance("DNET"); + Response3 = GetOrderBook(); + + if((Response.size() > 0 && Response != "Error") && (Response2.size() > 0 && Response2 != "Error")){ + DisplayBalance(*ui->BtcAvailableLabel, *ui->DNETAvailableLabel, Response, Response2); + } + if ((Response3.size() > 0 && Response3 != "Error")) { + ParseAndPopulateOrderBookTables(Response3); + } + + break; + + case 1: //Cross send tab active + Response = GetBalance("DNET"); + Response2 = GetBalance("BTC"); + if((Response.size() > 0 && Response != "Error") && (Response2.size() > 0 && Response2 != "Error")){ + DisplayBalance(*ui->BittrexDNETLabel, *ui->BittrexBTCLabel, Response, Response2); + } + + break; + + case 2://market history tab + Response = GetMarketHistory(); + if(Response.size() > 0 && Response != "Error"){ + ParseAndPopulateMarketHistoryTable(Response); + } + break; + + case 3: //open orders tab + Response = GetOpenOrders(); + if(Response.size() > 0 && Response != "Error"){ + ParseAndPopulateOpenOrdersTable(Response); + } + + break; + + case 4://account history tab + Response = GetAccountHistory(); + if(Response.size() > 0 && Response != "Error"){ + ParseAndPopulateAccountHistoryTable(Response); + } + break; + + case 5://show balance tab + Response = GetBalance("BTC"); + if(Response.size() > 0 && Response != "Error"){ + DisplayBalance(*ui->BitcoinBalanceLabel,*ui->BitcoinAvailableLabel,*ui->BitcoinPendingLabel, QString::fromUtf8("BTC"),Response); + } + + Response = GetBalance("DNET"); + if(Response.size() > 0 && Response != "Error"){ + DisplayBalance(*ui->DNETBalanceLabel,*ui->DNETAvailableLabel_2,*ui->DNETPendingLabel, QString::fromUtf8("DNET"),Response); + } + break; + + case 6: + + break; + + } +} + +void BittrexTradingTab::on_TradingTabWidget_tabBarClicked(int index){ + //tab was clicked, interrupt the timer and restart after action completed. + + this->timer->stop(); + + ActionsOnSwitch(index); + + this->timer->start(); +} + +QString BittrexTradingTab::sendRequest(QString url){ + + QString Response = ""; + QString Secret = this->SecretKey; + + // create custom temporary event loop on stack + QEventLoop eventLoop; + + // "quit()" the event-loop, when the network request "finished()" + QNetworkAccessManager mgr; + QObject::connect(&mgr, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit())); + + // the HTTP request + QNetworkRequest req = QNetworkRequest(QUrl(url)); + + req.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); + + //make this conditional,depending if we are using private api call + req.setRawHeader("apisign",HMAC_SHA512_SIGNER(url,Secret).toStdString().c_str()); //set header for bittrex + + QNetworkReply *reply = mgr.get(req); + eventLoop.exec(); // blocks stack until "finished()" has been called + + if (reply->error() == QNetworkReply::NoError) { + //success + Response = reply->readAll(); + delete reply; + } + else{ + //failure + qDebug() << "Failure" <errorString(); + Response = "Error"; + //QMessageBox::information(this,"Error",reply->errorString()); + delete reply; + } + + return Response; +} + +QString BittrexTradingTab::BittrexTimeStampToReadable(QString DateTime){ + //Seperate Time and date. + int TPos = DateTime.indexOf("T"); + int sPos = DateTime.indexOf("."); + QDateTime Date = QDateTime::fromString(DateTime.left(TPos),"yyyy-MM-dd"); //format to convert from + DateTime.remove(sPos,sizeof(DateTime)); + DateTime.remove(0,TPos+1); + QDateTime Time = QDateTime::fromString(DateTime.right(TPos),"hh:mm:ss"); + + //Reconstruct time and date in our own format, one that QDateTime will recognise. + QString DisplayDate = Date.toString("dd/MM/yyyy") + " " + Time.toString("hh:mm:ss A"); //formats to convert to + + return DisplayDate; +} + +void BittrexTradingTab::CalculateBuyCostLabel(){ + + double price = ui->BuyBidPriceEdit->text().toDouble(); + double Quantity = ui->UnitsInput->text().toDouble(); + double cost = ((price * Quantity) + ((price * Quantity / 100) * 0.25)); + + QString Str = ""; + ui->BuyCostLabel->setText("" + Str.number(cost,'i',8) + ""); +} + +void BittrexTradingTab::CalculateSellCostLabel(){ + + double price = ui->SellBidPriceEdit->text().toDouble(); + double Quantity = ui->UnitsInputDNET->text().toDouble(); + double cost = ((price * Quantity) - ((price * Quantity / 100) * 0.25)); + + QString Str = ""; + ui->SellCostLabel->setText("" + Str.number(cost,'i',8) + ""); +} + +void BittrexTradingTab::CalculateCSReceiveLabel(){ + + //calculate amount of currency than can be transferred to bitcoin + QString balance = GetBalance("DNET"); + QString buyorders = GetOrderBook(); + + QJsonObject BuyObject = GetResultObjectFromJSONObject(buyorders); + QJsonObject BalanceObject = GetResultObjectFromJSONObject(balance); + QJsonObject obj; + + double AvailableDNET = BalanceObject["Available"].toDouble(); + double Quantity = ui->CSUnitsInput->text().toDouble(); + double Received = 0; + double Qty = 0; + double Price = 0; + QJsonArray BuyArray = BuyObject.value("buy").toArray(); //get buy/sell object from result object + + // For each buy order + Q_FOREACH (const QJsonValue & value, BuyArray) + { + obj = value.toObject(); + + double x = obj["Rate"].toDouble(); //would like to use int64 here + double y = obj["Quantity"].toDouble(); + // If + if ( ((Quantity / x) - y) > 0 ) + { + Price = x; + Received += ((Price * y) - ((Price * y / 100) * 0.25)); + Qty += y; + Quantity -= ((Price * y) - ((Price * y / 100) * 0.25)); + } else { + Price = x; + Received += ((Price * (Quantity / x)) - ((Price * (Quantity / x) / 100) * 0.25)); + Qty += (Quantity / x); + Quantity -= 0; + break; + } + } + + QString ReceiveStr = ""; + QString DumpStr = ""; + QString TotalStr = ""; + if ( Qty < AvailableDNET ) + { + ui->CSReceiveLabel->setText("" + ReceiveStr.number((ui->CSUnitsInput->text().toDouble() - 0.0002),'i',8) + ""); + ui->CSDumpLabel->setText("" + DumpStr.number(Price,'i',8) + ""); + ui->CSTotalLabel->setText("" + TotalStr.number(Qty,'i',8) + ""); + } else { + ReceiveStr = "N/A"; + TotalStr = "N/A"; + DumpStr = "N/A"; + ui->CSReceiveLabel->setText("" + ReceiveStr + ""); + ui->CSDumpLabel->setText("" + DumpStr + ""); + ui->CSTotalLabel->setText("" + TotalStr + ""); + } +} + +void BittrexTradingTab::on_UpdateKeys_clicked(bool Save, bool Load){ + this->ApiKey = ui->ApiKeyInput->text(); + this->SecretKey = ui->SecretKeyInput->text(); + + QJsonDocument jsonResponse = QJsonDocument::fromJson(GetAccountHistory().toUtf8()); //get json from str. + QJsonObject ResponseObject = jsonResponse.object(); //get json obj + + if ( ResponseObject.value("success").toBool() == false){ + QMessageBox::information(this,"API Configuration Failed","Api configuration was unsuccesful."); + + }else if ( ResponseObject.value("success").toBool() == true && Load){ + QMessageBox::information(this,"API Configuration Complete","Your API keys have been loaded and the connection has been successfully configured and tested."); + ui->ApiKeyInput->setEchoMode(QLineEdit::Password); + ui->SecretKeyInput->setEchoMode(QLineEdit::Password); + ui->PasswordInput->setText(""); + ui->TradingTabWidget->setTabEnabled(0,true); + ui->TradingTabWidget->setTabEnabled(1,true); + ui->TradingTabWidget->setTabEnabled(3,true); + ui->TradingTabWidget->setTabEnabled(4,true); + ui->TradingTabWidget->setTabEnabled(5,true); + }else if ( ResponseObject.value("success").toBool() == true && Save){ + QMessageBox::information(this,"API Configuration Complete","Your API keys have been saved and the connection has been successfully configured and tested."); + ui->ApiKeyInput->setEchoMode(QLineEdit::Password); + ui->SecretKeyInput->setEchoMode(QLineEdit::Password); + ui->PasswordInput->setText(""); + ui->TradingTabWidget->setTabEnabled(0,true); + ui->TradingTabWidget->setTabEnabled(1,true); + ui->TradingTabWidget->setTabEnabled(3,true); + ui->TradingTabWidget->setTabEnabled(4,true); + ui->TradingTabWidget->setTabEnabled(5,true); + }else{ + QMessageBox::information(this,"API Configuration Complete","Api connection has been successfully configured and tested."); + ui->ApiKeyInput->setEchoMode(QLineEdit::Password); + ui->SecretKeyInput->setEchoMode(QLineEdit::Password); + ui->PasswordInput->setText(""); + ui->TradingTabWidget->setTabEnabled(0,true); + ui->TradingTabWidget->setTabEnabled(1,true); + ui->TradingTabWidget->setTabEnabled(3,true); + ui->TradingTabWidget->setTabEnabled(4,true); + ui->TradingTabWidget->setTabEnabled(5,true); + } +} + +string BittrexTradingTab::encryptDecrypt(string toEncrypt, string password) { + + char * key = new char [password.size()+1]; + std::strcpy (key, password.c_str()); + key[password.size()] = '\0'; // don't forget the terminating 0 + + string output = toEncrypt; + + for (unsigned int i = 0; i < toEncrypt.size(); i++) + output[i] = toEncrypt[i] ^ key[i % (sizeof(key) / sizeof(char))]; + return output; +} + +void BittrexTradingTab::on_SaveKeys_clicked(){ + bool fSuccess = true; + boost::filesystem::path pathConfigFile = GetDataDir() / "APIcache.txt"; + boost::filesystem::ofstream stream (pathConfigFile.string(), ios::out | ios::trunc); + + // Qstring to string + string password = ui->PasswordInput->text().toUtf8().constData(); + + if (password.length() <= 6){ + QMessageBox::information(this,"Error !","Your password is too short !"); + fSuccess = false; + stream.close(); + } + + // qstrings to utf8, add to byteArray and convert to const char for stream + string Secret = ui->SecretKeyInput->text().toUtf8().constData(); + string Key = ui->ApiKeyInput->text().toUtf8().constData(); + string ESecret = ""; + string EKey = ""; + + if (stream.is_open() && fSuccess) + { + ESecret = encryptDecrypt(Secret, password); + EKey = encryptDecrypt(Key, password); + stream << ESecret << '\n'; + stream << EKey; + stream.close(); + } + if (fSuccess) { + bool Save = true; + on_UpdateKeys_clicked(Save); + } +} + +void BittrexTradingTab::on_LoadKeys_clicked(){ + bool fSuccess = true; + boost::filesystem::path pathConfigFile = GetDataDir() / "APIcache.txt"; + boost::filesystem::ifstream stream (pathConfigFile.string()); + + // Qstring to string + string password = ui->PasswordInput->text().toUtf8().constData(); + + if (password.length() <= 6){ + QMessageBox::information(this,"Error !","Your password is too short !"); + fSuccess = false; + stream.close(); + } + + QString DSecret = ""; + QString DKey = ""; + + if (stream.is_open() && fSuccess) + { + int i =0; + for ( std::string line; std::getline(stream,line); ) + { + if (i == 0 ){ + DSecret = QString::fromUtf8(encryptDecrypt(line, password).c_str()); + ui->SecretKeyInput->setText(DSecret); + } else if (i == 1){ + DKey = QString::fromUtf8(encryptDecrypt(line, password).c_str()); + ui->ApiKeyInput->setText(DKey); + } + i++; + } + stream.close(); + } + if (fSuccess) { + bool Save = false; + bool Load = true; + on_UpdateKeys_clicked(Save, Load); + } +} + +void BittrexTradingTab::on_GenDepositBTN_clicked() { + QString response = GetDepositAddress(); + QJsonObject ResultObject = GetResultObjectFromJSONObject(response); + ui->DepositAddressLabel->setText(ResultObject["Address"].toString()); +} + +void BittrexTradingTab::on_Sell_Max_Amount_clicked() { + //calculate amount of BTC that can be gained from selling DNET available balance + QString responseA = GetBalance("DNET"); + QString str; + QJsonObject ResultObject = GetResultObjectFromJSONObject(responseA); + + double AvailableDNET = ResultObject["Available"].toDouble(); + + ui->UnitsInputDNET->setText(str.number(AvailableDNET,'i',8)); +} + +void BittrexTradingTab::on_Buy_Max_Amount_clicked() { + //calculate amount of currency than can be brought with the BTC balance available + QString responseA = GetBalance("BTC"); + QString responseB = GetMarketSummary(); + QString str; + + QJsonObject ResultObject = GetResultObjectFromJSONObject(responseA); + QJsonObject ResultObj = GetResultObjectFromJSONArray(responseB); + + //Get the Bid ask or last value from combo + QString value = ui->BuyBidcomboBox->currentText(); + + double AvailableBTC = ResultObject["Available"].toDouble(); + double CurrentASK = ResultObj[value].toDouble(); + double Result = (AvailableBTC / CurrentASK); + double percentofnumber = (Result * 0.0025); + + Result = Result - percentofnumber; + ui->UnitsInput->setText(str.number(Result,'i',8)); +} + +void BittrexTradingTab::on_CS_Max_Amount_clicked() { + double Quantity = ui->BittrexDNETLabel->text().toDouble(); + double Received = 0; + double Qty = 0; + double Price = 0; + QString buyorders = GetOrderBook(); + QJsonObject BuyObject = GetResultObjectFromJSONObject(buyorders); + QJsonObject obj; + QString str; + + QJsonArray BuyArray = BuyObject.value("buy").toArray(); //get buy/sell object from result object + + // For each buy order + Q_FOREACH (const QJsonValue & value, BuyArray) + { + obj = value.toObject(); + + double x = obj["Rate"].toDouble(); //would like to use int64 here + double y = obj["Quantity"].toDouble(); + // If + if ( (Quantity - y) > 0 ) + { + Price = x; + Received += ((Price * y) - ((Price * y / 100) * 0.25)); + Qty += y; + Quantity -= y; + + } else { + Price = x; + Received += ((Price * Quantity) - ((Price * Quantity / 100) * 0.25)); + Qty += Quantity; + + if ((Quantity * x) < 0.00055){ + Quantity = (0.00055 / x); + } + + break; + } + } + + ui->CSUnitsInput->setText(str.number(Received,'i',8)); +} + +void BittrexTradingTab::on_Withdraw_Max_Amount_clicked() { + //calculate amount of currency than can be brought with the BTC balance available + QString responseA = GetBalance("DNET"); + QString str; + + QJsonObject ResultObject = GetResultObjectFromJSONObject(responseA); + + double AvailableDNET = ResultObject["Available"].toDouble(); + + ui->WithdrawUnitsInput->setText(str.number(AvailableDNET,'i',8)); +} + +QJsonObject BittrexTradingTab::GetResultObjectFromJSONObject(QString response){ + + QJsonDocument jsonResponse = QJsonDocument::fromJson(response.toUtf8()); //get json from str. + QJsonObject ResponseObject = jsonResponse.object(); //get json obj + QJsonObject ResultObject = ResponseObject.value(QString("result")).toObject(); //get result object + + return ResultObject; +} + +QJsonObject BittrexTradingTab::GetResultObjectFromJSONArray(QString response){ + + QJsonDocument jsonResponsea = QJsonDocument::fromJson(response.toUtf8()); + QJsonObject jsonObjecta = jsonResponsea.object(); + QJsonArray jsonArraya = jsonObjecta["result"].toArray(); + QJsonObject obj; + + Q_FOREACH (const QJsonValue & value, jsonArraya) + { + obj = value.toObject(); + } + + return obj; +} + +QJsonArray BittrexTradingTab::GetResultArrayFromJSONObject(QString response){ + + QJsonDocument jsonResponse = QJsonDocument::fromJson(response.toUtf8()); + QJsonObject jsonObject = jsonResponse.object(); + QJsonArray jsonArray = jsonObject["result"].toArray(); + + return jsonArray; +} + +QString BittrexTradingTab::HMAC_SHA512_SIGNER(QString UrlToSign, QString Secret){ + + QString retval = ""; + + QByteArray byteArray = UrlToSign.toUtf8(); + const char* URL = byteArray.constData(); + + QByteArray byteArrayB = Secret.toUtf8(); + const char* Secretkey = byteArrayB.constData(); + + const EVP_MD *md = EVP_sha512(); + unsigned char* digest = NULL; + + // Using sha512 hash engine here. + digest = HMAC(md, Secretkey, strlen( Secretkey), (unsigned char*) URL, strlen( URL), NULL, NULL); + + // Be careful of the length of string with the choosen hash engine. SHA1 produces a 20-byte hash value which rendered as 40 characters. + // Change the length accordingly with your choosen hash engine + char mdString[129] = { 0 }; + + for(int i = 0; i < 64; i++){ + sprintf(&mdString[i*2], "%02x", (unsigned int)digest[i]); + } + retval = mdString; + //qDebug() << "HMAC digest:"<< retval; + + return retval; +} + +void BittrexTradingTab::on_SellBidcomboBox_currentIndexChanged(const QString &arg1){ + QString response = GetMarketSummary(); + QJsonObject ResultObject = GetResultObjectFromJSONArray(response); + QString Str; + + //Get the Bid ask or last value from combo + ui->SellBidPriceEdit->setText(Str.number(ResultObject[arg1].toDouble(),'i',8)); + + CalculateSellCostLabel(); //update cost +} + +void BittrexTradingTab::on_BuyBidcomboBox_currentIndexChanged(const QString &arg1){ + QString response = GetMarketSummary(); + QJsonObject ResultObject = GetResultObjectFromJSONArray(response); + QString Str; + + //Get the Bid ask or last value from combo + ui->BuyBidPriceEdit->setText(Str.number(ResultObject[arg1].toDouble(),'i',8)); + + CalculateBuyCostLabel(); //update cost +} + +void BittrexTradingTab::on_BuyDNET_clicked(){ + double Rate; + double Quantity; + + Rate = ui->BuyBidPriceEdit->text().toDouble(); + Quantity = ui->UnitsInput->text().toDouble(); + + QString OrderType = "Limit"; + QString Order; + + if(OrderType == "Limit"){Order = "buylimit";}else if (OrderType == "Market"){ Order = "buymarket";} + + QString Msg = "Are you sure you want to buy "; + Msg += ui->UnitsInput->text(); + Msg += "DNET @ "; + Msg += ui->BuyBidPriceEdit->text(); + Msg += " BTC Each"; + + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this,"Buy Order",Msg,QMessageBox::Yes|QMessageBox::No); + + if (reply == QMessageBox::Yes) { + + QString Response = BuyDNET(Order,Quantity,Rate); + + QJsonDocument jsonResponse = QJsonDocument::fromJson(Response.toUtf8()); //get json from str. + QJsonObject ResponseObject = jsonResponse.object(); //get json obj + + if (ResponseObject["success"].toBool() == false){ + QMessageBox::information(this,"Buy Order Failed",ResponseObject["message"].toString()); + + }else if (ResponseObject["success"].toBool() == true){ + QMessageBox::information(this,"Buy Order Initiated","You Placed an order"); + } + }else{ + //do nothing + } +} + +void BittrexTradingTab::on_SellDNETBTN_clicked(){ + double Rate; + double Quantity; + + Rate = ui->SellBidPriceEdit->text().toDouble(); + Quantity = ui->UnitsInputDNET->text().toDouble(); + + QString OrderType = "Limit"; + QString Order; + + if(OrderType == "Limit"){Order = "selllimit";}else if (OrderType == "Market"){ Order = "sellmarket";} + + QString Msg = "Are you sure you want to Sell "; + Msg += ui->UnitsInputDNET->text(); + Msg += " DNET @ "; + Msg += ui->SellBidPriceEdit->text(); + Msg += " BTC Each"; + + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this,"Sell Order",Msg,QMessageBox::Yes|QMessageBox::No); + + if (reply == QMessageBox::Yes) { + + QString Response = SellDNET(Order,Quantity,Rate); + QJsonDocument jsonResponse = QJsonDocument::fromJson(Response.toUtf8()); //get json from str. + QJsonObject ResponseObject = jsonResponse.object(); //get json obj + + if (ResponseObject["success"].toBool() == false){ + QMessageBox::information(this,"Sell Order Failed",ResponseObject["message"].toString()); + + }else if (ResponseObject["success"].toBool() == true){ + QMessageBox::information(this,"Sell Order Initiated","You Placed an order"); + } + }else{ + //do nothing + } +} + +void BittrexTradingTab::on_CSUnitsBtn_clicked(){ + double Quantity = ui->CSUnitsInput->text().toDouble(); + double Rate = ui->CSDumpLabel->text().toDouble(); + double Received = 0; + double Qty = 0; + double Price = 0; + double Add = 0; + + QString buyorders = GetOrderBook(); + QJsonObject BuyObject = GetResultObjectFromJSONObject(buyorders); + QJsonObject obj; + QString Astr; + QString Qstr; + QString Rstr; + QString Coin = "BTC"; + QString Msg = "Are you sure you want to Send "; + Msg += Qstr.number((Quantity - 0.0002),'i',8); + Msg += " BTC to "; + Msg += ui->CSUnitsAddress->text(); + Msg += ", DUMPING your coins at "; + Msg += Rstr.number(Rate,'i',8); + Msg += " satoshis ?"; + + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this,"Cross-Send",Msg,QMessageBox::Yes|QMessageBox::No); + + if(reply != QMessageBox::Yes) + { + return; + } + + bool relock = true; + + WalletModel::UnlockContext ctx(model->requestUnlock(relock)); + if(!ctx.isValid()) + { + // Unlock wallet was cancelled + return; + } + + QString Order = "selllimit"; + QJsonArray BuyArray = BuyObject.value("buy").toArray(); //get buy/sell object from result object + + // For each buy order + Q_FOREACH (const QJsonValue & value, BuyArray) + { + obj = value.toObject(); + + double x = obj["Rate"].toDouble(); //would like to use int64 here + double y = obj["Quantity"].toDouble(); + // If + if ( ((Quantity / x) - y) > 0 ) + { + Price = x; + Received += ((Price * y) - ((Price * y / 100) * 0.25)); + Qty += y; + Quantity -= ((Price * y) - ((Price * y / 100) * 0.25)); + + QString SellResponse = SellDNET(Order,y,x); + QJsonDocument SelljsonResponse = QJsonDocument::fromJson(SellResponse.toUtf8()); //get json from str. + QJsonObject SellResponseObject = SelljsonResponse.object(); //get json obj + + if (SellResponseObject["success"].toBool() == false){ + if (SellResponseObject["message"].toString() == "DUST_TRADE_DISALLOWED_MIN_VALUE_50K_SAT"){ + Add += y; + continue; + } + QMessageBox::information(this,"sFailed",SellResponse); + break; + } + MilliSleep(100); + + } else { + Price = x; + Received += ((Price * (Quantity / x)) - ((Price * (Quantity / x) / 100) * 0.25)); + Qty += (Quantity / x); + if (Add > 0) + Quantity += (Add * x); + if (Quantity < 0.00051){ + Quantity = 0.00051; + } + QString SellResponse = SellDNET(Order,(Quantity / x),x); + QJsonDocument SelljsonResponse = QJsonDocument::fromJson(SellResponse.toUtf8()); //get json from str. + QJsonObject SellResponseObject = SelljsonResponse.object(); //get json obj + + if (SellResponseObject["success"].toBool() == false){ + QMessageBox::information(this,"sFailed",SellResponse); + + } else if (SellResponseObject["success"].toBool() == true){ + MilliSleep(5000); + QString Response = Withdraw(ui->CSUnitsInput->text().toDouble(),ui->CSUnitsAddress->text(),Coin); + QJsonDocument jsonResponse = QJsonDocument::fromJson(Response.toUtf8()); //get json from str. + QJsonObject ResponseObject = jsonResponse.object(); //get json obj + + if (ResponseObject["success"].toBool() == false){ + MilliSleep(5000); + QString Response = Withdraw(ui->CSUnitsInput->text().toDouble(),ui->CSUnitsAddress->text(),Coin); + QJsonDocument jsonResponse = QJsonDocument::fromJson(Response.toUtf8()); //get json from str. + QJsonObject ResponseObject = jsonResponse.object(); + + if (ResponseObject["success"].toBool() == false){ + QMessageBox::information(this,"Failed",ResponseObject["message"].toString()); + } else if (ResponseObject["success"].toBool() == true){ + QMessageBox::information(this,"Success","
Cross-Send Successful
\n Sold "+Astr.number(Qty,'i',4)+" DNET for "+Qstr.number((ui->CSUnitsInput->text().toDouble()-0.0002),'i',8)+" BTC"); + } + } else if (ResponseObject["success"].toBool() == true){ + QMessageBox::information(this,"Success","
Cross-Send Successful
\n Sold "+Astr.number(Qty,'i',4)+" DNET for "+Qstr.number((ui->CSUnitsInput->text().toDouble()-0.0002),'i',8)+" BTC"); + } + } + break; + } + } +} + +void BittrexTradingTab::on_WithdrawUnitsBtn_clicked(){ + double Quantity = ui->WithdrawUnitsInput->text().toDouble(); + QString Qstr; + QString Coin = "DNET"; + QString Msg = "Are you sure you want to Withdraw "; + Msg += Qstr.number((Quantity - 0.02),'i',8); + Msg += " DNET to "; + Msg += ui->WithdrawAddress->text(); + Msg += " ?"; + + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this,"Withdraw",Msg,QMessageBox::Yes|QMessageBox::No); + + if(reply != QMessageBox::Yes) + { + return; + } + + bool relock = true; + + WalletModel::UnlockContext ctx(model->requestUnlock(relock)); + if(!ctx.isValid()) + { + // Unlock wallet was cancelled + return; + } + + QString Response = Withdraw(Quantity, ui->WithdrawAddress->text(), Coin); + QJsonDocument jsonResponse = QJsonDocument::fromJson(Response.toUtf8()); //get json from str. + QJsonObject ResponseObject = jsonResponse.object(); //get json obj + + if (ResponseObject["success"].toBool() == false){ + QMessageBox::information(this,"Failed",ResponseObject["message"].toString()); + + }else if (ResponseObject["success"].toBool() == true){ + QMessageBox::information(this,"Success","Withdrawal Successful !"); + } +} + +void BittrexTradingTab::on_UnitsInputDNET_textChanged(const QString &arg1) +{ + CalculateSellCostLabel(); //update cost +} + +void BittrexTradingTab::on_UnitsInput_textChanged(const QString &arg1) +{ + CalculateBuyCostLabel(); //update cost +} + +void BittrexTradingTab::on_BuyBidPriceEdit_textChanged(const QString &arg1) +{ + CalculateBuyCostLabel(); //update cost +} + +void BittrexTradingTab::on_SellBidPriceEdit_textChanged(const QString &arg1) +{ + CalculateSellCostLabel(); +} + +void BittrexTradingTab::on_CSUnitsInput_textChanged(const QString &arg1) +{ + CalculateCSReceiveLabel(); //update cost +} + +void BittrexTradingTab::on_CSPasteButton_clicked() +{ + // Paste text from clipboard into recipient field + ui->CSUnitsAddress->setText(QApplication::clipboard()->text()); +} + +void BittrexTradingTab::on_WithdrawPasteButton_clicked() +{ + // Paste text from clipboard into recipient field + ui->WithdrawAddress->setText(QApplication::clipboard()->text()); +} + +void BittrexTradingTab::on_SecretPasteButton_clicked() +{ + // Paste text from clipboard into recipient field + ui->SecretKeyInput->setText(QApplication::clipboard()->text()); +} + +void BittrexTradingTab::on_KeyPasteButton_clicked() +{ + // Paste text from clipboard into recipient field + ui->ApiKeyInput->setText(QApplication::clipboard()->text()); +} + +void setClipboard(const QString& str) +{ + QApplication::clipboard()->setText(str, QClipboard::Clipboard); + QApplication::clipboard()->setText(str, QClipboard::Selection); +} + +void BittrexTradingTab::on_DepositCopyButton_clicked() +{ + // + setClipboard(ui->DepositAddressLabel->text()); +} + +void BittrexTradingTab::setModel(WalletModel *model) +{ + // set model + this->model = model; +} + diff --git a/src/qt/bittrextradingtab.h b/src/qt/bittrextradingtab.h new file mode 100644 index 000000000000..fc1c57c31d0f --- /dev/null +++ b/src/qt/bittrextradingtab.h @@ -0,0 +1,130 @@ +#ifndef BITTREXTRADINGTAB_H +#define BITTREXTRADINGTAB_H + +#include "clientmodel.h" +#include "walletmodel.h" + + +#include +#include +#include +#include + +#include +#include +#include + +class WalletModel; + +namespace Ui { + class BittrexTradingTab; +} + +QT_BEGIN_NAMESPACE +class QFrame; +class QTableView; +class QItemSelection; +class QTableWidget; +class QSortFilterProxyModel; +class QMenu; +class QModelIndex; +class QLabel; +class QTimer; +class QString; +QT_END_NAMESPACE + +/** Page for Bittrex trading */ +class BittrexTradingTab : public QWidget +{ + Q_OBJECT + +public: + explicit BittrexTradingTab(QWidget *parent = 0); + ~BittrexTradingTab(); + + void setModel(WalletModel *walletModel); + +private: + Ui::BittrexTradingTab *ui; + // QMenu *contextMenu; + int timerid; + QTimer *timer; + QString ApiKey; + QString SecretKey; + WalletModel *model; + +public Q_SLOTS: + // void exportClicked(); + +private Q_SLOTS: + + void InitTrading(); + void on_TradingTabWidget_tabBarClicked(int index); + void ParseAndPopulateOrderBookTables(QString Response); + void ParseAndPopulateMarketHistoryTable(QString Response); + void ParseAndPopulateAccountHistoryTable(QString Response); + void ParseAndPopulateOpenOrdersTable(QString Response); + void UpdaterFunction(); + void CreateOrderBookTables(QTableWidget& Table,QStringList TableHeader); + void DisplayBalance(QLabel &BalanceLabel,QLabel &Available, QLabel &Pending, QString Currency,QString Response); + void DisplayBalance(QLabel &BalanceLabel, QLabel &BalanceLabel2, QString Response, QString Response2); + void DisplayBalance(QLabel &BalanceLabel, QString Response); + void ActionsOnSwitch(int index); + void CancelOrderSlot(int row, int col); + void on_UpdateKeys_clicked(bool Save=false, bool Load=false); + void on_LoadKeys_clicked(); + void on_SaveKeys_clicked(); + void on_GenDepositBTN_clicked(); + + void CalculateBuyCostLabel(); + void on_Buy_Max_Amount_clicked(); + void on_BuyBidcomboBox_currentIndexChanged(const QString &arg1); + void on_UnitsInput_textChanged(const QString &arg1); + void on_BuyBidPriceEdit_textChanged(const QString &arg1); + void on_BuyDNET_clicked(); + + void CalculateSellCostLabel(); + void on_Sell_Max_Amount_clicked(); + void on_SellBidcomboBox_currentIndexChanged(const QString &arg1); + void on_UnitsInputDNET_textChanged(const QString &arg1); + void on_SellBidPriceEdit_textChanged(const QString &arg1); + void on_SellDNETBTN_clicked(); + + void CalculateCSReceiveLabel(); + void on_CSUnitsInput_textChanged(const QString &arg1); + void on_CSUnitsBtn_clicked(); + void on_CS_Max_Amount_clicked(); + + void on_Withdraw_Max_Amount_clicked(); + void on_WithdrawUnitsBtn_clicked(); + + void on_KeyPasteButton_clicked(); + void on_SecretPasteButton_clicked(); + void on_CSPasteButton_clicked(); + void on_WithdrawPasteButton_clicked(); + void on_DepositCopyButton_clicked(); + + int SetExchangeInfoTextLabels(); + + QString BittrexTimeStampToReadable(QString DateTime); + QString CancelOrder(QString Orderid); + QString BuyDNET(QString OrderType, double Quantity, double Rate); + QString SellDNET(QString OrderType, double Quantity, double Rate); + QString Withdraw(double Amount, QString Address, QString Coin); + QString GetMarketHistory(); + QString GetMarketSummary(); + QString GetOrderBook(); + QString GetOpenOrders(); + QString GetAccountHistory(); + QString GetBalance(QString Currency); + QString GetDepositAddress(); + QString HMAC_SHA512_SIGNER(QString UrlToSign,QString Secretkey); + QString sendRequest(QString url); + std::string encryptDecrypt(std::string toEncrypt, std::string password); + QJsonObject GetResultObjectFromJSONObject(QString response); + QJsonObject GetResultObjectFromJSONArray(QString response); + QJsonArray GetResultArrayFromJSONObject(QString response); + +}; + +#endif // BITTREXTRADINGTAB_H diff --git a/src/qt/darknet.qrc b/src/qt/darknet.qrc index b21c40c4c930..7d01f07ded7a 100644 --- a/src/qt/darknet.qrc +++ b/src/qt/darknet.qrc @@ -32,6 +32,7 @@ res/icons/export.png res/icons/synced.png res/icons/remove.png + res/icons/trade.png res/icons/tx_mined.png res/icons/tx_input.png res/icons/tx_output.png diff --git a/src/qt/forms/bittrextradingtab.ui b/src/qt/forms/bittrextradingtab.ui new file mode 100644 index 000000000000..1d18da634aac --- /dev/null +++ b/src/qt/forms/bittrextradingtab.ui @@ -0,0 +1,5598 @@ + + + BittrexTradingTab + + + + 0 + 0 + 850 + 553 + + + + + 16777215 + 16777215 + + + + Bittrex + + + + + 0 + 0 + 840 + 540 + + + + color: black; background: #0000000; border: none; + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + 0 + 0 + + + + + 849 + 35 + + + + + 16777215 + 220 + + + + QFrame::NoFrame + + + QFrame::Raised + + + 0 + + + + + + + + + 0 + 0 + + + + + 8 + 50 + false + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 0 + 0 + + + + + 8 + 50 + false + + + + 0.000000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 0 + 0 + + + + + 8 + 50 + false + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 0 + 0 + + + + + 8 + 50 + false + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + + + + + true + + + + 50 + false + + + + QTabWidget::North + + + QTabWidget::Rounded + + + 0 + + + + Trade + + + + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + + 9 + 50 + false + + + + QAbstractItemView::NoEditTriggers + + + false + + + false + + + true + + + false + + + QAbstractItemView::NoSelection + + + + + + + + 75 + true + + + + Qt::LeftToRight + + + false + + + Units + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + + + + + 75 + true + + + + BTC Available: + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + 75 + true + + + + BTC + + + + + + + + + + + + 75 + true + + + + DNET Available: + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + 75 + true + + + + DNET + + + + + + + + + + 10 + + + + Max + + + + + + + + 0 + 0 + + + + + 9 + 75 + true + + + + + + + + DNET + + + + + + + + 10 + + + + Max + + + + + + + + 0 + 0 + + + + + 9 + 75 + true + + + + + + + + DNET + + + + + + + + 75 + true + + + + Bid + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 10 + + + + + + + + + 0 + 0 + + + + + 9 + 75 + true + + + + + + + + BTC + + + + + + + + 10 + + + + + + + + + 0 + 0 + + + + + 9 + 75 + true + + + + + + + + BTC + + + + + + + + + + 75 + true + + + + Total w/ 0.25% Fee + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 50 + false + + + + BTC + + + + + + + + + + + + 75 + true + + + + Total w/ 0.25% Fee + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 50 + false + + + + BTC + + + + + + + + + Buy DNET + + + + + + + Sell DNET + + + + + + + + 0 + 0 + + + + + 9 + 50 + false + + + + QAbstractItemView::NoEditTriggers + + + false + + + false + + + true + + + false + + + QAbstractItemView::NoSelection + + + + + + + 0.00000000 BTC + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Asks: 0000 + + + + + + + 0.00000000 BTC + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 8 + + + + Demand: 0.00000000 DNET + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Supply: 0.00000000 DNET + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Bids: 0000 + + + + + + + + Send + + + + + + + + + 10 + 75 + true + + + + Lowest price: + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 10 + 75 + true + + + + false + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 50 + false + + + + BTC + + + + + + + + + + + + 10 + 75 + true + + + + Amount in DNET: + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 10 + 75 + true + + + + false + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 50 + false + + + + DNET + + + + + + + + + + + + 10 + 75 + true + + + + Total w/ Fees : + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 10 + 75 + true + + + + false + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 50 + false + + + + BTC + + + + + + + + + Send + + + + + + + + 10 + 50 + false + + + + + + + + + + + + 10 + 50 + false + + + + <html><head/><body><p><span style=" font-size:9pt; font-weight:600;">Warning:</span><span style=" font-size:9pt;"> This feature is in </span><span style=" font-size:9pt; font-weight:600;">ALPHA ! USE AT OWN RISK !</span></p></body></html> + + + + + + + + 10 + 50 + false + + + + <html><head/><body><p align="center"><span style=" font-weight:600; text-decoration: underline;">Instructions:</span></p><p align="center">To use the cross sending feature you need to have </p><p align="center">DNET available to spend on Bittrex. If you don't have any </p><p align="center">you can find your deposit address on the &quot;Balance&quot; tab.</p><p align="center">1. Enter the amount you want to receive in Bitcoin.</p><p align="center">2. Enter the Bitcoin address you are sending to.</p><p align="center">3. Check that the Total with fee's is correct.</p><p align="center">4. Press send and watch the magic happen.</p><p align="center"><span style=" font-weight:600; text-decoration: underline;">Notes.</span></p><p align="center"><span style=" font-size:7pt;">Total w/ fees: N/A means you dont have enough DNET to sell !</span></p><p align="center"><span style=" font-size:7pt;">All trades are done through Bittrex using your own balance and API keys.</span></p><p align="center"><span style=" font-size:7pt;">Encrypt and backup your wallet when using this feature.</span></p><p align="center"><span style=" font-size:7pt;">If you don't have a password you bittrex account will be accessible 24/7</span></p><p align="center"><span style=" font-size:7pt;">Withdrawal fee of 0.002 and 0.25% taken by Bittrex.</span></p></body></html> + + + + + + + + 10 + 75 + true + + + + Amount: + + + + + + + Qt::Horizontal + + + + 212 + 368 + + + + + + + + + 10 + 75 + true + + + + + + + + + 10 + 75 + true + + + + Address: + + + + + + + + + + 10 + 75 + true + + + + DNET Balance: + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 10 + 75 + true + + + + false + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 50 + false + + + + DNET + + + + + + + + + + + + 10 + 75 + true + + + + BTC Balance: + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 10 + 75 + true + + + + false + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 50 + false + + + + BTC + + + + + + + + + + 10 + + + + Max + + + + + + + + 10 + 75 + true + + + + + + + + Paste from clipboard + + + + + + + :/icons/editpaste:/icons/editpaste + + + Alt+P + + + + + + + + 18 + 75 + true + + + + Cross-Send + + + Qt::AlignCenter + + + + + + + Qt::Vertical + + + + 915 + 73 + + + + + + CSUnitsInput + CSUnitsAddress + CSUnitsBtn + CS_Max_Amount + CSPasteButton + + + + Market History + + + + + + + + + + Open Orders + + + + + + + + + + Trade history + + + + + + + + + + Balance + + + + + + + 10 + 75 + true + + + + DNET Balance: + + + + + + + + 10 + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 75 + true + + + + BTC Balance: + + + + + + + + 10 + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + Qt::Horizontal + + + + 478 + 488 + + + + + + + + + 10 + 75 + true + + + + DNET Available: + + + + + + + + 10 + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 75 + true + + + + BTC Available: + + + + + + + + 10 + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 75 + true + + + + DNET Pending: + + + + + + + + 10 + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 75 + true + + + + BTC Pending: + + + + + + + + 10 + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + + + + Generate DNET Coin Deposit Address + + + + + + + + 10 + 75 + true + + + + Deposit Address: + + + + + + + + 300 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 10 + 75 + true + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Copy to clipboard + + + + + + + :/icons/editcopy:/icons/editcopy + + + Alt+P + + + + + + + + 10 + 75 + true + + + + Withdraw DNET: + + + + + + + + 10 + 75 + true + + + + Amount: + + + + + + + + 9 + 75 + true + + + + + + + + + + + + 10 + + + + Max + + + + + + + + 10 + 75 + true + + + + Address: + + + + + + + + 9 + 75 + true + + + + + + + + Paste from clipboard + + + + + + + :/icons/editpaste:/icons/editpaste + + + Alt+P + + + + + + + + 10 + + + + Withdraw + + + + + + + Qt::Vertical + + + + 428 + 262 + + + + + + + + + Settings + + + + + + + 75 + true + + + + API Key + + + + + + + + + + + + + + Paste from clipboard + + + + + + + :/icons/editpaste:/icons/editpaste + + + Alt+P + + + + + + + Qt::Horizontal + + + + 519 + 488 + + + + + + + + + 75 + true + + + + Secret Key + + + + + + + + + + Paste from clipboard + + + + + + + :/icons/editpaste:/icons/editpaste + + + Alt+P + + + + + + + + 75 + true + + + + Password + + + + + + + QLineEdit::Password + + + + + + + + 120 + 0 + + + + Load API Keys + + + + + + + + 135 + 0 + + + + Update API Keys + + + + + + + + 115 + 0 + + + + Save API Keys + + + + + + + Qt::Vertical + + + + 358 + 247 + + + + + + + + + 10 + 50 + false + + + + <html><head/><body><p>Loading keys:</p><p>1) Enter Password</p><p>2) Load API Keys</p><p>3) Start trading on Bittrex</p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 10 + 50 + false + + + + <html><head/><body><p>Saving keys:</p><p>1) Enter in API Keys found at <a href="https://bittrex.com/Account/ManageApiKey"><span style=" text-decoration: underline; color:#0000ff;">Bittrex</span></a></p><p>2) Enter Password</p><p>3) Save API Keys</p><p>4) Start trading on Bittrex</p></body></html> + + + + + + + + + + + + + + + diff --git a/src/qt/res/icons/trade.png b/src/qt/res/icons/trade.png new file mode 100644 index 000000000000..977847eda472 Binary files /dev/null and b/src/qt/res/icons/trade.png differ diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp index d2b1faaf67e9..abd624d135ff 100644 --- a/src/qt/walletframe.cpp +++ b/src/qt/walletframe.cpp @@ -133,6 +133,13 @@ void WalletFrame::gotoSendCoinsPage(QString addr) i.value()->gotoSendCoinsPage(addr); } +void WalletFrame::gotoBittrexTradingTab() +{ + QMap::const_iterator i; + for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) + i.value()->gotoBittrexTradingTab(); +} + void WalletFrame::gotoSignMessageTab(QString addr) { WalletView *walletView = currentWalletView(); diff --git a/src/qt/walletframe.h b/src/qt/walletframe.h index 57b377b9efef..a8a0c42055a7 100644 --- a/src/qt/walletframe.h +++ b/src/qt/walletframe.h @@ -56,6 +56,8 @@ public slots: void gotoReceiveCoinsPage(); /** Switch to send coins page */ void gotoSendCoinsPage(QString addr = ""); + /** Switch to manage names page */ + void gotoBittrexTradingTab(); /** Show Sign/Verify Message dialog and switch to sign message tab */ void gotoSignMessageTab(QString addr = ""); diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index 652385958b37..f1ec547b548c 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -17,6 +17,7 @@ #include "transactiontablemodel.h" #include "transactionview.h" #include "walletmodel.h" +#include "bittrextradingtab.h" #include "ui_interface.h" @@ -67,11 +68,13 @@ WalletView::WalletView(QWidget *parent): receiveCoinsPage = new ReceiveCoinsDialog(); sendCoinsPage = new SendCoinsDialog(); + bittrextradingTab = new BittrexTradingTab(this); addWidget(overviewPage); addWidget(transactionsPage); addWidget(receiveCoinsPage); addWidget(sendCoinsPage); + addWidget(bittrextradingTab); // Clicking on a transaction on the overview pre-selects the transaction on the transaction history page connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), transactionView, SLOT(focusTransaction(QModelIndex))); @@ -130,6 +133,7 @@ void WalletView::setWalletModel(WalletModel *walletModel) overviewPage->setWalletModel(walletModel); receiveCoinsPage->setModel(walletModel); sendCoinsPage->setModel(walletModel); + bittrextradingTab->setModel(walletModel); if (walletModel) { @@ -193,6 +197,11 @@ void WalletView::gotoSendCoinsPage(QString addr) sendCoinsPage->setAddress(addr); } +void WalletView::gotoBittrexTradingTab() +{ + setCurrentWidget(bittrextradingTab); +} + void WalletView::gotoSignMessageTab(QString addr) { // calls show() in showTab_SM() diff --git a/src/qt/walletview.h b/src/qt/walletview.h index 691875396bc0..fb4838074356 100644 --- a/src/qt/walletview.h +++ b/src/qt/walletview.h @@ -15,6 +15,7 @@ class OverviewPage; class ReceiveCoinsDialog; class SendCoinsDialog; class SendCoinsRecipient; +class BittrexTradingTab; class TransactionView; class WalletModel; @@ -61,6 +62,7 @@ class WalletView : public QStackedWidget QWidget *transactionsPage; ReceiveCoinsDialog *receiveCoinsPage; SendCoinsDialog *sendCoinsPage; + BittrexTradingTab *bittrextradingTab; TransactionView *transactionView; @@ -82,6 +84,9 @@ public slots: /** Show Sign/Verify Message dialog and switch to verify message tab */ void gotoVerifyMessageTab(QString addr = ""); + /** Go to Bittrex trading tab */ + void gotoBittrexTradingTab(); + /** Show incoming transaction notification for new transactions. The new items are those between start and end inclusive, under the given parent item.