diff --git a/iguana/iguana_wallet.c b/iguana/iguana_wallet.c index ec8074f70..91ae50608 100755 --- a/iguana/iguana_wallet.c +++ b/iguana/iguana_wallet.c @@ -1458,21 +1458,23 @@ THREE_INTS(bitcoinrpc,listreceivedbyaccount,minconf,includeempty,watchonly) THREE_INTS(bitcoinrpc,listreceivedbyaddress,minconf,includeempty,flag) { - cJSON *retjson,*item,*array,*txids,*vouts; struct iguana_waccount *wacct,*tmp; struct iguana_waddress *waddr,*tmp2; + cJSON *retjson,*item,*array,*txids,*vouts; struct iguana_waccount *wacct,*tmp; struct iguana_waddress *waddr,*tmp2; uint8_t addrtype; char coinaddr[64]; if ( remoteaddr != 0 ) return(clonestr("{\"error\":\"no remote\"}")); - //if ( myinfo->expiration == 0 ) - // return(clonestr("{\"error\":\"need to unlock wallet\"}")); + if ( myinfo->expiration == 0 ) + return(clonestr("{\"error\":\"need to unlock wallet\"}")); array = cJSON_CreateArray(); HASH_ITER(hh,myinfo->wallet,wacct,tmp) { HASH_ITER(hh,wacct->waddr,waddr,tmp2) { item = cJSON_CreateObject(); - jaddstr(item,"address",waddr->coinaddr); + addrtype = (waddr->scriptlen > 0) ? coin->chain->p2shtype : coin->chain->pubtype; + bitcoin_address(coinaddr,addrtype,waddr->rmd160,20); + jaddstr(item,"address",coinaddr); txids = cJSON_CreateArray(); vouts = cJSON_CreateArray(); - jaddnum(item,"amount",dstr(iguana_addressreceived(myinfo,coin,0,remoteaddr,txids,vouts,waddr->coinaddr,minconf))); + jaddnum(item,"amount",dstr(iguana_addressreceived(myinfo,coin,0,remoteaddr,txids,vouts,coinaddr,minconf))); jadd(item,"txids",txids); jadd(item,"vouts",vouts); jaddi(array,item); diff --git a/iguana/tests/importprivkeyB b/iguana/tests/importprivkeyB index fea5c86cc..daf596641 100755 --- a/iguana/tests/importprivkeyB +++ b/iguana/tests/importprivkeyB @@ -1 +1 @@ -curl --url "http://127.0.0.1:7778" --data "{\"method\":\"importprivkey\",\"params\":[\"b81e824a58cefff953eb53e9743059d001be0f5cfeb7599fbdd6bd18dba6616c\"]}" +curl --url "http://127.0.0.1:7778" --data "{\"method\":\"importprivkey\",\"params\":[\"Kzw1ordPLaxDqgn2Uz8UyjszcjyPsSM8a16CpHQ4DJF2DiVtFSX1\"]}" diff --git a/iguana/tests/listreceivedbyaddress b/iguana/tests/listreceivedbyaddress new file mode 100755 index 000000000..52be059a5 --- /dev/null +++ b/iguana/tests/listreceivedbyaddress @@ -0,0 +1 @@ +curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTC\",\"method\":\"listreceivedbyaddress\",\"params\":[]}"