Browse Source

Test

etomic
jl777 7 years ago
parent
commit
ca44b554c5
  1. 31
      iguana/exchanges/LP_bitcoin.c
  2. 1
      iguana/exchanges/LP_include.h
  3. 17
      iguana/exchanges/LP_secp.c
  4. 1
      iguana/mini-gmp.c

31
iguana/exchanges/LP_bitcoin.c

@ -2113,7 +2113,36 @@ int32_t bitcoin_addr2rmd160(char *symbol,uint8_t taddr,uint8_t *addrtypep,uint8_
char *bitcoin_address(char *symbol,char *coinaddr,uint8_t taddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len)
{
int32_t offset,i,len5; char prefixed[64]; uint8_t data[64],data5[64]; bits256 hash;
static void *ctx;
int32_t offset,i,len5; char prefixed[64]; uint8_t data[64],data5[64],bigpubkey[65]; bits256 hash; struct iguana_info *coin;
if ( (coin= LP_coinfind(symbol)) != 0 && coin->etomic[0] != 0 )
{
if ( len == 20 )
{
strcpy(coinaddr,"0x");
init_hexbytes_noT(coinaddr+2,pubkey_or_rmd160,20);
return(coinaddr);
}
else if ( len == 33 || len == 65 )
{
strcpy(coinaddr,"0x");
if ( len == 33 )
{
if ( ctx == 0 )
ctx = bitcoin_ctx();
bitcoin_expandcompressed(ctx,bigpubkey,pubkey_or_rmd160);
LP_etomic_pub2addr(coinaddr+2,bigpubkey+1);
for (i=0; i<33; i++)
printf("%02x",pubkey_or_rmd160[i]);
printf(" compressed -> ");
for (i=0; i<65; i++)
printf("%02x",bigpubkey[i]);
printf(" -> %s\n",coinaddr);
}
else LP_etomic_pub2addr(coinaddr+2,pubkey_or_rmd160+1);
return(coinaddr);
}
}
coinaddr[0] = 0;
offset = 1 + (taddr != 0);
if ( len != 20 )

1
iguana/exchanges/LP_include.h

@ -546,6 +546,7 @@ void LP_postutxos(char *symbol,char *coinaddr);
int32_t LP_listunspent_both(char *symbol,char *coinaddr,int32_t fullflag);
uint16_t LP_randpeer(char *destip);
void LP_tradebot_pauseall();
int32_t LP_etomic_pub2addr(char *coinaddr,uint8_t pub64[64]);
void LP_portfolio_reset();
struct LP_pubkey_info *LP_pubkeyadd(bits256 pubkey);
uint32_t LP_atomic_locktime(char *base,char *rel);

17
iguana/exchanges/LP_secp.c

@ -191,3 +191,20 @@ int32_t bitcoin_verify(void *ctx,uint8_t *sig,int32_t siglen,bits256 txhash2,uin
}
return(retval);
}
int32_t bitcoin_expandcompressed(void *ctx,uint8_t *bigpubkey,uint8_t *pub33)
{
int32_t retval = -1; secp256k1_pubkey PUB; size_t plen = 65;
SECP_ENSURE_CTX
{
if ( secp256k1_ec_pubkey_parse(ctx,&PUB,pub33,33) != 0 )
{
secp256k1_ec_pubkey_serialize(ctx,bigpubkey,&plen,&PUB,SECP256K1_EC_UNCOMPRESSED);
retval = 0;
}
ENDSECP_ENSURE_CTX
}
return(retval);
}

1
iguana/mini-gmp.c

@ -4404,7 +4404,6 @@ int32_t bitcoin_base58decode(uint8_t *data,char *coinaddr)
{
int32_t zeroval();
printf("bitcoin_base58decode error: p %02x != 0x00\n",*p);
printf("div0 %d\n",1/zeroval());
mpz_clear(bn), mpz_clear(bn58);
return(-1);
}

Loading…
Cancel
Save