Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
239e19efd5
  1. 2
      basilisk/basilisk_MSG.c
  2. 1
      basilisk/basilisk_bitcoin.c
  3. 51
      basilisk/basilisk_swap.c

2
basilisk/basilisk_MSG.c

@ -136,7 +136,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.%u datalen.%d\n",bits256_str(str,hash),juint(valsobj,"channel"),juint(valsobj,"msgid"),datalen);
return(basilisk_respond_getmessage(myinfo,key,keylen));
}

1
basilisk/basilisk_bitcoin.c

@ -310,6 +310,7 @@ char *basilisk_valuestr(struct iguana_info *coin,char *coinaddr,uint64_t value,i
jadd64bits(retjson,"satoshis",value);
jaddnum(retjson,"value",dstr(value));
jaddnum(retjson,"height",height);
jaddnum(retjson,"numconfirms",coin->blocks.hwmchain.height - height);
jaddbits256(retjson,"txid",txid);
jaddnum(retjson,"vout",vout);
jaddstr(retjson,"coin",coin->symbol);

51
basilisk/basilisk_swap.c

@ -285,21 +285,56 @@ int32_t basilisk_verify_alicepaid(struct supernet_info *myinfo,struct basilisk_s
int32_t basilisk_numconfirms(struct supernet_info *myinfo,struct basilisk_rawtx *rawtx)
{
//return(iguana_numconfirms(rawtx->coin,rawtx->actualtxid));
return(10);
cJSON *argjson,*valuearray=0,*item; char *valstr; int32_t numconfirms,height,i,n;
/*int32_t height; struct iguana_txid T;
if ( iguana_txidfind(rawtx->coin,&height,&T,rawtx->actualtxid,rawtx->coin->bundlescount-1) != 0 )*/
argjson = cJSON_CreateObject();
jaddbits256(argjson,"txid",rawtx->actualtxid);
jaddnum(argjson,"vout",0);
jaddstr(argjson,"coin",rawtx->coin->symbol);
if ( (valstr= basilisk_value(myinfo,rawtx->coin,0,0,myinfo->myaddr.persistent,argjson,0)) != 0 )
{
printf("valstr.(%s)\n",valstr);
if ( (valuearray= cJSON_Parse(valstr)) != 0 )
{
if ( is_cJSON_Array(valuearray) != 0 )
{
n = cJSON_GetArraySize(valuearray);
for (i=0; i<n; i++)
{
item = jitem(valuearray,i);
height = jint(valuearray,"height");
numconfirms = jint(valuearray,"numconfirms");
if ( height > 0 && numconfirms >= 0 )
{
free_json(argjson);
free_json(valuearray);
free(valstr);
char str[65]; printf("%s height.%d -> numconfirms.%d\n",bits256_str(str,rawtx->actualtxid),height,numconfirms);
}
}
}
}
}
free_json(argjson);
if ( valuearray != 0 )
free_json(valuearray);
free(valstr);
return(-1);
}
bits256 basilisk_swap_broadcast(char *name,struct supernet_info *myinfo,struct basilisk_swap *swap,struct iguana_info *coin,uint8_t *data,int32_t datalen)
{
bits256 txid;
bits256 txid; char *signedtx;
memset(txid.bytes,0,sizeof(txid));
if ( data != 0 && datalen != 0 )
{
txid = bits256_doublesha256(0,data,datalen);
int32_t i; for (i=0; i<datalen; i++)
printf("%02x",data[i]);
char str[65]; printf(" <- sendrawtransaction %s.(%s)\n",name,bits256_str(str,txid));
//txid = iguana_sendrawtransaction(coin,data,datalen);
//txid = bits256_doublesha256(0,data,datalen);
signedtx = malloc(datalen*2 + 1);
init_hexbytes_noT(signedtx,data,datalen);
txid = iguana_sendrawtransaction(myinfo,coin,signedtx);
char str[65]; printf("%s <- sendrawtransaction %s.(%s)\n",name,signedtx,bits256_str(str,txid));
free(signedtx);
}
return(txid);
}

Loading…
Cancel
Save