Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -6,56 +6,56 @@ const char *coin_err;
|
|||
#define bail(s) { coin_err = s; return 0; }
|
||||
|
||||
int unbase58(const char *s, unsigned char *out) {
|
||||
static const char *tmpl = "123456789"
|
||||
"ABCDEFGHJKLMNPQRSTUVWXYZ"
|
||||
"abcdefghijkmnopqrstuvwxyz";
|
||||
int i, j, c;
|
||||
const char *p;
|
||||
static const char *tmpl = "123456789"
|
||||
"ABCDEFGHJKLMNPQRSTUVWXYZ"
|
||||
"abcdefghijkmnopqrstuvwxyz";
|
||||
int i, j, c;
|
||||
const char *p;
|
||||
|
||||
memset(out, 0, 25);
|
||||
for (i = 0; s[i]; i++) {
|
||||
if (!(p = strchr(tmpl, s[i])))
|
||||
bail("bad char");
|
||||
memset(out, 0, 25);
|
||||
for (i = 0; s[i]; i++) {
|
||||
if (!(p = strchr(tmpl, s[i])))
|
||||
bail("bad char");
|
||||
|
||||
c = p - tmpl;
|
||||
for (j = 25; j--; ) {
|
||||
c += 58 * out[j];
|
||||
out[j] = c % 256;
|
||||
c /= 256;
|
||||
}
|
||||
c = p - tmpl;
|
||||
for (j = 25; j--; ) {
|
||||
c += 58 * out[j];
|
||||
out[j] = c % 256;
|
||||
c /= 256;
|
||||
}
|
||||
|
||||
if (c) bail("address too long");
|
||||
}
|
||||
if (c) bail("address too long");
|
||||
}
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int valid(const char *s) {
|
||||
unsigned char dec[32], d1[SHA256_DIGEST_LENGTH], d2[SHA256_DIGEST_LENGTH];
|
||||
unsigned char dec[32], d1[SHA256_DIGEST_LENGTH], d2[SHA256_DIGEST_LENGTH];
|
||||
|
||||
coin_err = "";
|
||||
if (!unbase58(s, dec)) return 0;
|
||||
coin_err = "";
|
||||
if (!unbase58(s, dec)) return 0;
|
||||
|
||||
SHA256(SHA256(dec, 21, d1), SHA256_DIGEST_LENGTH, d2);
|
||||
SHA256(SHA256(dec, 21, d1), SHA256_DIGEST_LENGTH, d2);
|
||||
|
||||
if (memcmp(dec + 21, d2, 4))
|
||||
bail("bad digest");
|
||||
if (memcmp(dec + 21, d2, 4))
|
||||
bail("bad digest");
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main (void) {
|
||||
const char *s[] = {
|
||||
"1Q1pE5vPGEEMqRcVRMbtBK842Y6Pzo6nK9",
|
||||
"1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i",
|
||||
"1Q1pE5vPGEEMqRcVRMbtBK842Y6Pzo6nJ9",
|
||||
"1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62I",
|
||||
0 };
|
||||
int i;
|
||||
for (i = 0; s[i]; i++) {
|
||||
int status = valid(s[i]);
|
||||
printf("%s: %s\n", s[i], status ? "Ok" : coin_err);
|
||||
}
|
||||
const char *s[] = {
|
||||
"1Q1pE5vPGEEMqRcVRMbtBK842Y6Pzo6nK9",
|
||||
"1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i",
|
||||
"1Q1pE5vPGEEMqRcVRMbtBK842Y6Pzo6nJ9",
|
||||
"1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62I",
|
||||
0 };
|
||||
int i;
|
||||
for (i = 0; s[i]; i++) {
|
||||
int status = valid(s[i]);
|
||||
printf("%s: %s\n", s[i], status ? "Ok" : coin_err);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue