Browse Source

getreceivedbyaddress RPC

release/v0.1
jl777 9 years ago
parent
commit
3b972344b0
  1. 9
      iguana/iguana_unspents.c
  2. 26
      iguana/iguana_wallet.c
  3. 1
      iguana/tests/getreceivedbyaddress
  4. 2
      includes/iguana_apideclares.h

9
iguana/iguana_unspents.c

@ -2634,14 +2634,17 @@ STRING_ARG(iguana,initfastfind,activecoin)
} else return(clonestr("{\"error\":\"no coin to initialize\"}"));
}
TWOSTRINGS_AND_INT(iguana,balance,activecoin,address,lastheight)
TWO_STRINGS_AND_TWO_DOUBLES(iguana,balance,activecoin,address,lastheightd,minconfd)
{
int32_t minconf=1,maxconf=SATOSHIDEN; int64_t total; uint8_t rmd160[20],pubkey33[33],addrtype;
int32_t lastheight,minconf,maxconf=SATOSHIDEN; int64_t total; uint8_t rmd160[20],pubkey33[33],addrtype;
struct iguana_pkhash *P; cJSON *array,*retjson = cJSON_CreateObject();
if ( activecoin != 0 && activecoin[0] != 0 )
coin = iguana_coinfind(activecoin);
if ( coin != 0 )
{
if ( (minconf= minconfd) <= 0 )
minconf = 1;
lastheight = lastheightd;
jaddstr(retjson,"address",address);
if ( bitcoin_validaddress(coin,address) < 0 )
{
@ -2672,7 +2675,7 @@ TWOSTRINGS_AND_INT(iguana,balance,activecoin,address,lastheight)
int64_t iguana_addressreceived(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *json,char *remoteaddr,cJSON *txids,cJSON *vouts,char *coinaddr,int32_t minconf)
{
int64_t balance = 0; cJSON *unspentsjson,*balancejson,*item; int32_t i,n; char *balancestr;
if ( (balancestr= iguana_balance(IGUANA_CALLARGS,coin->symbol,coinaddr,-1)) != 0 )
if ( (balancestr= iguana_balance(IGUANA_CALLARGS,coin->symbol,coinaddr,-1,minconf)) != 0 )
{
if ( (balancejson= cJSON_Parse(balancestr)) != 0 )
{

26
iguana/iguana_wallet.c

@ -1226,7 +1226,7 @@ STRING_AND_THREEINTS(bitcoinrpc,listtransactions,account,count,skip,includewatch
{
vouts = cJSON_CreateArray();
txids = cJSON_CreateArray();
iguana_addressreceived(myinfo,coin,json,remoteaddr,txids,vouts,coinaddr,1);
iguana_addressreceived(myinfo,coin,0,remoteaddr,txids,vouts,coinaddr,1);
if ( (m= cJSON_GetArraySize(txids)) > 0 )
{
for (j=0; j<m; j++,total++)
@ -1305,7 +1305,7 @@ THREE_INTS(bitcoinrpc,listreceivedbyaddress,minconf,includeempty,flag)
jaddstr(item,"address",waddr->coinaddr);
txids = cJSON_CreateArray();
vouts = cJSON_CreateArray();
jaddnum(item,"amount",dstr(iguana_addressreceived(myinfo,coin,json,remoteaddr,txids,vouts,waddr->coinaddr,minconf)));
jaddnum(item,"amount",dstr(iguana_addressreceived(myinfo,coin,0,remoteaddr,txids,vouts,waddr->coinaddr,minconf)));
jadd(item,"txids",txids);
jadd(item,"vouts",vouts);
jaddi(array,item);
@ -1316,6 +1316,22 @@ THREE_INTS(bitcoinrpc,listreceivedbyaddress,minconf,includeempty,flag)
return(jprint(retjson,1));
}
STRING_AND_INT(bitcoinrpc,getreceivedbyaddress,address,minconf)
{
char *balancestr; cJSON *balancejson,*retjson = cJSON_CreateObject();
if ( (balancestr= iguana_balance(IGUANA_CALLARGS,coin->symbol,address,-1,minconf)) != 0 )
{
if ( (balancejson= cJSON_Parse(balancestr)) != 0 )
{
jaddnum(retjson,"result",dstr(jdouble(balancejson,"balance")));
free_json(balancejson);
}
}
if ( jobj(retjson,"result") == 0 )
jaddstr(retjson,"error","couldnt get received by address");
return(jprint(retjson,1));
}
TWO_INTS(bitcoinrpc,listaccounts,minconf,includewatchonly)
{
cJSON *retjson,*array; int64_t balance; struct iguana_waccount *wacct,*tmp;
@ -1338,12 +1354,6 @@ HASH_AND_TWOINTS(bitcoinrpc,listsinceblock,blockhash,target,flag)
return(jprint(retjson,1));
}
STRING_AND_INT(bitcoinrpc,getreceivedbyaddress,address,minconf)
{
cJSON *retjson = cJSON_CreateObject();
return(jprint(retjson,1));
}
INT_ARRAY_STRING(bitcoinrpc,createmultisig,M,pubkeys,ignore)
{
cJSON *retjson,*pkjson,*addresses; uint8_t script[2048],p2sh_rmd160[20]; char pubkeystr[256],msigaddr[64],*pkstr,scriptstr[sizeof(script)*2+1]; struct vin_info V; int32_t i,plen,len,n = cJSON_GetArraySize(pubkeys);

1
iguana/tests/getreceivedbyaddress

@ -0,0 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"method\":\"getreceivedbyaddress\",\"params\":[\"17outUgtsnLkguDuXm14tcQ7dMbdD8KZGK\"]}"

2
includes/iguana_apideclares.h

@ -97,7 +97,7 @@ TWO_STRINGS(iguana,persistent,activecoin,ipaddr);
TWO_STRINGS(iguana,removenode,activecoin,ipaddr);
TWO_STRINGS(iguana,oneshot,activecoin,ipaddr);
TWO_STRINGS(iguana,nodestatus,activecoin,ipaddr);
TWOSTRINGS_AND_INT(iguana,balance,activecoin,address,height);
TWO_STRINGS_AND_TWO_DOUBLES(iguana,balance,activecoin,address,heightd,minconfd);
P2SH_SPENDAPI(iguana,spendmsig,activecoin,vintxid,vinvout,destaddress,destamount,destaddress2,destamount2,M,N,pubA,wifA,pubB,wifB,pubC,wifC);
STRING_AND_INT(iguana,bundleaddresses,activecoin,height);
STRING_AND_INT(iguana,bundlehashes,activecoin,height);

Loading…
Cancel
Save