Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
f9f68f255b
  1. 2
      basilisk/basilisk_MSG.c
  2. 5
      basilisk/basilisk_swap.c
  3. 6
      iguana/exchanges/bitcoin.c
  4. 2
      iguana/iguana_sign.c
  5. 39
      iguana/iguana_wallet.c
  6. 2
      includes/iguana_funcs.h
  7. 2
      includes/iguana_structs.h

2
basilisk/basilisk_MSG.c

@ -145,7 +145,7 @@ char *basilisk_respond_MSG(struct supernet_info *myinfo,char *CMD,void *addr,cha
{
int32_t keylen; uint8_t key[64];
keylen = basilisk_messagekey(key,hash,valsobj);
char str[65]; printf("%s channel.%u msgid.%u datalen.%d\n",bits256_str(str,hash),juint(valsobj,"channel"),juint(valsobj,"msgid"),datalen);
//char str[65]; printf("%s channel.%u msgid.%x datalen.%d\n",bits256_str(str,hash),juint(valsobj,"channel"),juint(valsobj,"msgid"),datalen);
return(basilisk_respond_getmessage(myinfo,key,keylen));
}

5
basilisk/basilisk_swap.c

@ -1026,6 +1026,11 @@ void basilisk_alicepayment(struct supernet_info *myinfo,struct iguana_info *coin
basilisk_rawtx_gen("alicepayment",myinfo,0,1,alicepayment,alicepayment->locktime,alicepayment->spendscript,alicepayment->spendlen,coin->chain->txfee,1);
}
// test all spend paths upfront
// detect insufficient funds/inputs
// mode to autocreate required outputs
// send across or regenerate redeem scripts by alice
void basilisk_swaploop(void *_swap)
{
uint8_t *data; uint32_t expiration; int32_t retval=0,i,j,maxlen,datalen; struct supernet_info *myinfo; struct basilisk_swap *swap = _swap;

6
iguana/exchanges/bitcoin.c

@ -42,9 +42,13 @@ int32_t bitcoin_addr2rmd160(uint8_t *addrtypep,uint8_t rmd160[20],char *coinaddr
else
{
int32_t i;
if ( len > 20 )
{
hash = bits256_doublesha256(0,buf,len);
}
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[21]&0xff,buf[22]&0xff,buf[23]&0xff,buf[24]&0xff,hash.bytes[31],hash.bytes[30],hash.bytes[29],hash.bytes[28],bits256_str(str,hash));
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-1]&0xff,buf[len-2]&0xff,buf[len-3]&0xff,buf[len-4]&0xff,hash.bytes[31],hash.bytes[30],hash.bytes[29],hash.bytes[28],bits256_str(str,hash));
}
}
return(0);

2
iguana/iguana_sign.c

