From 180c57df422709a73a0664d220c2c79675a19790 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 31 Jan 2017 07:30:29 +0200 Subject: [PATCH 1/2] interests field for gettxout and listunspent --- iguana/iguana_payments.c | 4 ++++ iguana/iguana_unspents.c | 2 ++ iguana/tests/listunspent | 2 +- includes/iguana_funcs.h | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/iguana/iguana_payments.c b/iguana/iguana_payments.c index 3d0301f9b..bae043847 100755 --- a/iguana/iguana_payments.c +++ b/iguana/iguana_payments.c @@ -777,9 +777,13 @@ HASH_AND_TWOINTS(bitcoinrpc,gettxout,txid,vout,mempool) jaddbits256(retjson,"bestblock",coin->blocks.hwmchain.RO.hash2); jaddnum(retjson,"bestheight",coin->blocks.hwmchain.height); jaddnum(retjson,"height",height); + jaddbits256(retjson,"txid",txid); + jaddnum(retjson,"vout",vout); jaddnum(retjson,"confirmations",coin->blocks.hwmchain.height - height + 1); jaddnum(retjson,"value",dstr(value)); jaddnum(retjson,"amount",dstr(value)); + if ( strcmp(coin->symbol,"KMD") == 0 ) + jaddnum(retjson,"interest",dstr(iguana_interest(myinfo,coin,txid,vout,value))); if ( (height % coin->chain->bundlesize) == 0 && vout == 0 ) jadd(retjson,"coinbase",jtrue()); else jadd(retjson,"coinbase",jfalse()); diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 5ddad189b..dea1a720c 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -305,6 +305,8 @@ cJSON *iguana_RTunspentjson(struct supernet_info *myinfo,struct iguana_info *coi jaddstr(item,"scriptPubKey",scriptstr); } jaddnum(item,"amount",dstr(value)); + if ( strcmp(coin->symbol,"KMD") == 0 ) + jaddnum(item,"interest",dstr(iguana_interest(myinfo,coin,txid,vout,value))); //jaddnum(item,"timestamp",T[up->txidind].timestamp); if ( iguana_RTunspentindfind(myinfo,coin,&outpt,0,0,0,0,&height,txid,vout,coin->bundlescount-1,0) == 0 ) { diff --git a/iguana/tests/listunspent b/iguana/tests/listunspent index 5e66227ec..bec4770b5 100755 --- a/iguana/tests/listunspent +++ b/iguana/tests/listunspent @@ -1,2 +1,2 @@ #!/bin/bash -curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"listunspent\",\"params\":[1, 9999999, []]}" +curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"KMD\",\"method\":\"listunspent\",\"params\":[1, 9999999, []]}" diff --git a/includes/iguana_funcs.h b/includes/iguana_funcs.h index cb70621e1..e3094974e 100755 --- a/includes/iguana_funcs.h +++ b/includes/iguana_funcs.h @@ -434,6 +434,7 @@ cJSON *iguana_RTunspentjson(struct supernet_info *myinfo,struct iguana_info *coi int32_t bitcoin_standardspend(uint8_t *script,int32_t n,uint8_t rmd160[20]); struct iguana_waddress *iguana_waddresssearch(struct supernet_info *myinfo,struct iguana_waccount **wacctp,char *coinaddr); cJSON *iguana_RTlistunspent(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *argarray,int32_t minconf,int32_t maxconf,char *remoteaddr,int32_t includespends); +uint64_t iguana_interest(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t vout,uint64_t value); void calc_shares(struct supernet_info *myinfo,uint8_t *shares,uint8_t *secret,int32_t size,int32_t width,int32_t M,int32_t N,uint8_t *sharenrs,uint8_t *space,int32_t spacesize); //struct basilisk_spend *basilisk_addspend(struct supernet_info *myinfo,char *symbol,bits256 txid,uint16_t vout,int32_t addflag); //void iguana_wallet_Cclear(struct supernet_info *myinfo,char *symbol); From 9e06c9a34e6c5e736052eec88e408e477385839d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 31 Jan 2017 08:03:23 +0200 Subject: [PATCH 2/2] test --- iguana/tests/gettxout | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/tests/gettxout b/iguana/tests/gettxout index db806313a..25e276573 100755 --- a/iguana/tests/gettxout +++ b/iguana/tests/gettxout @@ -1,3 +1,3 @@ #!/bin/bash -curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"gettxout\",\"params\":[\"091c99b7b7f9b83ad2385c45b342ed5dd57035d15ff812262a3ceb3f1b291a5a\", 1]}" +curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"KMD\",\"method\":\"gettxout\",\"params\":[\"78d8efb10877c2293d5f2ed6fd3b7ff2da4f599ab63de25043e9211ddb669c13\", 1]}"