diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 558702efd..9fcd1e36d 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,5 +1,5 @@ name: Report Bug -description: Create a bug report. +description: Submit a bug report to help improve CoreMiner. title: "[BUG] " labels: - bug @@ -9,18 +9,18 @@ body: - type: markdown attributes: value: | - Please, provide as much details as possible to make proper evaluation and in the end resolve the bug report faster. + Please provide as many details as possible to help us evaluate and resolve the bug report efficiently. - type: markdown attributes: value: | - Hardware details. + Hardware Information - type: input id: device attributes: label: Device - description: Used device. + description: Device being used placeholder: Device name - type: dropdown @@ -40,27 +40,27 @@ body: - type: input id: cpubrand attributes: - label: CPU brand - description: Brand of used CPU. + label: CPU Brand + description: CPU brand being used placeholder: CPU brand - type: input id: cpumodel attributes: - label: CPU model - description: Model of used CPU. + label: CPU Model + description: CPU model being used placeholder: CPU model - type: markdown attributes: value: | - Software specific details. + Software Information - type: input id: os attributes: - label: OS and version - description: Name and version of OS used. + label: OS and Version + description: Operating system and version being used placeholder: OS validations: required: true @@ -68,8 +68,8 @@ body: - type: input id: version attributes: - label: Software version - description: Version of software used. + label: Software Version + description: Version of CoreMiner being used placeholder: Version validations: required: true @@ -77,8 +77,8 @@ body: - type: textarea id: bug attributes: - label: Bug - description: Describe the Bug. + label: Bug Description + description: Describe the bug in detail placeholder: Bug description validations: required: true @@ -86,8 +86,8 @@ body: - type: textarea id: reproduce attributes: - label: Reproduce Bug - description: Steps to reproduce the behavior. + label: Steps to Reproduce + description: Steps to reproduce the behavior placeholder: 1. Step 1 validations: required: true @@ -95,8 +95,8 @@ body: - type: textarea id: expected attributes: - label: Expected behavior - description: Describe the result you are expecting. + label: Expected Behavior + description: Describe the expected result placeholder: Result validations: required: true @@ -104,5 +104,5 @@ body: - type: textarea id: additional attributes: - label: Additional context - description: Please, place additional content or screenshots. + label: Additional Context + description: Add any additional information or screenshots diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 433291565..cba989b23 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -2,10 +2,13 @@ blank_issues_enabled: false contact_links: - name: Community Discussion url: https://github.com/catchthatrabbit/coreminer/discussions - about: Discussion about mining on the Core Blockchain. - - name: Quick Start + about: Join discussions about mining on the Core Blockchain + - name: Quick Start Guide url: https://catchthatrabbit.com/start-mining - about: To start mining, please follow this guide. + about: Follow our step-by-step guide to start mining + - name: Add Miner to Profitability Calculator + url: https://github.com/catchthatrabbit/ctr-web/edit/master/src/constants/machines.ts + about: Add your miner to CTR's profitability calculator - name: Support url: https://catchthatrabbit.com/contact - about: Contact support. + about: Get help from our support team diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 3e7f84c1c..4d189b3e7 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -1,5 +1,5 @@ -name: Feature request -description: Suggest an idea for this project. +name: Feature Request +description: Suggest a new feature or enhancement for CoreMiner. title: "[FEATURE] " labels: - feature @@ -9,38 +9,38 @@ body: - type: markdown attributes: value: | - Suggest an idea for this project and developers will consider the integration. + Suggest a new feature or enhancement for CoreMiner. Our development team will review your proposal. - type: textarea id: problem attributes: - label: Problem - description: Is your feature request related to a problem? Please describe. + label: Problem Statement + description: What problem are you trying to solve? validations: required: true - type: textarea id: solution attributes: - label: Solution - description: Describe the solution you'd like. + label: Proposed Solution + description: Describe your proposed solution validations: required: true - type: textarea id: alternatives attributes: - label: Alternatives - description: Describe alternatives you've considered. + label: Alternative Solutions + description: What alternatives have you considered? - type: textarea id: implementation attributes: - label: Implementation - description: Describe implementation with example of the code. + label: Implementation Details + description: Provide implementation details or code examples - type: textarea id: additional attributes: - label: Additional context - description: Please, place additional content or screenshots. + label: Additional Information + description: Add any relevant information or screenshots diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 60fef13c2..b8eec9170 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,7 @@ jobs: matrix: config: [ {os: ubuntu-latest, path: linux-x86_64}, - {os: raspbian-private, path: linux-arm64}, + {os: ubuntu-24.04-arm, path: linux-arm64}, ] runs-on: ${{matrix.config.os}} steps: @@ -63,7 +63,7 @@ jobs: matrix: config: [ {os: ubuntu-latest, path: linux-x86_64}, - {os: raspbian-private, path: linux-arm64}, + {os: ubuntu-24.04-arm, path: linux-arm64}, ] runs-on: ${{matrix.config.os}} needs: release diff --git a/CODEOWNERS b/CODEOWNERS deleted file mode 100644 index 30b719734..000000000 --- a/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -ethminer/DBusInt.h @MRZA-MRZA diff --git a/README.md b/README.md index 4837ef620..fd7cac85e 100644 --- a/README.md +++ b/README.md @@ -6,15 +6,25 @@ ## Table of Contents -* [Install](#install) - * [Manual Installation](#manual-installation) - * [Automatic Installation](#automatic-installation) -* [Usage](#usage) -* [Limitations](#limitations) -* [Post-installation steps](#post-installation-steps) -* [Config file](#config-file) -* [Build](#build) -* [Pools](#pools) +- [Core Miner](#core-miner) + - [Table of Contents](#table-of-contents) + - [Install](#install) + - [Manual Installation](#manual-installation) + - [Automatic Installation](#automatic-installation) + - [Pre-requirements](#pre-requirements) + - [Execution](#execution) + - [Cloud Deployment](#cloud-deployment) + - [Usage](#usage) + - [How to start mining](#how-to-start-mining) + - [Standalone](#standalone) + - [Limitations](#limitations) + - [Post-installation steps](#post-installation-steps) + - [Config file](#config-file) + - [Build](#build) + - [Building from source](#building-from-source) + - [API documentation](#api-documentation) + - [Pools](#pools) + - [License](#license) ## Install @@ -47,6 +57,43 @@ bash <(curl -s https://raw.githubusercontent.com/catchthatrabbit/coreminer/maste After the installation completes, we recommend proceeding with the [post-installation steps](docs/AUTOSTART-LINUX.md) to ensure continuous high availability. +### Cloud Deployment + +You can deploy CoreMiner to cloud instances using cloud-init. This method is particularly useful for automated deployments and scaling. + +Create a `cloud-init-coreminer.yaml` file with the following configuration: + +```yaml +… +# Define your Coreminer environment variables here +write_files: + - path: /etc/coreminer_env + permissions: '0644' + content: | + COREID=your_core_id_here + WORKER=your_worker_name_here + SERVER1=fi + SERVER2=de +… +``` + +The cloud-init configuration: + +1. Updates system packages +2. Sets up environment variables for your CoreMiner configuration +3. Creates a systemd service for automatic startup +4. Installs required dependencies +5. Clones the CoreMiner repository +6. Configures the mining pool settings +7. Enables and starts the CoreMiner service + +To use this configuration: + +1. Replace `your_core_id_here` with your CoreMiner wallet address +2. Replace `your_worker_name_here` with your desired worker name +3. Adjust the server locations (`SERVER1`, `SERVER2`) as needed +4. Use this configuration when launching your cloud instance + ## Usage The **CoreMiner** is a command line program. This means you launch it either @@ -88,6 +135,7 @@ Follow the [post-installation steps](docs/AUTOSTART-LINUX.md) from documentation After running the `mine.sh` in the same folder produced setting file `pool.cfg`. This file is loaded from two possible sources: + 1. Same directory as `mine.sh` file with name `pool.cfg`. 1. Connected flash drive named `coredrive` and `pool.cfg` is located in the root folder. @@ -96,13 +144,13 @@ Example of the contents of `pool.cfg` file: ```bash wallet=cb… worker=Rabbit -server[1]=eu.catchthatrabbit.com +server[1]=fi.catchthatrabbit.com port[1]=8008 -server[2]=as.catchthatrabbit.com +server[2]=de.catchthatrabbit.com port[2]=8008 -server[3]=eu1.catchthatrabbit.com +server[3]=sg.catchthatrabbit.com port[3]=8008 -server[4]=as1.catchthatrabbit.com +server[4]=hk.catchthatrabbit.com port[4]=8008 ``` @@ -125,5 +173,3 @@ Read more about [Stratum server](docs/STRATUM.md) in the documentation. ## License Licensed under the [GNU General Public License, Version 3](LICENSE). - -*Cryptoni confidimus* diff --git a/cloud-init-coreminer.yaml b/cloud-init-coreminer.yaml new file mode 100644 index 000000000..888c27aa2 --- /dev/null +++ b/cloud-init-coreminer.yaml @@ -0,0 +1,62 @@ +#cloud-config +package_update: true +package_upgrade: true + +# Define your Coreminer environment variables here +write_files: + - path: /etc/coreminer_env + permissions: '0644' + content: | + COREID=your_core_id_here + WORKER=your_worker_name_here + SERVER1=fi + SERVER2=de + + - path: /etc/systemd/system/coreminer.service + permissions: '0644' + content: | + [Unit] + Description=Coreminer Service + After=network.target + + [Service] + EnvironmentFile=/etc/coreminer_env + ExecStart=/usr/bin/coreminer --wallet ${COREID} --name ${WORKER} + WorkingDirectory=/usr/bin/ + Restart=always + RestartSec=10 + + [Install] + WantedBy=multi-user.target + +runcmd: + - | + if [ -f /var/log/coreminer_installed ]; then + echo "Coreminer already installed. Skipping setup." + exit 0 + fi + + - source /etc/coreminer_env + - apt update && apt install -y git wget curl unzip screen + - git clone https://github.com/catchthatrabbit/coreminer.git /opt/coreminer + - cp /opt/coreminer/coreminer /usr/bin/coreminer + - chmod +x /usr/bin/coreminer + + - | + cat < /usr/bin/pool.cfg + wallet=${COREID} + worker=${WORKER} + server[1]=${SERVER1}.catchthatrabbit.com + port[1]=8008 + server[2]=${SERVER2}.catchthatrabbit.com + port[2]=8008 + EOF + + - chmod 644 /usr/bin/pool.cfg + + - systemctl daemon-reexec + - systemctl daemon-reload + - systemctl enable coreminer.service + - systemctl start coreminer.service + + - touch /var/log/coreminer_installed diff --git a/cmake/Hunter/config.cmake b/cmake/Hunter/config.cmake index d4378c2ab..d7d8f34fc 100644 --- a/cmake/Hunter/config.cmake +++ b/cmake/Hunter/config.cmake @@ -3,6 +3,6 @@ hunter_config( Boost VERSION 1.79.0_new_url SHA1 28b4c71b7d9b8e323d40748f14e5c6d390e19720 - URL https://boostorg.jfrog.io/artifactory/main/release/1.79.0/source/boost_1_79_0.tar.gz + URL https://archives.boost.io/release/1.79.0/source/boost_1_79_0.tar.gz CMAKE_ARGS USE_CONFIG_FROM_BOOST=ON Boost_USE_STATIC_LIBS=OFF Boost_USE_STATIC_RUNTIME=OFF ) diff --git a/docs/API.md b/docs/API.md index 2fe8bf5a6..4f85c6186 100644 --- a/docs/API.md +++ b/docs/API.md @@ -1,102 +1,101 @@ -# Coreminer's API documentation +# CoreMiner API Documentation ## Table of Contents -* [Introduction](#introduction) -* [Activation and Security](#activation-and-security) -* [Usage](#usage) -* [List of requests](#list-of-requests) - * [api_authorize](#api_authorize) - * [miner_ping](#miner_ping) - * [miner_getstatdetail](#miner_getstatdetail) - * [miner_getstat1](#miner_getstat1) - * [miner_restart](#miner_restart) - * [miner_reboot](#miner_reboot) - * [miner_shuffle](#miner_shuffle) - * [miner_getconnections](#miner_getconnections) - * [miner_setactiveconnection](#miner_setactiveconnection) - * [miner_addconnection](#miner_addconnection) - * [miner_removeconnection](#miner_removeconnection) - * [miner_getscramblerinfo](#miner_getscramblerinfo) - * [miner_setscramblerinfo](#miner_setscramblerinfo) - * [miner_pausegpu](#miner_pausegpu) - * [miner_setverbosity](#miner_setverbosity) +- [CoreMiner API Documentation](#coreminer-api-documentation) + - [Table of Contents](#table-of-contents) + - [Introduction](#introduction) + - [Activation and Security](#activation-and-security) + - [Usage](#usage) + - [List of Requests](#list-of-requests) + - [api\_authorize](#api_authorize) + - [miner\_ping](#miner_ping) + - [miner\_getstatdetail](#miner_getstatdetail) + - [miner\_getstat1](#miner_getstat1) + - [miner\_restart](#miner_restart) + - [miner\_reboot](#miner_reboot) + - [miner\_shuffle](#miner_shuffle) + - [miner\_getconnections](#miner_getconnections) + - [miner\_setactiveconnection](#miner_setactiveconnection) + - [miner\_addconnection](#miner_addconnection) + - [miner\_removeconnection](#miner_removeconnection) + - [miner\_getscramblerinfo](#miner_getscramblerinfo) + - [miner\_setscramblerinfo](#miner_setscramblerinfo) + - [miner\_pausegpu](#miner_pausegpu) + - [miner\_setverbosity](#miner_setverbosity) ## Introduction -Coreminer implements an API (Application Programming Interface) interface which allows to monitor/control some of the run-time values endorsed by this miner. The API interface is available under the following circumstances: +CoreMiner implements an API (Application Programming Interface) that allows monitoring and controlling various runtime values. The API interface is available under the following conditions: -* If you're using a binary release downloaded from the [releases](https://github.com/catchthatrabbit/coreminer/releases) section of this repository -* If you build the application from source ensuring you add the compilation switch `-D APICORE=ON` +- If you're using a binary release downloaded from the [releases](https://github.com/catchthatrabbit/coreminer/releases) section of this repository +- If you build the application from source with the compilation switch `-D APICORE=ON` ## Activation and Security -Whenever the above depicted conditions are met you can take advantage of the API support by adding the `--api-bind` argument to the command line used to launch Coreminer. The format of this argument is `--api-bind address:port` where `nnnn` is any valid TCP port number (1-65535) and is required, and the `address` dictates what ip the api will listen on, and is optional, and defaults to "all ipv4 addresses". Examples: +When the above conditions are met, you can enable API support by adding the `--api-bind` argument to the command line. The format is `--api-bind address:port` where: -```shell -./coreminer [...] --api-bind 3333 -``` +- `port` is any valid TCP port number (1-65535) and is required +- `address` specifies which IP the API will listen on (optional, defaults to all IPv4 addresses) -This example puts the API interface listening on port 3333 of **any** local IPv4 address which means the loop-back interface (127.0.0.1/127.0.1.1) and any configured IPv4 address of the network card(s). To only listen to localhost connections (which may be a more secure setting), +Examples: + +```bash +# Listen on all IPv4 addresses +./coreminer [...] --api-bind 3333 -```shell +# Listen only on localhost ./coreminer [...] --api-bind 127.0.0.1:3333 ``` -and likewise, to only listen on a specific address, replace `127.0.0.1` accordingly. +The API interface offers both monitoring queries and methods that can affect the miner's operation. These operations are called _write_ actions. To restrict access to read-only mode (allowing only data queries), prefix the port number with a minus sign: - -The API interface not only offers monitoring queries but also implements some methods which may affect the functioning of the miner. These latter operations are named _write_ actions: if you want to inhibit the invocation of such methods you may want to put the API interface in **read-only** mode which means only query to **get** data will be allowed and no _write_ methods will be allowed. To do this simply add the - (minus) sign in front of the port number thus transforming the port number into a negative number. Example for read-only mode: - -```shell +```bash +# Read-only mode ./coreminer [...] --api-bind -3333 ``` -_Note. The port number in this examples is taken randomly and does not imply a suggested value. You can use any port number you wish while it's not in use by other applications._ - -To gain further security you may wish to password protect the access to your API interface simply by adding the `--api-password` argument to the command line sequence, followed by the password you wish. Password may be composed by any printable char and **must not** have spaces. Password checking is **case sensitive**. Example for password protected API interface: +For additional security, you can password-protect the API interface using the `--api-password` argument: -```shell +```bash ./coreminer [...] --api-bind -3333 --api-password MySuperSecurePassword!!#123456 ``` -At the time of writing of this document Coreminer's API interface does not implement any sort of data encryption over SSL secure channel so **be advised your passwords will be sent as plain text over plain TCP sockets**. +> **Note**: At the time of writing, CoreMiner's API interface does not implement SSL encryption. Passwords are sent as plain text over TCP sockets. ## Usage -Access to API interface is performed through a TCP socket connection to the API endpoint (which is the IP address of the computer running Coreminer's API instance at the configured port). For instance if your computer address is 192.168.1.1 and have configured Coreminer to run with `--api-bind 3333` your endpoint will be 192.168.1.1:3333. +Access the API interface through a TCP socket connection to the API endpoint (IP address and port of the computer running CoreMiner). For example, if your computer's address is 192.168.1.1 and CoreMiner is configured with `--api-bind 3333`, your endpoint will be 192.168.1.1:3333. -Messages exchanged through this channel must conform to the [JSON-RPC 2.0 specification](http://www.jsonrpc.org/specification) so basically you will issue **requests** and will get back **responses**. At the time of writing this document do not expect any **notification**. All messages must be line feed terminated. +Messages must conform to the [JSON-RPC 2.0 specification](http://www.jsonrpc.org/specification). You will issue **requests** and receive **responses**. All messages must be terminated with a line feed. -To quickly test if your Coreminer's API instance is working properly you can issue this simple command: +To test if your CoreMiner API instance is working: -```shell +```bash echo '{"id":0,"jsonrpc":"2.0","method":"miner_ping"}' | netcat 192.168.1.1 3333 ``` -and will get back a response like this: +Expected response: -```shell +```json {"id":0,"jsonrpc":"2.0","result":"pong"} ``` -This shows the API interface is live and listening on the configured endpoint. +## List of Requests -## List of requests - -| Method | Description | Write Protected | -| --------- | ------------ | --------------- | -| [api_authorize](#api_authorize) | Issues the password to authenticate the session | No | -| [miner_ping](#miner_ping) | Responds back with a "pong" | No | -| [miner_getstatdetail](#miner_getstatdetail) | Request the retrieval of operational data in most detailed form | No -| [miner_getstat1](#miner_getstat1) | Request the retrieval of operational data in compatible format | No -| [miner_restart](#miner_restart) | Instructs Coreminer to stop and restart mining | Yes | -| [miner_reboot](#miner_reboot) | Try to launch reboot.bat (on Windows) or reboot.sh (on Linux) in the Coreminer executable directory | Yes -| [miner_shuffle](#miner_shuffle) | Initializes a new random scramble nonce | Yes -| [miner_getconnections](#miner_getconnections) | Returns the list of connections held by Coreminer | No -| [miner_setactiveconnection](#miner_setactiveconnection) | Instruct Coreminer to immediately connect to the specified connection | Yes -| [miner_addconnection](#miner_addconnection) | Provides Coreminer with a new connection to use | Yes -| [miner_removeconnection](#miner_removeconnection) | Removes the given connection from the list of available so it won't be used again | Yes +| Method | Description | Write Protected | +|--------|-------------|-----------------| +| [api_authorize](#api_authorize) | Authenticates the session with a password | No | +| [miner_ping](#miner_ping) | Returns "pong" to verify API is active | No | +| [miner_getstatdetail](#miner_getstatdetail) | Retrieves detailed operational data | No | +| [miner_getstat1](#miner_getstat1) | Retrieves operational data in compatible format | No | +| [miner_restart](#miner_restart) | Stops and restarts mining | Yes | +| [miner_reboot](#miner_reboot) | Executes reboot script | Yes | +| [miner_shuffle](#miner_shuffle) | Initializes a new random scramble nonce | Yes | +| [miner_getconnections](#miner_getconnections) | Returns the list of active connections | No | +| [miner_setactiveconnection](#miner_setactiveconnection) | Switches to a specified connection | Yes | +| [miner_addconnection](#miner_addconnection) | Adds a new connection | Yes | +| [miner_removeconnection](#miner_removeconnection) | Removes a connection from the list | Yes | ### api_authorize @@ -162,7 +161,7 @@ and expect back a result like this: which confirms the action has been performed. -If you get no response or the socket timeouts it's likely your Coreminer's instance has become unresponsive (or in worst cases the OS of your mining rig is unresponsive) and needs to be re-started/re-booted. +If you get no response or the socket timeouts it's likely your CoreMiner's instance has become unresponsive (or in worst cases the OS of your mining rig is unresponsive) and needs to be re-started/re-booted. ### miner_getstatdetail @@ -221,7 +220,7 @@ and expect back a response like this: { ... } // And another ... ], "host": { - "name": "miner01", // Host name of the computer running Coreminer + "name": "miner01", // Host name of the computer running CoreMiner "runtime": 121, // Duration time (in seconds) "version": "coreminer-0.18.0-alpha.1+commit.70c7cdbe.dirty" }, @@ -266,7 +265,7 @@ and expect back a response like this: "id": 1, "jsonrpc": "2.0", "result": [ - "coreminer-0.16.0.dev0+commit.41639944", // Running Coreminer's version + "coreminer-0.16.0.dev0+commit.41639944", // Running CoreMiner's version "48", // Total running time in minutes "87221;54;0", // ETH hashrate in KH/s, submitted shares, rejected shares "14683;14508;14508;14508;14508;14508", // Detailed ETH hashrate in KH/s per GPU @@ -279,19 +278,19 @@ and expect back a response like this: } ``` -Some of the arguments here expressed have been set for compatibility with other miners so their values are not set. For instance, Coreminer **does not** support dual (ETH/DCR) mining. +Some of the arguments here expressed have been set for compatibility with other miners so their values are not set. For instance, CoreMiner **does not** support dual (ETH/DCR) mining. ### miner_restart -With this method you instruct Coreminer to _restart_ mining. Restarting means: +With this method you instruct CoreMiner to _restart_ mining. Restarting means: -* Stop actual mining work -* Unload generated DAG files -* Reset devices (GPU) -* Regenerate DAG files -* Restart mining +- Stop actual mining work +- Unload generated DAG files +- Reset devices (GPU) +- Regenerate DAG files +- Restart mining -The invocation of this method **_may_** be useful if you detect one or more GPUs are in error, but in a recoverable state (eg. no hashrate but the GPU has not fallen off the bus). In other words, this method works like stopping Coreminer and restarting it **but without loosing connection to the pool**. +The invocation of this method **_may_** be useful if you detect one or more GPUs are in error, but in a recoverable state (eg. no hashrate but the GPU has not fallen off the bus). In other words, this method works like stopping CoreMiner and restarting it **but without loosing connection to the pool**. To invoke the action: @@ -319,8 +318,8 @@ which confirms the action has been performed. ### miner_reboot -With this method you instruct Coreminer to execute reboot.bat (on Windows) or reboot.sh (on Linux) script which must exists and being executable in the Coreminer directory. -As Coreminer has no idea what's going on in the script, Coreminer continues with it's normal work. +With this method you instruct CoreMiner to execute reboot.bat (on Windows) or reboot.sh (on Linux) script which must exists and being executable in the CoreMiner directory. +As CoreMiner has no idea what's going on in the script, CoreMiner continues with it's normal work. If you invoke this function `api_miner_reboot` is passed to the script as first parameter. To invoke the action: @@ -343,7 +342,7 @@ and expect back a result like this: } ``` -which confirms an executable file was found and Coreminer tried to start it. +which confirms an executable file was found and CoreMiner tried to start it. **Note**: This method is not available if the API interface is in read-only mode (see above). @@ -352,10 +351,10 @@ which confirms an executable file was found and Coreminer tried to start it. The mining process is nothing more that finding the right number (nonce) which, applied to an algorithm (cryptore) and some data, gives a result which is below or equal to a given target. This is very very (very) short! The range of nonces to be searched is a huge number: 2^64 = 18446744073709600000~ possible values. Each one has the same probability to be the _right_ one. -Every time Coreminer receives a job from a pool you'd expect the miner to begin searching from the first, but that would be boring. So the concept of scramble nonce has been introduced to achieve these goals: +Every time CoreMiner receives a job from a pool you'd expect the miner to begin searching from the first, but that would be boring. So the concept of scramble nonce has been introduced to achieve these goals: -* Start the searching from a random point within the range -* Ensure all GPUs do not search the same data, or, in other words, ensure each GPU searches its own range of numbers without overlapping with the same numbers of the other GPUs +- Start the searching from a random point within the range +- Ensure all GPUs do not search the same data, or, in other words, ensure each GPU searches its own range of numbers without overlapping with the same numbers of the other GPUs All `miner_shuffle` method does is to re-initialize a new random scramble nonce to start from in next jobs. @@ -383,7 +382,7 @@ which confirms the action has been performed. ### miner_getconnections -When you launch Coreminer you provide a list of connections specified by the `-P` argument. If you want to remotely check which is the list of connections Coreminer is using, you can issue this method: +When you launch CoreMiner you provide a list of connections specified by the `-P` argument. If you want to remotely check which is the list of connections CoreMiner is using, you can issue this method: ```js { @@ -435,7 +434,9 @@ Given the example above for the method [miner_getconnections](#miner_getconnecti } } ``` + or + ```js { "id": 1, @@ -449,15 +450,15 @@ or You have to pass the `params` member as an object which has member `index` valued to the ordinal index of the connection you want to activate. Alternatively, you can pass a regular expression to be matched against the connection URIs. As a result you expect one of the following: -* Nothing happens if the provided index is already bound to an _active_ connection -* If the selected index is not of an active connection then Coreminer will disconnect from currently active connection and reconnect immediately to the newly selected connection -* An error result if the index is out of bounds or the request is not properly formatted +- Nothing happens if the provided index is already bound to an _active_ connection +- If the selected index is not of an active connection then CoreMiner will disconnect from currently active connection and reconnect immediately to the newly selected connection +- An error result if the index is out of bounds or the request is not properly formatted -**Please note** that this method changes the runtime behavior only. If you restart Coreminer from a batch file the active connection will become again the first one of the `-P` arguments list. +**Please note** that this method changes the runtime behavior only. If you restart CoreMiner from a batch file the active connection will become again the first one of the `-P` arguments list. ### miner_addconnection -If you want to remotely add a new connection to the running instance of Coreminer you can use this this method by sending a message like this +If you want to remotely add a new connection to the running instance of CoreMiner you can use this this method by sending a message like this ```js { @@ -472,13 +473,13 @@ If you want to remotely add a new connection to the running instance of Coremine You have to pass the `params` member as an object which has member `uri` valued exactly the same way you'd add a connection using the `-P` argument. As a result you expect one of the following: -* An error if the uri is not properly formatted -* An error if you try to _mix_ stratum mode with getwork mode (which begins with `http://`) -* A success message if the newly defined connection has been properly added +- An error if the uri is not properly formatted +- An error if you try to _mix_ stratum mode with getwork mode (which begins with `http://`) +- A success message if the newly defined connection has been properly added -Eventually you may want to issue [miner_getconnections](#miner_getconnections) method to identify which is the ordinal position assigned to the newly added connection and make use of [miner_setactiveconnection](#miner_setactiveconnection) method to instruct Coreminer to use it immediately. +Eventually you may want to issue [miner_getconnections](#miner_getconnections) method to identify which is the ordinal position assigned to the newly added connection and make use of [miner_setactiveconnection](#miner_setactiveconnection) method to instruct CoreMiner to use it immediately. -**Please note** that this method changes the runtime behavior only. If you restart Coreminer from a batch file the added connection won't be available if not present in the `-P` arguments list. +**Please note** that this method changes the runtime behavior only. If you restart CoreMiner from a batch file the added connection won't be available if not present in the `-P` arguments list. ### miner_removeconnection @@ -497,10 +498,10 @@ Recall once again the example for the method [miner_getconnections](#miner_getco You have to pass the `params` member as an object which has member `index` valued to the ordinal index (zero based) of the connection you want to remove. As a result you expect one of the following: -* An error if the index is out of bounds **or if the index corresponds to the currently active connection** -* A success message. In such case you can later reissue [miner_getconnections](#miner_getconnections) method to check the connection has been effectively removed. +- An error if the index is out of bounds **or if the index corresponds to the currently active connection** +- A success message. In such case you can later reissue [miner_getconnections](#miner_getconnections) method to check the connection has been effectively removed. -**Please note** that this method changes the runtime behavior only. If you restart Coreminer from a batch file the removed connection will become again again available if provided in the `-P` arguments list. +**Please note** that this method changes the runtime behavior only. If you restart CoreMiner from a batch file the removed connection will become again again available if provided in the `-P` arguments list. ### miner_getscramblerinfo @@ -508,7 +509,7 @@ When searching for a valid nonce the miner has to find (at least) 1 of possible This gives you an idea of numbers in play. Luckily a couple of factors come in our help: difficulty and time. We can imagine difficulty as a sort of judge who determines how many of those possible solutions are valid. And the block time which allows the miner to stay longer on a sequence of numbers to find the solution. This all said it's however impossible for any miner (no matter if CPU or GPU or even ASIC) to cover the most part of this huge range in reasonable amount of time. So we need to resign to examine and test only a small fraction of this range. -Coreminer, at start, randomly chooses a scramble_nonce, a random number picked in the 2^64 range to start checking nonces from. In addition Coreminer gives each GPU a unique, non overlapping, range of nonces called _segment_. Segments ensure no GPU does the same job of another GPU thus avoiding two GPU find the same result. +CoreMiner, at start, randomly chooses a scramble_nonce, a random number picked in the 2^64 range to start checking nonces from. In addition CoreMiner gives each GPU a unique, non overlapping, range of nonces called _segment_. Segments ensure no GPU does the same job of another GPU thus avoiding two GPU find the same result. To accomplish this each segment has a range 2^40 nonces by default. If you want to check which is the scramble_nonce and which are the segments assigned to each GPU you can issue this method: ```js @@ -532,12 +533,13 @@ and expect a result like this: } } ``` + To compute the effective start_nonce assigned to each device you can use this simple math : `start_nonce + ((2^segment_width) * device_index))` The information hereby exposed may be used in large mining operations to check whether or not two (or more) rigs may result having overlapping segments. The possibility is very remote ... but is there. ### miner_setscramblerinfo -To approach this method you have to read carefully the method [miner_getscrambleinfo](#miner_getscrambleinfo) and what it reports. By the use of this method you can set a new scramble_nonce and/or set a new segment width: +To approach this method you have to read carefully the method [miner_getscramblerinfo](#miner_getscramblerinfo) and what it reports. By the use of this method you can set a new scramble_nonce and/or set a new segment width: ```js { @@ -550,7 +552,9 @@ To approach this method you have to read carefully the method [miner_getscramble } } ``` -or, if you prefer the hexadecimal notation, + +or, if you prefer the hexadecimal notation + ```js { "id": 1, @@ -598,7 +602,7 @@ Again: This ONLY (re)starts mining if GPU was paused via a previous API call and ### miner_setverbosity -Set the verbosity level of Coreminer. +Set the verbosity level of CoreMiner. ```js { diff --git a/docs/AUTOSTART-LINUX.md b/docs/AUTOSTART-LINUX.md index f5539c0f2..a289cf7b5 100644 --- a/docs/AUTOSTART-LINUX.md +++ b/docs/AUTOSTART-LINUX.md @@ -1,61 +1,90 @@ -# Coreminer Autostart +# CoreMiner Autostart -You can autostart the miner on Linux distribution using unit `service` under the [Systemd](https://en.wikipedia.org/wiki/Systemd) software suite. +You can configure CoreMiner to start automatically on Linux distributions using the `systemd` service manager. ## Installation -Please, follow few steps, which can differ depends on your OS used. +Follow these steps to set up automatic startup. The steps may vary depending on your operating system. -You can choose one of the installation types: -- [Coreminer Autostart](#coreminer-autostart) +You can choose one of the following installation methods: + +- [CoreMiner Autostart](#coreminer-autostart) - [Installation](#installation) - [Manual Installation](#manual-installation) - - [Optional steps](#optional-steps) + - [Optional Steps](#optional-steps) - [Automatic Installation](#automatic-installation) - [Troubleshooting](#troubleshooting) ## Manual Installation -1. Download latest release of CoreMiner and initiate the first setup using `mine.sh` script. -1. Please, copy the contents of file `coreverif.service`. Replace `WorkingDirectory` with your miner location and `ExecStart` with the `mine.sh` script location. (Example is showing fresh Kali linux.) To print your current directory, you can use `pwd` command. +1. Download the latest release of CoreMiner and run the initial setup using the `mine.sh` script. +2. Create a systemd service file with the following content. Replace `WorkingDirectory` with your miner location and `ExecStart` with the `mine.sh` script location. (The example shows a fresh Kali Linux installation.) Use the `pwd` command to print your current directory. + + ```ini + [Unit] + Description=CoreMiner Service + After=network.target + StartLimitIntervalSec=0 + + [Service] + Type=simple + WorkingDirectory=$(pwd) + ExecStart=/bin/bash $(pwd)/mine.sh + Restart=always + RestartSec=3 + TimeoutStartSec=0 + + [Install] + WantedBy=multi-user.target + ``` + +3. Save the service file as `coreminer.service` in `/etc/systemd/system/`. +4. Reload the systemd daemon: -Contents of file `coreverif.service`: + ```bash + sudo systemctl daemon-reload + ``` -```bash -[Unit] -Description=CoreVerificator -After=network.target -StartLimitIntervalSec=0 +5. Enable the service: -[Service] -Type=simple -WorkingDirectory=$(pwd) -ExecStart=/bin/bash $(pwd)/mine.sh -Restart=always -RestartSec=3 -TimeoutStartSec=0 + ```bash + sudo systemctl enable coreminer.service + ``` -[Install] -WantedBy=multi-user.target -``` +6. Start the service: -1. Create file `coreverif.service` and save it into `/etc/systemd/system/` folder. -1. Execute the command for reloading the client: `sudo systemctl daemon-reload`. -1. Execute the command for enabling the service: `sudo systemctl enable coreverif.service`. -1. Execute the command for starting the service: `sudo systemctl start coreverif.service`. -1. Restart your machine. (Optional, but recommended.) + ```bash + sudo systemctl start coreminer.service + ``` -### Optional steps +7. Restart your machine (optional but recommended). -1. Check if service is registered with the command: `systemctl --all | grep coreverif.service`. -1. Reduce log files to remember past for 1 day: `sudo journalctl --rotate && journalctl --vacuum-time=1d`. +### Optional Steps + +1. Verify the service is registered: + + ```bash + systemctl --all | grep coreminer.service + ``` + +2. Configure log rotation to keep logs for one day: + + ```bash + sudo journalctl --rotate && journalctl --vacuum-time=1d + ``` ## Automatic Installation -Automatic installation is included in the `mine.sh` script. You can use it for the first setup or for the reinstallation. +The automatic installation is included in the `mine.sh` script. You can use it for both initial setup and reinstallation. ## Troubleshooting -Please, first follow the log file, where you can find many answers: `journalctl -u coreverif.service`. +1. Check the service logs for detailed information: + + ```bash + journalctl -u coreminer.service + ``` -If your issue persist, open thread in [discussion board](https://github.com/catchthatrabbit/coreminer/discussions) or lastly [raise an Issue](https://github.com/catchthatrabbit/coreminer/issues/new/choose). +2. If issues persist: + - Open a thread in the [discussion board](https://github.com/catchthatrabbit/coreminer/discussions) + - Or [raise an issue](https://github.com/catchthatrabbit/coreminer/issues/new/choose) diff --git a/docs/BUILD.md b/docs/BUILD.md index 04f0e1f4c..1d1961742 100644 --- a/docs/BUILD.md +++ b/docs/BUILD.md @@ -1,17 +1,18 @@ -# Building from source +# Building CoreMiner from Source ## Table of Contents -* [Requirements](#requirements) - * [Common](#common) - * [Linux](#linux) - * [macOS](#macos) - * [Windows](#windows) -* [CMake configuration options](#cmake-configuration-options) -* [Disable Hunter](#disable-hunter) -* [Instructions](#instructions) - * [Windows-specific script](#windows-specific-script) - +- [Building CoreMiner from Source](#building-coreminer-from-source) + - [Table of Contents](#table-of-contents) + - [Requirements](#requirements) + - [Common](#common) + - [Linux](#linux) + - [macOS](#macos) + - [Windows](#windows) + - [Instructions](#instructions) + - [Windows-specific Script](#windows-specific-script) + - [CMake Configuration Options](#cmake-configuration-options) + - [Disable Hunter](#disable-hunter) ## Requirements @@ -21,16 +22,16 @@ This project uses [CMake] and [Hunter] package manager. 1. [CMake] >= 3.5 2. [Git](https://git-scm.com/downloads) -3. [Perl](https://www.perl.org/get.html), needed to build OpenSSL +3. [Perl](https://www.perl.org/get.html) (required for OpenSSL build) ### Linux 1. GCC version >= 4.8 -2. DBUS development libs if building with `-DETHDBUS`. E.g. on Ubuntu run: +2. DBUS development libraries (if building with `-DETHDBUS`). For Ubuntu: -```shell -sudo apt install libdbus-1-dev -``` + ```bash + sudo apt install libdbus-1-dev + ``` ### macOS @@ -38,73 +39,76 @@ sudo apt install libdbus-1-dev ### Windows -1. [Visual Studio 2017](https://www.visualstudio.com/downloads/); Community Edition works fine. **Make sure you install MSVC 2015 toolkit (v140).** +1. [Visual Studio 2017](https://www.visualstudio.com/downloads/) (Community Edition is sufficient) + > **Note**: Make sure you install MSVC 2015 toolkit (v140). ## Instructions -1. Make sure git submodules are up to date: +1. Update git submodules: - ```shell - git submodule update --init --recursive - ``` + ```bash + git submodule update --init --recursive + ``` 2. Create a build directory: - ```shell - mkdir build - cd build - ``` + ```bash + mkdir build + cd build + ``` + +3. Configure the project with CMake. See [configuration options](#cmake-configuration-options) for additional settings: -3. Configure the project with CMake. Check out the additional [configuration options](#cmake-configuration-options). + ```bash + cmake .. + ``` - ```shell - cmake .. - ``` + For Windows: - ```shell - cmake .. -G "Visual Studio 15 2017 Win64" - # or this if you have build errors - cmake .. -G "Visual Studio 15 2017 Win64" -T v140 - ``` + ```bash + cmake .. -G "Visual Studio 15 2017 Win64" + # If you encounter build errors, try: + cmake .. -G "Visual Studio 15 2017 Win64" -T v140 + ``` -4. Build the project using [CMake Build Tool Mode]. This is a portable variant of `make`. +4. Build the project using CMake Build Tool Mode: - ```shell - cmake --build . - ``` + ```bash + cmake --build . + ``` - Note: On Windows, it is possible to have compiler issues if you don't specify the build config. In that case use: + > **Note**: On Windows, specify the build config if you encounter compiler issues: - ```shell - cmake --build . --config Release - ``` + ```bash + cmake --build . --config Release + ``` 5. _(Optional, Linux only)_ Install the built executable: - ```shell - sudo make install - ``` + ```bash + sudo make install + ``` -### Windows-specific script +### Windows-specific Script -Complete sample Windows batch file - **adapt it to your system**. Assumes that: +Here's a complete Windows batch file example. **Adapt it to your system**. The script assumes: -* it's placed one folder up from the coreminer source folder -* you have CMake installed -* you have Perl installed +- It's placed one folder up from the CoreMiner source folder +- CMake is installed +- Perl is installed -```bat +```batch @echo off setlocal -rem add MSVC in PATH +rem Add MSVC to PATH call "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\Common7\Tools\VsMSBuildCmd.bat" -rem add Perl in PATH; it's needed for OpenSSL build +rem Add Perl to PATH (needed for OpenSSL build) set "PERL_PATH=C:\Perl\perl\bin" set "PATH=%PERL_PATH%;%PATH%" -rem switch to coreminer's source folder +rem Switch to CoreMiner's source folder cd "%~dp0\coreminer\" if not exist "build\" mkdir "build\" @@ -116,24 +120,16 @@ endlocal pause ``` -## CMake configuration options +## CMake Configuration Options -Pass these options to CMake configuration command, e.g. +Add these options to your CMake configuration command: -```shell -cmake .. -``` - -* `-DAPICORE=ON` - enable API Server, `ON` by default. -* `-DETHDBUS=ON` - enable D-Bus support, `OFF` by default. +- `-DAPICORE=ON` - Enable API Server (default: ON) +- `-DETHDBUS=ON` - Enable D-Bus support (default: OFF) ## Disable Hunter -If you want to install dependencies yourself or use system package manager you can disable Hunter by adding -[`-DHUNTER_ENABLED=OFF`](https://docs.hunter.sh/en/latest/reference/user-variables.html#hunter-enabled) -to the configuration options. - +To install dependencies manually or use your system's package manager, disable Hunter by adding `-DHUNTER_ENABLED=OFF` to your CMake configuration options. [CMake]: https://cmake.org/ -[CMake Build Tool Mode]: https://cmake.org/cmake/help/latest/manual/cmake.1.html#build-tool-mode [Hunter]: https://docs.hunter.sh/ diff --git a/docs/STRATUM.md b/docs/STRATUM.md index 6a1afd7b6..f1ed9b5de 100644 --- a/docs/STRATUM.md +++ b/docs/STRATUM.md @@ -1,24 +1,29 @@ -# Pool Examples for Core +# CoreMiner Stratum Protocol -Pool connection definition is issued via `-P` argument which has this syntax: +## Connection Format -``` +Pool connections are defined using the `-P` argument with the following syntax: + +```bash -P scheme://user[.workername][:password]@hostname:port[/...] ``` -__values in square brackets are optional__ -where `scheme` can be any of: +> **Note**: Values in square brackets are optional. -* `http` for getwork mode -* `stratum+tcp` for plain stratum mode -* `stratum1+tcp` for plain stratum core-proxy compatible mode -* `stratum2+tcp` for plain stratum NiceHash compatible mode +Supported schemes: -## A note about this form of notation -This notation is called URI notation and gives us great flexibility allowing Coreminer to specify all needed arguments per single connection (other miners offer single dedicated CLI arguments which are valid for all connections). -An URI is formed like this +- `http` - getwork mode +- `stratum+tcp` - plain stratum mode +- `stratum1+tcp` - plain stratum core-proxy compatible mode +- `stratum2+tcp` - plain stratum NiceHash compatible mode -``` +## URI Notation + +This notation provides flexibility by allowing CoreMiner to specify all needed arguments per connection. Other miners typically use dedicated CLI arguments that apply to all connections. + +A URI is structured as follows: + +```txt Authority +-----------------------------------------------------------------------------------------+ stratum://cb57bbbb54cdf60fa666fd741be78f794d4608d67109.worker-01:password@eu.catchthatrabbit.com:8008 @@ -28,71 +33,88 @@ An URI is formed like this | | + -------------------------------- > Host | + ------------------------------------------------------------------- > User Info + --------------------------------------------------------------------------------------------- > Scheme - ``` -Optionally you can append to the above notation anything which might be useful in the form of a path. -Example +You can optionally append additional information as a path: -``` +```txt stratum://cb57bbbb54cdf60fa666fd741be78f794d4608d67109.worker-01:password@eu.catchthatrabbit.com:8008/something/else +--------------+ | Path --------------- + ``` -**Anything you put in the `Path` part must be Url Encoded thus, for example, `@` must be written as `%40`** +> **Note**: Any characters in the Path section must be URL encoded. For example, `@` must be written as `%40`. -As you may have noticed due to compatibility with pools we need to know exactly which are the delimiters for the account, the workername (if any) and the password (if any) which are respectively a dot `.` and a column `:`. -Should your values contain any of the above mentioned chars or any other char which may impair the proper parsing of the URI you have two options: -- either enclose the string in backticks (ASCII 96) -- or URL encode the impairing chars +## Special Characters -Say you need to provide the pool with an account name which contains a dot. At your discretion you may either write -``` +Due to pool compatibility, we need specific delimiters: + +- `.` (dot) separates the account from the workername +- `:` (colon) separates the workername from the password + +If your values contain these characters or others that might affect parsing, you have two options: + +1. Enclose the string in backticks (ASCII 96) +2. URL encode the problematic characters + +Example with an account name containing a dot: + +```bash +# Using backticks -P stratum://`account.1234`.worker-01:password@eu.catchthatrabbit.com:8008 -``` -or -``` --P stratum://account%2e1234.worker-01:password@eu.catchthatrabbit.com:8008 -``` -The above samples produce the very same result. -**Backticks on *nix**. The backtick enclosure has a special meaning of execution thus you may need to further escape the sequence as +# Using URL encoding +-P stratum://account%2e1234.worker-01:password@eu.catchthatrabbit.com:8008 ``` + +> **Note**: On Unix-like systems, backticks have special meaning for command execution. You may need to escape them: + +```bash -P stratum://\`account.1234\`.worker-01:password@eu.catchthatrabbit.com:8008 -``` -**`%` on Windows**. The percent symbol `%` has a special meaning in Windows batch files thus you may need to further escape it by doubling. Following example shows `%2e` needs to be replaced as `%%2e` ``` + +> **Note**: On Windows, the `%` symbol has special meaning in batch files. You may need to double it: + +```batch -P stratum://account%%2e1234.worker-01:password@eu.catchthatrabbit.com:8008 -``` +``` -## Secure socket communications for stratum only +## Secure Socket Communications -Coreminer supports secure socket communications (where pool implements and offers it) to avoid the risk of a [man-in-the-middle attack](https://en.wikipedia.org/wiki/Man-in-the-middle_attack) -To enable it simply replace tcp with either: +CoreMiner supports secure socket communications to prevent [man-in-the-middle attacks](https://en.wikipedia.org/wiki/Man-in-the-middle_attack). To enable it, replace `tcp` with: -* `tls` to enable secure socket communication -* `ssl` or `tls12` to enable secure socket communication **allowing only TLS 1.2** encryption +- `tls` - Enable secure socket communication +- `ssl` or `tls12` - Enable secure socket communication with TLS 1.2 only + +Example: + +```bash +-P stratum+tls://[...] +# or +-P stratum+tls12://[...] +``` -thus your connection scheme changes to `-P stratum+tls://[...]` or `-P stratum+tls12://[...]`. Same applies for `stratum1` and `stratum2`. +This applies to all stratum variants (`stratum1` and `stratum2`). -## Special characters in variables +## URL Encoding Reference -You can use the %xx (xx=hexvalue of character) to pass special values. -Some examples: +Common special characters and their URL encodings: | Code | Character | -| :---: | :---: | -|%25 | % | -|%26 | & | -|%2e | . | -|%2f | / | -|%3a | : | -|%3f | ? | -|%40 | @ | - -## Secure connections - -Stratum autodetection has been introduced to mitigate user's duty to guess/find which stratum flavour to apply (stratum or stratum1 or stratum2). -If you want to let Coreminer do the tests for you simply enter scheme as `stratum://` (note `+tcp` is missing) or `stratums://` for secure socket or `stratumss://` for secure socket **allowing only TLS 1.2** encryption. +|:----:|:---------:| +| %25 | % | +| %26 | & | +| %2e | . | +| %2f | / | +| %3a | : | +| %3f | ? | +| %40 | @ | + +## Automatic Stratum Detection + +CoreMiner includes automatic stratum detection to simplify connection setup. Instead of guessing the correct stratum variant, you can use: + +- `stratum://` - For automatic detection of plain stratum +- `stratums://` - For automatic detection of secure stratum +- `stratumss://` - For automatic detection of TLS 1.2 secure stratum diff --git a/mine.sh b/mine.sh index 3a71ed424..8b8b2da3b 100755 --- a/mine.sh +++ b/mine.sh @@ -9,29 +9,83 @@ units_available() fi } +request_worker_name() { + echo "$(tput setaf 3)●$(tput sgr 0) Enter worker name. Choose format:" + echo "1) Plain name (alphanumeric and underscores/hyphens)" + echo "2) Fediverse user (e.g., _username_instance_tld-machineid)" + echo "3) Random (e.g., worker-34874)" + read -p "$(tput setaf 3)➤$(tput sgr 0) Select format (1, 2, or 3): " choice + + case $choice in + 1) + while true; do + read -p "$(tput setaf 3)➤$(tput sgr 0) Enter plain name: " worker + if [[ $worker =~ ^[a-zA-Z0-9_-]+$ ]]; then + break + else + echo "$(tput setaf 1)●$(tput sgr 0) Invalid format. Please use alphanumeric characters, underscores, or hyphens." + fi + done + ;; + 2) + read -p "$(tput setaf 3)➤$(tput sgr 0) Enter Fediverse username (alphanumeric): " username + while ! [[ $username =~ ^[a-zA-Z0-9]+$ ]]; do + echo "$(tput setaf 1)●$(tput sgr 0) Invalid username. Must be alphanumeric." + read -p "$(tput setaf 3)➤$(tput sgr 0) Enter Fediverse username (alphanumeric): " username + done + username=$(echo "$username" | awk '{print tolower($0)}') # Convert to lowercase + + read -p "$(tput setaf 3)➤$(tput sgr 0) Enter Fediverse domain (instance.tld): " domain + # Transform domain to lowercase and replace dots with underscores + formatted_domain=$(echo "$domain" | tr '[:upper:]' '[:lower:]' | tr '.' '_') + + read -p "$(tput setaf 3)➤$(tput sgr 0) Enter optional Machine ID (alphanumeric, can be skipped): " id + while ! [[ $id =~ ^[a-zA-Z0-9]*$ ]]; do + echo "$(tput setaf 1)●$(tput sgr 0) Invalid Machine ID. Must be alphanumeric." + read -p "$(tput setaf 3)➤$(tput sgr 0) Enter optional Machine ID (alphanumeric, can be skipped): " id + done + + worker="_${username}_${formatted_domain}" + if [[ -n $id ]]; then + worker+="-${id}" + fi + ;; + 3) + random_number=$(shuf -i 10000-99999 -n 1) # Generate a random number + worker="worker-${random_number}" + ;; + *) + echo "$(tput setaf 1)●$(tput sgr 0) Invalid choice. Please try again." + request_worker_name + ;; + esac + echo "$(tput setaf 2)●$(tput sgr 0) Worker name set to: $worker" +} + add_pool() { if [[ "$1" -gt "1" ]]; then echo - echo "$(tput setaf 3)●$(tput sgr 0) Please, select the additional mining pool." + echo "$(tput setaf 3)●$(tput sgr 0) Please select an additional mining pool." PS3="➤ Additional Pool: " else - echo "$(tput setaf 3)●$(tput sgr 0) Please, select the mining pool." + echo "$(tput setaf 3)●$(tput sgr 0) Please select a mining pool." PS3="$(tput setaf 3)➤$(tput sgr 0) Pool: " fi units=`units_available` - options=("CTR EU" "CTR EU Backup" "CTR AS" "CTR AS Backup" "CTR US" "CTR US Backup" "Other" "Exit") + options=("DACH Pool 🇩🇪🇦🇹🇨🇭" "Nordic Pool 🇫🇮🇳🇴🇸🇪" "ASEAN Pool 🇸🇬🇹🇭🇵🇭" "Far-East Pool 🇭🇰🇨🇳🇯🇵" "American Pool 🇺🇸🇲🇽🇧🇷" "Other 🌐" "Exit ❌") + IFS=$'\n' select opt in "${options[@]}" do case "$REPLY" in 1) pool_heading $opt - server[$1]="eu.catchthatrabbit.com" + server[$1]="de.catchthatrabbit.com" port[$1]=8008 if [[ "$1" -lt "2" ]]; then read -p "$(tput setaf 3)➤$(tput sgr 0) Enter wallet address: " wallet - read -p "$(tput setaf 3)➤$(tput sgr 0) Enter worker name: " worker + request_worker_name printf "$(tput setaf 3)●$(tput sgr 0) Available processing units: %s\n" $units read -p "$(tput setaf 3)➤$(tput sgr 0) How many units to use? [Enter for all] " threads fi @@ -39,11 +93,11 @@ add_pool() ;; 2) pool_heading $opt - server[$1]="eu1.catchthatrabbit.com" + server[$1]="fi.catchthatrabbit.com" port[$1]=8008 if [[ "$1" -lt "2" ]]; then read -p "$(tput setaf 3)➤$(tput sgr 0) Enter wallet address: " wallet - read -p "$(tput setaf 3)➤$(tput sgr 0) Enter worker name: " worker + request_worker_name printf "$(tput setaf 3)●$(tput sgr 0) Available processing units: %s\n" $units read -p "$(tput setaf 3)➤$(tput sgr 0) How many units to use? [Enter for all] " threads fi @@ -51,11 +105,11 @@ add_pool() ;; 3) pool_heading $opt - server[$1]="as.catchthatrabbit.com" + server[$1]="sg.catchthatrabbit.com" port[$1]=8008 if [[ "$1" -lt "2" ]]; then read -p "$(tput setaf 3)➤$(tput sgr 0) Enter wallet address: " wallet - read -p "$(tput setaf 3)➤$(tput sgr 0) Enter worker name: " worker + request_worker_name printf "$(tput setaf 3)●$(tput sgr 0) Available processing units: %s\n" $units read -p "$(tput setaf 3)➤$(tput sgr 0) How many units to use? [Enter for all] " threads fi @@ -63,11 +117,11 @@ add_pool() ;; 4) pool_heading $opt - server[$1]="as1.catchthatrabbit.com" + server[$1]="hk.catchthatrabbit.com" port[$1]=8008 if [[ "$1" -lt "2" ]]; then read -p "$(tput setaf 3)➤$(tput sgr 0) Enter wallet address: " wallet - read -p "$(tput setaf 3)➤$(tput sgr 0) Enter worker name: " worker + request_worker_name printf "$(tput setaf 3)●$(tput sgr 0) Available processing units: %s\n" $units read -p "$(tput setaf 3)➤$(tput sgr 0) How many units to use? [Enter for all] " threads fi @@ -79,7 +133,7 @@ add_pool() port[$1]=8008 if [[ "$1" -lt "2" ]]; then read -p "$(tput setaf 3)➤$(tput sgr 0) Enter wallet address: " wallet - read -p "$(tput setaf 3)➤$(tput sgr 0) Enter worker name: " worker + request_worker_name printf "$(tput setaf 3)●$(tput sgr 0) Available processing units: %s\n" $units read -p "$(tput setaf 3)➤$(tput sgr 0) How many units to use? [Enter for all] " threads fi @@ -87,29 +141,17 @@ add_pool() ;; 6) pool_heading $opt - server[$1]="us1.catchthatrabbit.com" - port[$1]=8008 - if [[ "$1" -lt "2" ]]; then - read -p "$(tput setaf 3)➤$(tput sgr 0) Enter wallet address: " wallet - read -p "$(tput setaf 3)➤$(tput sgr 0) Enter worker name: " worker - printf "$(tput setaf 3)●$(tput sgr 0) Available processing units: %s\n" $units - read -p "$(tput setaf 3)➤$(tput sgr 0) How many units to use? [Enter for all] " threads - fi - break - ;; - 7) - pool_heading $opt read -p "$(tput setaf 3)➤$(tput sgr 0) Enter server address: " server[$1] read -p "$(tput setaf 3)➤$(tput sgr 0) Enter server port: " port[$1] if [[ "$1" -lt "2" ]]; then read -p "$(tput setaf 3)➤$(tput sgr 0) Enter wallet address: " wallet - read -p "$(tput setaf 3)➤$(tput sgr 0) Enter worker name: " worker + request_worker_name printf "$(tput setaf 3)●$(tput sgr 0) Available processing units: %s\n" $units read -p "$(tput setaf 3)➤$(tput sgr 0) How many units to use? [Enter for all] " threads fi break ;; - 8) clear; exit 0;; + 7) clear; exit 0;; *) echo "$(tput setaf 1)●$(tput sgr 0) Invalid option."; continue;; esac done @@ -119,7 +161,7 @@ pool_heading() { echo echo "╒════════════════════════════════════" - echo "│ Pool $1" + echo "│ $1" echo "╘════════════════════════════════════" } @@ -157,7 +199,7 @@ start_mining() fi if [ ! -f "coreminer" ]; then - echo "$(tput setaf 1)●$(tput sgr 0) Miner not found!" + echo "$(tput setaf 1)●$(tput sgr 0) Miner executable not found!" exit 2 fi @@ -195,11 +237,11 @@ validate_wallet() done OPERAND=`echo $SUM``echo $CHECKSUM` if [[ `echo "$OPERAND % 97" | $BC` -ne 1 ]]; then - echo "$(tput setaf 1)●$(tput sgr 0) Invalid wallet!" + echo "$(tput setaf 1)●$(tput sgr 0) Invalid wallet address!" exit 1 fi else - echo "$(tput setaf 3)●$(tput sgr 0) Not able to validate wallet! (Install 'bc' if needed.)" + echo "$(tput setaf 3)●$(tput sgr 0) Unable to validate wallet. Please install 'bc' if needed." fi } @@ -215,10 +257,12 @@ compose_stratum() export_config() { - > $1 - for setting in "${@:2}" + filename=$1 + shift # Remove the first argument (filename) from the list + > "$filename" + for setting in "$@" do - echo $setting >> $1 + echo "$setting" >> "$filename" done } @@ -288,7 +332,7 @@ autostart_service() echo "$(tput setaf 2)●$(tput sgr 0) Creating autostart service." > /etc/systemd/system/coreminer.service echo "[Unit]" >> /etc/systemd/system/coreminer.service - echo "Description=CoreVerificator" >> /etc/systemd/system/coreminer.service + echo "Description=CoreMiner Service" >> /etc/systemd/system/coreminer.service echo "After=network.target" >> /etc/systemd/system/coreminer.service echo "StartLimitIntervalSec=0" >> /etc/systemd/system/coreminer.service echo "" >> /etc/systemd/system/coreminer.service @@ -305,9 +349,9 @@ autostart_service() systemctl daemon-reload systemctl enable coreminer.service echo "$(tput setaf 2)●$(tput sgr 0) Autostart service created." - echo "$(tput setaf 2)●$(tput sgr 0) Vacuuming journal." + echo "$(tput setaf 2)●$(tput sgr 0) Configuring journal rotation." journalctl --rotate && journalctl --vacuum-time=1d - echo "$(tput setaf 2)●$(tput sgr 0) Starting autostart service and script." + echo "$(tput setaf 2)●$(tput sgr 0) Starting autostart service." systemctl start coreminer.service } @@ -331,7 +375,7 @@ echo CONFIG=`extdrive_check` if [ -f "$CONFIG" ]; then - echo "$(tput setaf 2)●$(tput sgr 0) Mine settings file '$CONFIG' exists." + echo "$(tput setaf 2)●$(tput sgr 0) Mine settings file '$CONFIG' found." echo "$(tput setaf 2)●$(tput sgr 0) Importing settings." import_config $CONFIG if [ "$update" = true ]; then @@ -339,7 +383,7 @@ if [ -f "$CONFIG" ]; then fi ICANWALLET=${wallet//[[:blank:]]/} validate_wallet $ICANWALLET - echo "$(tput setaf 2)●$(tput sgr 0) Wallet validated." + echo "$(tput setaf 2)●$(tput sgr 0) Wallet address validated." STRATUM="" echo "$(tput setaf 2)●$(tput sgr 0) Configuring stratum server." for i in "${!server[@]}" @@ -347,15 +391,15 @@ if [ -f "$CONFIG" ]; then STRATUM+=`compose_stratum "$ICANWALLET" "${server[$i]}" "${port[$i]}" "$worker"` STRATUM+=" " done - echo "$(tput setaf 2)●$(tput sgr 0) Starting mining command." + echo "$(tput setaf 2)●$(tput sgr 0) Starting mining process." start_mining "$threads" $STRATUM else - echo "$(tput setaf 3)●$(tput sgr 0) Mine settings file '$CONFIG' doesn't exist." - echo "$(tput setaf 2)●$(tput sgr 0) Proceeding with setup." + echo "$(tput setaf 3)●$(tput sgr 0) Mine settings file '$CONFIG' not found." + echo "$(tput setaf 2)●$(tput sgr 0) Starting setup process." echo while true do - read -r -p "$(tput setaf 3)➤$(tput sgr 0) Check for the update? [yes/no] " upd + read -r -p "$(tput setaf 3)➤$(tput sgr 0) Check for the update? [Yes/No] " upd case $upd in [yY][eE][sS]|[yY]) update_app @@ -366,7 +410,7 @@ else break ;; *) - echo "$(tput setaf 1)➤$(tput sgr 0) Invalid input. [yes,no]" + echo "$(tput setaf 1)➤$(tput sgr 0) Invalid input. [Yes/No]" ;; esac done @@ -380,7 +424,7 @@ else (( LOOP++ )) while true do - read -r -p "$(tput setaf 3)➤$(tput sgr 0) Do you wish to add additional pool? [yes/no] " back + read -r -p "$(tput setaf 3)➤$(tput sgr 0) Do you wish to add additional pool? [Yes/No] " back case $back in [yY][eE][sS]|[yY]) add_pool $LOOP @@ -390,7 +434,7 @@ else break ;; *) - echo "$(tput setaf 1)➤$(tput sgr 0) Invalid input. [yes,no]" + echo "$(tput setaf 1)➤$(tput sgr 0) Invalid input. [Yes/No]" ;; esac done @@ -398,21 +442,26 @@ else echo echo "$(tput setaf 2)●$(tput sgr 0) Saving the settings." - EXPORTDATA="" + # Build settings array + settings=() if [[ "$threads" -gt "0" ]]; then - EXPORTDATA+="$CONFIG wallet=${ICANWALLET} worker=${worker} threads=${threads}" + settings+=("wallet=${ICANWALLET}") + settings+=("worker=${worker}") + settings+=("threads=${threads}") else - EXPORTDATA+="$CONFIG wallet=${ICANWALLET} worker=${worker}" + settings+=("wallet=${ICANWALLET}") + settings+=("worker=${worker}") fi for ((i = 1; i < $LOOP; i++)); do - EXPORTDATA+=" server[$i]=${server[$i]} port[$i]=${port[$i]}" + settings+=("server[$i]=${server[$i]}") + settings+=("port[$i]=${port[$i]}") done - export_config $EXPORTDATA + export_config "$CONFIG" "${settings[@]}" echo while true do - read -r -p "$(tput setaf 3)➤$(tput sgr 0) Add the autostart service? [yes/no] " autostart + read -r -p "$(tput setaf 3)➤$(tput sgr 0) Add the autostart service? [Yes/No] " autostart case $autostart in [yY][eE][sS]|[yY]) autostart_service @@ -423,7 +472,7 @@ else break ;; *) - echo "$(tput setaf 1)➤$(tput sgr 0) Invalid input. [yes,no]" + echo "$(tput setaf 1)➤$(tput sgr 0) Invalid input. [Yes/No]" ;; esac done @@ -431,7 +480,7 @@ else echo while true do - read -r -p "$(tput setaf 3)➤$(tput sgr 0) Start mining now? [yes/no] " mine + read -r -p "$(tput setaf 3)➤$(tput sgr 0) Start mining now? [Yes/No] " mine case $mine in [yY][eE][sS]|[yY]) STRATUM="" @@ -446,7 +495,7 @@ else exit 0 ;; *) - echo "$(tput setaf 1)➤$(tput sgr 0) Invalid input. [yes,no]" + echo "$(tput setaf 1)➤$(tput sgr 0) Invalid input. [Yes/No]" ;; esac done