@ -800,7 +800,7 @@ void iguana_ensure_privkey(struct supernet_info *myinfo,struct iguana_info *coin
{
memset(&addr,0,sizeof(addr));
iguana_waddresscalc(myinfo,coin->chain->pubtype,coin->chain->wiftype,&addr,privkey);
if ( (wacct= iguana_waccountfind(myinfo,coin,"default")) != 0 )
if ( (wacct= iguana_waccountfind(myinfo,"default")) != 0 )
waddr = iguana_waddressadd(myinfo,coin,wacct,&addr,0);
}
if ( waddr != 0 )

39
iguana/iguana_wallet.c

@ -54,16 +54,16 @@ struct iguana_waddress *iguana_waddressalloc(uint8_t addrtype,char *symbol,char
return(waddr);
}
struct iguana_waccount *iguana_waccountfind(struct supernet_info *myinfo,struct iguana_info *coin,char *account)
struct iguana_waccount *iguana_waccountfind(struct supernet_info *myinfo,char *account)
{
struct iguana_waccount *wacct = 0;
if ( account != 0 && wacct != 0 )
if ( account != 0 )
HASH_FIND(hh,myinfo->wallet,account,strlen(account)+1,wacct);
//printf("waccountfind.(%s) -> wacct.%p\n",account,wacct);
return(wacct);
}
struct iguana_waccount *iguana_waccountcreate(struct supernet_info *myinfo,struct iguana_info *coin,char *account)
struct iguana_waccount *iguana_waccountcreate(struct supernet_info *myinfo,char *account)
{
struct iguana_waccount *wacct=0,*ptr; int32_t len;
if ( account != 0 )
@ -74,13 +74,18 @@ struct iguana_waccount *iguana_waccountcreate(struct supernet_info *myinfo,struc
HASH_FIND(hh,myinfo->wallet,account,len,wacct);
if ( wacct == 0 )
{
wacct = mycalloc('w',1,sizeof(*wacct));
wacct = mycalloc('w',1,sizeof(*wacct) + len);
strcpy(wacct->account,account);
HASH_ADD_KEYPTR(hh,myinfo->wallet,wacct->account,len,wacct);
printf("waccountcreate.(%s) -> wacct.%p\n",account,wacct);
if ( (ptr= iguana_waccountfind(myinfo,account)) != wacct )
{
printf("ERROR: iguana_waccountcreate verify error %p vs %p\n",ptr,wacct);
HASH_FIND(hh,myinfo->wallet,account,len,wacct);
printf("HASH_FIND.%p\n",wacct);
getchar();
}
myinfo->dirty = (uint32_t)time(NULL);
if ( (ptr= iguana_waccountfind(myinfo,coin,account)) != wacct )
printf("iguana_waccountcreate verify error %p vs %p\n",ptr,wacct);
}
}
return(wacct);
@ -91,7 +96,7 @@ struct iguana_waddress *iguana_waddresscreate(struct supernet_info *myinfo,struc
struct iguana_waddress *waddr,*ptr; uint8_t rmd160[20],addrtype;
bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr);
if ( wacct == 0 )
wacct = iguana_waccountcreate(myinfo,coin,"");
wacct = iguana_waccountcreate(myinfo,"");
HASH_FIND(hh,wacct->waddr,rmd160,sizeof(rmd160),waddr);
if ( waddr == 0 )
{
@ -231,7 +236,7 @@ struct iguana_waddress *iguana_waccountswitch(struct supernet_info *myinfo,struc
iguana_waddressdelete(myinfo,coin,wacct,coinaddr);
}
}
if ( (wacct= iguana_waccountcreate(myinfo,coin,account)) != 0 )
if ( (wacct= iguana_waccountcreate(myinfo,account)) != 0 )
{
waddr = iguana_waddresscreate(myinfo,coin,wacct,coinaddr,redeemScript);
if ( waddr != 0 && redeemScript == 0 )
@ -280,7 +285,7 @@ cJSON *iguana_getaddressesbyaccount(struct supernet_info *myinfo,struct iguana_i
account = "*";
if ( strcmp("*",account) != 0 )
{
if ( (subset= iguana_waccountfind(myinfo,coin,account)) != 0 )
if ( (subset= iguana_waccountfind(myinfo,account)) != 0 )
{
HASH_ITER(hh,subset->waddr,waddr,tmp2)
{
@ -494,8 +499,8 @@ cJSON *iguana_payloadmerge(cJSON *loginjson,cJSON *importjson)
cJSON *iguana_walletadd(struct supernet_info *myinfo,struct iguana_waddress **waddrp,struct iguana_info *coin,char *retstr,char *account,struct iguana_waddress *refwaddr,int32_t setcurrent,char *redeemScript)
{
cJSON *retjson=0; struct iguana_waccount *wacct; struct iguana_waddress *waddr;
if ( (wacct= iguana_waccountfind(myinfo,coin,account)) == 0 )
wacct = iguana_waccountcreate(myinfo,coin,account);
if ( (wacct= iguana_waccountfind(myinfo,account)) == 0 )
wacct = iguana_waccountcreate(myinfo,account);
if ( wacct != 0 )
{
//waddr = iguana_waddressfind(myinfo,wacct,refwaddr->coinaddr);
@ -750,7 +755,7 @@ cJSON *iguana_walletiterate(struct supernet_info *myinfo,struct iguana_info *coi
if ( flag < -1 )
{
HASH_DELETE(hh,myinfo->wallet,wacct);
myfree(wacct,sizeof(*wacct));
myfree(wacct,(int32_t)(sizeof(*wacct) + strlen(wacct->account) + 1));
}
}
if ( myinfo->expiration != 0 )
@ -820,7 +825,7 @@ void iguana_walletinitcheck(struct supernet_info *myinfo,struct iguana_info *coi
child = item->child;
while ( child != 0 )
{
if ( (wacct= iguana_waccountcreate(myinfo,coin,account)) != 0 )
if ( (wacct= iguana_waccountcreate(myinfo,account)) != 0 )
{
if ( (privstr= iguana_walletfields(coin,&p2shflag,wifstr,coinaddr,child->string,child->valuestring)) != 0 )
{
@ -1067,8 +1072,8 @@ struct iguana_waddress *iguana_getaccountaddress(struct supernet_info *myinfo,st
{
char *newstr,*retstr; struct iguana_waccount *wacct; struct iguana_waddress *waddr=0;
coinaddr[0] = 0;
if ( (wacct= iguana_waccountfind(myinfo,coin,account)) == 0 )
wacct = iguana_waccountcreate(myinfo,coin,account);
if ( (wacct= iguana_waccountfind(myinfo,account)) == 0 )
wacct = iguana_waccountcreate(myinfo,account);
if ( wacct != 0 )
{
if ( (waddr= wacct->current) == 0 )
@ -1441,7 +1446,7 @@ STRING_AND_INT(bitcoinrpc,getreceivedbyaccount,account,minconf)
if ( myinfo->expiration == 0 )
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
retjson = cJSON_CreateObject();
if ( (wacct= iguana_waccountfind(myinfo,coin,account)) != 0 )
if ( (wacct= iguana_waccountfind(myinfo,account)) != 0 )
{
balance = iguana_waccountbalance(myinfo,coin,wacct,minconf,0);
jaddnum(retjson,"result",dstr(balance));
@ -1458,7 +1463,7 @@ STRING_AND_THREEINTS(bitcoinrpc,listtransactions,account,count,skip,includewatch
return(clonestr("{\"error\":\"need to unlock wallet\"}"));
retjson = cJSON_CreateObject();
retarray = cJSON_CreateArray();
if ( (wacct= iguana_waccountfind(myinfo,coin,account)) != 0 )
if ( (wacct= iguana_waccountfind(myinfo,account)) != 0 )
{
if ( (array= iguana_getaddressesbyaccount(myinfo,coin,account)) != 0 )
{

2
includes/iguana_funcs.h

@ -250,7 +250,7 @@ struct iguana_ramchain *iguana_bundleload(struct iguana_info *coin,struct iguana
int32_t iguana_sendblockreq(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_bundle *bp,int32_t bundlei,bits256 hash2,int32_t iamthreadsafe);
int32_t iguana_send_supernet(struct iguana_peer *addr,char *jsonstr,int32_t delay);
struct iguana_waccount *iguana_waccountfind(struct supernet_info *myinfo,struct iguana_info *coin,char *account);
struct iguana_waccount *iguana_waccountfind(struct supernet_info *myinfo,char *account);
struct iguana_waddress *iguana_waccountadd(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_waccount **wacctp,char *walletaccount,char *coinaddr);
struct iguana_waddress *iguana_waccountswitch(struct supernet_info *myinfo,struct iguana_info *coin,char *account,char *coinaddr,char *redeemScript);
struct iguana_waddress *iguana_waddresscalc(struct supernet_info *myinfo,uint8_t pubval,uint8_t wiftype,struct iguana_waddress *addr,bits256 privkey);

2
includes/iguana_structs.h

@ -370,7 +370,7 @@ struct basilisk_spend { bits256 txid,spentfrom; uint64_t relaymask,value; uint32
struct basilisk_unspent { bits256 txid; uint64_t value,relaymask; uint32_t unspentind,timestamp; int32_t RTheight,height,spentheight; int16_t status,hdrsi,vout,spendlen; char symbol[16]; uint8_t script[256]; };
struct iguana_waddress { UT_hash_handle hh; struct basilisk_unspent *unspents; uint64_t balance; uint32_t maxunspents,numunspents; uint16_t scriptlen; uint8_t rmd160[20],pubkey[33],wiftype,addrtype; bits256 privkey; char symbol[8],coinaddr[36],wifstr[54]; uint8_t redeemScript[]; };
struct iguana_waccount { UT_hash_handle hh; char account[128]; struct iguana_waddress *waddr,*current; };
struct iguana_waccount { UT_hash_handle hh; struct iguana_waddress *waddr,*current; char account[]; };
struct iguana_wallet { UT_hash_handle hh; struct iguana_waccount *wacct; };
struct scriptinfo { UT_hash_handle hh; uint32_t fpos; uint16_t scriptlen; uint8_t script[]; };

Loading…
Cancel
Save