Browse Source

test

etomic
jl777 8 years ago
parent
commit
83baf6d456
  1. 2
      iguana/dPoW.h
  2. 34
      iguana/iguana_notary.c
  3. 28
      iguana/kmd_lookup.h
  4. 4
      includes/iguana_apideclares.h

2
iguana/dPoW.h

@ -191,7 +191,7 @@ cJSON *dpow_checkaddress(struct supernet_info *myinfo,struct iguana_info *coin,c
void dex_channelsend(struct supernet_info *myinfo,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgid,uint8_t *data,int32_t datalen);
void kmd_bitcoinscan();
struct iguana_info *iguana_coinfind(char *symbol);
cJSON *kmd_listtransactions(struct iguana_info *coin,char *coinaddr);
cJSON *kmd_listtransactions(struct iguana_info *coin,char *coinaddr,int32_t count,int32_t skip);
cJSON *kmd_listunspent(struct iguana_info *coin,char *coinaddr);
#endif

34
iguana/iguana_notary.c

@ -612,6 +612,16 @@ HASH_AND_STRING_AND_INT(dex,gettxout,txid,symbol,vout)
return(_dex_gettxout(myinfo,symbol,txid,vout));
}
TWO_STRINGS(dex,listunspent,symbol,address)
{
return(_dex_listunspent(myinfo,symbol,address));
}
TWO_STRINGS_AND_TWO_DOUBLES(dex,listtransactions,symbol,address,count,skip)
{
return(_dex_listtransactions(myinfo,symbol,address,count,skip));
}
STRING_ARG(dex,getinfo,symbol)
{
return(_dex_getinfo(myinfo,symbol));
@ -690,14 +700,30 @@ THREE_STRINGS_AND_THREE_INTS(dex,kvupdate,symbol,key,value,flags,unused,unusedb)
#include "kmd_lookup.h"
TWO_STRINGS(dex,listunspent,symbol,address)
TWO_STRINGS(dex,listunspent2,symbol,address)
{
return(_dex_listunspent(myinfo,symbol,address));
cJSON *retjson;
if ( symbol != 0 && address != 0 && (coin= iguana_coinfind(symbol)) != 0 )
{
if ( strcmp(coin->symbol,"BTC") == 0 )
return(clonestr("[]"));
if ( (retjson= kmd_listunspent(coin,address)) != 0 )
return(jprint(retjson,1));
}
return(clonestr("{\"error\":\"listunspent2 null symbol, address or coin\"}"));
}
TWO_STRINGS_AND_TWO_DOUBLES(dex,listtransactions,symbol,address,count,skip)
TWO_STRINGS_AND_TWO_DOUBLES(dex,listtransactions2,symbol,address,count,skip)
{
return(_dex_listtransactions(myinfo,symbol,address,count,skip));
cJSON *retjson;
if ( symbol != 0 && address != 0 && (coin= iguana_coinfind(symbol)) != 0 )
{
if ( strcmp(coin->symbol,"BTC") == 0 )
return(clonestr("[]"));
if ( (retjson= kmd_listtransactions(coin,address,count,skip)) != 0 )
return(jprint(retjson,1));
}
return(clonestr("{\"error\":\"listunspent2 null symbol, address or coin\"}"));
}
#include "../includes/iguana_apiundefs.h"

28
iguana/kmd_lookup.h

@ -240,19 +240,35 @@ int32_t kmd_height(struct iguana_info *coin)
return(height);
}
cJSON *kmd_listtransactions(struct iguana_info *coin,char *coinaddr)
cJSON *kmd_listtransactions(struct iguana_info *coin,char *coinaddr,int32_t count,int32_t skip)
{
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,counter=0; 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 )
{
jaddi(array,kmd_transactionjson(ptr,"received"));
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_transactionjson(spent,"sent"));
if ( counter >= skip && counter < count+skip )
jaddi(array,kmd_transactionjson(ptr,"received"));
if ( ++counter >= count+skip )
break;
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]) != 0 )
{
if ( counter >= skip && counter < count+skip )
jaddi(array,kmd_transactionjson(spent,"sent"));
if ( ++counter >= count+skip )
break;
if ( ptr->ptrs[i << 1] != 0 )
prev = ptr->ptrs[i << 1];
}
}
if ( counter >= count+skip )
break;
ptr = prev;
}
}
return(array);

4
includes/iguana_apideclares.h

@ -42,8 +42,8 @@ TWO_STRINGS(dex,listunspent,symbol,address);
TWO_STRINGS_AND_TWO_DOUBLES(dex,listtransactions,symbol,address,count,skip);
TWO_STRINGS(dex,kvsearch,symbol,key);
THREE_STRINGS_AND_THREE_INTS(dex,kvupdate,symbol,key,value,flags,unused,unusedb);
TWO_STRINGS(dex,listunspent2,symbol,coinaddr);
TWO_STRINGS(dex,listtransactions2,symbol,coinaddr);
TWO_STRINGS(dex,listunspent2,symbol,address);
TWO_STRINGS_AND_TWO_DOUBLES(dex,listtransactions2,symbol,address,count,skip);
TWO_STRINGS(zcash,passthru,function,hex);
TWO_STRINGS(komodo,passthru,function,hex);

Loading…
Cancel
Save