├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── drawable │ │ │ │ ├── pose2.png │ │ │ │ ├── pose3.png │ │ │ │ ├── bigicon.png │ │ │ │ ├── btc_icon.png │ │ │ │ ├── ils_icon.png │ │ │ │ ├── ltc_icon.png │ │ │ │ ├── lteteminer.gif │ │ │ │ ├── together2.png │ │ │ │ ├── usd_icon.png │ │ │ │ ├── lteteminer_2.gif │ │ │ │ ├── lteteminer_3.gif │ │ │ │ ├── lteteminer_4.gif │ │ │ │ ├── lteteminer_5.gif │ │ │ │ ├── pose1_noback.png │ │ │ │ ├── btc_icon_scaled.png │ │ │ │ ├── ils_icon_scaled.png │ │ │ │ ├── usd_icon_scaled.png │ │ │ │ ├── ltcte_launcher_icon_sketch.png │ │ │ │ ├── card_item_background.xml │ │ │ │ ├── activated_background_item_card.xml │ │ │ │ ├── pressed_background_item_card.xml │ │ │ │ ├── tab_color_selector.xml │ │ │ │ ├── custom_spinner_background.xml │ │ │ │ ├── border.xml │ │ │ │ ├── background_splash.xml │ │ │ │ ├── button_shape_selector.xml │ │ │ │ ├── item_selector.xml │ │ │ │ ├── button_shape_selector_stopminer.xml │ │ │ │ ├── button_shape_disabled.xml │ │ │ │ ├── button_shape_stopminer.xml │ │ │ │ ├── button_shape_disabled_stopminer.xml │ │ │ │ ├── button_shape_pressed_stopminer.xml │ │ │ │ ├── button_shape.xml │ │ │ │ └── button_shape_pressed.xml │ │ │ ├── drawable-hdpi │ │ │ │ └── ic_down.png │ │ │ ├── drawable-mdpi │ │ │ │ └── ic_down.png │ │ │ ├── drawable-xhdpi │ │ │ │ └── ic_down.png │ │ │ ├── drawable-xxhdpi │ │ │ │ └── ic_down.png │ │ │ ├── drawable-xxxhdpi │ │ │ │ └── ic_down.png │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ ├── ltcte_launcher_icon.png │ │ │ │ └── ltcte_actionbar_icon.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ ├── ltcte_launcher_icon.png │ │ │ │ └── ltcte_actionbar_icon.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ ├── ltcte_actionbar_icon.png │ │ │ │ └── ltcte_launcher_icon.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ ├── ltcte_actionbar_icon.png │ │ │ │ └── ltcte_launcher_icon.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ ├── ltcte_launcher_icon.png │ │ │ │ └── ltcte_actionbar_icon.png │ │ │ ├── menu │ │ │ │ ├── card_wallet_menu_item.xml │ │ │ │ └── card_rates_menu_item.xml │ │ │ ├── layout │ │ │ │ ├── fragment_test.xml │ │ │ │ ├── fragment_settings.xml │ │ │ │ ├── new_user_dialog.xml │ │ │ │ ├── card_rates_inner_header.xml │ │ │ │ ├── new_password_dialog.xml │ │ │ │ ├── enter_amount_dialog.xml │ │ │ │ ├── fragment_rates.xml │ │ │ │ ├── new_url_dialog.xml │ │ │ │ ├── simple_popup_window.xml │ │ │ │ ├── activity_main.xml │ │ │ │ ├── splash_screen.xml │ │ │ │ ├── card_rates_inner_main.xml │ │ │ │ ├── fragment_about.xml │ │ │ │ ├── wallaet_card_layout.xml │ │ │ │ ├── fragment_mine.xml │ │ │ │ └── activity_miner.xml │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── styles.xml │ │ │ │ └── strings.xml │ │ │ └── xml │ │ │ │ └── settings_main.xml │ │ ├── ltcte_launcher_icon-web.png │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── android │ │ │ │ └── ltcteminer │ │ │ │ ├── StratumMiner │ │ │ │ ├── Worker │ │ │ │ │ ├── IWorkerEvent.java │ │ │ │ │ ├── IMiningWorker.java │ │ │ │ │ └── CpuMiningWorker.java │ │ │ │ ├── Connection │ │ │ │ │ ├── IConnectionEvent.java │ │ │ │ │ └── IMiningConnection.java │ │ │ │ ├── MinyaException.java │ │ │ │ ├── StratumMiningWork.java │ │ │ │ ├── Stratum │ │ │ │ │ ├── StratumJsonResultStandard.java │ │ │ │ │ ├── StratumJson.java │ │ │ │ │ ├── StratumJsonMethod.java │ │ │ │ │ ├── StratumJsonMethodGetVersion.java │ │ │ │ │ ├── StratumJsonResult.java │ │ │ │ │ ├── StratumJsonMethodSetDifficulty.java │ │ │ │ │ ├── StratumJsonMethodShowMessage.java │ │ │ │ │ ├── StratumJsonMethodReconnect.java │ │ │ │ │ ├── StratumJsonResultSubscribe.java │ │ │ │ │ ├── StratumJsonMethodMiningNotify.java │ │ │ │ │ ├── StratumSocket.java │ │ │ │ │ └── StratumWorkBuilder.java │ │ │ │ ├── Base64.java │ │ │ │ ├── MinyaLog.java │ │ │ │ ├── MiningWork.java │ │ │ │ ├── Console.java │ │ │ │ ├── Constants.java │ │ │ │ ├── HexArray.java │ │ │ │ ├── Hasher │ │ │ │ │ └── Hasher.java │ │ │ │ └── MinerService.java │ │ │ │ ├── SplashScreen.java │ │ │ │ ├── MainActivity.java │ │ │ │ ├── NetworkUtil.java │ │ │ │ ├── TabFragmentAdapter.java │ │ │ │ ├── AboutFragment.java │ │ │ │ ├── TestFragment.java │ │ │ │ ├── SettingsFragment.java │ │ │ │ ├── ExchangeRatesCard.java │ │ │ │ └── RatesFragment.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── android │ │ │ └── ltcteminer │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── example │ │ └── android │ │ └── ltcteminer │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── .idea ├── copyright │ └── profiles_settings.xml ├── vcs.xml ├── inspectionProfiles │ ├── profiles_settings.xml │ └── Project_Default.xml ├── modules.xml ├── runConfigurations.xml ├── gradle.xml ├── compiler.xml └── misc.xml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── README.md ├── gradle.properties ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/pose2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/drawable/pose2.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/pose3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/drawable/pose3.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable/bigicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/drawable/bigicon.png -------------------------------------------------------------------------------- /app/src/main/ltcte_launcher_icon-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/ltcte_launcher_icon-web.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/btc_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/drawable/btc_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ils_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/drawable/ils_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ltc_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/drawable/ltc_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/lteteminer.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/drawable/lteteminer.gif -------------------------------------------------------------------------------- /app/src/main/res/drawable/together2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/drawable/together2.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/usd_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/drawable/usd_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/drawable-hdpi/ic_down.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/drawable-mdpi/ic_down.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/lteteminer_2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/drawable/lteteminer_2.gif -------------------------------------------------------------------------------- /app/src/main/res/drawable/lteteminer_3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/drawable/lteteminer_3.gif -------------------------------------------------------------------------------- /app/src/main/res/drawable/lteteminer_4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/drawable/lteteminer_4.gif -------------------------------------------------------------------------------- /app/src/main/res/drawable/lteteminer_5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/drawable/lteteminer_5.gif -------------------------------------------------------------------------------- /app/src/main/res/drawable/pose1_noback.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/drawable/pose1_noback.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/drawable-xhdpi/ic_down.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/drawable-xxhdpi/ic_down.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/drawable-xxxhdpi/ic_down.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/btc_icon_scaled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/drawable/btc_icon_scaled.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ils_icon_scaled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/drawable/ils_icon_scaled.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/usd_icon_scaled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/drawable/usd_icon_scaled.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ltcte_launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/mipmap-hdpi/ltcte_launcher_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ltcte_launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/mipmap-mdpi/ltcte_launcher_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ltcte_actionbar_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/mipmap-hdpi/ltcte_actionbar_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ltcte_actionbar_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/mipmap-mdpi/ltcte_actionbar_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ltcte_actionbar_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/mipmap-xhdpi/ltcte_actionbar_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ltcte_launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/mipmap-xhdpi/ltcte_launcher_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ltcte_actionbar_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/mipmap-xxhdpi/ltcte_actionbar_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ltcte_launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/mipmap-xxhdpi/ltcte_launcher_icon.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ltcte_launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/mipmap-xxxhdpi/ltcte_launcher_icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ltcte_launcher_icon_sketch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/drawable/ltcte_launcher_icon_sketch.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ltcte_actionbar_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taldatech/LtcTEMiner/master/app/src/main/res/mipmap-xxxhdpi/ltcte_actionbar_icon.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/card_item_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/activated_background_item_card.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/pressed_background_item_card.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jul 28 14:25:12 IDT 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip 7 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/tab_color_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LtcTEMiner 2 | Android application for mining Scrypt coins with custom options. 3 | For a simple version of this miner, checkout StratumMiner. 4 | This project was made possible thanks to the following projects: JMinYa,JMiner,AndLTC-Miner,LTCMiner. 5 | Many thanks to the developers of these amazing projects! 6 | 7 | Video: https://vimeo.com/229402111 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/custom_spinner_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/border.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/StratumMiner/Worker/IWorkerEvent.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer.StratumMiner.Worker; 2 | 3 | import com.example.android.ltcteminer.StratumMiner.MiningWork; 4 | 5 | /** 6 | * Created by Tal on 09/08/2017. 7 | */ 8 | 9 | public interface IWorkerEvent 10 | { 11 | public void onNonceFound(MiningWork i_work, int i_nonce); 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/res/menu/card_wallet_menu_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/menu/card_rates_menu_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/background_splash.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/StratumMiner/Connection/IConnectionEvent.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer.StratumMiner.Connection; 2 | 3 | import com.example.android.ltcteminer.StratumMiner.MiningWork; 4 | 5 | /** 6 | * Created by Tal on 09/08/2017. 7 | */ 8 | 9 | public interface IConnectionEvent 10 | { 11 | public void onNewWork(MiningWork i_new_work); 12 | public void onSubmitResult(MiningWork i_listener,int i_nonce,boolean i_result); 13 | 14 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/button_shape_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/item_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/test/java/com/example/android/ltcteminer/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/button_shape_selector_stopminer.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/StratumMiner/MinyaException.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer.StratumMiner; 2 | 3 | /** 4 | * Created by Tal on 09/08/2017. 5 | */ 6 | 7 | public class MinyaException extends Exception 8 | { 9 | private static final long serialVersionUID = 3363L; 10 | public MinyaException() 11 | { 12 | super(); 13 | } 14 | public MinyaException(Throwable e) 15 | { 16 | super(e); 17 | } 18 | public MinyaException(String s) 19 | { 20 | super(s); 21 | } 22 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/StratumMiner/StratumMiningWork.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer.StratumMiner; 2 | 3 | /** 4 | * Created by Tal on 09/08/2017. 5 | */ 6 | 7 | public class StratumMiningWork extends MiningWork 8 | { 9 | public String job_id; 10 | public String xnonce2; 11 | public StratumMiningWork(HexArray i_data,HexArray i_target, String i_job_id, String i_xnonce2) 12 | { 13 | super(i_data,i_target); 14 | this.job_id=i_job_id; 15 | this.xnonce2=i_xnonce2; 16 | return; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_test.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/button_shape_disabled.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 9 | 15 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/button_shape_stopminer.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 9 | 15 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/button_shape_disabled_stopminer.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 9 | 15 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/button_shape_pressed_stopminer.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 9 | 15 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/button_shape.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 9 | 15 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/button_shape_pressed.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 9 | 15 | 19 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 13 | 14 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/StratumMiner/Stratum/StratumJsonResultStandard.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer.StratumMiner.Stratum; 2 | 3 | import com.example.android.ltcteminer.StratumMiner.MinyaException; 4 | import com.fasterxml.jackson.databind.JsonNode; 5 | 6 | /** 7 | * Created by Tal on 09/08/2017. 8 | */ 9 | 10 | public class StratumJsonResultStandard extends StratumJsonResult 11 | { 12 | public final static String TEST_PATT = "{\"error\": null, \"jsonrpc\": \"2.0\", \"id\": 2, \"result\": true}"; 13 | public final boolean result; 14 | public StratumJsonResultStandard(JsonNode i_json_node) throws MinyaException 15 | { 16 | super(i_json_node); 17 | this.result=i_json_node.get("result").asBoolean(); 18 | return; 19 | } 20 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/StratumMiner/Stratum/StratumJson.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer.StratumMiner.Stratum; 2 | 3 | import com.example.android.ltcteminer.StratumMiner.HexArray; 4 | import com.example.android.ltcteminer.StratumMiner.MinyaException; 5 | 6 | /** 7 | * Created by Tal on 09/08/2017. 8 | */ 9 | 10 | public class StratumJson 11 | { 12 | protected StratumJson() 13 | { 14 | return; 15 | } 16 | 17 | protected StratumJson(StratumJson i_src) 18 | { 19 | return; 20 | } 21 | protected static HexArray toHexArray(String i_str, int i_str_len) throws MinyaException 22 | { 23 | if (i_str.length() != i_str_len) { 24 | throw new MinyaException(); 25 | } 26 | return new HexArray(i_str); 27 | } 28 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/StratumMiner/Stratum/StratumJsonMethod.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer.StratumMiner.Stratum; 2 | 3 | import com.example.android.ltcteminer.StratumMiner.MinyaException; 4 | import com.fasterxml.jackson.databind.JsonNode; 5 | 6 | /** 7 | * Created by Tal on 09/08/2017. 8 | */ 9 | 10 | public class StratumJsonMethod extends StratumJson 11 | { 12 | public final Long id; 13 | 14 | public StratumJsonMethod(JsonNode i_json_node) throws MinyaException { 15 | if (i_json_node.has("id")){ 16 | this.id = i_json_node.get("id").isNull()?null:i_json_node.get("id").asLong(); 17 | } else { 18 | this.id = null; 19 | } 20 | if(!i_json_node.has("method")){ 21 | throw new MinyaException(); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/StratumMiner/Connection/IMiningConnection.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer.StratumMiner.Connection; 2 | 3 | import com.example.android.ltcteminer.StratumMiner.MiningWork; 4 | import com.example.android.ltcteminer.StratumMiner.MinyaException; 5 | 6 | /** 7 | * Created by Tal on 09/08/2017. 8 | */ 9 | 10 | public interface IMiningConnection 11 | { 12 | public void addListener(IConnectionEvent i_listener) throws MinyaException; 13 | public MiningWork connect() throws MinyaException; 14 | // public void connect() throws MinyaException; 15 | public void disconnect() throws MinyaException; 16 | public MiningWork getWork() throws MinyaException; 17 | public void submitWork(MiningWork i_work, int i_nonce) throws MinyaException; 18 | // public boolean submitWork(MiningWork i_work, int i_nonce) throws MinyaException; 19 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/new_user_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/example/android/ltcteminer/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.example.android.ltcteminer", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/StratumMiner/Stratum/StratumJsonMethodGetVersion.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer.StratumMiner.Stratum; 2 | 3 | import com.example.android.ltcteminer.StratumMiner.MinyaException; 4 | import com.fasterxml.jackson.databind.JsonNode; 5 | 6 | /** 7 | * Created by Tal on 09/08/2017. 8 | */ 9 | 10 | public class StratumJsonMethodGetVersion extends StratumJsonMethod 11 | { 12 | //{"method":"client.reconnect",params:["host",1]} 13 | public final static String TEST_PATT = "{\"params\": [], \"jsonrpc\": \"2.0\", \"method\": \"client.get_version\", \"id\": null}"; 14 | 15 | public StratumJsonMethodGetVersion(JsonNode i_json_node) throws MinyaException { 16 | super(i_json_node); 17 | String s = i_json_node.get("method").asText(); 18 | if (s.compareTo("client.get_version") != 0) { 19 | throw new MinyaException(); 20 | } 21 | return; 22 | } 23 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/card_rates_inner_header.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 16 | 17 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/layout/new_password_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/layout/enter_amount_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_rates.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/layout/new_url_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/StratumMiner/Stratum/StratumJsonResult.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer.StratumMiner.Stratum; 2 | 3 | import com.example.android.ltcteminer.StratumMiner.MinyaException; 4 | import com.fasterxml.jackson.databind.JsonNode; 5 | 6 | /** 7 | * Created by Tal on 09/08/2017. 8 | */ 9 | 10 | public class StratumJsonResult extends StratumJson 11 | { 12 | public final JsonNode error; 13 | public final Long id; 14 | 15 | public StratumJsonResult(JsonNode i_json_node) throws MinyaException { 16 | if (i_json_node.has("id")) { 17 | this.id = i_json_node.get("id").isNull()?null:i_json_node.get("id").asLong(); 18 | } else { 19 | this.id = null; 20 | } 21 | if (!i_json_node.has("error")){ 22 | throw new MinyaException(); 23 | } 24 | if (i_json_node.get("error").isNull()) { 25 | this.error = null; 26 | } else { 27 | this.error=i_json_node.get("error"); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Users\Tal\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/StratumMiner/Stratum/StratumJsonMethodSetDifficulty.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer.StratumMiner.Stratum; 2 | 3 | import com.example.android.ltcteminer.StratumMiner.MinyaException; 4 | import com.fasterxml.jackson.databind.JsonNode; 5 | 6 | /** 7 | * Created by Tal on 09/08/2017. 8 | */ 9 | 10 | public class StratumJsonMethodSetDifficulty extends StratumJsonMethod 11 | { 12 | public final static String TEST_PATT = "{\"params\": [533.210506917676], \"jsonrpc\": \"2.0\", \"method\": \"mining.set_difficulty\", \"id\": 44016281}"; 13 | 14 | // public parameter 15 | public double difficulty; 16 | 17 | public StratumJsonMethodSetDifficulty(JsonNode i_json_node) throws MinyaException { 18 | super(i_json_node); 19 | String s = i_json_node.get("method").asText(); 20 | if (s.compareTo("mining.set_difficulty") != 0) { 21 | throw new MinyaException(); 22 | } 23 | this.difficulty = i_json_node.get("params").get(0).asDouble(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/StratumMiner/Stratum/StratumJsonMethodShowMessage.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer.StratumMiner.Stratum; 2 | 3 | import com.example.android.ltcteminer.StratumMiner.MinyaException; 4 | import com.fasterxml.jackson.databind.JsonNode; 5 | 6 | /** 7 | * Created by Tal on 09/08/2017. 8 | */ 9 | 10 | public class StratumJsonMethodShowMessage extends StratumJsonMethod 11 | { 12 | //{"method":"client.reconnect",params:["test",1]} 13 | public final static String TEST_PATT = "{\"params\": [\"TEST\"], \"jsonrpc\": \"2.0\", \"method\": \"client.show_message\", \"id\": null}"; 14 | public final String val; 15 | // public parameterima 16 | public StratumJsonMethodShowMessage(JsonNode i_json_node) throws MinyaException { 17 | super(i_json_node); 18 | String s = i_json_node.get("method").asText(); 19 | if (s.compareTo("client.show_message") != 0) { 20 | throw new MinyaException(); 21 | } 22 | this.val=i_json_node.get("params").asText(); 23 | return; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/res/layout/simple_popup_window.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 19 | 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/SplashScreen.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.os.Handler; 7 | 8 | /** 9 | * Created by Tal on 07/08/2017. 10 | */ 11 | 12 | public class SplashScreen extends Activity { 13 | 14 | // Splash screen timer 15 | // private static int SPLASH_TIME_OUT = 10000; 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | Intent i = new Intent(SplashScreen.this, MainActivity.class); 21 | startActivity(i); 22 | finish(); 23 | // setContentView(R.layout.splash_screen); 24 | 25 | // new Handler().postDelayed(new Runnable() { 26 | // 27 | // @Override 28 | // public void run() { 29 | // 30 | // Intent i = new Intent(SplashScreen.this, MainActivity.class); 31 | // startActivity(i); 32 | // finish(); 33 | // } 34 | // }, SPLASH_TIME_OUT); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/StratumMiner/Worker/IMiningWorker.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer.StratumMiner.Worker; 2 | 3 | import com.example.android.ltcteminer.StratumMiner.MiningWork; 4 | import com.example.android.ltcteminer.StratumMiner.MinyaException; 5 | 6 | /** 7 | * Created by Tal on 09/08/2017. 8 | */ 9 | 10 | public interface IMiningWorker 11 | { 12 | public enum Notification { 13 | SYSTEM_ERROR, 14 | PERMISSION_ERROR, 15 | CONNECTION_ERROR, 16 | AUTHENTICATION_ERROR, 17 | COMMUNICATION_ERROR, 18 | LONG_POLLING_FAILED, 19 | LONG_POLLING_ENABLED, 20 | CONNECTING, 21 | NEW_BLOCK_DETECTED, 22 | SPEED, 23 | NEW_WORK, 24 | POW_TRUE, 25 | POW_FALSE, 26 | TERMINATED 27 | }; 28 | 29 | public boolean doWork(MiningWork i_work) throws MinyaException; 30 | 31 | public void stopWork() throws MinyaException; 32 | 33 | public int getProgress(); 34 | 35 | public long getNumberOfHash(); 36 | 37 | public void addListener(IWorkerEvent i_listener) throws MinyaException; 38 | } -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | #ff5252 7 | #eeeeee 8 | #424242 9 | #424242 10 | 11 | #eeeeee 12 | #ff8a65 13 | #eeeeee 14 | #4db6ac 15 | 16 | #7E0099CC 17 | #CFE9F3 18 | #eeeeee 19 | 20 | #10000000 21 | #eeeeee 22 | #eeeeee 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/StratumMiner/Stratum/StratumJsonMethodReconnect.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer.StratumMiner.Stratum; 2 | 3 | import com.example.android.ltcteminer.StratumMiner.MinyaException; 4 | import com.fasterxml.jackson.databind.JsonNode; 5 | 6 | /** 7 | * Created by Tal on 09/08/2017. 8 | */ 9 | 10 | public class StratumJsonMethodReconnect extends StratumJsonMethod 11 | { 12 | //{"method":"client.reconnect",params:["host",1]} 13 | public final static String TEST_PATT = "{\"params\": [\"host\",80], \"jsonrpc\": \"2.0\", \"method\": \"client.reconnect\", \"id\": null}"; 14 | 15 | // public parameter 16 | public int port; 17 | public String host; 18 | 19 | public StratumJsonMethodReconnect(JsonNode i_json_node) throws MinyaException { 20 | super(i_json_node); 21 | String s = i_json_node.get("method").asText(); 22 | if (s.compareTo("client.reconnect") != 0) { 23 | throw new MinyaException(); 24 | } 25 | JsonNode p=i_json_node.get("params"); 26 | this.host=p.get(0).asText(); 27 | this.port=p.get(1).asInt(); 28 | return; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/StratumMiner/Base64.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer.StratumMiner; 2 | 3 | /** 4 | * Created by Tal on 09/08/2017. 5 | */ 6 | 7 | public class Base64 8 | { 9 | private final static char[] BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".toCharArray(); 10 | public final static String encode(String str) 11 | { 12 | byte[] buf = str.getBytes(); 13 | int size = buf.length; 14 | char[] ar = new char[((size + 2) / 3) * 4]; 15 | int a = 0; 16 | int i = 0; 17 | while (i < size) { 18 | byte b0 = buf[i++]; 19 | byte b1 = (i < size) ? buf[i++] : 0; 20 | byte b2 = (i < size) ? buf[i++] : 0; 21 | ar[a++] = BASE64_ALPHABET[(b0 >> 2) & 0x3f]; 22 | ar[a++] = BASE64_ALPHABET[((b0 << 4) | ((b1 & 0xFF) >> 4)) & 0x3f]; 23 | ar[a++] = BASE64_ALPHABET[((b1 << 2) | ((b2 & 0xFF) >> 6)) & 0x3f]; 24 | ar[a++] = BASE64_ALPHABET[b2 & 0x3f]; 25 | } 26 | switch (size % 3) { 27 | case 1: 28 | ar[--a] = '='; 29 | case 2: 30 | ar[--a] = '='; 31 | } 32 | return new String(ar); 33 | } 34 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 15 | 16 | 20 | 21 | 22 | 27 | 28 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/res/layout/splash_screen.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 15 | 16 | 24 | 25 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.support.design.widget.TabLayout; 7 | import android.support.v4.view.ViewPager; 8 | import android.support.v7.widget.Toolbar; 9 | 10 | 11 | public class MainActivity extends AppCompatActivity { 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | setContentView(R.layout.activity_main); 17 | 18 | Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar); 19 | myToolbar.setLogo(R.mipmap.ltcte_actionbar_icon); 20 | myToolbar.setTitle(R.string.app_title); 21 | myToolbar.setTitleTextAppearance(this,R.style.TextAppearance_AppCompat_Medium); 22 | myToolbar.setTitleTextColor(getResources().getColor(R.color.AppNameColor)); 23 | setSupportActionBar(myToolbar); 24 | 25 | // Get the ViewPager and set it's PagerAdapter so that it can display items 26 | ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager); 27 | viewPager.setAdapter(new TabFragmentAdapter(getSupportFragmentManager(), 28 | MainActivity.this)); 29 | 30 | // Give the TabLayout the ViewPager 31 | TabLayout tabLayout = (TabLayout) findViewById(R.id.sliding_tabs); 32 | tabLayout.setupWithViewPager(viewPager); 33 | } 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | defaultConfig { 7 | applicationId "com.example.android.ltcteminer" 8 | minSdkVersion 17 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | packagingOptions { 15 | exclude 'META-INF/LICENSE' 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | compile fileTree(dir: 'libs', include: ['*.jar']) 27 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 28 | exclude group: 'com.android.support', module: 'support-annotations' 29 | }) 30 | compile 'com.android.support:appcompat-v7:25.3.1' 31 | compile 'com.android.support.constraint:constraint-layout:1.0.2' 32 | compile 'com.android.support:support-v4:25.3.1' 33 | compile 'com.android.support:design:23.3.0' 34 | compile 'com.github.gabrielemariotti.cards:cardslib-core:2.1.0' 35 | compile 'com.github.gabrielemariotti.cards:cardslib-cards:2.1.0' 36 | compile 'com.fasterxml.jackson.core:jackson-databind:2.8.5' 37 | compile 'com.fasterxml.jackson.core:jackson-core:2.8.5' 38 | compile 'com.fasterxml.jackson.core:jackson-annotations:2.8.5' 39 | testCompile 'junit:junit:4.12' 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/NetworkUtil.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer; 2 | 3 | import android.content.Context; 4 | import android.net.ConnectivityManager; 5 | import android.net.NetworkInfo; 6 | 7 | /** 8 | * Created by Tal on 06/08/2017. 9 | */ 10 | 11 | public class NetworkUtil { 12 | 13 | public static int TYPE_WIFI = 1; 14 | public static int TYPE_MOBILE = 2; 15 | public static int TYPE_NOT_CONNECTED = 0; 16 | 17 | 18 | public static int getConnectivityStatus(Context context) { 19 | ConnectivityManager cm = (ConnectivityManager) context 20 | .getSystemService(Context.CONNECTIVITY_SERVICE); 21 | 22 | NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); 23 | if (null != activeNetwork) { 24 | if(activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) 25 | return TYPE_WIFI; 26 | 27 | if(activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) 28 | return TYPE_MOBILE; 29 | } 30 | return TYPE_NOT_CONNECTED; 31 | } 32 | 33 | public static String getConnectivityStatusString(Context context) { 34 | int conn = NetworkUtil.getConnectivityStatus(context); 35 | String status = null; 36 | if (conn == NetworkUtil.TYPE_WIFI) { 37 | status = "Wifi enabled"; 38 | } else if (conn == NetworkUtil.TYPE_MOBILE) { 39 | status = "Mobile data enabled"; 40 | } else if (conn == NetworkUtil.TYPE_NOT_CONNECTED) { 41 | status = "Not connected to Internet"; 42 | } 43 | return status; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/StratumMiner/MinyaLog.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer.StratumMiner; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Calendar; 5 | 6 | /** 7 | * Created by Tal on 09/08/2017. 8 | */ 9 | 10 | public class MinyaLog 11 | { 12 | public static interface ILogOutput 13 | { 14 | final static int LV_DEBUG =1; 15 | final static int LV_MESSAGE =2; 16 | final static int LV_WARNING =3; 17 | public void println(int level,String s); 18 | } 19 | public static class StandardOutput implements ILogOutput 20 | { 21 | public void println(int level,String s) 22 | { 23 | System.out.println(s); 24 | System.out.flush(); 25 | } 26 | } 27 | private static ILogOutput output=new StandardOutput(); 28 | public static void setOutput(ILogOutput p){ 29 | MinyaLog.output=p; 30 | } 31 | 32 | private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); 33 | private static String getDateHeader() 34 | { 35 | 36 | Calendar c = Calendar.getInstance(); 37 | 38 | return "["+sdf.format(c.getTime())+"]"; 39 | } 40 | public static synchronized void message(String s) 41 | { 42 | MinyaLog.output.println(ILogOutput.LV_MESSAGE,getDateHeader()+s); 43 | } 44 | 45 | public static synchronized void warning(String s) 46 | { 47 | MinyaLog.output.println(ILogOutput.LV_WARNING,getDateHeader()+"Warning:"+s); 48 | } 49 | public static synchronized void debug(String s) 50 | { 51 | MinyaLog.output.println(ILogOutput.LV_DEBUG,getDateHeader()+"Debug:"+s); 52 | } 53 | } 54 | 55 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 16 | 17 | 24 | 27 | 28 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/StratumMiner/MiningWork.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer.StratumMiner; 2 | 3 | /** 4 | * Created by Tal on 09/08/2017. 5 | */ 6 | 7 | public class MiningWork 8 | { 9 | public final HexArray data; //big endian 10 | public final HexArray target; //big endian 11 | public final HexArray header; //little endian 12 | private static byte[] headerByData(byte[] data) 13 | { 14 | byte[] h = new byte[80]; 15 | for (int i = 0; i < 80; i += 4) { 16 | h[i] = data[i + 3]; 17 | h[i + 1] = data[i + 2]; 18 | h[i + 2] = data[i + 1]; 19 | h[i + 3] = data[i]; 20 | } 21 | return h; 22 | } 23 | public MiningWork(HexArray i_data,HexArray i_target) 24 | { 25 | this.data=i_data; 26 | this.target=i_target; 27 | this.header=new HexArray(headerByData(i_data.refHex())); 28 | return; 29 | } 30 | public void dump() 31 | { 32 | System.out.println("data:"+this.data.getStr()); 33 | System.out.println("target:"+this.target.getStr()); 34 | } 35 | /** 36 | * This function makes submitdata from current work and nonce value. 37 | * @param i_nonce 38 | * @return 39 | */ 40 | public String makeSubmitData(int i_nonce) 41 | { 42 | byte[] d = this.data.refHex().clone(); 43 | d[79] = (byte) (i_nonce >> 0); 44 | d[78] = (byte) (i_nonce >> 8); 45 | d[77] = (byte) (i_nonce >> 16); 46 | d[76] = (byte) (i_nonce >> 24); 47 | return new HexArray(d).getStr(); 48 | } 49 | public final static int INDEX_OF_PREVHASH =4; //32byte 50 | public final static int INDEX_OF_MARKERTOOT =INDEX_OF_PREVHASH+32; //32byte 51 | public final static int INDEX_OF_NTIME =INDEX_OF_MARKERTOOT+32; //4byte 52 | public final static int INDEX_OF_NBIT =INDEX_OF_NTIME+4; //4byte 53 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 19 | 20 | 21 | 22 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/StratumMiner/Console.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer.StratumMiner; 2 | 3 | import android.os.Bundle; 4 | import android.os.Handler; 5 | import android.os.Message; 6 | import android.util.Log; 7 | 8 | import java.text.DateFormat; 9 | import java.text.SimpleDateFormat; 10 | import java.util.Date; 11 | 12 | /** 13 | * Created by Tal on 09/08/2017. 14 | */ 15 | 16 | public class Console { 17 | final int MSG_UIUPDATE = 1; 18 | final int MSG_STATUPDATE = 2; 19 | final int MSG_CONSOLE_UPDATE = 7; 20 | private static final DateFormat logDateFormat = new SimpleDateFormat("[yyyy-MM-dd HH:mm:ss] "); 21 | StringBuilder sb=new StringBuilder(); 22 | boolean c_new=false; 23 | String[] console_a = new String[20]; 24 | Handler sHandler = new Handler(); 25 | 26 | public Console(Handler h) 27 | { 28 | Log.i("LC", "Console: Console()"); 29 | console_a=new String[20]; 30 | for (int i=0; i<20; i++) {console_a[i]="";} 31 | sHandler = h; 32 | } 33 | 34 | public void write (String s) 35 | { 36 | Message msg = new Message(); 37 | Bundle bundle = new Bundle(); 38 | 39 | Log.i("LC", "Console: write():"+s); 40 | if(s!=null) 41 | { 42 | for (int i=19; i>0; i--) {console_a[i]=console_a[i-1]; } 43 | console_a[0]= logDateFormat.format(new Date()) + s; 44 | } 45 | msg.arg1=MSG_CONSOLE_UPDATE; 46 | bundle.putString("console", getConsole()); 47 | msg.setData(bundle); 48 | sHandler.sendMessage(msg); 49 | } 50 | 51 | public String getConsole() 52 | { 53 | sb=new StringBuilder(); 54 | for (int i=0; i<20; i++) 55 | { 56 | try { 57 | sb.append(console_a[i] + '\n'); 58 | } 59 | catch (ArrayIndexOutOfBoundsException e) { 60 | e.printStackTrace(); 61 | continue; 62 | } 63 | } 64 | return sb.toString(); 65 | } 66 | 67 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/TabFragmentAdapter.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer; 2 | 3 | import android.content.Context; 4 | import android.support.v4.app.Fragment; 5 | import android.support.v4.app.FragmentManager; 6 | import android.support.v4.app.FragmentPagerAdapter; 7 | 8 | /** 9 | * Created by Tal on 28/07/2017. 10 | */ 11 | 12 | public class TabFragmentAdapter extends FragmentPagerAdapter { 13 | final int PAGE_COUNT = 4; 14 | private Context mContext; 15 | private String tabTitles[]; 16 | 17 | public TabFragmentAdapter(FragmentManager fm, Context context) { 18 | super(fm); 19 | mContext = context; 20 | tabTitles = new String[] { context.getResources().getString(R.string.settings_tab_title) , context.getResources().getString(R.string.rates_tab_title) , 21 | context.getResources().getString(R.string.mine_tab_title) ,context.getResources().getString(R.string.about_tab_title) }; 22 | } 23 | 24 | @Override 25 | public int getCount() { 26 | return PAGE_COUNT; 27 | } 28 | 29 | @Override 30 | public Fragment getItem(int position) { 31 | if (position == 0) { 32 | return SettingsFragment.newInstance(position+1); 33 | } 34 | else if (position == 1) { 35 | return RatesFragment.newInstance(position+1); 36 | } 37 | else if (position == 2) { 38 | return MineFragment.newInstance(position+1); 39 | } 40 | else { 41 | return AboutFragment.newInstance(position+1); 42 | } 43 | // switch (position) { 44 | // case 0: 45 | // return new SettingsFragment(); 46 | // case 1: 47 | // return new MineFragment(); 48 | // case 2: 49 | // return new RatesFragment(); 50 | // case 3: 51 | // return new AboutFragment(); 52 | // default: 53 | // return new SettingsFragment(); 54 | // } 55 | } 56 | 57 | @Override 58 | public CharSequence getPageTitle(int position) { 59 | // Generate title based on item position 60 | return tabTitles[position]; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /app/src/main/res/xml/settings_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 17 | 18 | 19 | 26 | 27 | 34 | 35 | 42 | 43 | 50 | 51 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /app/src/main/res/layout/card_rates_inner_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 19 | 20 | 29 | 30 | 38 | 39 | 47 | 48 | 49 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/StratumMiner/Constants.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer.StratumMiner; 2 | 3 | /** 4 | * Created by Tal on 09/08/2017. 5 | */ 6 | 7 | public class Constants { 8 | 9 | public static final int MSG_UIUPDATE = 1; 10 | public static final int MSG_TERMINATED = 2; 11 | public static final int MSG_SPEED_UPDATE = 3; 12 | public static final int MSG_STATUS_UPDATE = 4; 13 | public static final int MSG_ACCEPTED_UPDATE = 5; 14 | public static final int MSG_REJECTED_UPDATE = 6; 15 | public static final int MSG_CONSOLE_UPDATE = 7; 16 | 17 | public static final String PREF_URL="URL"; 18 | public static final String PREF_USER= "USER"; 19 | public static final String PREF_PASS= "PASS"; 20 | public static final String PREF_THREAD= "THREAD"; 21 | public static final String PREF_THROTTLE = "THROTTLE"; 22 | public static final String PREF_SCANTIME = "SCANTIME"; 23 | public static final String PREF_RETRYPAUSE = "RETRYPAUSE"; 24 | //public static final String PREF_DONATE = "DONATE"; 25 | public static final String PREF_SERVICE = "SERVICE"; 26 | public static final String PREF_TITLE="SETTINGS"; 27 | public static final String PREF_PRIORITY="PRIORITY"; 28 | public static final String PREF_BACKGROUND="BACKGROUND"; 29 | public static final String PREF_SCREEN="SCREEN_AWAKE"; 30 | //public static final String PREF_NEWS_RUN_ONCE="NEWS_RUN_ONCE"; 31 | 32 | public static final String DEFAULT_URL="stratum+tcp://litecoinpool.org:3333"; 33 | public static final String DEFAULT_USER="Username"; 34 | public static final String DEFAULT_PASS="Password"; 35 | 36 | // public static final String DONATE_URL="http://litecoinpool.org:9332"; 37 | // public static final String DONATE_USER="raad287.3"; 38 | // public static final String DONATE_PASS="3"; 39 | 40 | public static final int DEFAULT_PRIORITY=1; 41 | public static final int DEFAULT_THREAD=1; 42 | public static final long DEFAULT_SCANTIME=500; 43 | public static final long DEFAULT_RETRYPAUSE=500; 44 | public static final float DEFAULT_THROTTLE=1; 45 | // public static final boolean DEFAULT_DONATE = false; 46 | public static final boolean DEFAULT_BACKGROUND = false; 47 | public static final boolean DEFAULT_SCREEN = true; 48 | 49 | public static final String CLIENT_NAME_STRING="LTCteMiner"; 50 | 51 | 52 | public static final String STATUS_NOT_MINING = "Not Mining"; 53 | public static final String STATUS_MINING = "Mining"; 54 | public static final String STATUS_ERROR = "Error"; 55 | public static final String STATUS_TERMINATED = "Terminated"; 56 | public static final String STATUS_CONNECTING = "Connecting"; 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/AboutFragment.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer; 2 | 3 | import android.content.Context; 4 | import android.net.Uri; 5 | import android.os.Bundle; 6 | import android.support.v4.app.Fragment; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.widget.TextView; 11 | 12 | import it.gmariotti.cardslib.library.view.CardViewNative; 13 | 14 | 15 | public class AboutFragment extends Fragment { 16 | private static final String ARG_PARAM1 = "param1"; 17 | int tabNumber; 18 | 19 | // private OnFragmentInteractionListener mListener; 20 | 21 | public AboutFragment() { 22 | // Required empty public constructor 23 | } 24 | 25 | public static AboutFragment newInstance(int currentTab) { 26 | AboutFragment fragment = new AboutFragment(); 27 | Bundle args = new Bundle(); 28 | String param1 = "" + currentTab; 29 | args.putString(ARG_PARAM1, param1); 30 | fragment.setArguments(args); 31 | return fragment; 32 | } 33 | 34 | @Override 35 | public void onCreate(Bundle savedInstanceState) { 36 | if (getArguments() != null) { 37 | tabNumber = Integer.parseInt(getArguments().getString(ARG_PARAM1)); 38 | } 39 | super.onCreate(savedInstanceState); 40 | } 41 | 42 | 43 | 44 | @Override 45 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 46 | Bundle savedInstanceState) { 47 | // Inflate the layout for this fragment 48 | View view = inflater.inflate(R.layout.fragment_about, container, false); 49 | //TextView textView = (TextView) view; 50 | //textView.setText("Fragment #" + mPage); 51 | return view; 52 | } 53 | 54 | // // TODO: Rename method, update argument and hook method into UI event 55 | // public void onButtonPressed(Uri uri) { 56 | // if (mListener != null) { 57 | // mListener.onFragmentInteraction(uri); 58 | // } 59 | // } 60 | // 61 | // @Override 62 | // public void onAttach(Context context) { 63 | // super.onAttach(context); 64 | // if (context instanceof OnFragmentInteractionListener) { 65 | // mListener = (OnFragmentInteractionListener) context; 66 | // } else { 67 | // throw new RuntimeException(context.toString() 68 | // + " must implement OnFragmentInteractionListener"); 69 | // } 70 | // } 71 | // 72 | // @Override 73 | // public void onDetach() { 74 | // super.onDetach(); 75 | // mListener = null; 76 | // } 77 | // 78 | // /** 79 | // * This interface must be implemented by activities that contain this 80 | // * fragment to allow an interaction in this fragment to be communicated 81 | // * to the activity and potentially other fragments contained in that 82 | // * activity. 83 | // *

