This repository has been archived by the owner on Jun 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added more config options - Added $/Day income calculation - Bug fixes
- Loading branch information
nicehashdev
committed
Oct 22, 2015
1 parent
2a34342
commit b9aa683
Showing
9 changed files
with
196 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Net; | ||
using System.IO; | ||
using Newtonsoft.Json; | ||
|
||
namespace NiceHashMiner | ||
{ | ||
class Bitcoin | ||
{ | ||
#pragma warning disable 649 | ||
class CoinbaseResponse | ||
{ | ||
public double amount; | ||
public string currency; | ||
} | ||
#pragma warning restore 649 | ||
|
||
public static double GetUSDExchangeRate() | ||
{ | ||
string jsondata = GetCoinbaseAPIData("https://api.coinbase.com/v1/prices/spot_rate"); | ||
if (jsondata == null) return 0; | ||
|
||
try | ||
{ | ||
CoinbaseResponse cbr = JsonConvert.DeserializeObject<CoinbaseResponse>(jsondata); | ||
return cbr.amount; | ||
} | ||
catch | ||
{ | ||
return 0; | ||
} | ||
} | ||
|
||
private static string GetCoinbaseAPIData(string URL) | ||
{ | ||
string ResponseFromServer; | ||
try | ||
{ | ||
HttpWebRequest WR = (HttpWebRequest)WebRequest.Create(URL); | ||
WR.Timeout = 5000; | ||
WebResponse Response = WR.GetResponse(); | ||
Stream SS = Response.GetResponseStream(); | ||
SS.ReadTimeout = 5000; | ||
StreamReader Reader = new StreamReader(SS); | ||
ResponseFromServer = Reader.ReadToEnd(); | ||
if (ResponseFromServer.Length == 0 || ResponseFromServer[0] != '{') | ||
throw new Exception("Not JSON!"); | ||
Reader.Close(); | ||
Response.Close(); | ||
} | ||
catch | ||
{ | ||
return null; | ||
} | ||
|
||
return ResponseFromServer; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.