diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 77e76b7be..c526f8bdc 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -461,6 +461,20 @@ struct pax_transaction char symbol[16],coinaddr[64]; uint8_t rmd160[20],shortflag; } *PAX; +cJSON *dpow_paxjson(struct pax_transaction *pax) +{ + cJSON *item = cJSON_CreateObject(); + jaddbits256(item,"prev_hash",pax->txid); + jaddnum(item,"prev_vout",pax->vout); + if ( pax->shortflag != 0 ) + jaddnum(item,"short",pax->shortflag); + jaddnum(item,pax->symbol,dstr(pax->fiatoshis)); + jaddstr(item,"fiat",pax->symbol); + jaddnum(item,"height",pax->height); + jaddnum(item,"KMD",dstr(pax->komodoshis)); + jaddstr(item,"address",pax->coinaddr); + return(item); +} uint64_t dpow_paxtotal() { struct pax_transaction *pax,*tmp; uint64_t total = 0; @@ -507,13 +521,29 @@ struct pax_transaction *dpow_paxmark(struct dpow_info *dp,struct pax_transaction return(pax); } +cJSON *dpow_withdraws_pending(struct dpow_info *dp) +{ + struct pax_transaction *pax,*tmp; cJSON *retjson = cJSON_CreateArray(); + pthread_mutex_lock(&dp->mutex); + HASH_ITER(hh,PAX,pax,tmp); + { + if ( pax->marked == 0 ) + jaddi(retjson,dpow_paxjson(pax)); + } + pthread_mutex_unlock(&dp->mutex); + return(retjson); +} + void dpow_issuer_withdraw(struct dpow_info *dp,char *coinaddr,uint64_t fiatoshis,int32_t shortflag,char *symbol,uint64_t komodoshis,uint8_t *rmd160,bits256 txid,uint16_t vout,int32_t height) // assetchain context { - struct pax_transaction *pax; + struct pax_transaction *pax; int32_t addflag = 0; pthread_mutex_lock(&dp->mutex); HASH_FIND(hh,PAX,&txid,sizeof(txid),pax); if ( pax == 0 ) + { pax = (struct pax_transaction *)calloc(1,sizeof(*pax)); + addflag = 1; + } if ( coinaddr != 0 ) { strcpy(pax->coinaddr,coinaddr); @@ -534,7 +564,8 @@ void dpow_issuer_withdraw(struct dpow_info *dp,char *coinaddr,uint64_t fiatoshis } pax->txid = txid; pax->vout = vout; - HASH_ADD_KEYPTR(hh,PAX,&pax->txid,sizeof(pax->txid),pax); + if ( addflag != 0 ) + HASH_ADD_KEYPTR(hh,PAX,&pax->txid,sizeof(pax->txid),pax); pthread_mutex_unlock(&dp->mutex); } diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index 3efcd9b96..647ebc9ba 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -277,6 +277,24 @@ TWO_STRINGS(komodo,passthru,function,hex) else return(clonestr("{\"error\":\"KMD not active, start in bitcoind mode\"}")); } +STRING_ARG(dpow,pending,fiat) +{ + struct dpow_info *dp; char base[64]; int32_t i; + if ( fiat != 0 && fiat[0] != 0 ) + { + for (i=0; fiat[i]!=0; i++) + base[i] = toupper(fiat[i]); + base[i] = 0; + for (i=0; inumdpows; i++) + { + dp = &myinfo->DPOWS[i]; + if ( strcmp(dp->symbol,fiat) == 0 ) + return(jprint(dpow_withdraws_pending(dp),1)); + } + } + return(clonestr("[]")); +} + STRING_ARG(iguana,addnotary,ipaddr) { static int32_t didinit;