84 | // * See the Android Training lesson Communicating with Other Fragments for more information. 87 | // */ 88 | // public interface OnFragmentInteractionListener { 89 | // // TODO: Update argument type and name 90 | // void onFragmentInteraction(Uri uri); 91 | // } 92 | } 93 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_about.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 19 | 20 | 27 | 40 | 52 | 53 | 54 | 64 | 65 | 66 | 76 | 77 | 87 | 88 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/StratumMiner/HexArray.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer.StratumMiner; 2 | 3 | /** 4 | * Created by Tal on 09/08/2017. 5 | */ 6 | 7 | public final class HexArray 8 | { 9 | private byte[] _v; 10 | public HexArray(String i_s) 11 | { 12 | this._v=toByteArray(i_s); 13 | } 14 | 15 | public HexArray(HexArray i_src) 16 | { 17 | this._v=new byte[i_src._v.length]; 18 | System.arraycopy(i_src._v,0,this._v,0,i_src._v.length); 19 | } 20 | 21 | 22 | public HexArray(byte[] i_attach_array) 23 | { 24 | this._v=i_attach_array; 25 | } 26 | public HexArray(HexArray i_src, int i_start,int i_len) 27 | { 28 | this(new byte[i_len]); 29 | System.arraycopy(i_src._v,i_start,this._v,0,i_len); 30 | } 31 | public byte[] refHex() 32 | { 33 | return this._v; 34 | } 35 | public String getStr() 36 | { 37 | return toHexString(this._v); 38 | } 39 | 40 | 41 | public String getStr(int i_s,int i_l) 42 | { 43 | return toHexString(this._v,i_s,i_l); 44 | } 45 | 46 | public void swapEndian(HexArray i_add) 47 | { 48 | byte[] v=this._v; 49 | for(int i=0;i 100 | * See the Android Training lesson Communicating with Other Fragments for more information. 103 | */ 104 | public interface OnFragmentInteractionListener { 105 | // TODO: Update argument type and name 106 | void onFragmentInteraction(Uri uri); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /app/src/main/res/layout/wallaet_card_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 16 | 17 | 20 | 26 | 27 | 32 | 33 | 39 | 40 | 41 | 42 | 47 | 53 | 54 | 63 | 64 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/StratumMiner/Hasher/Hasher.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer.StratumMiner.Hasher; 2 | 3 | import java.security.GeneralSecurityException; 4 | 5 | import javax.crypto.Mac; 6 | import javax.crypto.spec.SecretKeySpec; 7 | 8 | import static java.lang.Integer.rotateLeft; 9 | import static java.lang.System.arraycopy; 10 | 11 | /** 12 | * Created by Tal on 09/08/2017. 13 | */ 14 | 15 | public class Hasher 16 | { 17 | 18 | private Mac mac; 19 | private byte[] H = new byte[32]; 20 | private byte[] B = new byte[128 + 4]; 21 | private int[] X = new int[32]; 22 | private int[] V = new int[32 * 1024]; 23 | 24 | public Hasher() throws GeneralSecurityException { 25 | mac = Mac.getInstance("HmacSHA256"); 26 | } 27 | public byte[] hash(byte[] header, int nonce) throws GeneralSecurityException 28 | { 29 | int i, j, k; 30 | 31 | arraycopy(header, 0, B, 0, 76); 32 | B[76] = (byte) (nonce >> 24); 33 | B[77] = (byte) (nonce >> 16); 34 | B[78] = (byte) (nonce >> 8); 35 | B[79] = (byte) (nonce >> 0); 36 | mac.init(new SecretKeySpec(B, 0, 80, "HmacSHA256")); 37 | B[80] = 0; 38 | B[81] = 0; 39 | B[82] = 0; 40 | for (i = 0; i < 4; i++) { 41 | B[83] = (byte) (i + 1); 42 | mac.update(B, 0, 84); 43 | mac.doFinal(H, 0); 44 | 45 | for (j = 0; j < 8; j++) { 46 | X[i * 8 + j] = (H[j * 4 + 0] & 0xff) << 0 47 | | (H[j * 4 + 1] & 0xff) << 8 48 | | (H[j * 4 + 2] & 0xff) << 16 49 | | (H[j * 4 + 3] & 0xff) << 24; 50 | } 51 | } 52 | 53 | for (i = 0; i < 1024; i++) { 54 | arraycopy(X, 0, V, i * 32, 32); 55 | xorSalsa8(0, 16); 56 | xorSalsa8(16, 0); 57 | } 58 | for (i = 0; i < 1024; i++) { 59 | k = (X[16] & 1023) * 32; 60 | for (j = 0; j < 32; j++) 61 | X[j] ^= V[k + j]; 62 | xorSalsa8(0, 16); 63 | xorSalsa8(16, 0); 64 | } 65 | 66 | for (i = 0; i < 32; i++) { 67 | B[i * 4 + 0] = (byte) (X[i] >> 0); 68 | B[i * 4 + 1] = (byte) (X[i] >> 8); 69 | B[i * 4 + 2] = (byte) (X[i] >> 16); 70 | B[i * 4 + 3] = (byte) (X[i] >> 24); 71 | } 72 | 73 | B[128 + 3] = 1; 74 | mac.update(B, 0, 128 + 4); 75 | mac.doFinal(H, 0); 76 | 77 | return H; 78 | } 79 | 80 | private void xorSalsa8(int di, int xi) { 81 | int x00 = (X[di + 0] ^= X[xi + 0]); 82 | int x01 = (X[di + 1] ^= X[xi + 1]); 83 | int x02 = (X[di + 2] ^= X[xi + 2]); 84 | int x03 = (X[di + 3] ^= X[xi + 3]); 85 | int x04 = (X[di + 4] ^= X[xi + 4]); 86 | int x05 = (X[di + 5] ^= X[xi + 5]); 87 | int x06 = (X[di + 6] ^= X[xi + 6]); 88 | int x07 = (X[di + 7] ^= X[xi + 7]); 89 | int x08 = (X[di + 8] ^= X[xi + 8]); 90 | int x09 = (X[di + 9] ^= X[xi + 9]); 91 | int x10 = (X[di + 10] ^= X[xi + 10]); 92 | int x11 = (X[di + 11] ^= X[xi + 11]); 93 | int x12 = (X[di + 12] ^= X[xi + 12]); 94 | int x13 = (X[di + 13] ^= X[xi + 13]); 95 | int x14 = (X[di + 14] ^= X[xi + 14]); 96 | int x15 = (X[di + 15] ^= X[xi + 15]); 97 | for (int i = 0; i < 8; i += 2) { 98 | x04 ^= rotateLeft(x00+x12, 7); x08 ^= rotateLeft(x04+x00, 9); 99 | x12 ^= rotateLeft(x08+x04,13); x00 ^= rotateLeft(x12+x08,18); 100 | x09 ^= rotateLeft(x05+x01, 7); x13 ^= rotateLeft(x09+x05, 9); 101 | x01 ^= rotateLeft(x13+x09,13); x05 ^= rotateLeft(x01+x13,18); 102 | x14 ^= rotateLeft(x10+x06, 7); x02 ^= rotateLeft(x14+x10, 9); 103 | x06 ^= rotateLeft(x02+x14,13); x10 ^= rotateLeft(x06+x02,18); 104 | x03 ^= rotateLeft(x15+x11, 7); x07 ^= rotateLeft(x03+x15, 9); 105 | x11 ^= rotateLeft(x07+x03,13); x15 ^= rotateLeft(x11+x07,18); 106 | x01 ^= rotateLeft(x00+x03, 7); x02 ^= rotateLeft(x01+x00, 9); 107 | x03 ^= rotateLeft(x02+x01,13); x00 ^= rotateLeft(x03+x02,18); 108 | x06 ^= rotateLeft(x05+x04, 7); x07 ^= rotateLeft(x06+x05, 9); 109 | x04 ^= rotateLeft(x07+x06,13); x05 ^= rotateLeft(x04+x07,18); 110 | x11 ^= rotateLeft(x10+x09, 7); x08 ^= rotateLeft(x11+x10, 9); 111 | x09 ^= rotateLeft(x08+x11,13); x10 ^= rotateLeft(x09+x08,18); 112 | x12 ^= rotateLeft(x15+x14, 7); x13 ^= rotateLeft(x12+x15, 9); 113 | x14 ^= rotateLeft(x13+x12,13); x15 ^= rotateLeft(x14+x13,18); 114 | } 115 | X[di + 0] += x00; 116 | X[di + 1] += x01; 117 | X[di + 2] += x02; 118 | X[di + 3] += x03; 119 | X[di + 4] += x04; 120 | X[di + 5] += x05; 121 | X[di + 6] += x06; 122 | X[di + 7] += x07; 123 | X[di + 8] += x08; 124 | X[di + 9] += x09; 125 | X[di + 10] += x10; 126 | X[di + 11] += x11; 127 | X[di + 12] += x12; 128 | X[di + 13] += x13; 129 | X[di + 14] += x14; 130 | X[di + 15] += x15; 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/StratumMiner/Stratum/StratumJsonMethodMiningNotify.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer.StratumMiner.Stratum; 2 | 3 | import com.example.android.ltcteminer.StratumMiner.HexArray; 4 | import com.example.android.ltcteminer.StratumMiner.MinyaException; 5 | import com.fasterxml.jackson.databind.JsonNode; 6 | 7 | import java.util.ArrayList; 8 | import java.util.Iterator; 9 | 10 | /** 11 | * Created by Tal on 09/08/2017. 12 | */ 13 | 14 | public class StratumJsonMethodMiningNotify extends StratumJsonMethod { 15 | public final static String TEST_PATT = "{\"params\":" 16 | + "[\"113341302436276469056253036457324159787\"," 17 | + " \"7bbb491d8da308c42bb84c28dd6c8f77aa0102a676b266bec530c737959ec4b4\"," 18 | + " \"01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0b03485215062f503253482fffffffff110024f400000000001976a9140833120f05dc473d8d3e4b7f0a7174207e62144588acfd718006000000001976a9147077906a5f88819a036bbb804c2435e239b384ef88aceea18106000000001976a91483eb72afc57909a4b44430e9783b2d18cb24315b88ac83708706000000001976a914a1d2c08641709fb25bbd5f35a3de1eae2fff161f88ac43ef9c06000000001976a9149d5584f55d593958a20e6b8f7353345551f8fd3d88ac05c1c406000000001976a914147a6c5a927d9422a819b58cb6a4803523b1c08888ac063dc706000000001976a9142fe80ea5aaf8dbfc819265dd2e6d8a56b5979b0f88ac401bb20b000000001976a9143bc4089dbb0a83c69365926434ccba8b8001626088acec522b0d000000001976a914ce1f15f063a332c71b9030a7ecffc4f22dfc635888ac86142e0d000000001976a914a68ce3ed72d8b8bd695129c97ff276ea673b179c88acf0ac300d000000001976a91420ac5a56c73a88e6492556d438c27d6844746e0388ac50f2330d000000001976a9148639380456dec002ed1238eabdabfb25cf8e88b988ac20f46b0d000000001976a914df5a67b33cb8c08693c0dcbbfd5a619632f9e66688ac757f451a000000001976a9149bd07713fd6c44bb2a0652f5c21f654420448e1b88acb7f4f32d000000001976a914b553762cbd73a73ed3def6f7fb48eec16a88191788ac0600000000000000434104ffd03de44a6e11b9917f3a29f9443283d9871c9d743ef30d5eddcd37094b64d1b3d8090496b53256786bf5c82932ec23c3b74d9f05a6f95a8b5529352656664bac00000000000000002a6a287cf05a8a20076248b28f7963992718a0dd3765ea76c77c8656dcf6ff985c4eb9000000000100\"," 19 | + " \"00000000\", [], \"00000001\", \"1d00bf80\", \"52ac5e55\", true], \"jsonrpc\": \"2.0\", \"method\": \"mining.notify\", \"id\": 764659215}"; 20 | // public 21 | public final String job_id; 22 | public final HexArray version; 23 | public final HexArray[] merkle_arr; 24 | public final HexArray ntime; 25 | public final HexArray nbit; 26 | public final boolean clean; 27 | public final HexArray prev_hash; 28 | public final HexArray coinb1; 29 | public final HexArray coinb2; 30 | 31 | public StratumJsonMethodMiningNotify(JsonNode i_json_node) throws MinyaException { 32 | super(i_json_node); 33 | { 34 | String s = i_json_node.get("method").asText(); 35 | if (s.compareTo("mining.notify") != 0) { 36 | throw new MinyaException(); 37 | } 38 | } 39 | JsonNode params = i_json_node.get("params"); 40 | // job_id 41 | { 42 | this.job_id = params.get(0).asText(); 43 | } 44 | { 45 | this.prev_hash = toHexArray(params.get(1).asText(), 64); 46 | } 47 | { 48 | this.coinb1 = new HexArray(params.get(2).asText()); 49 | } 50 | { 51 | this.coinb2 = new HexArray(params.get(3).asText()); 52 | } 53 | // merkle_arr 54 | { 55 | JsonNode merkle_arr = params.get(4); 56 | if (!merkle_arr.isArray()) { 57 | throw new MinyaException(); 58 | } 59 | ArrayList l=new ArrayList(); 60 | for (Iterator i = merkle_arr.iterator(); i.hasNext();) { 61 | l.add(toHexArray(i.next().asText(), 64)); 62 | } 63 | this.merkle_arr = l.toArray(new HexArray[l.size()]); 64 | } 65 | // version 66 | { 67 | this.version = toHexArray(params.get(5).asText(), 8); 68 | } 69 | // nbit 70 | { 71 | this.nbit = toHexArray(params.get(6).asText(), 8); 72 | } 73 | // ntime 74 | { 75 | this.ntime = toHexArray(params.get(7).asText(), 8); 76 | } 77 | // clean 78 | { 79 | this.clean = params.get(8).asBoolean(); 80 | } 81 | } 82 | public HexArray getXnonce2(StratumJsonResultSubscribe i_subscribe) 83 | { 84 | //xnonce2 85 | HexArray xnonce2=new HexArray(new byte[i_subscribe.xnonce2_size]); 86 | return xnonce2; 87 | } 88 | public HexArray getCoinbase(StratumJsonResultSubscribe i_subscribe) 89 | { 90 | //coinbase 91 | HexArray coinbase=new HexArray(this.coinb1); 92 | coinbase.append(i_subscribe.xnonce1); 93 | coinbase.append(this.getXnonce2(i_subscribe)); 94 | coinbase.append(this.coinb2); 95 | return coinbase; 96 | // coinb1_size = strlen(coinb1) / 2; 97 | // coinb2_size = strlen(coinb2) / 2; 98 | // sctx->job.coinbase_size = coinb1_size + sctx->xnonce1_size +sctx->xnonce2_size + coinb2_size; 99 | // sctx->job.coinbase = realloc(sctx->job.coinbase, sctx->job.coinbase_size); 100 | // hex2bin(sctx->job.coinbase, coinb1, coinb1_size); 101 | // memcpy(sctx->job.coinbase + coinb1_size, sctx->xnonce1, sctx->xnonce1_size); 102 | 103 | // sctx->job.xnonce2 = sctx->job.coinbase + coinb1_size + sctx->xnonce1_size; 104 | // if (!sctx->job.job_id || strcmp(sctx->job.job_id, job_id)) 105 | // memset(sctx->job.xnonce2, 0, sctx->xnonce2_size); 106 | // hex2bin(sctx->job.xnonce2 + sctx->xnonce2_size, coinb2, coinb2_size); 107 | } 108 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/StratumMiner/Stratum/StratumSocket.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer.StratumMiner.Stratum; 2 | 3 | import com.example.android.ltcteminer.StratumMiner.MinyaException; 4 | import com.example.android.ltcteminer.StratumMiner.MinyaLog; 5 | import com.fasterxml.jackson.core.JsonProcessingException; 6 | import com.fasterxml.jackson.databind.JsonNode; 7 | import com.fasterxml.jackson.databind.ObjectMapper; 8 | 9 | import java.io.BufferedReader; 10 | import java.io.BufferedWriter; 11 | import java.io.IOException; 12 | import java.io.InputStreamReader; 13 | import java.io.OutputStreamWriter; 14 | import java.io.Reader; 15 | import java.io.Writer; 16 | import java.net.Socket; 17 | import java.net.URI; 18 | import java.net.UnknownHostException; 19 | 20 | /** 21 | * Created by Tal on 09/08/2017. 22 | */ 23 | 24 | public class StratumSocket extends Socket 25 | { 26 | private class LoggingWriter extends BufferedWriter 27 | { 28 | public LoggingWriter(Writer arg0) { 29 | super(arg0); 30 | } 31 | @Override 32 | public void write(String str) throws IOException 33 | { 34 | super.write(str); 35 | MinyaLog.debug("TX>"+str); 36 | } 37 | } 38 | private class LoggingReader extends BufferedReader 39 | { 40 | public LoggingReader(Reader arg0) 41 | { 42 | super(arg0); 43 | } 44 | public String readLine() throws IOException 45 | { 46 | String s=super.readLine(); 47 | MinyaLog.debug("RX<"+s); 48 | return s; 49 | } 50 | } 51 | private BufferedWriter _tx; 52 | private BufferedReader _rx; 53 | private int _id; 54 | 55 | protected StratumSocket() 56 | { 57 | } 58 | public StratumSocket(URI i_url) throws UnknownHostException, IOException 59 | { 60 | super(i_url.getHost(),i_url.getPort()); 61 | this._tx = new LoggingWriter(new OutputStreamWriter(this.getOutputStream())); 62 | this._rx = new LoggingReader(new InputStreamReader(this.getInputStream())); 63 | this._id=1; 64 | } 65 | public long subscribe(String i_agent_name) throws IOException 66 | { 67 | long id; 68 | synchronized(this) 69 | { 70 | id=this._id; 71 | this._id++; 72 | } 73 | // this._tx.write("{\"id\": "+id+", \"method\": \"mining.subscribe\", \"params\": [\""+i_agent_name+"\"]}\n"); 74 | this._tx.write("{\"id\": "+id+", \"method\": \"mining.subscribe\", \"params\": []}\n"); 75 | this._tx.flush(); 76 | return id; 77 | } 78 | public long authorize(String i_user,String i_password) throws IOException 79 | { 80 | long id; 81 | synchronized(this) 82 | { 83 | id=this._id; 84 | this._id++; 85 | } 86 | this._tx.write("{\"id\": "+id+", \"method\": \"mining.authorize\", \"params\": [\""+i_user+"\",\""+i_password+"\"]}\n"); 87 | this._tx.flush(); 88 | return id; 89 | } 90 | public long submit(int i_nonce,String i_user,String i_jobid,String i_nonce2,String i_ntime) throws IOException 91 | { 92 | long id; 93 | synchronized(this) 94 | { 95 | id=this._id; 96 | this._id++; 97 | } 98 | String sn=String.format("%08x",( 99 | ((i_nonce & 0xff000000)>>24)| 100 | ((i_nonce & 0x00ff0000)>>8)| 101 | ((i_nonce & 0x0000ff00)<<8)| 102 | ((i_nonce & 0x000000ff)<<24))); 103 | // {"method": "mining.submit", "params": ["nyajira.xa", "e4c", "00000000", "52b7a1a9", "79280100"], "id":4} 104 | String s="{\"id\": "+id+", \"method\": \"mining.submit\", \"params\": [\"" 105 | +i_user+"\", \""+i_jobid+"\",\""+i_nonce2+"\",\""+i_ntime+"\",\""+sn+"\"]}\n"; 106 | this._tx.write(s); 107 | this._tx.flush(); 108 | return id; 109 | } 110 | public StratumJson recvStratumJson() throws IOException 111 | { 112 | ObjectMapper mapper = new ObjectMapper(); 113 | JsonNode jn=mapper.readTree(this._rx.readLine()); 114 | //parse method 115 | try { 116 | return new StratumJsonMethodGetVersion(jn); 117 | } catch (MinyaException e) {} 118 | try { 119 | return new StratumJsonMethodMiningNotify(jn); 120 | } catch (MinyaException e) {} 121 | try { 122 | return new StratumJsonMethodReconnect(jn); 123 | } catch (MinyaException e) {} 124 | try { 125 | return new StratumJsonMethodSetDifficulty(jn); 126 | } catch (MinyaException e) {} 127 | try { 128 | return new StratumJsonMethodShowMessage(jn); 129 | } catch (MinyaException e) {} 130 | //parse result(複雑なものから順にね!) 131 | try { 132 | return new StratumJsonResultSubscribe(jn); 133 | } catch (MinyaException e) {} 134 | try { 135 | return new StratumJsonResultStandard(jn); 136 | } catch (MinyaException e) {} 137 | return null; 138 | } 139 | public static void main(String[] args) 140 | { 141 | //JsonParseTest 142 | ObjectMapper mapper = new ObjectMapper(); 143 | try { 144 | StratumJson s1=new StratumJsonMethodGetVersion(mapper.readTree(StratumJsonMethodGetVersion.TEST_PATT)); 145 | StratumJson s2=new StratumJsonMethodMiningNotify(mapper.readTree(StratumJsonMethodMiningNotify.TEST_PATT)); 146 | StratumJson s3=new StratumJsonMethodReconnect(mapper.readTree(StratumJsonMethodReconnect.TEST_PATT)); 147 | StratumJson s4=new StratumJsonMethodSetDifficulty(mapper.readTree(StratumJsonMethodSetDifficulty.TEST_PATT)); 148 | StratumJson s5=new StratumJsonMethodShowMessage(mapper.readTree(StratumJsonMethodShowMessage.TEST_PATT)); 149 | StratumJson s6=new StratumJsonResultStandard(mapper.readTree(StratumJsonResultStandard.TEST_PATT)); 150 | StratumJson s7=new StratumJsonResultSubscribe(mapper.readTree(StratumJsonResultSubscribe.TEST_PATT)); 151 | return; 152 | } catch (JsonProcessingException e) { 153 | // TODO Auto-generated catch block 154 | e.printStackTrace(); 155 | } catch (MinyaException e) { 156 | // TODO Auto-generated catch block 157 | e.printStackTrace(); 158 | } catch (IOException e) { 159 | // TODO Auto-generated catch block 160 | e.printStackTrace(); 161 | } 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/StratumMiner/MinerService.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer.StratumMiner; 2 | 3 | import android.app.Service; 4 | import android.content.Intent; 5 | import android.content.SharedPreferences; 6 | import android.os.Binder; 7 | import android.os.Bundle; 8 | import android.os.Handler; 9 | import android.os.IBinder; 10 | import android.os.Message; 11 | import android.util.Log; 12 | import android.widget.Toast; 13 | 14 | import com.example.android.ltcteminer.StratumMiner.Connection.IMiningConnection; 15 | import com.example.android.ltcteminer.StratumMiner.Connection.StratumMiningConnection; 16 | import com.example.android.ltcteminer.StratumMiner.Worker.CpuMiningWorker; 17 | import com.example.android.ltcteminer.StratumMiner.Worker.IMiningWorker; 18 | 19 | import static com.example.android.ltcteminer.StratumMiner.Constants.DEFAULT_PASS; 20 | import static com.example.android.ltcteminer.StratumMiner.Constants.DEFAULT_PRIORITY; 21 | import static com.example.android.ltcteminer.StratumMiner.Constants.DEFAULT_RETRYPAUSE; 22 | import static com.example.android.ltcteminer.StratumMiner.Constants.DEFAULT_THREAD; 23 | import static com.example.android.ltcteminer.StratumMiner.Constants.DEFAULT_URL; 24 | import static com.example.android.ltcteminer.StratumMiner.Constants.DEFAULT_USER; 25 | import static com.example.android.ltcteminer.StratumMiner.Constants.MSG_ACCEPTED_UPDATE; 26 | import static com.example.android.ltcteminer.StratumMiner.Constants.MSG_CONSOLE_UPDATE; 27 | import static com.example.android.ltcteminer.StratumMiner.Constants.MSG_REJECTED_UPDATE; 28 | import static com.example.android.ltcteminer.StratumMiner.Constants.MSG_SPEED_UPDATE; 29 | import static com.example.android.ltcteminer.StratumMiner.Constants.MSG_STATUS_UPDATE; 30 | import static com.example.android.ltcteminer.StratumMiner.Constants.MSG_TERMINATED; 31 | import static com.example.android.ltcteminer.StratumMiner.Constants.PREF_PASS; 32 | import static com.example.android.ltcteminer.StratumMiner.Constants.PREF_PRIORITY; 33 | import static com.example.android.ltcteminer.StratumMiner.Constants.PREF_THREAD; 34 | import static com.example.android.ltcteminer.StratumMiner.Constants.PREF_TITLE; 35 | import static com.example.android.ltcteminer.StratumMiner.Constants.PREF_URL; 36 | import static com.example.android.ltcteminer.StratumMiner.Constants.PREF_USER; 37 | import static com.example.android.ltcteminer.StratumMiner.Constants.STATUS_NOT_MINING; 38 | 39 | /** 40 | * Created by Tal on 09/08/2017. 41 | */ 42 | 43 | public class MinerService extends Service { 44 | 45 | IMiningConnection mc; 46 | IMiningWorker imw; 47 | SingleMiningChief smc; 48 | //Miner miner; 49 | Console console; 50 | // String news=null; 51 | Boolean running=false; 52 | float speed=0; 53 | int accepted=0; 54 | int rejected=0; 55 | String status= STATUS_NOT_MINING; 56 | String cString=""; 57 | //int baseThreadCount = Thread.activeCount(); 58 | 59 | Handler serviceHandler = new Handler() { 60 | @Override 61 | public void handleMessage(Message msg) { 62 | Bundle bundle=msg.getData(); 63 | Log.i("LC", "Service: handleMessage() "+msg.arg1); 64 | 65 | if(msg.arg1==MSG_CONSOLE_UPDATE) { cString = bundle.getString("console"); } 66 | else if(msg.arg1==MSG_SPEED_UPDATE) { speed = bundle.getFloat("speed"); } 67 | else if(msg.arg1==MSG_STATUS_UPDATE) { status = bundle.getString("status"); } 68 | else if(msg.arg1==MSG_ACCEPTED_UPDATE) { accepted = (int) bundle.getLong("accepted"); } 69 | else if(msg.arg1==MSG_REJECTED_UPDATE) { rejected = (int) bundle.getLong("rejected"); } 70 | else if(msg.arg1==MSG_TERMINATED) { running=false; } 71 | super.handleMessage(msg); 72 | } 73 | }; 74 | // Binder given to clients 75 | private final IBinder mBinder = new LocalBinder(); 76 | 77 | public class LocalBinder extends Binder { 78 | MinerService getService() { 79 | return MinerService.this; 80 | } 81 | } 82 | 83 | public MinerService() { 84 | Log.i("LC", "Service: MinerService()"); 85 | } 86 | 87 | 88 | public void startMiner() 89 | { 90 | console = new Console(serviceHandler); 91 | Log.i("LC", "MinerService:startMiner()"); 92 | SharedPreferences settings = getSharedPreferences(PREF_TITLE, 0); 93 | String url, user, pass; 94 | speed=0; 95 | accepted=0; 96 | rejected=0; 97 | 98 | console.write("Service: Start mining"); 99 | url = settings.getString(PREF_URL, DEFAULT_URL); 100 | user = settings.getString(PREF_USER, DEFAULT_USER); 101 | pass = settings.getString(PREF_PASS, DEFAULT_PASS); 102 | 103 | // if (settings.getBoolean(PREF_DONATE, DEFAULT_DONATE)==true) 104 | // { 105 | // console.write("Main: Donate mode"); 106 | // url=DONATE_URL; 107 | // user=DONATE_USER; 108 | // pass=DONATE_PASS; 109 | // } 110 | // else 111 | // { 112 | // url = settings.getString(PREF_URL, DEFAULT_URL); 113 | // user = settings.getString(PREF_USER, DEFAULT_USER); 114 | // pass = settings.getString(PREF_PASS, DEFAULT_PASS); 115 | // } 116 | 117 | try { 118 | mc = new StratumMiningConnection(url,user,pass); 119 | int nThread = settings.getInt(PREF_THREAD, DEFAULT_THREAD); 120 | int nProirity = settings.getInt(PREF_PRIORITY,DEFAULT_PRIORITY); 121 | imw = new CpuMiningWorker(nThread,DEFAULT_RETRYPAUSE,nProirity,console); 122 | smc = new SingleMiningChief(mc,imw,console,serviceHandler); 123 | smc.startMining(); 124 | running =true; 125 | } catch (MinyaException e) { 126 | e.printStackTrace(); 127 | } 128 | 129 | // miner = new Miner(url, 130 | // user+":"+ 131 | // pass, 132 | // settings.getLong(PREF_SCANTIME, DEFAULT_SCANTIME), 133 | // settings.getLong(PREF_RETRYPAUSE, DEFAULT_RETRYPAUSE), 134 | // settings.getInt(PREF_THREAD, DEFAULT_THREAD), 135 | // settings.getFloat(PREF_THROTTLE, DEFAULT_THROTTLE), 136 | // settings.getInt(PREF_PRIORITY, DEFAULT_PRIORITY), 137 | // serviceHandler, console); 138 | // miner.start(); 139 | } 140 | 141 | public void stopMiner() 142 | { 143 | Log.i("LC", "Service: onBind()"); 144 | console.write("Service: Stopping mining"); 145 | Toast.makeText(this,"Worker cooling down, this can take a few minutes",Toast.LENGTH_LONG).show(); 146 | running=false; 147 | try { 148 | smc.stopMining(); 149 | } catch (MinyaException e) { 150 | e.printStackTrace(); 151 | } 152 | // int lastThreadCount = Thread.activeCount(); 153 | // while (Thread.activeCount() != baseThreadCount) { 154 | // if (Thread.activeCount() == lastThreadCount) { 155 | // lastThreadCount = Thread.activeCount(); 156 | // continue; 157 | // } 158 | // Log.i("Thread.ActiveCount()" , "" + Thread.activeCount()); 159 | // lastThreadCount = Thread.activeCount(); 160 | // } 161 | // miner.stop(); 162 | } 163 | 164 | @Override 165 | public IBinder onBind(Intent intent) { 166 | Log.i("LC", "Service: onBind()"); 167 | 168 | return mBinder; 169 | } 170 | 171 | 172 | 173 | } -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/StratumMiner/Stratum/StratumWorkBuilder.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer.StratumMiner.Stratum; 2 | 3 | import com.example.android.ltcteminer.StratumMiner.HexArray; 4 | import com.example.android.ltcteminer.StratumMiner.MiningWork; 5 | import com.example.android.ltcteminer.StratumMiner.MinyaException; 6 | import com.example.android.ltcteminer.StratumMiner.StratumMiningWork; 7 | import com.fasterxml.jackson.core.JsonProcessingException; 8 | import com.fasterxml.jackson.databind.ObjectMapper; 9 | 10 | import java.io.IOException; 11 | import java.security.MessageDigest; 12 | import java.security.NoSuchAlgorithmException; 13 | import java.util.Arrays; 14 | 15 | /** 16 | * Created by Tal on 09/08/2017. 17 | */ 18 | 19 | public class StratumWorkBuilder 20 | { 21 | private StratumJsonResultSubscribe _subscribe=null; 22 | private StratumJsonMethodMiningNotify _notify=null; 23 | private HexArray _xnonce2; 24 | private HexArray _coinbase; 25 | private HexArray _merkle_loot; 26 | private double _difficulty=Double.NEGATIVE_INFINITY; 27 | private byte[] sha256d(byte[] i_s) throws NoSuchAlgorithmException 28 | { 29 | MessageDigest md = MessageDigest.getInstance("SHA-256"); 30 | return md.digest(md.digest(i_s)); 31 | } 32 | public StratumWorkBuilder(StratumJsonResultSubscribe i_attached_subscribe) 33 | { 34 | this._subscribe=i_attached_subscribe; 35 | } 36 | public void setDiff(StratumJsonMethodSetDifficulty i_difficulty) throws MinyaException 37 | { 38 | this._difficulty=i_difficulty.difficulty; 39 | } 40 | public void setNotify(StratumJsonMethodMiningNotify i_attached_notify) throws MinyaException 41 | { 42 | this._notify=i_attached_notify; 43 | try{ 44 | //複製 45 | this._xnonce2=this._notify.getXnonce2(this._subscribe); 46 | this._coinbase=this._notify.getCoinbase(this._subscribe); 47 | /* 48 | //Generate merkle root 49 | sha256d(merkle_root, sctx->job.coinbase, sctx->job.coinbase_size); 50 | for (i = 0; i < sctx->job.merkle_count; i++) { 51 | memcpy(merkle_root + 32, sctx->job.merkle[i], 32); 52 | sha256d(merkle_root, merkle_root, 64); 53 | } 54 | */ 55 | byte[] merkle_loot=new byte[64]; 56 | System.arraycopy(sha256d(this._coinbase.refHex()),0,merkle_loot,0,32); 57 | for(int i=0;i 0 && diff > 1.0; k--){ 103 | diff /= 4294967296.0; 104 | } 105 | m = (long)(4294901760.0 / diff); 106 | if (m == 0 && k == 6){ 107 | Arrays.fill(target,(byte)0xff); 108 | }else{ 109 | Arrays.fill(target,(byte)0); 110 | for(int i=0;i<8;i++){ 111 | target[k*4+i]=(byte)((m>>(i*8))&0xff); 112 | } 113 | } 114 | return new HexArray(target); 115 | } 116 | 117 | 118 | 119 | public static void main(String[] args) 120 | { 121 | try { 122 | String SR="{\"error\": null, \"id\": 1, \"result\": [[\"mining.notify\", \"ae6812eb4cd7735a302a8a9dd95cf71f\"], \"f801d02f\", 4]}"; 123 | String NT="{\"params\": [\"8bf\", \"8e50f956acdabb3f8e981a4797466043021388791bfa70b1c1a1ba54a8fbdf50\", \"01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff26022d53062f503253482f042e4cb55208\", \"0d2f7374726174756d506f6f6c2f0000000001310cb3fca45500001976a91446a9148895dfa88b9e1596c14afda26b9071861488ac00000000\", [\"e5af4fcc527ce0aecc36848b550032e10f1359a16a3d6b07d76d0ccd361a66e3\", \"9bb81dcf2f43dafcdb6006353ce628a81e27bafd9ea13142bbce9cdf2fa0319b\", \"d7c70d31366c6068a5481f1a9fd786ee1aaa5032c3abd87ac9e024279cd21432\", \"af8cf8b535246110f17fc823c380d1c129d72d20db91cc7be4fb99d5327234e7\", \"5ed74269c86186c14bed42d020fceb631c2db2ad46de19d593f85888503a4c3d\", \"9243decb3a9a34360650f9132cdfca33bbc26677a3c079e978d7c455303861ee\", \"6c7c245323e51b1cda9e7f9de1917c36f94a09d06726352b952c7bf18e5f0dd1\", \"cad9bdc3937c263d78879ccb935cde980f43469260dd0a23d0f0ad9d16fe1b89\", \"b13743cd86b181d1cf8de23404951e4b0c39a273e2061f1a418c36d51dfd3be9\"], \"00000001\", \"1c00adb7\", \"52b54c29\", true], \"id\": null, \"method\": \"mining.notify\"}"; 124 | String ST="{\"params\": [128], \"id\": null, \"method\": \"mining.set_difficulty\"}"; 125 | String WORK_DATA="000000018e50f956acdabb3f8e981a4797466043021388791bfa70b1c1a1ba54a8fbdf5093b73998a3b9d1ad9ee12578b6ffb49088bb9321fcb159e15f10b397cb514e4952b54c291c00adb700000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000"; 126 | String WORK_TARGET="000000000000000000000000000000000000000000000000000000feff010000"; 127 | ObjectMapper mapper = new ObjectMapper(); 128 | StratumJsonResultSubscribe s=new StratumJsonResultSubscribe(mapper.readTree(SR)); 129 | StratumJsonMethodMiningNotify n=new StratumJsonMethodMiningNotify(mapper.readTree(NT)); 130 | StratumJsonMethodSetDifficulty d=new StratumJsonMethodSetDifficulty(mapper.readTree(ST)); 131 | StratumWorkBuilder j=new StratumWorkBuilder(s); 132 | j.setNotify(n); 133 | j.setDiff(d); 134 | MiningWork w=j.buildMiningWork(); 135 | w.dump(); 136 | System.out.println(WORK_DATA); 137 | System.out.println(WORK_TARGET); 138 | 139 | } catch (JsonProcessingException e) { 140 | // TODO Auto-generated catch block 141 | e.printStackTrace(); 142 | } catch (MinyaException e) { 143 | // TODO Auto-generated catch block 144 | e.printStackTrace(); 145 | } catch (IOException e) { 146 | // TODO Auto-generated catch block 147 | e.printStackTrace(); 148 | } 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/SettingsFragment.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer; 2 | 3 | import android.app.FragmentTransaction; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.content.SharedPreferences; 7 | import android.net.Uri; 8 | import android.os.Bundle; 9 | import android.preference.CheckBoxPreference; 10 | import android.preference.EditTextPreference; 11 | import android.preference.ListPreference; 12 | import android.preference.Preference; 13 | import android.preference.PreferenceFragment; 14 | import android.preference.PreferenceManager; 15 | import android.support.annotation.Nullable; 16 | import android.support.v4.app.Fragment; 17 | import android.util.Log; 18 | import android.view.LayoutInflater; 19 | import android.view.View; 20 | import android.view.ViewGroup; 21 | import android.widget.TextView; 22 | 23 | import static android.content.Context.MODE_PRIVATE; 24 | import static android.os.Build.VERSION_CODES.M; 25 | 26 | 27 | public class SettingsFragment extends Fragment { 28 | private static final String ARG_PARAM1 = "param1"; 29 | int tabNumber; 30 | 31 | // private OnFragmentInteractionListener mListener; 32 | 33 | public SettingsFragment() { 34 | // Required empty public constructor 35 | } 36 | 37 | public static SettingsFragment newInstance(int currentTab) { 38 | SettingsFragment fragment = new SettingsFragment(); 39 | String param1 = "" + currentTab; 40 | Bundle args = new Bundle(); 41 | args.putString(ARG_PARAM1, param1); 42 | fragment.setArguments(args); 43 | return fragment; 44 | } 45 | 46 | public static class SettingsFragmentInside extends PreferenceFragment implements Preference.OnPreferenceChangeListener { 47 | @Override 48 | public void onCreate(@Nullable Bundle savedInstanceState) { 49 | super.onCreate(savedInstanceState); 50 | addPreferencesFromResource(R.xml.settings_main); 51 | 52 | Preference mWifi = findPreference(getString(R.string.settings_wifi_key)); 53 | bindPreferenceSummaryToValue(mWifi); 54 | 55 | Preference mCharger = findPreference(getString(R.string.settings_charger_key)); 56 | bindPreferenceSummaryToValue(mCharger); 57 | 58 | Preference mWallet = findPreference(getString((R.string.settings_wallet_key))); 59 | bindPreferenceSummaryToValue((mWallet)); 60 | 61 | Preference mPool = findPreference(getString(R.string.settings_pool_key)); 62 | bindPreferenceSummaryToValue(mPool); 63 | 64 | Preference mUser = findPreference(getString(R.string.settings_user_key)); 65 | bindPreferenceSummaryToValue(mUser); 66 | 67 | Preference mPassword = findPreference(getString(R.string.settings_password_key)); 68 | bindPreferenceSummaryToValue(mPassword); 69 | 70 | 71 | Preference button = findPreference(getString(R.string.settings_reset_key)); 72 | button.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { 73 | @Override 74 | public boolean onPreferenceClick(Preference preference) { 75 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(preference.getContext()); 76 | prefs.edit().clear().apply(); 77 | RestartApp(); 78 | return true; 79 | } 80 | }); 81 | } 82 | 83 | @Override 84 | public boolean onPreferenceChange(Preference preference, Object newValue) { 85 | if (preference instanceof CheckBoxPreference) { 86 | //DO NOTHING 87 | } else { 88 | if (newValue != null) { 89 | if ( preference.getTitleRes() != R.string.settings_password_label ) { 90 | String stringValue = newValue.toString(); 91 | preference.setSummary(stringValue); 92 | } else { 93 | String stringValue = getResources().getString(R.string.settings_password_hidden); 94 | preference.setSummary(stringValue); 95 | } 96 | } 97 | } 98 | return true; 99 | } 100 | private void bindPreferenceSummaryToValue(Preference preference) { 101 | if (preference != null) { 102 | preference.setOnPreferenceChangeListener(this); 103 | SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(preference.getContext()); 104 | if (preference instanceof EditTextPreference) { 105 | String preferenceString = preferences.getString(preference.getKey(), ""); 106 | onPreferenceChange(preference, preferenceString); 107 | } else { 108 | Boolean boolVal = preferences.getBoolean(preference.getKey(), true); 109 | onPreferenceChange(preference,boolVal); 110 | } 111 | } 112 | } 113 | 114 | public void RestartApp() { 115 | Intent i = getActivity().getBaseContext().getPackageManager(). 116 | getLaunchIntentForPackage(getActivity().getBaseContext().getPackageName()); 117 | i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 118 | i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 119 | //getActivity().finish(); 120 | startActivity(i); 121 | } 122 | 123 | } 124 | 125 | @Override 126 | public void onCreate(Bundle savedInstanceState) { 127 | if (getArguments() != null) { 128 | tabNumber = Integer.parseInt(getArguments().getString(ARG_PARAM1)); 129 | } 130 | super.onCreate(savedInstanceState); 131 | // getActivity().getFragmentManager().beginTransaction() 132 | // .replace(android.R.id.content, new SettingsFragmentInside()) 133 | // .commit(); 134 | } 135 | 136 | @Override 137 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 138 | Bundle savedInstanceState) { 139 | // Inflate the layout for this fragment 140 | View view = inflater.inflate(R.layout.fragment_settings, container, false); 141 | return view; 142 | } 143 | 144 | 145 | // // TODO: Rename method, update argument and hook method into UI event 146 | // public void onButtonPressed(Uri uri) { 147 | // if (mListener != null) { 148 | // mListener.onFragmentInteraction(uri); 149 | // } 150 | // } 151 | // 152 | // @Override 153 | // public void onAttach(Context context) { 154 | // super.onAttach(context); 155 | // if (context instanceof OnFragmentInteractionListener) { 156 | // mListener = (OnFragmentInteractionListener) context; 157 | // } else { 158 | // throw new RuntimeException(context.toString() 159 | // + " must implement OnFragmentInteractionListener"); 160 | // } 161 | // } 162 | // 163 | // @Override 164 | // public void onDetach() { 165 | // super.onDetach(); 166 | // mListener = null; 167 | // } 168 | // 169 | // /** 170 | // * This interface must be implemented by activities that contain this 171 | // * fragment to allow an interaction in this fragment to be communicated 172 | // * to the activity and potentially other fragments contained in that 173 | // * activity. 174 | // *

