diff --git a/Nanoget/Nanoget/About.swift b/Nanoget/Nanoget/About.swift
new file mode 100644
index 0000000..21fa23b
--- /dev/null
+++ b/Nanoget/Nanoget/About.swift
@@ -0,0 +1,32 @@
+//
+// About.swift
+// Nanoget
+//
+// Created by s on 2018-02-08.
+// Copyright © 2018 Hudson Graeme. All rights reserved.
+//
+
+import Cocoa
+
+class About: NSViewController {
+
+ override func viewDidLoad() {
+ super.viewDidLoad()
+ // Do view setup here.
+ self.view.window?.styleMask.remove(NSWindow.StyleMask.resizable)
+ self.Icon.image = NSApplication.shared.applicationIconImage
+ }
+ @IBOutlet weak var PayPal: NSButton!
+ @IBOutlet weak var Patreon: NSButton!
+ @IBOutlet weak var Icon: NSImageView!
+ @IBOutlet weak var Txt: NSScrollView!
+
+ @IBAction func PayPal(_ sender: Any) {
+ NSWorkspace.shared.open(URL(string: "https://www.paypal.me/SpencerGraham")!)
+ }
+ @IBAction func Patreon(_ sender: Any) {
+ NSWorkspace.shared.open(URL(string: "https://www.patreon.com/OSXSpencer")!)
+ }
+
+
+}
diff --git a/Nanoget/Nanoget/AddressController.swift b/Nanoget/Nanoget/AddressController.swift
new file mode 100644
index 0000000..88e797f
--- /dev/null
+++ b/Nanoget/Nanoget/AddressController.swift
@@ -0,0 +1,128 @@
+//
+// ViewController.swift
+// Nanoget
+//
+// Created by s on 2018-01-10.
+// Copyright © 2018 Carspotter Daily. All rights reserved.
+//
+
+import Cocoa
+import Alamofire
+import SwiftyJSON
+
+class AddressController: NSViewController {
+
+ @IBOutlet weak var Lbl: NSTextField!
+ @IBOutlet weak var Addr: NSTextField!
+ @IBOutlet weak var Btn: NSButton!
+
+ override func viewDidLoad() {
+ super.viewDidLoad()
+ if let acc = UserDefaults.standard.string(forKey: "Acc") {
+ Addr.stringValue = acc
+ }
+let area = NSTrackingArea.init(rect: Btn.bounds, options: [.mouseEnteredAndExited, .activeAlways], owner: self, userInfo: nil)
+ Btn.addTrackingArea(area)
+ self.Btn.wantsLayer = true
+ self.Btn.layer?.backgroundColor = NSColor.systemBlue.cgColor
+ self.view.wantsLayer = true
+ self.view.layer?.backgroundColor = NSColor.lightGray.cgColor
+ }
+
+ override func mouseEntered(with event: NSEvent) {
+ self.Btn.layer?.backgroundColor = NSColor.blue.blended(withFraction: 0.5, of: .systemBlue)?.cgColor
+ }
+
+ override func mouseExited(with event: NSEvent) {
+ self.Btn.layer?.backgroundColor = NSColor.systemBlue.cgColor
+
+ }
+
+
+ @IBAction func Btn(_ sender: Any) {
+
+ if(Addr.stringValue.count == 42) {
+ Addr.textColor = NSColor.orange
+ Addr.stringValue = Addr.stringValue.replacingOccurrences(of: "0x", with: "")
+ HandleCoins(suspectedCoin: "eth")
+ }
+ else if(Addr.stringValue.contains("etn")) {
+ Addr.textColor = NSColor.black
+ HandleCoins(suspectedCoin: "etn")
+ }
+ else if(Addr.stringValue.count == 40&&Addr.stringValue.contains("0x") != true){
+ Addr.textColor = NSColor.orange
+ HandleCoins(suspectedCoin: "eth")
+ }
+ else if(Addr.stringValue.count == 76) {
+ Addr.textColor = NSColor.green
+ HandleCoins(suspectedCoin: "sia")
+ }
+ else if(Addr.stringValue.count == 8) {
+ Addr.textColor = NSColor.yellow
+ HandleCoins(suspectedCoin: "pasc")
+ }
+ else if(Addr.stringValue.count == 95) {
+ Addr.textColor = NSColor.gray
+ HandleCoins(suspectedCoin: "xmr")
+ }
+ else if(Addr.stringValue.count == 35) {
+ Addr.textColor = NSColor.systemBlue
+ HandleCoins(suspectedCoin: "zec")
+ }
+ else {
+ Addr.textColor = NSColor.red
+ Addr.stringValue = "Invalid Address"
+ }
+ }
+
+ func HandleCoins(suspectedCoin coin:String) {
+ if(coin == "eth"){
+ Go(Addr.stringValue, coin)
+ Go(Addr.stringValue, "etc")
+ }
+ else {
+ Go(Addr.stringValue, coin)
+ }
+ }
+ var canload: Bool = false
+ func Go(_ Address:String, _ coin: String){
+ UserDefaults.standard.set(Address, forKey: "Acc")
+ Alamofire.request("https://api.nanopool.org/v1/\(coin)/balance/\(Address)") .responseJSON { response in
+ let data = response.data
+ if(response.result.isSuccess) {
+ if let result = response.result.value {
+ print(result)
+
+ let json = JSON(data: data!)
+ if(json["status"].intValue == 1) {
+ self.canload = true
+ self.YorN(coin)
+ }
+ else {
+ self.canload = false
+ self.Btn.title = "Error.. Try again."
+ self.YorN(coin)
+ }
+
+ }
+ }
+ else {
+ print("Failure")
+ self.canload = false
+ self.YorN(coin)
+ }
+ }
+ }
+ func YorN(_ coin: String) {
+ if(self.canload == true) {
+ UserDefaults.standard.set(coin, forKey: "Coin")
+ self.performSegue(withIdentifier:NSStoryboardSegue.Identifier(rawValue: "ToMain"), sender: self)
+ self.view.window?.close()
+ }
+ else {
+ print("nope")
+ }
+ }
+}
+
diff --git a/Nanoget/Nanoget/Assets.xcassets/Contents.json b/Nanoget/Nanoget/Assets.xcassets/Contents.json
new file mode 100644
index 0000000..da4a164
--- /dev/null
+++ b/Nanoget/Nanoget/Assets.xcassets/Contents.json
@@ -0,0 +1,6 @@
+{
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/Nanoget/Nanoget/Assets.xcassets/Patreon.imageset/Contents.json b/Nanoget/Nanoget/Assets.xcassets/Patreon.imageset/Contents.json
new file mode 100644
index 0000000..6488566
--- /dev/null
+++ b/Nanoget/Nanoget/Assets.xcassets/Patreon.imageset/Contents.json
@@ -0,0 +1,21 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "filename" : "downloads_wordmark_navy.png",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/Nanoget/Nanoget/Assets.xcassets/Patreon.imageset/downloads_wordmark_navy.png b/Nanoget/Nanoget/Assets.xcassets/Patreon.imageset/downloads_wordmark_navy.png
new file mode 100644
index 0000000..677eac0
Binary files /dev/null and b/Nanoget/Nanoget/Assets.xcassets/Patreon.imageset/downloads_wordmark_navy.png differ
diff --git a/Nanoget/Nanoget/Assets.xcassets/PayPal.imageset/580b57fcd9996e24bc43c530.png b/Nanoget/Nanoget/Assets.xcassets/PayPal.imageset/580b57fcd9996e24bc43c530.png
new file mode 100644
index 0000000..e0d87b9
Binary files /dev/null and b/Nanoget/Nanoget/Assets.xcassets/PayPal.imageset/580b57fcd9996e24bc43c530.png differ
diff --git a/Nanoget/Nanoget/Assets.xcassets/PayPal.imageset/Contents.json b/Nanoget/Nanoget/Assets.xcassets/PayPal.imageset/Contents.json
new file mode 100644
index 0000000..041b451
--- /dev/null
+++ b/Nanoget/Nanoget/Assets.xcassets/PayPal.imageset/Contents.json
@@ -0,0 +1,21 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "filename" : "580b57fcd9996e24bc43c530.png",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/Nanoget/Nanoget/Base.lproj/Main.storyboard b/Nanoget/Nanoget/Base.lproj/Main.storyboard
index 22b6176..2f2a04c 100644
--- a/Nanoget/Nanoget/Base.lproj/Main.storyboard
+++ b/Nanoget/Nanoget/Base.lproj/Main.storyboard
@@ -3,6 +3,7 @@
+
@@ -19,6 +20,7 @@
+
@@ -55,619 +57,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Default
-
-
-
-
-
-
- Left to Right
-
-
-
-
-
-
- Right to Left
-
-
-
-
-
-
-
-
-
-
- Default
-
-
-
-
-
-
- Left to Right
-
-
-
-
-
-
- Right to Left
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -704,7 +93,7 @@
-
+
@@ -712,27 +101,18 @@
-
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
+
+
@@ -771,14 +160,14 @@ DQ
-
+
-
+
-
+
@@ -790,7 +179,7 @@ DQ
-
+
@@ -798,7 +187,7 @@ DQ
-
+
@@ -807,7 +196,7 @@ DQ
-
+
@@ -824,11 +213,20 @@ DQ
+
+
+
+
+
+
+
+
+
-
+
-
+
@@ -836,6 +234,7 @@ DQ
+
@@ -849,5 +248,93 @@ DQ
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Nanoget/Nanoget/Info.plist b/Nanoget/Nanoget/Info.plist
index f38acc9..a8783b2 100644
--- a/Nanoget/Nanoget/Info.plist
+++ b/Nanoget/Nanoget/Info.plist
@@ -17,9 +17,11 @@
CFBundlePackageType
APPL
CFBundleShortVersionString
- 1.0
+ 1.2
CFBundleVersion
1
+ LSApplicationCategoryType
+ public.app-category.finance
LSMinimumSystemVersion
$(MACOSX_DEPLOYMENT_TARGET)
NSHumanReadableCopyright
diff --git a/Nanoget/Nanoget/MainView.swift b/Nanoget/Nanoget/MainView.swift
index 5f49798..7e61c28 100644
--- a/Nanoget/Nanoget/MainView.swift
+++ b/Nanoget/Nanoget/MainView.swift
@@ -15,7 +15,12 @@ class MainView: NSViewController {
override func viewDidLoad() {
super.viewDidLoad()
-
+ self.Graph.scaleYEnabled = false
+ self.Graph.scaleXEnabled = false
+ self.Graph.rightAxis.enabled = false
+ self.Graph.leftAxis.enabled = false
+ self.Graph.xAxis.enabled = false
+ self.Graph.legend.enabled = false
let Address = UserDefaults.standard.string(forKey: "SSHAddress")
let Port = UserDefaults.standard.integer(forKey: "SSHPort")
let Username = UserDefaults.standard.string(forKey: "SSHUser")
@@ -47,9 +52,9 @@ class MainView: NSViewController {
self.Lvl?.fillColor = .yellow
LineColour = .yellow
case "etn":
- self.Lvl?.maxValue = 500
- self.Lvl?.fillColor = .black
- LineColour = .black
+ self.Lvl?.maxValue = 50000
+ self.Lvl?.fillColor = .systemGray
+ LineColour = .systemGray
default:
self.Lvl?.maxValue = 1
}
@@ -74,7 +79,7 @@ class MainView: NSViewController {
shell("ssh", "-p", "\(Port)", "\(Username)@\(Address)")
}
self.Graph?.drawGridBackgroundEnabled = true
- self.Graph?.gridBackgroundColor = NSColor.gray
+ self.Graph?.gridBackgroundColor = NSColor.darkGray
self.Graph?.autoScaleMinMaxEnabled = true
_ = Timer.scheduledTimer(timeInterval: 30.0, target: self, selector: #selector(DoAll), userInfo: self, repeats: true)
_ = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(Update1s), userInfo: self, repeats: true)
@@ -89,6 +94,7 @@ class MainView: NSViewController {
@IBOutlet weak var Graph: LineChartView!
@IBOutlet weak var RefreshLabel: NSTextField!
@IBOutlet weak var RefreshInd: NSProgressIndicator!
+ @IBOutlet weak var CalcHash: NSTextField!
let coin = UserDefaults.standard.string(forKey: "Coin")
var LineColour = NSColor.brown
@@ -97,9 +103,11 @@ class MainView: NSViewController {
var i = 0
var time : Double = 30
var retry : Int = 0
+ var CalcHashRetry : Int = 0
+ var RepHashRetry : Int = 0
+
@objc func Update1s(timer: Timer?) {
time -= 1
- print(time)
self.RefreshLabel?.stringValue = "Refreshing in \(time)"
self.RefreshInd?.doubleValue = time
}
@@ -140,7 +148,6 @@ class MainView: NSViewController {
let data = response.data
if(response.result.isSuccess) {
if let result = response.result.value {
- print(result)
let json = JSON(data: data!)
if(json["success"].intValue == 1) {
let usdvalue = json["ticker"]["price"].doubleValue
@@ -163,13 +170,12 @@ class MainView: NSViewController {
}
}
- func GetBalance() -> Int{
+ func GetBalance() -> Int {
let Address = UserDefaults.standard.string(forKey: "Acc")
Alamofire.request("https://api.nanopool.org/v1/\(coin!)/balance/\(Address!)") .responseJSON { response in
let data = response.data
if(response.result.isSuccess) {
if let result = response.result.value {
- print(result)
let json = JSON(data: data!)
if(json["status"].intValue == 1) {
let money = json["data"].doubleValue
@@ -207,7 +213,6 @@ class MainView: NSViewController {
let data = response.data
if(response.result.isSuccess) {
if let result = response.result.value {
- print(result)
let json = JSON(data: data!)
if(json["status"].intValue == 1) {
@@ -219,16 +224,28 @@ class MainView: NSViewController {
indRate = json["data"][i]["hashrate"].doubleValue
rate += indRate
i += 1
- print("\(i) - \(indRate)")
}
- self.RepHash?.stringValue = "\(rate)Mh/s Reported"
+ if(self.RepHashRetry <= 2 && rate == 0) {
+ self.GetReportedHash()
+ self.RepHashRetry += 1
+ print("Retry Reported \(self.RepHashRetry)")
+ }
+ else {
+ self.RepHash?.stringValue = "\(rate)Mh/s Reported"
+ self.RepHashRetry = 0
+ }
}
else {
- print("Bad address")
- if(json["error"].stringValue != "") {
- self.RepHash?.stringValue = json["error"].stringValue
+ if(self.RepHashRetry <= 2) {
+ self.GetReportedHash()
+ self.RepHashRetry += 1
+ print("Retry Reported \(self.RepHashRetry)")
+ }
+ else {
+ if(json["error"].stringValue != "") {
+ self.RepHash?.stringValue = json["error"].stringValue
+ }
}
-
}
}
@@ -241,33 +258,36 @@ class MainView: NSViewController {
func GetCalculatedHash() {
let Address = UserDefaults.standard.string(forKey: "Acc")
- Alamofire.request("https://api.nanopool.org/v1/\(self.coin!)/reportedhashrates/\(Address!)") .responseJSON { response in
+ Alamofire.request("https://api.nanopool.org/v1/\(self.coin!)/hashrate/\(Address!)") .responseJSON { response in
let data = response.data
if(response.result.isSuccess) {
if let result = response.result.value {
print(result)
let json = JSON(data: data!)
- if(json["status"].intValue == 1) {
-
- var i = 0
- var rate = 0 as Double
- var indRate = 0 as Double
- while json["data"][i] != JSON.null {
- indRate = json["data"][i]["hashrate"].doubleValue
- rate += indRate
- i += 1
- print("\(i) - \(indRate)")
+ if(json["status"].boolValue == true) {
+ let rate = json["data"].doubleValue
+ self.CalcHash?.stringValue = "\(rate)Mh/s Calculated"
+ if(self.CalcHashRetry <= 2 && rate == 0) {
+ self.GetCalculatedHash()
+ self.CalcHashRetry += 1
+ print("Calculated Retry \(self.CalcHashRetry)")
}
- self.RepHash?.stringValue = "\(rate)Mh/s Reported"
-
+ else {
+ self.CalcHashRetry = 0
+ }
}
else {
- print("Bad address")
+ if(self.CalcHashRetry <= 2) {
+ self.GetCalculatedHash()
+ self.CalcHashRetry += 1
+ print("Calculated Retry \(self.CalcHashRetry)")
+ }
+ else {
if(json["error"].stringValue != "") {
- self.RepHash?.stringValue = json["error"].stringValue
+ self.CalcHash?.stringValue = json["error"].stringValue
+ }
}
-
}
}
@@ -285,8 +305,6 @@ class MainView: NSViewController {
let data = response.data
if(response.result.isSuccess) {
if let result = response.result.value {
- print(result)
-
let json = JSON(data: data!)
if(json["status"].boolValue == true) {
print("Status good")
@@ -294,19 +312,21 @@ class MainView: NSViewController {
var rate = 0 as Double
var indRate = 0 as Double
while json["data"][i] != JSON.null {
- print("while \(i)")
indRate = json["data"][i]["shares"].doubleValue
let value = ChartDataEntry(x: Double(i), y: indRate)
self.lineChartEntry.append(value)
- i += 4
+ i += 1
let line = LineChartDataSet(values: self.lineChartEntry, label: "Shares")
line.colors = [self.LineColour]
+ line.mode = .cubicBezier
+ line.fillColor = self.LineColour
+ line.fillAlpha = 1
+ line.drawFilledEnabled = true
+ line.drawCirclesEnabled = false
let chartdat = LineChartData()
chartdat.addDataSet(line)
self.Graph?.data = chartdat
- self.Graph?.chartDescription?.text = "Shares"
- print("\(i) - \(indRate)")
-
+ self.Graph?.chartDescription?.enabled = false
}
self.RepHash?.stringValue = "\(rate)Mh/s Reported"
diff --git a/Nanoget/Nanoget/Nanoget.xcworkspace/xcuserdata/gra.xcuserdatad/UserInterfaceState.xcuserstate b/Nanoget/Nanoget/Nanoget.xcworkspace/xcuserdata/gra.xcuserdatad/UserInterfaceState.xcuserstate
index 3f678d1..4321c0a 100644
Binary files a/Nanoget/Nanoget/Nanoget.xcworkspace/xcuserdata/gra.xcuserdatad/UserInterfaceState.xcuserstate and b/Nanoget/Nanoget/Nanoget.xcworkspace/xcuserdata/gra.xcuserdatad/UserInterfaceState.xcuserstate differ