jl777 7 years ago
parent
commit
105e114445
  1. 11
      iguana/exchanges/LP_privkey.c

11
iguana/exchanges/LP_privkey.c

@ -254,7 +254,7 @@ int32_t LP_wifstr_valid(char *symbol,char *wifstr)
bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguana_info *coin,char *passphrase,char *wifstr) bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguana_info *coin,char *passphrase,char *wifstr)
{ {
//static uint32_t counter; //static uint32_t counter;
bits256 privkey,userpub,zero,userpass,checkkey,tmpkey; char tmpstr[128]; cJSON *retjson; uint8_t tmptype,sig[128]; int32_t notarized; uint64_t nxtaddr; bits256 privkey,userpub,zero,userpass,checkkey,tmpkey; char str[65],str2[65],tmpstr[128]; cJSON *retjson; uint8_t tmptype,sig[128]; int32_t notarized,siglen; uint64_t nxtaddr;
if ( (wifstr == 0 || wifstr[0] == 0) && LP_wifstr_valid(coin->symbol,passphrase) > 0 ) if ( (wifstr == 0 || wifstr[0] == 0) && LP_wifstr_valid(coin->symbol,passphrase) > 0 )
{ {
wifstr = passphrase; wifstr = passphrase;
@ -294,9 +294,14 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan
RS_encode(G.LP_NXTaddr,nxtaddr); RS_encode(G.LP_NXTaddr,nxtaddr);
} }
OS_randombytes(tmpkey.bytes,sizeof(tmpkey)); OS_randombytes(tmpkey.bytes,sizeof(tmpkey));
if ( bits256_nonz(privkey) == 0 || bitcoin_sign(ctx,coin->symbol,sig,tmpkey,privkey,0) <= 0 ) if ( bits256_nonz(privkey) == 0 || (siglen= bitcoin_sign(ctx,coin->symbol,sig,tmpkey,privkey,0)) <= 0 )
{ {
char str[65]; printf("illegal privkey %s\n",bits256_str(str,privkey)); printf("illegal privkey %s\n",bits256_str(str,privkey));
exit(0);
}
if ( bitcoin_verify(ctx,sig,siglen-1,tmpkey,coin->pubkey33,33) != 0 )
{
printf("signature for %s by %s didnt verify\n",bits256_str(str,tmpkey),bits256_str(str2,privkey));
exit(0); exit(0);
} }
bitcoin_priv2pub(ctx,coin->symbol,coin->pubkey33,coin->smartaddr,privkey,coin->taddr,coin->pubtype); bitcoin_priv2pub(ctx,coin->symbol,coin->pubkey33,coin->smartaddr,privkey,coin->taddr,coin->pubtype);

Loading…
Cancel
Save