Browse Source

test

etomic
jl777 8 years ago
parent
commit
5a11a68af4
  1. 2
      iguana/dPoW.h
  2. 14
      iguana/iguana_notary.c
  3. 39
      iguana/kmd_lookup.h
  4. 2
      includes/iguana_apideclares.h

2
iguana/dPoW.h

@ -193,5 +193,7 @@ void kmd_bitcoinscan();
struct iguana_info *iguana_coinfind(char *symbol);
cJSON *kmd_listtransactions(struct iguana_info *coin,char *coinaddr,int32_t count,int32_t skip);
cJSON *kmd_listunspent(struct iguana_info *coin,char *coinaddr);
cJSON *kmd_listspent(struct iguana_info *coin,char *coinaddr);
cJSON *kmd_gettxin(struct iguana_info *coin,bits256 txid,int32_t vout);
#endif

14
iguana/iguana_notary.c

@ -726,6 +726,20 @@ TWO_STRINGS_AND_TWO_DOUBLES(dex,listtransactions2,symbol,address,count,skip)
return(clonestr("{\"error\":\"listunspent2 null symbol, address or coin\"}"));
}
HASH_AND_STRING_AND_INT(dex,gettxin,txid,symbol,vout)
{
if ( symbol != 0 && (coin= iguana_coinfind(symbol)) != 0 )
return(jprint(kmd_gettxin(coin,txid,vout),1));
return(clonestr("{\"error\":\"listspent null symbol, address or coin\"}"));
}
TWO_STRINGS(dex,listspent,symbol,address)
{
if ( symbol != 0 && address != 0 && (coin= iguana_coinfind(symbol)) != 0 )
return(jprint(kmd_listspent(coin,address),1));
return(clonestr("{\"error\":\"listspent null symbol, address or coin\"}"));
}
#include "../includes/iguana_apiundefs.h"

39
iguana/kmd_lookup.h

@ -310,23 +310,44 @@ cJSON *kmd_gettxin(struct iguana_info *coin,bits256 txid,int32_t vout)
return(cJSON_Parse("{\"error\":\"txid not found\"}"));
}
cJSON *kmd_listunspent(struct iguana_info *coin,char *coinaddr)
cJSON *kmd_listaddress(struct iguana_info *coin,char *coinaddr,int32_t mode)
{
struct kmd_addresshh *addr; struct kmd_transactionhh *ptr,*spent; uint8_t type_rmd160[21]; int32_t i,height; cJSON *array = cJSON_CreateArray();
struct kmd_addresshh *addr; struct kmd_transactionhh *ptr,*spent,*prev=0; uint8_t type_rmd160[21]; int32_t i,height; cJSON *array = cJSON_CreateArray();
if ( (height= kmd_height(coin)) > coin->kmd_height+3 )
return(cJSON_Parse("[]"));
bitcoin_addr2rmd160(&type_rmd160[0],&type_rmd160[1],coinaddr);
if ( (addr= _kmd_address(coin,type_rmd160)) != 0 && (ptr= addr->prev) != 0 && ptr->tx != 0 )
{
for (i=0; i<ptr->numvouts; i++)
while ( ptr != 0 )
{
if ( memcmp(ptr->tx->vouts[i].type_rmd160,type_rmd160,21) == 0 && (spent= ptr->ptrs[(i<<1)+1]) == 0 )
jaddi(array,kmd_unspentjson(ptr->tx,i));
prev = 0;
for (i=0; i<ptr->numvouts; i++)
{
if ( memcmp(ptr->tx->vouts[i].type_rmd160,type_rmd160,21) == 0 )
{
spent = ptr->ptrs[(i<<1) + 1];
if ( (mode == 0 && spent == 0) || (mode == 1 && spent != 0) )
jaddi(array,kmd_unspentjson(ptr->tx,i));
if ( ptr->ptrs[i<<1] != 0 )
prev = ptr->ptrs[i<<1];
}
}
ptr = prev;
}
}
return(array);
}
cJSON *kmd_listunspent(struct iguana_info *coin,char *coinaddr)
{
return(kmd_listaddress(coin,coinaddr,0));
}
cJSON *kmd_listspent(struct iguana_info *coin,char *coinaddr)
{
return(kmd_listaddress(coin,coinaddr,1));
}
char *kmd_bitcoinblockhashstr(char *coinstr,char *serverport,char *userpass,int32_t height)
{
char numstr[128],*blockhashstr=0; bits256 hash2; struct iguana_info *coin;
@ -387,7 +408,6 @@ int32_t _kmd_bitcoinscan(struct iguana_info *coin)
while ( loadheight < height )
{
flag = 0;
printf("load ht.%d\n",loadheight);
if ( (blockjson= kmd_blockjson(&h,coin->symbol,coin->chain->serverport,coin->chain->userpass,0,loadheight)) != 0 )
{
if ( (txids= jarray(&numtxids,blockjson,"tx")) != 0 )
@ -420,7 +440,7 @@ int32_t _kmd_bitcoinscan(struct iguana_info *coin)
if ( (sobj= jobj(vout,"scriptPubKey")) != 0 && (addresses= jarray(&n,sobj,"addresses")) != 0 )
{
kmd_transactionvout(coin,ptr,i,jdouble(vout,"value")*SATOSHIDEN,type_rmd160,zero,-1);
}
} else flag++;
}
for (i=0; i<numvins; i++)
{
@ -428,6 +448,7 @@ int32_t _kmd_bitcoinscan(struct iguana_info *coin)
if ( kmd_transactionvin(coin,txid,i,jbits256(vin,"txid"),jint(vin,"vout")) < 0 )
{
printf("error i.%d of numvins.%d\n",i,numvins);
flag++;
break;
}
}
@ -443,9 +464,9 @@ int32_t _kmd_bitcoinscan(struct iguana_info *coin)
}
free_json(blockjson);
}
coin->kmd_height = loadheight++;
if ( flag == 0 || num > 100 )
if ( flag != 0 || num > 100 )
break;
coin->kmd_height = loadheight++;
}
return(num);
}

2
includes/iguana_apideclares.h

@ -44,6 +44,8 @@ TWO_STRINGS(dex,kvsearch,symbol,key);
THREE_STRINGS_AND_THREE_INTS(dex,kvupdate,symbol,key,value,flags,unused,unusedb);
TWO_STRINGS(dex,listunspent2,symbol,address);
TWO_STRINGS_AND_TWO_DOUBLES(dex,listtransactions2,symbol,address,count,skip);
HASH_AND_STRING_AND_INT(dex,gettxin,txid,symbol,vout);
TWO_STRINGS(dex,listspent,symbol,address);
TWO_STRINGS(zcash,passthru,function,hex);
TWO_STRINGS(komodo,passthru,function,hex);

Loading…
Cancel
Save