Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
c20eacccb6
  1. 0
      deprecated/iguana_pubkeys.c
  2. 8
      iguana/SuperNET.c
  3. 11
      iguana/SuperNET_keys.c
  4. 246
      iguana/exchanges/bitcoin.c
  5. 2
      iguana/iguana.sources
  6. 3
      iguana/iguana777.h
  7. 6
      iguana/iguana_bundles.c
  8. 4
      iguana/iguana_ramchain.c
  9. 18
      iguana/iguana_wallet.c
  10. 8
      iguana/peggy_tx.c

0
iguana/iguana_pubkeys.c → deprecated/iguana_pubkeys.c

8
iguana/SuperNET.c

@ -898,7 +898,7 @@ cJSON *SuperNET_rosettajson(bits256 privkey,int32_t showprivs)
RS_encode(str,nxt64bits);
jaddstr(retjson,"RS",str);
jadd64bits(retjson,"NXT",nxt64bits);
btc_priv2pub(pub,privkey.bytes);
bitcoin_pubkey33(pub,privkey);
init_hexbytes_noT(str,pub,33);
jaddstr(retjson,"btcpubkey",str);
calc_OP_HASH160(str2,rmd160,str);
@ -908,7 +908,7 @@ cJSON *SuperNET_rosettajson(bits256 privkey,int32_t showprivs)
jaddstr(retjson,"BTC",addr);
if ( showprivs != 0 )
{
btc_priv2wif(wifbuf,privkey.bytes,128);
bitcoin_priv2wif(wifbuf,privkey,128);
jaddstr(retjson,"BTCwif",wifbuf);
}
}
@ -917,7 +917,7 @@ cJSON *SuperNET_rosettajson(bits256 privkey,int32_t showprivs)
jaddstr(retjson,"BTCD",addr);
if ( showprivs != 0 )
{
btc_priv2wif(wifbuf,privkey.bytes,188);
bitcoin_priv2wif(wifbuf,privkey,188);
jaddstr(retjson,"BTCDwif",wifbuf);
}
}
@ -1257,7 +1257,7 @@ THREE_STRINGS(SuperNET,survey,category,subcategory,message)
STRING_ARG(SuperNET,wif2priv,wif)
{
bits256 privkey; char str[65]; uint8_t privkeytype; cJSON *retjson = cJSON_CreateObject();
if ( btc_wif2priv(&privkeytype,privkey.bytes,wif) == sizeof(privkey) )
if ( bitcoin_wif2priv(&privkeytype,&privkey,wif) == sizeof(privkey) )
{
jaddstr(retjson,"result","success");
jaddstr(retjson,"privkey",bits256_str(str,privkey));

11
iguana/SuperNET_keys.c

@ -255,7 +255,7 @@ int32_t _SuperNET_encryptjson(char *destfname,char *passphrase,int32_t passsize,
void SuperNET_setkeys(struct supernet_info *myinfo,void *pass,int32_t passlen,int32_t dosha256)
{
char pubkeystr[128]; uint8_t pubkey33[33]; bits256 hash;
uint8_t pubkey33[33]; bits256 hash;
if ( dosha256 != 0 )
{
memcpy(myinfo->secret,pass,passlen+1);
@ -269,10 +269,11 @@ void SuperNET_setkeys(struct supernet_info *myinfo,void *pass,int32_t passlen,in
myinfo->myaddr.nxt64bits = hash.txid;
}
RS_encode(myinfo->myaddr.NXTADDR,myinfo->myaddr.nxt64bits);
btc_priv2pub(pubkey33,myinfo->persistent_priv.bytes);
init_hexbytes_noT(pubkeystr,pubkey33,33);
btc_coinaddr(myinfo->myaddr.BTC,0,pubkeystr);
btc_coinaddr(myinfo->myaddr.BTCD,60,pubkeystr);
bitcoin_pubkey33(pubkey33,myinfo->persistent_priv);
//btc_priv2pub(pubkey33,myinfo->persistent_priv.bytes);
//init_hexbytes_noT(pubkeystr,pubkey33,33);
bitcoin_address(myinfo->myaddr.BTC,0,pubkey33,33);
bitcoin_address(myinfo->myaddr.BTCD,60,pubkey33,33);
}
void SuperNET_parsemyinfo(struct supernet_info *myinfo,cJSON *msgjson)

246
iguana/exchanges/bitcoin.c

@ -146,80 +146,6 @@ out:
return(be_sz);
}
int32_t bitcoin_addr2rmd160(uint8_t *addrtypep,uint8_t rmd160[20],char *coinaddr)
{
bits256 hash; uint8_t *buf,_buf[25]; int32_t len;
memset(rmd160,0,20);
*addrtypep = 0;
buf = _buf;
if ( (len= bitcoin_base58decode(buf,coinaddr)) >= 4 )
{
// validate with trailing hash, then remove hash
hash = bits256_doublesha256(0,buf,len - 4);
*addrtypep = *buf;
memcpy(rmd160,buf+1,20);
if ( (buf[len - 4]&0xff) == hash.bytes[31] && (buf[len - 3]&0xff) == hash.bytes[30] &&(buf[len - 2]&0xff) == hash.bytes[29] &&(buf[len - 1]&0xff) == hash.bytes[28] )
{
//printf("coinaddr.(%s) valid checksum\n",coinaddr);
return(20);
}
else
{
char hexaddr[64];
btc_convaddr(hexaddr,coinaddr);
//for (i=0; i<len; i++)
// printf("%02x ",buf[i]);
char str[65]; printf("\nhex.(%s) checkhash.(%s) len.%d mismatch %02x %02x %02x %02x vs %02x %02x %02x %02x (%s)\n",hexaddr,coinaddr,len,buf[len - 4]&0xff,buf[len - 3]&0xff,buf[len - 2]&0xff,buf[len - 1]&0xff,hash.bytes[31],hash.bytes[30],hash.bytes[29],hash.bytes[28],bits256_str(str,hash));
}
}
return(0);
}
void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen)
{
bits256 hash;
vcalc_sha256(0,hash.bytes,data,datalen);
calc_rmd160(0,rmd160,hash.bytes,sizeof(hash));
}
char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey,int32_t len)
{
int32_t i; uint8_t data[25]; bits256 hash;// char checkaddr[65];
if ( len != 20 )
calc_rmd160_sha256(data+1,pubkey,len);
else memcpy(data+1,pubkey,20);
//btc_convrmd160(checkaddr,addrtype,data+1);
//for (i=0; i<20; i++)
// printf("%02x",data[i+1]);
//printf(" RMD160 len.%d\n",len);
data[0] = addrtype;
hash = bits256_doublesha256(0,data,21);
for (i=0; i<4; i++)
data[21+i] = hash.bytes[31-i];
if ( (coinaddr= bitcoin_base58encode(coinaddr,data,25)) != 0 )
{
//uint8_t checktype,rmd160[20];
//bitcoin_addr2rmd160(&checktype,rmd160,coinaddr);
//if ( strcmp(checkaddr,coinaddr) != 0 )
// printf("checkaddr.(%s) vs coinaddr.(%s) %02x vs [%02x] memcmp.%d\n",checkaddr,coinaddr,addrtype,checktype,memcmp(rmd160,data+1,20));
}
return(coinaddr);
}
int32_t bitcoin_validaddress(struct iguana_info *coin,char *coinaddr)
{
uint8_t rmd160[20],addrtype; char checkaddr[128];
if ( coin == 0 || coinaddr == 0 || coinaddr[0] == 0 )
return(-1);
else if ( bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr) < 0 )
return(-1);
else if ( addrtype != coin->chain->pubtype && addrtype != coin->chain->p2shtype )
return(-1);
else if ( bitcoin_address(checkaddr,addrtype,rmd160,sizeof(rmd160)) != checkaddr || strcmp(checkaddr,coinaddr) != 0 )
return(-1);
return(0);
}
EC_KEY *bitcoin_privkeyset(uint8_t *oddevenp,bits256 *pubkeyp,bits256 privkey)
{
BIGNUM *bn; BN_CTX *ctx = NULL; uint8_t *ptr,tmp[33]; EC_POINT *pub_key = NULL; const EC_GROUP *group;
@ -265,67 +191,6 @@ bits256 bitcoin_pubkey33(uint8_t *data,bits256 privkey)
return(pubkey);
}
int32_t bitcoin_priv2wif(char *wifstr,bits256 privkey,uint8_t addrtype)
{
uint8_t data[128]; bits256 hash; int32_t i;
memcpy(data,privkey.bytes,sizeof(privkey));
data[32] = 1;
data[0] = addrtype;
hash = bits256_doublesha256(0,data,33);
for (i=0; i<4; i++)
data[33+i] = hash.bytes[31-i];
if ( bitcoin_base58encode(wifstr,data,33+4) == 0 )
return(-1);
char str[65]; printf("(%s) -> wif.(%s) addrtype.%02x\n",bits256_str(str,privkey),wifstr,addrtype);
return(0);
}
/*int32_t bitcoin_wif2priv(uint8_t *addrtypep,uint8_t privkey[32],char *wifstr)
{
int32_t len = -1; bits256 hash; uint8_t buf[64];
if ( (len= bitcoin_base58decode(buf,wifstr)) >= 4 )
{
// validate with trailing hash, then remove hash
hash = bits256_doublesha256(0,buf,len - 4);
*addrtypep = *buf;
memcpy(rmd160,buf+1,20);
if ( (buf[len - 4]&0xff) == hash.bytes[31] && (buf[len - 3]&0xff) == hash.bytes[30] &&(buf[len - 2]&0xff) == hash.bytes[29] &&(buf[len - 1]&0xff) == hash.bytes[28] )
{
//printf("coinaddr.(%s) valid checksum\n",coinaddr);
return(20);
}
}
if ( (cstr= base58_decode_check(addrtypep,(const char *)wifstr)) != 0 )
{
init_hexbytes_noT((void *)privkey,(void *)cstr->str,cstr->len);
if ( cstr->str[cstr->len-1] == 0x01 )
cstr->len--;
memcpy(privkey,cstr->str,cstr->len);
len = (int32_t)cstr->len;
char tmp[138];
bitcoin_priv2wif(tmp,privkey,*addrtypep);
printf("addrtype.%02x wifstr.(%llx) len.%d\n",*addrtypep,*(long long *)privkey,len);
cstr_free(cstr,true);
}
return(len);
}*/
struct iguana_waddress *iguana_waddresscalc(uint8_t pubtype,uint8_t wiftype,struct iguana_waddress *addr,bits256 privkey)
{
memset(addr,0,sizeof(*addr));
addr->privkey = privkey;
bitcoin_pubkey33(addr->pubkey,addr->privkey);
calc_rmd160_sha256(addr->rmd160,addr->pubkey,33);
bitcoin_address(addr->coinaddr,pubtype,addr->rmd160,sizeof(addr->rmd160));
if ( bitcoin_priv2wif(addr->wifstr,addr->privkey,wiftype) == 0 )
{
addr->wiftype = wiftype;
addr->type = pubtype;
return(addr);
}
return(0);
}
int32_t bitcoin_sign(uint8_t *sig,int32_t maxlen,uint8_t *data,int32_t datalen,bits256 privkey)
{
uint32_t siglen; EC_KEY *KEY; uint8_t oddeven; bits256 pubkey; int32_t retval = -1;
@ -380,6 +245,113 @@ int32_t bitcoin_verify(uint8_t *sig,int32_t siglen,uint8_t *data,int32_t datalen
return(retval);
}
int32_t bitcoin_addr2rmd160(uint8_t *addrtypep,uint8_t rmd160[20],char *coinaddr)
{
bits256 hash; uint8_t *buf,_buf[25]; int32_t len;
memset(rmd160,0,20);
*addrtypep = 0;
buf = _buf;
if ( (len= bitcoin_base58decode(buf,coinaddr)) >= 4 )
{
// validate with trailing hash, then remove hash
hash = bits256_doublesha256(0,buf,len - 4);
*addrtypep = *buf;
memcpy(rmd160,buf+1,20);
if ( (buf[len - 4]&0xff) == hash.bytes[31] && (buf[len - 3]&0xff) == hash.bytes[30] &&(buf[len - 2]&0xff) == hash.bytes[29] &&(buf[len - 1]&0xff) == hash.bytes[28] )
{
//printf("coinaddr.(%s) valid checksum\n",coinaddr);
return(20);
}
else
{
//char hexaddr[64];
//btc_convaddr(hexaddr,coinaddr);
//for (i=0; i<len; i++)
// printf("%02x ",buf[i]);
char str[65]; printf("\nhex checkhash.(%s) len.%d mismatch %02x %02x %02x %02x vs %02x %02x %02x %02x (%s)\n",coinaddr,len,buf[len - 4]&0xff,buf[len - 3]&0xff,buf[len - 2]&0xff,buf[len - 1]&0xff,hash.bytes[31],hash.bytes[30],hash.bytes[29],hash.bytes[28],bits256_str(str,hash));
}
}
return(0);
}
void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen)
{
bits256 hash;
vcalc_sha256(0,hash.bytes,data,datalen);
calc_rmd160(0,rmd160,hash.bytes,sizeof(hash));
}
char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey,int32_t len)
{
int32_t i; uint8_t data[25]; bits256 hash;// char checkaddr[65];
if ( len != 20 )
calc_rmd160_sha256(data+1,pubkey,len);
else memcpy(data+1,pubkey,20);
//btc_convrmd160(checkaddr,addrtype,data+1);
//for (i=0; i<20; i++)
// printf("%02x",data[i+1]);
//printf(" RMD160 len.%d\n",len);
data[0] = addrtype;
hash = bits256_doublesha256(0,data,21);
for (i=0; i<4; i++)
data[21+i] = hash.bytes[31-i];
if ( (coinaddr= bitcoin_base58encode(coinaddr,data,25)) != 0 )
{
//uint8_t checktype,rmd160[20];
//bitcoin_addr2rmd160(&checktype,rmd160,coinaddr);
//if ( strcmp(checkaddr,coinaddr) != 0 )
// printf("checkaddr.(%s) vs coinaddr.(%s) %02x vs [%02x] memcmp.%d\n",checkaddr,coinaddr,addrtype,checktype,memcmp(rmd160,data+1,20));
}
return(coinaddr);
}
int32_t bitcoin_validaddress(struct iguana_info *coin,char *coinaddr)
{
uint8_t rmd160[20],addrtype; char checkaddr[128];
if ( coin == 0 || coinaddr == 0 || coinaddr[0] == 0 )
return(-1);
else if ( bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr) < 0 )
return(-1);
else if ( addrtype != coin->chain->pubtype && addrtype != coin->chain->p2shtype )
return(-1);
else if ( bitcoin_address(checkaddr,addrtype,rmd160,sizeof(rmd160)) != checkaddr || strcmp(checkaddr,coinaddr) != 0 )
return(-1);
return(0);
}
int32_t bitcoin_priv2wif(char *wifstr,bits256 privkey,uint8_t addrtype)
{
uint8_t data[128]; bits256 hash; int32_t i;
memcpy(data,privkey.bytes,sizeof(privkey));
data[32] = 1;
data[0] = addrtype;
hash = bits256_doublesha256(0,data,33);
for (i=0; i<4; i++)
data[33+i] = hash.bytes[31-i];
if ( bitcoin_base58encode(wifstr,data,33+4) == 0 )
return(-1);
char str[65]; printf("(%s) -> wif.(%s) addrtype.%02x\n",bits256_str(str,privkey),wifstr,addrtype);
return((int32_t)strlen(wifstr));
}
int32_t bitcoin_wif2priv(uint8_t *addrtypep,bits256 *privkeyp,char *wifstr)
{
int32_t len = -1; bits256 hash; uint8_t buf[64];
if ( (len= bitcoin_base58decode(buf,wifstr)) >= 4 )
{
// validate with trailing hash, then remove hash
hash = bits256_doublesha256(0,buf,len - 4);
*addrtypep = *buf;
memcpy(privkeyp,buf+1,32);
if ( (buf[len - 4]&0xff) == hash.bytes[31] && (buf[len - 3]&0xff) == hash.bytes[30] &&(buf[len - 2]&0xff) == hash.bytes[29] &&(buf[len - 1]&0xff) == hash.bytes[28] )
{
//printf("coinaddr.(%s) valid checksum\n",coinaddr);
return(32);
}
}
return(-1);
}
int32_t iguana_parsevoutobj(struct iguana_info *coin,uint8_t *serialized,int32_t maxsize,struct iguana_msgvout *vout,cJSON *voutobj)
{
int32_t len = 0; cJSON *skey; char *hexstr;
@ -1286,7 +1258,7 @@ uint64_t bitcoin_parseunspent(struct iguana_info *coin,struct bitcoin_unspent *u
wifstr = bitcoind_RPC(0,coin->symbol,coin->chain->serverport,coin->chain->userpass,"dumpprivkey",args);
if ( wifstr != 0 )
{
btc_wif2priv(&addrtype,unspent->privkeys[0].bytes,wifstr);
bitcoin_wif2priv(&addrtype,&unspent->privkeys[0],wifstr);
//printf("wifstr.(%s) -> %s\n",wifstr,bits256_str(str,unspent->privkeys[0]));
free(wifstr);
} else fprintf(stderr,"error (%s) cant find privkey\n",coinaddr);
@ -1576,7 +1548,7 @@ char *_setVsigner(struct iguana_info *coin,struct vin_info *V,int32_t ind,char *
{
uint8_t addrtype;
decode_hex(V->signers[ind].pubkey,(int32_t)strlen(pubstr)/2,pubstr);
btc_wif2priv(&addrtype,V->signers[ind].privkey.bytes,wifstr);
bitcoin_wif2priv(&addrtype,&V->signers[ind].privkey,wifstr);
if ( addrtype != coin->chain->pubtype )
return(clonestr("{\"error\":\"invalid wifA\"}"));
else return(0);

2
iguana/iguana.sources

@ -2,4 +2,4 @@
#SOURCES := iguana_rpc.c SuperNET.c SuperNET_keys.c SuperNET_category.c SuperNET_hexmsg.c iguana_exchanges.c iguana_tradebots.c iguana_instantdex.c pangea_api.c pangea_bets.c cards777.c pangea_summary.c pangea_json.c pangea_hand.c poker.c ramchain_api.c iguana_tx.c iguana_wallet.c iguana_scripts.c iguana_pubkeys.c iguana_unspents.c iguana_recv.c iguana_bundles.c iguana_msg.c iguana777.c iguana_chains.c iguana_peers.c iguana_accept.c iguana_bitmap.c iguana_init.c iguana_ramchain.c iguana_blocks.c iguana_json.c main.c peggy.c peggy_consensus.c peggy_price.c peggy_update.c peggy_accts.c peggy_tx.c peggy_txind.c peggy_ramkv.c peggy_serdes.c
SOURCES := SuperNET.c iguana_bundles.c iguana_pubkeys.c main.c peggy_price.c SuperNET_category.c iguana_chains.c iguana_ramchain.c pangea_api.c peggy_ramkv.c SuperNET_hexmsg.c iguana_exchanges.c iguana_recv.c pangea_bets.c peggy_serdes.c SuperNET_keys.c iguana_html.c iguana_rpc.c pangea_hand.c peggy_tx.c cards777.c iguana_init.c iguana_scripts.c pangea_json.c peggy_txind.c iguana777.c iguana_instantdex.c iguana_tradebots.c pangea_summary.c peggy_update.c iguana_accept.c iguana_json.c iguana_tx.c peggy.c poker.c iguana_bitmap.c iguana_msg.c iguana_unspents.c peggy_accts.c ramchain_api.c iguana_blocks.c iguana_peers.c iguana_wallet.c peggy_consensus.c databases/iguana_DB.c
SOURCES := SuperNET.c iguana_bundles.c main.c peggy_price.c SuperNET_category.c iguana_chains.c iguana_ramchain.c pangea_api.c peggy_ramkv.c SuperNET_hexmsg.c iguana_exchanges.c iguana_recv.c pangea_bets.c peggy_serdes.c SuperNET_keys.c iguana_html.c iguana_rpc.c pangea_hand.c peggy_tx.c cards777.c iguana_init.c iguana_scripts.c pangea_json.c peggy_txind.c iguana777.c iguana_instantdex.c iguana_tradebots.c pangea_summary.c peggy_update.c iguana_accept.c iguana_json.c iguana_tx.c peggy.c poker.c iguana_bitmap.c iguana_msg.c iguana_unspents.c peggy_accts.c ramchain_api.c iguana_blocks.c iguana_peers.c iguana_wallet.c peggy_consensus.c databases/iguana_DB.c

3
iguana/iguana777.h

@ -795,7 +795,8 @@ void iguana_iAkill(struct iguana_info *coin,struct iguana_peer *addr,int32_t mar
cJSON *SuperNET_bits2json(uint8_t *serialized,int32_t datalen);
int32_t SuperNET_sendmsg(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,bits256 destpub,bits256 mypriv,bits256 mypub,uint8_t *msg,int32_t len,uint8_t *data,int32_t delaymillis);
int32_t category_peer(struct supernet_info *myinfo,struct iguana_peer *addr,bits256 category,bits256 subhash);
int32_t btc_wif2priv(uint8_t *addrtypep,uint8_t privkey[32],char *wifstr);
int32_t bitcoin_wif2priv(uint8_t *addrtypep,bits256 *privkeyp,char *wifstr);
int32_t bitcoin_priv2wif(char *wifstr,bits256 privkey,uint8_t addrtype);
bits256 iguana_chaingenesis(bits256 genesishash,char *genesisblock,char *hashalgostr,int32_t version,uint32_t timestamp,uint32_t bits,uint32_t nonce,bits256 merkle_root);
int32_t iguana_send_ConnectTo(struct iguana_info *coin,struct iguana_peer *addr);
cJSON *iguana_txjson(struct iguana_info *coin,struct iguana_txid *tx,int32_t height,struct vin_info *V);

6
iguana/iguana_bundles.c

@ -419,13 +419,13 @@ struct iguana_txid *iguana_bundletx(struct iguana_info *coin,struct iguana_bundl
void iguana_bundlepurgefiles(struct iguana_info *coin,struct iguana_bundle *bp)
{
static const bits256 zero;
char fname[1024]; FILE *fp; int32_t hdrsi,m,j; uint32_t ipbits;
char fname[1024]; FILE *fp; int32_t hdrsi,m = 0; uint32_t ipbits = 0;
if ( bp->purgetime == 0 && time(NULL) > bp->emitfinish+30 )
{
//printf("purged hdrsi.[%d] lag.%ld\n",bp->hdrsi,time(NULL) - bp->emitfinish);
for (j=m=0; j<sizeof(coin->peers.active)/sizeof(*coin->peers.active); j++)
//for (j=m=0; j<sizeof(coin->peers.active)/sizeof(*coin->peers.active); j++)
{
if ( (ipbits= (uint32_t)coin->peers.active[j].ipbits) != 0 )
//if ( (ipbits= (uint32_t)coin->peers.active[j].ipbits) != 0 )
{
if ( iguana_peerfname(coin,&hdrsi,GLOBAL_TMPDIR,fname,ipbits,bp->hashes[0],zero,1,1) >= 0 )
{

4
iguana/iguana_ramchain.c

@ -513,8 +513,8 @@ uint32_t iguana_ramchain_addspend(struct iguana_info *coin,RAMCHAIN_FUNC,bits256
//for (i=0; i<vinscriptlen; i++)
// printf("%02x",vinscript[i]);
//printf(" SAVE vinscript len.%d\n",vinscriptlen);
if ( bits256_cmp(prev_hash,bits256_conv("d9151f0471a3982778c8acc623becc24bc35483bdecb07611d036209da541cde")) == 0 )
printf("found spend d9151... txidind.%u (first.%u + vout.%d) u%u [%d] s%u\n",txidind,T[txidind].firstvout,prev_vout,unspentind,hdrsi,spendind);
//if ( bits256_cmp(prev_hash,bits256_conv("d9151f0471a3982778c8acc623becc24bc35483bdecb07611d036209da541cde")) == 0 )
// printf("found spend d9151... txidind.%u (first.%u + vout.%d) u%u [%d] s%u\n",txidind,T[txidind].firstvout,prev_vout,unspentind,hdrsi,spendind);
s->sequenceid = sequence;
s->external = external, s->spendtxidind = txidind,
s->prevout = prev_vout;

18
iguana/iguana_wallet.c

@ -15,6 +15,22 @@
#include "iguana777.h"
struct iguana_waddress *iguana_waddresscalc(uint8_t pubtype,uint8_t wiftype,struct iguana_waddress *addr,bits256 privkey)
{
memset(addr,0,sizeof(*addr));
addr->privkey = privkey;
bitcoin_pubkey33(addr->pubkey,addr->privkey);
calc_rmd160_sha256(addr->rmd160,addr->pubkey,33);
bitcoin_address(addr->coinaddr,pubtype,addr->rmd160,sizeof(addr->rmd160));
if ( bitcoin_priv2wif(addr->wifstr,addr->privkey,wiftype) > 0 )
{
addr->wiftype = wiftype;
addr->type = pubtype;
return(addr);
}
return(0);
}
void iguana_walletlock(struct supernet_info *myinfo)
{
memset(&myinfo->persistent_priv,0,sizeof(myinfo->persistent_priv));
@ -273,7 +289,7 @@ bits256 iguana_str2priv(struct iguana_info *coin,char *str)
n = (int32_t)strlen(str) >> 1;
if ( n == sizeof(bits256) && is_hexstr(str,sizeof(bits256)) > 0 )
decode_hex(privkey.bytes,sizeof(privkey),str);
else if ( btc_wif2priv(&addrtype,privkey.bytes,str) != sizeof(bits256) )
else if ( bitcoin_wif2priv(&addrtype,&privkey,str) != sizeof(bits256) )
{
if ( (wacct= iguana_waddressfind(coin,&ind,str)) != 0 )
privkey = wacct->waddrs[ind].privkey;

8
iguana/peggy_tx.c

@ -301,13 +301,9 @@ int32_t peggy_univ2addr(char *coinaddr,struct peggy_univaddr *ua)
int32_t peggy_addr2univ(struct peggy_univaddr *ua,char *coinaddr,char *coin)
{
char hexstr[512]; uint8_t hex[21];
if ( btc_convaddr(hexstr,coinaddr) == 0 )
memset(ua,0,sizeof(*ua));
if ( bitcoin_addr2rmd160(&ua->addrtype,ua->rmd160,coinaddr) > 0 )
{
decode_hex(hex,21,hexstr);
memset(ua,0,sizeof(*ua));
ua->addrtype = hex[0];
memcpy(ua->rmd160,hex+1,20);
strncpy(ua->coin,coin,sizeof(ua->coin)-1);
return(0);
}

Loading…
Cancel
Save