jl777 7 years ago
parent
commit
f82aec69aa
  1. 4
      iguana/exchanges/LP_nativeDEX.c
  2. 15
      iguana/segwit_addr.c

4
iguana/exchanges/LP_nativeDEX.c

@ -754,7 +754,9 @@ void bech32_tests()
}
if ( bech32_encode(rebuild,hrp,data,data_len) == 0 )
{
printf("bech32_encode fails: '%s'\n",test);
for (i=0; i<data_len; i++)
printf("%02x",data[i]);
printf(" bech32_encode fails: '%s' -> hrp.(%s) datalen.%d\n",test,hrp,(int32_t)data_len);
}
if ( my_strncasecmp(rebuild,test,92))
{

15
iguana/segwit_addr.c

@ -66,12 +66,22 @@ int bech32_encode(char *output, const char *hrp, const uint8_t *data, size_t dat
while (hrp[i] != 0) {
int ch = hrp[i];
if (ch < 33 || ch > 126) {
printf("bech32_encode illegal ch.%d\n",ch);
return 0;
}
if (ch >= 'A' && ch <= 'Z') return 0;
if (ch >= 'A' && ch <= 'Z')
{
printf("bech32_encode illegal uppercase.%c\n",ch);
return 0;
}
if ( (c= charset_rev[ch]) < 0 )
{
printf("bech32_encode illegal base32.%d\n",ch);
return 0;
}
//chk = bech32_polymod_step(chk) ^ (ch >> 5);
chk = PolyMod_step(chk,ch >> 5);
chk = PolyMod_step(chk,c);
++i;
}
if (i + 7 + data_len > 90) return 0;
@ -98,6 +108,7 @@ int bech32_encode(char *output, const char *hrp, const uint8_t *data, size_t dat
*(output++) = charset[(chk >> ((5 - i) * 5)) & 0x1f];
}
*output = 0;
printf("checksum %llx\n",(long long)chk);
return 1;
}

Loading…
Cancel
Save