<commit_before>// Copyright (c) 2010 <NAME>
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "main.h"
#include "db.h"
#include "init.h"
#include "servicenodeconfig.h"
#include "rpcserver.h"
#include "utilmoneystr.h"

#include <fstream>
#include <string>
using namespace std;
using namespace json_spirit;

Value servicenode(const Array& params, bool fHelp)
{
    string strCommand;
    if (params.size() >= 1)
        strCommand = params[0].get_str();

    if (fHelp  ||
        (strCommand != "start" && strCommand != "start-alias" && strCommand != "start-many" && strCommand != "start-all" && 
         strCommand != "start-missing" && strCommand != "start-disabled" && strCommand != "list" && strCommand != "list-conf" && 
         strCommand != "count"  && strCommand != "enforce" && strCommand != "debug" && strCommand != "current" && 
         strCommand != "winners" && strCommand != "genkey" && strCommand != "connect" && strCommand != "outputs" && 
         strCommand != "status" && strCommand != "calcscore"))
        throw runtime_error(
                "servicenode \"command\"... ( \"passphrase\" )\n"
                "Set of commands to execute servicenode related actions\n"
                "\nArguments:\n"
                "1. \"command\"        (string or set of strings, required) The command to execute\n"
                "2. \"passphrase\"     (string, optional) The wallet passphrase\n"
                "\nAvailable commands:\n"
                "  count        - Print number of all known servicenodes (optional: 'ds', 'enabled', 'all', 'qualify')\n"
                "  current      - Print info on current servicenode winner\n"
                "  debug        - Print servicenode status\n"
                "  genkey       - Generate new servicenodeprivkey\n"
                "  enforce      - Enforce servicenode payments\n"
                "  outputs      - Print servicenode compatible outputs\n"
                "  start        - Start servicenode configured in crown.conf\n"
                "  start-alias  - Start single servicenode by assigned alias configured in servicenode.conf\n"
                "  start-<mode> - Start servicenodes configured in servicenode.conf (<mode>: 'all', 'missing', 'disabled')\n"
                "  status       - Print servicenode status information\n"
                "  list         - Print list of all known servicenodes (see servicenodelist for more info)\n"
                "  list-conf    - Print servicenode.conf in JSON format\n"
                "  winners      - Print list of servicenode winners\n"
                );

    if (strCommand == "list")
    {
        Array newParams(params.size() - 1);
        std::copy(params.begin() + 1, params.end(), newParams.begin());
        return servicenodelist(newParams, fHelp);
    }

    if (strCommand == "budget")
    {
        return "Show budgets";
    }

    if(strCommand == "connect")
    {
        std::string strAddress = "";
        if (params.size() == 2) {
            strAddress = params[1].get_str();
        } else {
            throw runtime_error("Servicenode address required\n");
        }

        CService addr = CService(strAddress);

        CNode *pnode = ConnectNode((CAddress)addr, NULL, false);
        if(pnode){
            pnode->Release();
            return "successfully connected";
        } else {
            throw runtime_error("error connecting\n");
        }
    }

    if (strCommand == "count")
    {
        // TODO to be implemented
        return "Option is not implemented yet";
    }

    if (strCommand == "current")
    {
        // TODO to be implemented
        return "Option is not implemented yet";
    }

    return Value::null;
}

Value servicenodelist(const Array& params, bool fHelp)
{
    return Value::null;
}

Value servicenodebroadcast(const Array& params, bool fHelp)
{
    return Value::null;
}<commit_msg>Added 'genkey' command for servicenode<commit_after>// Copyright (c) 2010 <NAME>
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "main.h"
#include "db.h"
#include "init.h"
#include "servicenodeconfig.h"
#include "rpcserver.h"
#include "utilmoneystr.h"
#include "key.h"
#include "base58.h"

#include <fstream>
#include <string>
using namespace std;
using namespace json_spirit;

Value servicenode(const Array& params, bool fHelp)
{
    string strCommand;
    if (params.size() >= 1)
        strCommand = params[0].get_str();

    if (fHelp  ||
        (strCommand != "start" && strCommand != "start-alias" && strCommand != "start-many" && strCommand != "start-all" && 
         strCommand != "start-missing" && strCommand != "start-disabled" && strCommand != "list" && strCommand != "list-conf" && 
         strCommand != "count"  && strCommand != "enforce" && strCommand != "debug" && strCommand != "current" && 
         strCommand != "winners" && strCommand != "genkey" && strCommand != "connect" && strCommand != "outputs" && 
         strCommand != "status" && strCommand != "calcscore"))
        throw runtime_error(
                "servicenode \"command\"... ( \"passphrase\" )\n"
                "Set of commands to execute servicenode related actions\n"
                "\nArguments:\n"
                "1. \"command\"        (string or set of strings, required) The command to execute\n"
                "2. \"passphrase\"     (string, optional) The wallet passphrase\n"
                "\nAvailable commands:\n"
                "  count        - Print number of all known servicenodes (optional: 'ds', 'enabled', 'all', 'qualify')\n"
                "  current      - Print info on current servicenode winner\n"
                "  debug        - Print servicenode status\n"
                "  genkey       - Generate new servicenodeprivkey\n"
                "  enforce      - Enforce servicenode payments\n"
                "  outputs      - Print servicenode compatible outputs\n"
                "  start        - Start servicenode configured in crown.conf\n"
                "  start-alias  - Start single servicenode by assigned alias configured in servicenode.conf\n"
                "  start-<mode> - Start servicenodes configured in servicenode.conf (<mode>: 'all', 'missing', 'disabled')\n"
                "  status       - Print servicenode status information\n"
                "  list         - Print list of all known servicenodes (see servicenodelist for more info)\n"
                "  list-conf    - Print servicenode.conf in JSON format\n"
                "  winners      - Print list of servicenode winners\n"
                );

    if (strCommand == "list")
    {
        Array newParams(params.size() - 1);
        std::copy(params.begin() + 1, params.end(), newParams.begin());
        return servicenodelist(newParams, fHelp);
    }

    if (strCommand == "budget")
    {
        return "Show budgets";
    }

    if(strCommand == "connect")
    {
        std::string strAddress = "";
        if (params.size() == 2) {
            strAddress = params[1].get_str();
        } else {
            throw runtime_error("Servicenode address required\n");
        }

        CService addr = CService(strAddress);

        CNode *pnode = ConnectNode((CAddress)addr, NULL, false);
        if(pnode){
            pnode->Release();
            return "successfully connected";
        } else {
            throw runtime_error("error connecting\n");
        }
    }

    if (strCommand == "count")
    {
        // TODO to be implemented
        return "Option is not implemented yet";
    }

    if (strCommand == "current")
    {
        // TODO to be implemented
        return "Option is not implemented yet";
    }

    if (strCommand == "genkey")
    {
        CKey secret;
        secret.MakeNewKey(false);

        return CBitcoinSecret(secret).ToString();
    }


    return Value::null;
}

Value servicenodelist(const Array& params, bool fHelp)
{
    return Value::null;
}

Value servicenodebroadcast(const Array& params, bool fHelp)
{
    return Value::null;
}
{'fraction_non_alphanumeric': 0.12659908279024862, 'fraction_numerical': 0.005551532705768767, 'mean_word_length': 2.125990192380234, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4974527', 'n_tokens_mistral': 2469, 'n_tokens_neox': 2306, 'n_words': 652}