Browse Source

Merge pull request #249 from jl777/dev

Dev
win-cross
jl777 8 years ago
committed by GitHub
parent
commit
e0bd5dcfbd
  1. 27
      iguana/kmd_lookup.h

27
iguana/kmd_lookup.h

@ -285,7 +285,7 @@ FILE *kmd_spendinit(struct iguana_info *coin)
return(fp); return(fp);
} }
cJSON *kmd_transactionjson(struct kmd_transactionhh *ptr,char *typestr) cJSON *kmd_transactionjson(int32_t height,struct kmd_transactionhh *ptr,char *typestr)
{ {
int32_t i; char coinaddr[64]; cJSON *item,*array,*obj = cJSON_CreateObject(); int32_t i; char coinaddr[64]; cJSON *item,*array,*obj = cJSON_CreateObject();
array = cJSON_CreateArray(); array = cJSON_CreateArray();
@ -304,7 +304,7 @@ cJSON *kmd_transactionjson(struct kmd_transactionhh *ptr,char *typestr)
return(obj); return(obj);
} }
cJSON *kmd_unspentjson(struct kmd_transaction *tx,int32_t vout) cJSON *kmd_unspentjson(int32_t height,struct kmd_transaction *tx,int32_t vout)
{ {
cJSON *item = cJSON_CreateObject(); cJSON *item = cJSON_CreateObject();
jaddstr(item,"type","received"); jaddstr(item,"type","received");
@ -316,10 +316,11 @@ cJSON *kmd_unspentjson(struct kmd_transaction *tx,int32_t vout)
return(item); return(item);
} }
cJSON *kmd_spentjson(struct kmd_transaction *tx,int32_t vout,struct kmd_transactionhh *spent) cJSON *kmd_spentjson(int32_t height,struct kmd_transaction *tx,int32_t vout,struct kmd_transactionhh *spent)
{ {
cJSON *item = cJSON_CreateObject(); cJSON *item = cJSON_CreateObject();
jaddstr(item,"type","sent"); jaddstr(item,"type","sent");
jaddnum(item,"confirmations",height - tx->height);
jaddnum(item,"height",tx->height); jaddnum(item,"height",tx->height);
jaddnum(item,"timestamp",tx->timestamp); jaddnum(item,"timestamp",tx->timestamp);
jaddbits256(item,"txid",tx->txid); jaddbits256(item,"txid",tx->txid);
@ -329,7 +330,7 @@ cJSON *kmd_spentjson(struct kmd_transaction *tx,int32_t vout,struct kmd_transact
jaddnum(item,"vin",tx->vouts[vout].spendvini); jaddnum(item,"vin",tx->vouts[vout].spendvini);
if ( spent != 0 ) if ( spent != 0 )
{ {
jadd(item,"paid",kmd_transactionjson(spent,"paid")); jadd(item,"paid",kmd_transactionjson(height,spent,"paid"));
} }
return(item); return(item);
} }
@ -409,30 +410,30 @@ cJSON *kmd_listaddress(struct iguana_info *coin,char *coinaddr,int32_t mode,cJSO
if ( fulltx == 0 ) if ( fulltx == 0 )
{ {
if ( mode == 0 ) if ( mode == 0 )
jaddi(array,kmd_unspentjson(ptr->tx,i)); jaddi(array,kmd_unspentjson(coin->kmd_height,ptr->tx,i));
else if ( mode == 1 ) else if ( mode == 1 )
jaddi(array,kmd_spentjson(ptr->tx,i,spent)); jaddi(array,kmd_spentjson(coin->kmd_height,ptr->tx,i,spent));
else if ( mode == 2 ) else if ( mode == 2 )
{ {
if ( spent != 0 ) if ( spent != 0 )
jaddi(array,kmd_spentjson(ptr->tx,i,spent)); jaddi(array,kmd_spentjson(coin->kmd_height,ptr->tx,i,spent));
else jaddi(array,kmd_unspentjson(ptr->tx,i)); else jaddi(array,kmd_unspentjson(coin->kmd_height,ptr->tx,i));
} }
} }
else if ( flag == 0 ) else if ( flag == 0 )
{ {
if ( mode == 0 ) if ( mode == 0 )
jaddi(array,kmd_transactionjson(ptr,"received")); jaddi(array,kmd_transactionjson(coin->kmd_height,ptr,"received"));
else if ( mode == 1 ) else if ( mode == 1 )
{ {
jaddi(array,kmd_transactionjson(ptr,"received")); jaddi(array,kmd_transactionjson(coin->kmd_height,ptr,"received"));
jaddi(array,kmd_transactionjson(spent,"sent")); jaddi(array,kmd_transactionjson(coin->kmd_height,spent,"sent"));
} }
else if ( mode == 2 ) else if ( mode == 2 )
{ {
if ( spent != 0 ) if ( spent != 0 )
jaddi(array,kmd_transactionjson(ptr,"spent")); jaddi(array,kmd_transactionjson(coin->kmd_height,ptr,"spent"));
else jaddi(array,kmd_transactionjson(ptr,"received")); else jaddi(array,kmd_transactionjson(coin->kmd_height,ptr,"received"));
} }
flag = 1; flag = 1;
} }

Loading…
Cancel
Save