175 | // * See the Android Training lesson Communicating with Other Fragments for more information. 178 | // */ 179 | // public interface OnFragmentInteractionListener { 180 | // // TODO: Update argument type and name 181 | // void onFragmentInteraction(Uri uri); 182 | // } 183 | } 184 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | LtcTEMiner 3 | 4 | Settings 5 | Mine 6 | Rates 7 | About 8 | LTC MINER BY TAL AND EYAL 9 | 10 | 11 | Miner Settings 12 | 13 | Wi-Fi-only Mining 14 | wifi 15 | true 16 | Enable/Disable Wi-Fi-only mining 17 | 18 | Charger-only Mining 19 | charger 20 | true 21 | Enable/Disable Charger-only mining 22 | 23 | Default Pool Address 24 | pool_add 25 | Enter Pool Address 26 | 27 | Pool URL (must start with "stratum+tcp://") 28 | stratum+tcp:// 29 | Pick URL 30 | New Pool URL 31 | Default Pool URL 32 | Enter Pool Address: 33 | New Pool URL 34 | 35 | Default Username 36 | user 37 | Enter Pool Username 38 | 39 | Pick User 40 | New User 41 | Enter Username: 42 | New Username 43 | Use Wallet ID 44 | 45 | Default Password 46 | password 47 | Enter Pool Password 48 | Hidden 49 | 50 | Pick Password 51 | New Password 52 | Default Password 53 | Enter Password: 54 | New Password 55 | 56 | 57 | Default Wallet ID 58 | wallet 59 | Enter Wallet ID 60 | 61 | Restore Defaults 62 | reset 63 | Restore Default Settings 64 | 65 | Change Amount 66 | Exchange Rates for 1 LTC 67 | 68 | Refresh 69 | Wallet Balance 70 | 71 | Error! 72 | X 73 | 74 | Bitcoin 75 | BTC 76 | 77 | USD 78 | $ 79 | 80 | ILS 81 | שח 82 | 83 | Enter LTC amount to convert: 84 | Set Amount 85 | 1.0 86 | 87 | 88 | Hello blank fragment 89 | 90 | "We are Electrical Engineering students of the Technion Institution, Israel.\n\nThe “LtcTEMiner” application was built as a part of a project under the NSSL lab of the faculty.\n\nThe app offers most android users the ability to mine Scrypt-based Cryptocurrency using their own device. 91 | \nThis app is based on the JMiner project, and one of its branches JMiNya which implements Java-based Stratum connection. 92 | \nProject supervisor is:\n Mr. Roman Kaplan." 93 | 94 | "\n*The project has been completed during April-September 2017." 95 | 96 | Run On Background 97 | Keep Screen Awake 98 | 99 | Min 100 | Med 101 | Max 102 | 103 | WARNING: USE AT YOUR OWN RISK\nUse of this app may lead to\nreduce in battery life and overheating\nof your device, use with care! 104 | 105 | Server Address 106 | Username: 107 | Password 108 | Start Mining 109 | Stop Mining 110 | "Threads: " 111 | Settings 112 | Speed: 113 | Settings 114 | Threads: 115 | Scan Time (ms): 116 | Retry Pause (ms): 117 | Run in Background 118 | Donate 119 | Save 120 | Restore Defaults 121 | Password: 122 | Username: 123 | Server URL 124 | Throttle (0-100%) 125 | Load 126 | Start Mining 127 | Speed: 128 | Thread Priority: 129 | Mining 130 | Error 131 | Terminated 132 | Connecting 133 | Not Mining 134 | Keep Screen Awake 135 | 136 | Pool URL: 137 | User: 138 | Threads: 139 | Priority: 140 | Run In Background: 141 | Keep Screen Awake: 142 | ON 143 | OFF 144 | Close Miner 145 | Start Mining 146 | LtcTEMiner-Stratum Miner 147 | 148 | 149 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/android/ltcteminer/ExchangeRatesCard.java: -------------------------------------------------------------------------------- 1 | package com.example.android.ltcteminer; 2 | 3 | import android.app.AlertDialog; 4 | import android.content.Context; 5 | import android.content.DialogInterface; 6 | import android.os.AsyncTask; 7 | import android.view.LayoutInflater; 8 | import android.view.MenuItem; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.widget.EditText; 12 | import android.widget.ImageView; 13 | import android.widget.TextView; 14 | import android.widget.Toast; 15 | 16 | import java.math.BigDecimal; 17 | import java.math.RoundingMode; 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | import java.util.concurrent.ExecutionException; 21 | 22 | import it.gmariotti.cardslib.library.internal.Card; 23 | import it.gmariotti.cardslib.library.internal.CardHeader; 24 | import it.gmariotti.cardslib.library.internal.base.BaseCard; 25 | import it.gmariotti.cardslib.library.prototypes.CardWithList; 26 | import it.gmariotti.cardslib.library.prototypes.LinearListView; 27 | 28 | import static android.support.v7.widget.AppCompatDrawableManager.get; 29 | 30 | /** 31 | * Created by Tal on 30/07/2017. 32 | */ 33 | 34 | public class ExchangeRatesCard extends CardWithList { 35 | 36 | //public static final String dataUrl ="http://ltc.blockr.io/api/v1/exchangerate/current"; 37 | public static final String dataUrl ="https://min-api.cryptocompare.com/data/price?fsym=LTC&tsyms=BTC,USD,ILS"; 38 | private getRatesAsyncTask mGetRatesTask; 39 | private double mAmount = 1.0; 40 | private boolean getError = false; 41 | 42 | public ExchangeRatesCard(Context context) { 43 | super(context); 44 | } 45 | 46 | @Override 47 | protected CardHeader initCardHeader() { 48 | CardHeader header = new CardHeader(getContext()); 49 | header.setPopupMenu(R.menu.card_rates_menu_item, new CardHeader.OnClickCardHeaderPopupMenuListener() { 50 | @Override 51 | public void onMenuItemClick(BaseCard card, MenuItem item) { 52 | switch (item.getItemId()) { 53 | case R.id.change_amount_action: 54 | LayoutInflater inflater = LayoutInflater.from(getContext()); 55 | View alertLayout = inflater.inflate(R.layout.enter_amount_dialog,null); 56 | final EditText etAmount = (EditText) alertLayout.findViewById(R.id.et_amount); 57 | etAmount.setText(R.string.enter_amount_default); 58 | AlertDialog.Builder alert = new AlertDialog.Builder(getContext()); 59 | alert.setTitle(getContext().getString(R.string.enter_amount_title)); 60 | alert.setView(alertLayout); 61 | alert.setCancelable(false); 62 | alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { 63 | @Override 64 | public void onClick(DialogInterface dialog, int which) { 65 | Toast.makeText(getContext(),"Not setting amount...",Toast.LENGTH_SHORT).show(); 66 | } 67 | }); 68 | alert.setPositiveButton("Set", new DialogInterface.OnClickListener() { 69 | @Override 70 | public void onClick(DialogInterface dialog, int which) { 71 | mAmount = Double.parseDouble(etAmount.getText().toString()); 72 | Toast.makeText(getContext(),"Amount Set to: " + mAmount ,Toast.LENGTH_SHORT).show(); 73 | } 74 | }); 75 | AlertDialog dialog = alert.create(); 76 | dialog.show(); 77 | init(); 78 | break; 79 | } 80 | } 81 | }); 82 | header.setTitle(getContext().getString(R.string.card_rates_header_title)); 83 | return header; 84 | } 85 | 86 | @Override 87 | protected void initCard() { 88 | setSwipeable(false); 89 | setUseProgressBar(true); 90 | } 91 | 92 | @Override 93 | protected List initChildren() { 94 | mGetRatesTask = new getRatesAsyncTask(); 95 | mGetRatesTask.execute(dataUrl); 96 | ArrayList ratesArray = new ArrayList(); 97 | try { 98 | ratesArray = mGetRatesTask.get(); 99 | } catch (InterruptedException e) { 100 | getError = true; 101 | e.printStackTrace(); 102 | } catch (ExecutionException e) { 103 | getError = true; 104 | e.printStackTrace(); 105 | } 106 | List mObjects = new ArrayList(); 107 | 108 | int networkStat = NetworkUtil.getConnectivityStatus(getContext()); 109 | if (networkStat == NetworkUtil.TYPE_NOT_CONNECTED || getError || ratesArray.isEmpty()) { 110 | RatesObject noInternet = new RatesObject(this); 111 | noInternet.coin = getContext().getString(R.string.no_internet_coin); 112 | noInternet.amount = 0; 113 | noInternet.rate = 0; 114 | noInternet.currencyIcon = android.R.drawable.stat_notify_error; 115 | noInternet.currencyUnits = getContext().getString(R.string.no_internet_units); 116 | mObjects.add(noInternet); 117 | 118 | } else { 119 | RatesObject btc = new RatesObject(this); 120 | btc.coin = getContext().getString(R.string.bitcoin); 121 | btc.amount = mAmount; 122 | btc.rate = round(ratesArray.get(0),3); 123 | btc.currencyIcon = R.drawable.btc_icon_scaled; 124 | btc.currencyUnits = getContext().getString(R.string.bitcoin_units); 125 | mObjects.add(btc); 126 | 127 | RatesObject usd = new RatesObject(this); 128 | usd.coin = getContext().getString(R.string.usd); 129 | usd.amount = mAmount; 130 | usd.rate = round(ratesArray.get(1),3); 131 | usd.currencyIcon = R.drawable.usd_icon_scaled; 132 | usd.currencyUnits = getContext().getString(R.string.usd_units); 133 | mObjects.add(usd); 134 | 135 | RatesObject ils = new RatesObject(this); 136 | ils.coin = getContext().getString(R.string.ils); 137 | ils.amount = mAmount; 138 | ils.rate = round(ratesArray.get(2),3); 139 | ils.currencyIcon = R.drawable.ils_icon_scaled; 140 | ils.currencyUnits = getContext().getString(R.string.ils_units); 141 | mObjects.add(ils); 142 | } 143 | 144 | return mObjects; 145 | } 146 | 147 | @Override 148 | public View setupChildView(int childPosition, ListObject object, View convertView, ViewGroup parent) { 149 | TextView currency = (TextView) convertView.findViewById(R.id.card_rates_currency); 150 | ImageView icon = (ImageView) convertView.findViewById(R.id.card_rates_item_icon); 151 | TextView amount = (TextView) convertView.findViewById(R.id.card_rates_amount); 152 | TextView units = (TextView) convertView.findViewById(R.id.card_rates_units); 153 | 154 | //Retrieve the values from the object 155 | RatesObject ratesObject= (RatesObject)object; 156 | currency.setText(ratesObject.coin); 157 | icon.setImageResource(ratesObject.currencyIcon); 158 | String rateS = "" + ratesObject.rate; 159 | amount.setText(rateS); 160 | units.setText(ratesObject.currencyUnits); 161 | 162 | return convertView; 163 | } 164 | 165 | @Override 166 | public int getChildLayoutId() { 167 | return R.layout.card_rates_inner_main; 168 | } 169 | 170 | //Rates Object 171 | 172 | public class RatesObject extends CardWithList.DefaultListObject { 173 | public String coin; 174 | public double rate; 175 | public double amount; 176 | public int currencyIcon; 177 | public String currencyUnits; 178 | 179 | public RatesObject(Card parentCard) { 180 | super(parentCard); 181 | init(); 182 | } 183 | 184 | public void init() { 185 | //OnClickListener 186 | setOnItemClickListener(new OnItemClickListener() { 187 | @Override 188 | public void onItemClick(LinearListView parent, View view, int position, ListObject object) { 189 | String text = mAmount + " LTC = " + round(mAmount*rate,4) + " " + currencyUnits; 190 | Toast.makeText(getContext(),text,Toast.LENGTH_SHORT).show(); 191 | } 192 | }); 193 | } 194 | 195 | } 196 | 197 | public static double round (double value, int places) { 198 | if (places<0) throw new IllegalArgumentException(); 199 | BigDecimal bd = new BigDecimal(value); 200 | bd = bd.setScale(places, RoundingMode.HALF_UP); 201 | return bd.doubleValue(); 202 | } 203 | 204 | private class getRatesAsyncTask extends AsyncTask> { 205 | 206 | @Override 207 | protected ArrayList doInBackground(String... urls) { 208 | if (urls.length < 1 || urls[0] == null) { 209 | return null; 210 | } 211 | ArrayList result = QueryUtilsRates.extractRates(urls[0]); 212 | return result; 213 | } 214 | } 215 | } 216 | 217 | 218 | 219 | 220 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_mine.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 17 | 18 | 28 | 29 | 39 | 40 | 44 | 45 | 46 | 56 | 57 | 67 | 68 | 72 | 73 | 83 | 84 | 94 | 95 | 99 | 100 | 104 | 105 | 109 | 110 | 119 | 120 | 130 | 131 | 140 | 141 | 151 | 152 | 153 | 154 | 158 | 159 | 163 | 164 | 168 | 169 | 177 | 178 | 185 | 186 | 187 | 188 | 189 | 193 | 194 | 198 | 199 |