diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 0164774..91ba746 100755 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -37,13 +37,15 @@ namespace Checkpoints boost::assign::map_list_of ( 0, uint256("0x2e28050194ad73f2405394d2f081361a23c2df8904ec7f026a018bbe148d5adf")) ( 2672, uint256("0xe31f98339ec0c628bcc5bd20aef177bdef83deb7a606528c8977ad3a1f511906")) - ( 29000, uint256("0x63a67152f31a4596fc6ca5073ffe4cf68264922e740285f0ae7b3bb8cbc66b39")) + ( 29000, uint256("0x63a67152f31a4596fc6ca5073ffe4cf68264922e740285f0ae7b3bb8cbc66b39")) + ( 60000, uint256("0x8ac508122d4f7b290c19cb45be6e071e7aace53cd043a892e79041672c1ba99d")) + ; static const CCheckpointData data = { &mapCheckpoints, - 1428497654, // * UNIX timestamp of last checkpoint block - 108399, // * total number of transactions between genesis and last checkpoint + 1448101689, // * UNIX timestamp of last checkpoint block + 176760, // * total number of transactions between genesis and last checkpoint // (the tx=... number in the SetBestChain debug.log lines) 12000.0 // * estimated number of transactions per day after checkpoint }; diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 28d9469..fcee0ef 100755 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -566,6 +566,7 @@ void BitcoinGUI::setWalletModel(WalletModel *walletModel) signVerifyMessageDialog->setModel(walletModel); miningPage->setModel(clientModel); blockBrowser->setModel(clientModel); + tradingDialogPage->setModel(walletModel); setEncryptionStatus(walletModel->getEncryptionStatus()); connect(walletModel, SIGNAL(encryptionStatusChanged(int)), this, SLOT(setEncryptionStatus(int))); diff --git a/src/qt/forms/tradingdialog.ui b/src/qt/forms/tradingdialog.ui index fb96232..f5d8490 100644 --- a/src/qt/forms/tradingdialog.ui +++ b/src/qt/forms/tradingdialog.ui @@ -20,9 +20,9 @@ 10 - 40 + 50 831 - 431 + 421 @@ -34,21 +34,21 @@ QTabWidget::North - + QTabWidget::Rounded - 6 + 1 - Buy + Trade - 30 - 330 + 140 + 240 75 23 @@ -79,9 +79,9 @@ - 330 + 150 110 - 451 + 101 23 @@ -96,9 +96,9 @@ - 330 + 150 140 - 451 + 101 23 @@ -113,7 +113,7 @@ - 790 + 260 110 31 23 @@ -126,7 +126,7 @@ - 790 + 260 140 21 23 @@ -177,9 +177,9 @@ - 129 + 80 110 - 191 + 61 23 @@ -195,9 +195,9 @@ - 129 + 80 140 - 191 + 61 23 @@ -210,9 +210,9 @@ - 129 + 80 170 - 191 + 61 23 @@ -225,10 +225,10 @@ - 21 + 20 11 - 180 - 15 + 221 + 16 @@ -691,18 +691,18 @@ - + - 11 - 301 - 209 - 15 + 10 + 300 + 271 + 16 - + - + 75 @@ -710,7 +710,7 @@ - Total w/ 0.25% Fee + Total w/ 0.25% Fee @@ -1141,7 +1141,7 @@ false - 0.00000000 + 0.00000000 Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse @@ -1149,7 +1149,7 @@ - + 50 @@ -1157,202 +1157,19 @@ - BTC + BTC - - - - Sell - - - - - 790 - 140 - 21 - 23 - - - - BTC - - - - - - 129 - 140 - 191 - 23 - - - - - 10 - - - - - - - 10 - 110 - 46 - 23 - - - - - 75 - true - - - - Units - - - - - - 129 - 110 - 191 - 23 - - - - - 10 - - - - Max - - - - - - 10 - 170 - 71 - 16 - - - - - 75 - true - - - - Order Type - - - - - - 129 - 170 - 191 - 23 - - - - - 10 - - - - - - - 10 - 140 - 46 - 23 - - - - - 75 - true - - - - Bid - - - - - - 790 - 110 - 31 - 23 - - - - BSTY - - - - - - 330 - 110 - 451 - 23 - - - - - 9 - 75 - true - - - - + 330 - 140 - 451 - 23 - - - - - 9 - 75 - true - - - - - - - 30 - 330 - 75 - 23 - - - - Sell BSTY - - - - - - 22 - 12 - 200 - 15 + 10 + 221 + 16 @@ -1815,74 +1632,182 @@ - + - 10 - 300 - 218 - 15 + 380 + 110 + 61 + 23 - - - - - - 75 - true - - - - Total w/ 0.25% Fee - - - - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 + + + 10 + + + + Max + + + + + + 450 + 110 + 101 + 23 + + + + + 9 + 75 + true + + + + + + + 560 + 110 + 31 + 23 + + + + BSTY + + + + + + 380 + 140 + 61 + 23 + + + + + 10 + + + + + + + 450 + 140 + 101 + 23 + + + + + 9 + 75 + true + + + + + + + 560 + 140 + 21 + 23 + + + + BTC + + + + + + 380 + 170 + 61 + 23 + + + + + 10 + + + + + + + 320 + 300 + 271 + 16 + + + + + + + + 75 + true + + + + Total w/ 0.25% Fee + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 85 0 @@ -2287,6 +2212,1803 @@ + + + + 440 + 240 + 75 + 23 + + + + Sell BSTY + + + + + + Send + + + + + 140 + 70 + 101 + 23 + + + + + 9 + 75 + true + + + + + + + 60 + 0 + 171 + 31 + + + + + 18 + 75 + true + + + + Cross-Send + + + + + + 10 + 140 + 271 + 16 + + + + + + + + 75 + true + + + + Total w/ Fees : + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 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 + 170 + 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 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 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 + + + + + + + + + 70 + 100 + 311 + 23 + + + + + 9 + 75 + true + + + + + + + 10 + 100 + 61 + 23 + + + + + 75 + true + + + + Address: + + + + + + 270 + 70 + 21 + 23 + + + + BTC + + + + + + 90 + 180 + 75 + 23 + + + + Send + + + + + + 10 + 230 + 491 + 31 + + + + + 10 + 50 + false + + + + <html><head/><body><p><span style=" font-size:9pt;">Sending will </span><span style=" font-size:9pt; font-weight:600;">SELL</span><span style=" font-size:9pt;"> your available </span><span style=" font-size:9pt; font-weight:600;">BSTY</span><span style=" font-size:9pt;"> to </span><span style=" font-size:9pt; font-weight:600;">RECEIVE Bitcoin</span><span style=" font-size:9pt;">.</span></p></body></html> + + + + + + 10 + 250 + 431 + 31 + + + + + 10 + 50 + false + + + + <html><head/><body><p><span style=" font-size:9pt;">By using this feature you acknowledge that a minimum withdrawal fee</span></p></body></html> + + + + + + 10 + 270 + 431 + 31 + + + + + 10 + 50 + false + + + + <html><head/><body><p><span style=" font-size:9pt;">of 0.002 and 0.25% will be taken by Bittrex for using their services</span></p></body></html> + + + + + + 10 + 290 + 431 + 31 + + + + + 10 + 50 + false + + + + + + + + + + 10 + 160 + 271 + 16 + + + + + + + + 75 + true + + + + Lowest price: + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 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 + 170 + 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 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 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 + + + + + + + + + 10 + 350 + 81 + 21 + + + + + 10 + 75 + true + + + + REMINDER: + + + + + + 100 + 360 + 301 + 21 + + + + + 8 + 50 + false + + + + if you dont have a password your bittrex acount will + + + + + + 100 + 350 + 301 + 16 + + + + + 8 + 50 + false + + + + Encrypt and backup your wallet when using this feature, + + + + + + 100 + 370 + 301 + 21 + + + + + 8 + 50 + false + + + + be accessible 24/7 + + + + + + 80 + 70 + 61 + 23 + + + + + 75 + true + + + + Amount: + + + + + + 10 + 210 + 491 + 31 + + + + + 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 + 290 + 431 + 31 + + + + + 10 + 50 + false + + + + <html><head/><body><p><span style=" font-size:9pt;">Careful when sending large amounts while in </span><span style=" font-size:9pt; font-weight:600;">APLHA</span><span style=" font-size:9pt;"> !</span></p></body></html> + + + + + + 440 + 0 + 371 + 371 + + + + + 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">BSTY 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.</span></p><p align="center"><span style=" font-size:7pt;">N/A means you dont have enough BSTY 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;">The only 3rd party that needs to be trusted in this instance is the exchange !</span></p></body></html> + + + + + + 11 + 41 + 161 + 16 + + + + + 75 + true + + + + BSTY Available on Bittrex: + + + + + + 180 + 41 + 72 + 16 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 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 + 170 + 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 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 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 + + + + + + 10 + 70 + 61 + 23 + + + + + 10 + + + + Max + + + label232_3 + BSTYAvailableLabel_3 + CSUnitsInput + label232_4 + layoutWidget_6 + CSUnitsAddress + label_8 + label_9 + CSUnitsBtn + label232_5 + label232_8 + layoutWidget_7 + label232_9 + label232_10 + label232_11 + label232_12 + label_27 + label232_13 + label232_14 + label232_15 + label232_6 + label232_7 + CS_Max_Amount @@ -2336,7 +4058,7 @@ - Bids + Bids: 0000 @@ -2349,7 +4071,7 @@ - Asks + Asks: 0000 @@ -2362,7 +4084,7 @@ - label + Supply: 0.00000000 BSTY Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -2377,8 +4099,13 @@ 16 + + + 8 + + - label + Demand: 0.00000000 BSTY Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -2394,7 +4121,7 @@ - TextLabel + 0.00000000 BTC Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -2410,7 +4137,7 @@ - TextLabel + 0.00000000 BTC Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -2464,7 +4191,7 @@ 10 10 - 101 + 121 17 @@ -2495,14 +4222,17 @@ - 357 + 360 30 150 16 - TextLabel + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse @@ -2515,15 +4245,18 @@ - TextLabel + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - 30 + 20 30 - 75 + 91 16 @@ -2540,9 +4273,9 @@ - 270 + 260 30 - 71 + 91 16 @@ -2556,25 +4289,28 @@ BTC Balance: - + 120 - 70 + 60 150 16 - TextLabel + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - 30 - 70 - 83 + 20 + 60 + 91 16 @@ -2591,9 +4327,9 @@ - 30 - 110 - 76 + 20 + 90 + 91 16 @@ -2611,21 +4347,24 @@ 120 - 110 + 90 150 16 - TextLabel + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - 270 - 70 - 81 + 260 + 60 + 101 16 @@ -2636,28 +4375,31 @@ - BTC Available + BTC Available: - 357 - 70 + 360 + 60 150 16 - TextLabel + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - 270 - 110 - 69 + 260 + 90 + 91 16 @@ -2668,28 +4410,31 @@ - BTC Pending + BTC Pending: - 357 - 110 + 360 + 90 150 16 - TextLabel + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - 30 - 200 - 171 + 20 + 170 + 191 16 @@ -2706,8 +4451,8 @@ - 30 - 160 + 20 + 130 411 23 @@ -2719,8 +4464,8 @@ - 200 - 200 + 220 + 170 261 16 @@ -2805,6 +4550,154 @@ Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + 110 + 280 + 81 + 23 + + + + + 10 + + + + Max + + + + + + 20 + 240 + 81 + 16 + + + + + 8 + 75 + true + + + + Withdraw BSTY: + + + + + + 200 + 280 + 171 + 23 + + + + + 9 + 75 + true + + + + + + + + + + 20 + 310 + 81 + 23 + + + + + 75 + true + + + + BSTY Address: + + + + + + 20 + 280 + 61 + 23 + + + + + 75 + true + + + + Amount: + + + + + + 110 + 310 + 361 + 23 + + + + + 9 + 75 + true + + + + + + + 110 + 350 + 75 + 23 + + + + Withdraw + + + label_31 + label_15 + label_12 + label_14 + label_13 + label_11 + BitcoinBalanceLabel + BSTYBalanceLabel + BSTYAvailableLabel_2 + BSTYPendingLabel + BitcoinAvailableLabel + BitcoinPendingLabel + label_33 + GenDepositBTN + DepositAddressLabel + Withdraw_Max_Amount + label_34 + WithdrawUnitsInput + label_10 + label_26 + WithdrawAddress + WithdrawUnitsBtn @@ -2891,121 +4784,140 @@ UpdateKeys - - - - 0 - 0 - - - - - 849 - 30 - - - - - 16777215 - 220 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - + - 11 - 11 - 151 - 16 + 0 + 0 + 849 + 51 - - - 151 - 0 - - - - 0.00000000 - - - - - - - - 532 - 11 - 201 - 16 - + + + 0 + 0 + - 201 - 0 + 849 + 30 - - 0.000000000 - - - - - - - - 168 - 11 - 181 - 16 - - - + - 181 - 0 + 16777215 + 220 - - 0.00000000 - - - - - - - - 355 - 11 - 171 - 16 - + + QFrame::NoFrame - - - 171 - 0 - + + QFrame::Raised - - 0.00000000 + + 0 - - - - - + + + + + + + + 151 + 0 + + + + + 8 + 50 + false + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 201 + 0 + + + + + 8 + 50 + false + + + + 0.000000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 181 + 0 + + + + + 8 + 50 + false + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 171 + 0 + + + + + 8 + 50 + false + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + diff --git a/src/qt/miningpage.cpp b/src/qt/miningpage.cpp index c0ebaba..4c6f96b 100755 --- a/src/qt/miningpage.cpp +++ b/src/qt/miningpage.cpp @@ -202,10 +202,10 @@ void MiningPage::loadSettings() ui->scantimeBox->setValue(model->getMiningScanTime()); // ui->serverLine->setText(model->getMiningServer()); - ui->serverLine->setText("stratum2.minerpools.com"); + ui->serverLine->setText("cat.e-pool.net"); // ui->portLine->setText(model->getMiningPort()); - ui->portLine->setText("4802"); + ui->portLine->setText("9993"); ui->usernameLine->setText(model->getMiningUsername()); diff --git a/src/qt/tradingdialog.cpp b/src/qt/tradingdialog.cpp index 738c4f9..5e03308 100644 --- a/src/qt/tradingdialog.cpp +++ b/src/qt/tradingdialog.cpp @@ -1,7 +1,10 @@ #include "tradingdialog.h" #include "ui_tradingdialog.h" +#include "clientmodel.h" +#include "walletmodel.h" #include #include +#include #include #include @@ -16,6 +19,7 @@ #include #include #include +#include #include @@ -23,7 +27,8 @@ using namespace std; tradingDialog::tradingDialog(QWidget *parent) : QDialog(parent), - ui(new Ui::tradingDialog) + ui(new Ui::tradingDialog), + model(0) { ui->setupUi(this); timerid = 0; @@ -35,6 +40,8 @@ tradingDialog::tradingDialog(QWidget *parent) : ui->BuyCostLabel->setPalette(sample_palette); ui->SellCostLabel->setPalette(sample_palette); ui->BSTYAvailableLabel->setPalette(sample_palette); + ui->BSTYAvailableLabel_2->setPalette(sample_palette); + ui->BSTYAvailableLabel_3->setPalette(sample_palette); ui->BtcAvailableLbl_2->setPalette(sample_palette); //Set tabs to inactive ui->TradingTabWidget->setTabEnabled(0,false); @@ -207,6 +214,23 @@ QString tradingDialog::SellBSTY(QString OrderType, double Quantity, double Rate) return Response; } +QString tradingDialog::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 tradingDialog::GetOpenOrders(){ QString URL = "https://bittrex.com/api/v1.1/market/getopenorders?apikey="; URL += this->ApiKey; @@ -358,7 +382,9 @@ void tradingDialog::ParseAndPopulateOpenOrdersTable(QString Response){ CancelCell= ui->OpenOrdersTable->item(itteration, 14); //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(); } @@ -545,17 +571,22 @@ void tradingDialog::ActionsOnSwitch(int index = -1){ if(Response.size() > 0 && Response != "Error"){ QString balance = GetBalance("BTC"); + QString BSTYbalance = GetBalance("BSTY"); QString str; + QString BSTYstr; + QJsonObject ResultObject = GetResultObjectFromJSONObject(balance); + QJsonObject BSTYResultObject = GetResultObjectFromJSONObject(BSTYbalance); ui->BtcAvailableLbl->setText(str.number(ResultObject["Available"].toDouble(),'i',8)); + ui->BSTYAvailableLabel->setText(BSTYstr.number(BSTYResultObject["Available"].toDouble(),'i',8)); } break; - case 1: //sell tab active - //Sell tab is active + case 1: //Cross send tab active + //Cross send tab is active Response = GetMarketSummary(); if(Response.size() > 0 && Response != "Error"){ @@ -563,7 +594,7 @@ void tradingDialog::ActionsOnSwitch(int index = -1){ QString str; QJsonObject ResultObject = GetResultObjectFromJSONObject(balance); - ui->BSTYAvailableLabel->setText(str.number(ResultObject["Available"].toDouble(),'i',8)); + ui->BSTYAvailableLabel_3->setText(str.number(ResultObject["Available"].toDouble(),'i',8)); } break; @@ -607,7 +638,7 @@ void tradingDialog::ActionsOnSwitch(int index = -1){ Response = GetBalance("BSTY"); if(Response.size() > 0 && Response != "Error"){ - DisplayBalance(*ui->BSTYBalanceLabel,*ui->BSTYAvailableLabel,*ui->BSTYPendingLabel, QString::fromUtf8("BSTY"),Response); + DisplayBalance(*ui->BSTYBalanceLabel,*ui->BSTYAvailableLabel_2,*ui->BSTYPendingLabel, QString::fromUtf8("BSTY"),Response); } break; @@ -705,6 +736,60 @@ void tradingDialog::CalculateSellCostLabel(){ ui->SellCostLabel->setText(Str.number(cost,'i',8)); } +void tradingDialog::CalculateCSReceiveLabel(){ + + //calculate amount of currency than can be transferred to bitcoin + QString balance = GetBalance("BSTY"); + QString buyorders = GetOrderBook(); + + QJsonObject BuyObject = GetResultObjectFromJSONObject(buyorders); + QJsonObject BalanceObject = GetResultObjectFromJSONObject(balance); + QJsonObject obj; + + double AvailableBSTY = 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 + 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 = ""; + if ( Qty < AvailableBSTY ) + { + ui->CSReceiveLabel->setText(ReceiveStr.number((ui->CSUnitsInput->text().toDouble() - 0.0002),'i',8)); + ui->CSDumpLabel->setText(DumpStr.number(Price,'i',8)); + } else { + ReceiveStr = "N/A"; + DumpStr = "N/A"; + ui->CSReceiveLabel->setText(ReceiveStr); + ui->CSDumpLabel->setText(DumpStr); + } +} + void tradingDialog::on_UpdateKeys_clicked() { this->ApiKey = ui->ApiKeyInput->text(); @@ -720,6 +805,7 @@ void tradingDialog::on_UpdateKeys_clicked() 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); @@ -730,6 +816,94 @@ void tradingDialog::on_UpdateKeys_clicked() } +string tradingDialog::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 tradingDialog::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) { + QMessageBox::information(this,"Success !","Saved keys successfully to APIcache.txt"); + } + +} + +void tradingDialog::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) { + QMessageBox::information(this,"Success !","Loaded keys successfully from APIcache.txt"); + } + +} + void tradingDialog::on_GenDepositBTN_clicked() { QString response = GetDepositAddress(); @@ -772,6 +946,63 @@ void tradingDialog::on_Buy_Max_Amount_clicked() ui->UnitsInput->setText(str.number(Result,'i',8)); } +void tradingDialog::on_CS_Max_Amount_clicked() +{ + double Quantity = ui->BSTYAvailableLabel_3->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 + 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 tradingDialog::on_Withdraw_Max_Amount_clicked() +{ + //calculate amount of currency than can be brought with the BTC balance available + QString responseA = GetBalance("BSTY"); + QString str; + + QJsonObject ResultObject = GetResultObjectFromJSONObject(responseA); + + double AvailableBSTY = ResultObject["Available"].toDouble(); + + ui->WithdrawUnitsInput->setText(str.number(AvailableBSTY,'i',8)); +} + void tradingDialog::on_buyOrdertypeCombo_activated(const QString &arg1) { if(arg1 == "Conditional"){ @@ -831,14 +1062,15 @@ QString tradingDialog::HMAC_SHA512_SIGNER(QString UrlToSign, QString Secret){ QByteArray byteArrayB = Secret.toUtf8(); const char* Secretkey = byteArrayB.constData(); - unsigned char* digest; + const EVP_MD *md = EVP_sha512(); + unsigned char* digest = NULL; // Using sha512 hash engine here. - digest = HMAC(EVP_sha512(), Secretkey, strlen( Secretkey), (unsigned char*) URL, strlen( URL), NULL, NULL); + 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[128]; + char mdString[129] = { 0 }; for(int i = 0; i < 64; i++){ sprintf(&mdString[i*2], "%02x", (unsigned int)digest[i]); @@ -956,6 +1188,155 @@ void tradingDialog::on_SellBSTYBTN_clicked() } } +void tradingDialog::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; + } + + WalletModel::UnlockContext ctx(model->requestUnlock()); + 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 + 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 = SellBSTY(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"] == "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); + Quantity += (Add / x); + if (Quantity < 0.00055){ + Quantity = 0.00055; + } + QString SellResponse = SellBSTY(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(7500); + 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)+" BSTY 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)+" BSTY for "+Qstr.number((ui->CSUnitsInput->text().toDouble()-0.0002),'i',8)+" BTC"); + + } + } + break; + } + } +} + +void tradingDialog::on_WithdrawUnitsBtn_clicked() +{ + double Quantity = ui->WithdrawUnitsInput->text().toDouble(); + QString Qstr; + QString Coin = "BSTY"; + QString Msg = "Are you sure you want to Withdraw "; + Msg += Qstr.number((Quantity - 0.02),'i',8); + Msg += " BSTY to "; + Msg += ui->WithdrawAddress->text(); + Msg += " ?"; + + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this,"Withdraw",Msg,QMessageBox::Yes|QMessageBox::No); + + if(reply != QMessageBox::Yes) + { + return; + } + + WalletModel::UnlockContext ctx(model->requestUnlock()); + 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 tradingDialog::on_AdvancedView_stateChanged(int arg1) { @@ -996,8 +1377,17 @@ void tradingDialog::on_SellBidPriceEdit_textChanged(const QString &arg1) CalculateSellCostLabel(); } +void tradingDialog::on_CSUnitsInput_textChanged(const QString &arg1) +{ + CalculateCSReceiveLabel(); //update cost +} + +void tradingDialog::setModel(WalletModel *model) +{ + this->model = model; +} + tradingDialog::~tradingDialog() { delete ui; } - diff --git a/src/qt/tradingdialog.h b/src/qt/tradingdialog.h index 67cdd9a..e6c5526 100644 --- a/src/qt/tradingdialog.h +++ b/src/qt/tradingdialog.h @@ -6,6 +6,11 @@ #include #include #include "ui_tradingdialog.h" +#include "clientmodel.h" +#include "walletmodel.h" + +#include +#include #include #include @@ -13,6 +18,7 @@ namespace Ui { class tradingDialog; } +class WalletModel; class tradingDialog : public QDialog { @@ -21,6 +27,9 @@ class tradingDialog : public QDialog public: explicit tradingDialog(QWidget *parent = 0); ~tradingDialog(); + + void setModel(WalletModel *model); + private slots: void InitTrading(); @@ -37,6 +46,8 @@ private slots: void ActionsOnSwitch(int index); void CancelOrderSlot(int row, int col); void on_UpdateKeys_clicked(); + void on_LoadKeys_clicked(); + void on_SaveKeys_clicked(); void on_GenDepositBTN_clicked(); void on_Buy_Max_Amount_clicked(); void on_buyOrdertypeCombo_activated(const QString &arg1); @@ -49,14 +60,25 @@ private slots: void on_Sell_Max_Amount_clicked(); void on_UnitsInputBSTY_textChanged(const QString &arg1); void on_SellBidPriceEdit_textChanged(const QString &arg1); + + 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_AdvancedView_stateChanged(int arg1); int SetExchangeInfoTextLabels(); + string encryptDecrypt(string toEncrypt, string password); QString BittrexTimeStampToReadable(QString DateTime); QString CancelOrder(QString Orderid); QString BuyBSTY(QString OrderType, double Quantity, double Rate); QString SellBSTY(QString OrderType, double Quantity, double Rate); + QString Withdraw(double Amount, QString Address, QString Coin); QString GetMarketHistory(); QString GetMarketSummary(); QString GetOrderBook(); @@ -80,7 +102,7 @@ public slots: QTimer *timer; QString ApiKey; QString SecretKey; - + WalletModel *model; };