
struct VEXON_COIND_AUX
{
	VEXON_COIND *coind;
//	int height;

	int index;
	int chainid;

	char hash[1024];
	char target[1024];
};

class VEXON_COIND: public VEXON_OBJECT
{
public:
	bool touch;
	bool newcoind;

	VEXON_RPC rpc;
	char rpcencoding[32];

//	pthread_t thread;
	pthread_mutex_t mutex;
//	pthread_cond_t cond;

//	bool closing;

	char name[1024];
	char symbol[256];
	char symbol2[256];
	char algo[256];
	char wallet[1024];
	char account[256];

	char pubkey[1024];
	char script_pubkey[1024];
	bool p2sh_address;

	bool pos;
	bool hassubmitblock;
	bool txmessage;

	char charity_address[1024];
	double charity_amount;
	double charity_percent;

	bool enable;
	bool auto_ready;
	bool newblock;
	char lastnotifyhash[192];

	int height;
	double difficulty;

	double reward;
	double reward_mul;

	double price;
	int pool_ttf;
	int actual_ttf;

	bool isaux;
	VEXON_COIND_AUX aux;

	int notreportingcounter;
	bool usegetwork;
	bool usememorypool;
	bool hasmasternodes;
	bool oldmasternodes;
	bool multialgos; // pow_hash field (or mined_hash)

	bool usesegwit;
	char commitment[128];
	char witness_magic[16];

	VEXON_JOB *job;
//	VEXON_JOB_TEMPLATE *templ;
};

//////////////////////////////////////////////////////////////////////////

inline void coind_delete(VEXON_OBJECT *object)
{
	VEXON_COIND *coind = (VEXON_COIND *)object;
	object_delete(coind->job);

//	if(coind->templ) delete coind->templ;
	delete coind;
}

void coind_error(VEXON_COIND *coind, const char *s);

double coind_profitability(VEXON_COIND *coind);
double coind_nethash(VEXON_COIND *coind);

bool coind_can_mine(VEXON_COIND *coind, bool isaux=false);
void coind_sort();

bool coind_submit(VEXON_COIND *coind, const char *block);
bool coind_submitgetauxblock(VEXON_COIND *coind, const char *hash, const char *block);

void coind_init(VEXON_COIND *coind);
void coind_terminate(VEXON_COIND *coind);
//void coind_getauxblock(VEXON_COIND *coind);

bool coind_create_job(VEXON_COIND *coind, bool force=false);

bool coind_validate_user_address(VEXON_COIND *coind, char* const address);




