diff --git a/iguana/kmd_lookup.h b/iguana/kmd_lookup.h index a1db90f94..de1d8ec0b 100755 --- a/iguana/kmd_lookup.h +++ b/iguana/kmd_lookup.h @@ -330,10 +330,14 @@ cJSON *kmd_gettxin(struct iguana_info *coin,bits256 txid,int32_t vout) cJSON *kmd_listaddress(struct iguana_info *coin,char *coinaddr,int32_t mode) { 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 ) + if ( time(NULL) > coin->kmd_lasttime+30 ) { - printf("height.%d > kmd_height.%d\n",height,coin->kmd_height); - return(cJSON_Parse("[]")); + coin->kmd_lasttime = (uint32_t)time(NULL); + if ( (height= kmd_height(coin)) > coin->kmd_height+3 ) + { + printf("height.%d > kmd_height.%d\n",height,coin->kmd_height); + 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 ) @@ -352,6 +356,7 @@ cJSON *kmd_listaddress(struct iguana_info *coin,char *coinaddr,int32_t mode) prev = ptr->ptrs[i<<1]; } } + printf("%s ht.%d prev.%p\n",coinaddr,ptr->tx->height,prev); ptr = prev; } } diff --git a/iguana/tests/dexgetsupply b/iguana/tests/dexgetsupply new file mode 100755 index 000000000..bb8cd941e --- /dev/null +++ b/iguana/tests/dexgetsupply @@ -0,0 +1,2 @@ +#!/bin/bash +curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"getbalance\",\"address\":\"*\",\"symbol\":\"KMD\"}" diff --git a/includes/iguana_structs.h b/includes/iguana_structs.h index 7b5a0b4d0..3f2a174f3 100755 --- a/includes/iguana_structs.h +++ b/includes/iguana_structs.h @@ -536,7 +536,7 @@ struct iguana_info struct iguana_block *RTblocks[65536]; uint8_t *RTrawdata[65536]; int32_t RTrecvlens[65536],RTnumtx[65536]; struct iguana_RTtxid *RTdataset; struct iguana_RTaddr *RTaddrs; struct hashstr_item *alladdresses; - struct kmd_transactionhh *kmd_transactions; struct kmd_addresshh *kmd_addresses; portable_mutex_t kmdmutex; FILE *kmd_txidfp; int32_t kmd_didinit,kmd_height; + struct kmd_transactionhh *kmd_transactions; struct kmd_addresshh *kmd_addresses; portable_mutex_t kmdmutex; FILE *kmd_txidfp; int32_t kmd_didinit,kmd_height; uint32_t kmd_lasttime; }; struct vin_signer { bits256 privkey; char coinaddr[64]; uint8_t siglen,sig[80],rmd160[20],pubkey[66]; };