Exemple #1
0
static bool do_command(const char *s)
{
    if (!strcmp(s, "chain-set"))
        chain_set();

    else if (!strcmp(s, "dns-seeds"))
        list_dns_seeds();

    else if (!strcmp(s, "list-settings"))
        list_settings();

    else if (!strcmp(s, "new-address"))
        wallet_new_address();

    else if (!strcmp(s, "new-wallet"))
        wallet_create();

    else if (!strcmp(s, "netsync"))
        network_sync();

    else if (!strcmp(s, "version"))
        printf("version=%s\n", VERSION);

    else if (!strcmp(s, "wallet-addr"))
        wallet_addresses();

    else if (!strcmp(s, "wallet-info"))
        wallet_info();

    else if (!strcmp(s, "wallet-dump"))
        wallet_dump();

    return true;
}
Exemple #2
0
int main (int argc, char *argv[])
{
    prog_name = argv[0];
    settings = g_hash_table_new_full(g_str_hash, g_str_equal,
                                     g_free, g_free);

    if (!preload_settings())
        return 1;
    chain_set();

    RAND_bytes((unsigned char *)&instance_nonce, sizeof(instance_nonce));

    unsigned int arg;
    for (arg = 1; arg < argc; arg++) {
        const char *argstr = argv[arg];
        if (is_command(argstr)) {
            if (!do_command(argstr))
                return 1;
        } else {
            if (!do_setting(argstr))
                return 1;
        }
    }

    return 0;
}
Exemple #3
0
int main (int argc, char *argv[])
{
	LOG_INIT(LOG_ALL);
	LOG_GMT_ZONE;

	LOG_BEGIN;

	settings = bp_hashtab_new_ext(czstr_hash, czstr_equal,
				      free, free);

	if (!preload_settings()){
		LOG_END_RC(1);
		//return 1;
	}
	chain_set();
	LOG("chain-set");
	RAND_bytes((unsigned char *)&instance_nonce, sizeof(instance_nonce));

	unsigned int arg;
	for (arg = 1; arg < argc; arg++) {
		const char *argstr = argv[arg];
		if (!do_setting(argstr)){
			LOG_END_RC(1);
			//return 1;
		}
	}
	LOG("arguments processed");

	/*
	 * properly capture TERM and other signals
	 */
	signal(SIGHUP, SIG_IGN);
	signal(SIGPIPE, SIG_IGN);
	signal(SIGINT, term_signal);
	signal(SIGTERM, term_signal);

	LOG("signals set");

	init_daemon(&global_nci);
	run_daemon(&global_nci);

	fprintf(plog, "daemon exiting\n");

	shutdown_daemon(&global_nci);
	LOG_END_RC(0);
	//return 0;
}