mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-08-23 09:27:25 +00:00
stratum: precheck addresses are valid base58
This commit is contained in:
parent
b517afb571
commit
1bfec2be32
3 changed files with 22 additions and 1 deletions
|
@ -96,3 +96,19 @@ bool base58_decode(const char *input, char *output)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_base58(char *input)
|
||||||
|
{
|
||||||
|
// All alphanumeric characters except "0", "O", "I" and "l"
|
||||||
|
size_t i=0, len = strlen(input);
|
||||||
|
char *c = input;
|
||||||
|
while (i < len) {
|
||||||
|
bool isdigit = (c[i] >= '1' && c[i] <= '9');
|
||||||
|
bool isalpha = (c[i] >= 'a' && c[i] <= 'z') || (c[i] >= 'A' && c[i] <= 'Z');
|
||||||
|
if (!isdigit && !isalpha) return false;
|
||||||
|
if (c[i] == 'I' || c[i] == 'O' || c[i] == 'l') return false;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -256,8 +256,12 @@ bool client_authorize(YAAMP_CLIENT *client, json_value *json_params)
|
||||||
CommonUnlock(&g_db_mutex);
|
CommonUnlock(&g_db_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_bad_address = !is_base58(client->username);
|
||||||
// when auto exchange is disabled, only authorize good wallet address...
|
// when auto exchange is disabled, only authorize good wallet address...
|
||||||
if (!g_autoexchange && !client_validate_user_address(client)) {
|
if (!g_autoexchange && !client_validate_user_address(client))
|
||||||
|
is_bad_address = true;
|
||||||
|
|
||||||
|
if (is_bad_address) {
|
||||||
|
|
||||||
clientlog(client, "bad mining address %s", client->username);
|
clientlog(client, "bad mining address %s", client->username);
|
||||||
client_send_result(client, "false");
|
client_send_result(client, "false");
|
||||||
|
|
|
@ -74,6 +74,7 @@ string merkle_with_first(vector<string> steps, string f);
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool base58_decode(const char *input, char *output);
|
bool base58_decode(const char *input, char *output);
|
||||||
|
bool is_base58(char *input);
|
||||||
|
|
||||||
void base64_encode(char *base64, const char *normal);
|
void base64_encode(char *base64, const char *normal);
|
||||||
void base64_decode(char *normal, const char *base64);
|
void base64_decode(char *normal, const char *base64);
|
||||||
|
|
Loading…
Add table
Reference in a new issue