From f08b7700ed1f6ec7b8804fb52d12140e5e2d6abd Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 6 Feb 2018 20:43:31 +0200 Subject: [PATCH] Test --- etomic_build/run | 1 + iguana/exchanges/LP_etomic.c | 43 +++++++++++++++++++++++++++++++++++ iguana/exchanges/LP_privkey.c | 12 ++++++++++ 3 files changed, 56 insertions(+) diff --git a/etomic_build/run b/etomic_build/run index 346795148..b757bb993 100755 --- a/etomic_build/run +++ b/etomic_build/run @@ -1,4 +1,5 @@ #!/bin/bash source passphrase source coins +./stop $1 iguana/exchanges/marketmaker "{\"netid\":9999,\"gui\":\"nogui\", \"profitmargin\":0.01, \"userhome\":\"/${HOME#"/"}\", \"passphrase\":\"$passphrase\", \"coins\":$coins}" & diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index 56d8dbbe0..fbdc99fb8 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -58,3 +58,46 @@ char *LP_etomicalice_start(struct basilisk_swap *swap) } return(0); } + +int32_t LP_etomic_priv2addr(char *coinaddr,bits256 privkey) +{ + char str[65],*addrstr; + bits256_str(str,privkey); + if ( (addrstr= privKey2Addr(str)) != 0 ) + { + strcpy(coinaddr,addrstr); + free(addrstr); + return(0); + } + return(-1); +} + +int32_t LP_etomic_priv2pub(uint8_t *pub33,bits256 privkey) +{ + char *pubstr,str[65]; int32_t retval = -1; + bits256_str(str,privkey); + if ( (pubstr= getPubKeyFromPriv(str)) != 0 ) + { + if ( strlen(pubstr) == 35 && pubstr[0] == '0' && pubstr[1] == 'x' ) + { + decode_hex(pub33,33,pubstr+2); + retval = 33; + } + free(pubstr); + } + return(retval); +} + +int32_t LP_etomic_pub2addr(char *coinaddr,uint8_t pub33[33]) +{ + char pubkeystr[72],*addrstr; + strcpy(pubkeystr,"0x"); + init_hexbytes_noT(pubkeystr+2,pub33,33); + if ( (addrstr= pubKey2Addr(pubkeystr+2)) != 0 ) + { + strcpy(coinaddr,addrstr); + free(addrstr); + return((int32_t)strlen(coinaddr)); + } + return(-1); +} diff --git a/iguana/exchanges/LP_privkey.c b/iguana/exchanges/LP_privkey.c index a2b9494a5..17cd22723 100644 --- a/iguana/exchanges/LP_privkey.c +++ b/iguana/exchanges/LP_privkey.c @@ -294,6 +294,18 @@ bits256 LP_privkeycalc(void *ctx,uint8_t *pubkey33,bits256 *pubkeyp,struct iguan RS_encode(G.LP_NXTaddr,nxtaddr); } bitcoin_priv2pub(ctx,coin->symbol,coin->pubkey33,coin->smartaddr,privkey,coin->taddr,coin->pubtype); + { + uint8_t check33[33]; char checkaddr[64]; + if ( LP_etomic_priv2pub(check33,privkey) > 0 ) + { + if ( memcmp(check33,coin->pubkey33) == 0 ) + { + printf("pubkey33 matches!\n"); + if ( LP_etomic_pub2addr(checkaddr,check33) > 0 ) + printf("addr is (%s)\n",checkaddr); + } else printf("pubkey 33 mismatch\n"); + } + } if ( coin->counter == 0 ) { coin->counter++;