mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-09-05 05:15:17 +00:00
stratum: function to check hex strings validity
This commit is contained in:
parent
bd888ff4e2
commit
165e93bf29
3 changed files with 15 additions and 0 deletions
|
@ -463,6 +463,11 @@ bool client_submit(YAAMP_CLIENT *client, json_value *json_params)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(!ishexa(extranonce2, client->extranonce2size*2)) {
|
||||||
|
client_submit_error(client, job, 27, "Invalid nonce2", extranonce2, ntime, nonce);
|
||||||
|
client->submit_bad++;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
|
@ -417,6 +417,14 @@ void hexlify(char *hex, const unsigned char *bin, int len)
|
||||||
sprintf(hex+strlen(hex), "%02x", bin[i]);
|
sprintf(hex+strlen(hex), "%02x", bin[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ishexa(char *hex, int len)
|
||||||
|
{
|
||||||
|
for(int i=0; i<len; i++) {
|
||||||
|
if (!isxdigit(hex[i])) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned char binvalue(const char v)
|
unsigned char binvalue(const char v)
|
||||||
{
|
{
|
||||||
if(v >= '0' && v <= '9')
|
if(v >= '0' && v <= '9')
|
||||||
|
|
|
@ -86,6 +86,8 @@ void ser_string_be2(const char *input, char *output, int len);
|
||||||
void string_be(const char *input, char *output);
|
void string_be(const char *input, char *output);
|
||||||
void string_be1(char *s);
|
void string_be1(char *s);
|
||||||
|
|
||||||
|
bool ishexa(char *hex, int len);
|
||||||
|
|
||||||
void hexlify(char *hex, const unsigned char *bin, int len);
|
void hexlify(char *hex, const unsigned char *bin, int len);
|
||||||
void binlify(unsigned char *bin, const char *hex);
|
void binlify(unsigned char *bin, const char *hex);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue