|
|
@ -617,15 +617,49 @@ TWO_STRINGS(dex,listunspent,symbol,address) |
|
|
|
{ |
|
|
|
if ( symbol != 0 && strcmp(symbol,"BTC") == 0 && (coin= iguana_coinfind("BTC")) != 0 && coin->FULLNODE == 0 && myinfo->IAMLP != 0 ) |
|
|
|
{ |
|
|
|
char url[1024],*retstr; int32_t n; cJSON *retjson,*data; |
|
|
|
char url[1024],*retstr,*coinaddr,*script; int32_t i,n,vout; cJSON *retjson,*data,*item,*item3,*data3; bits256 txid; uint64_t val; |
|
|
|
sprintf(url,"https://api.blocktrail.com/v1/btc/address/%s/unspent-outputs?api_key=%s",address,myinfo->blocktrail_apikey); |
|
|
|
if ( (retstr= issue_curl(url)) != 0 ) |
|
|
|
{ |
|
|
|
if ( (retjson= cJSON_Parse(retstr)) != 0 ) |
|
|
|
{ |
|
|
|
data = jarray(&n,retjson,"data"); |
|
|
|
data3 = cJSON_CreateArray(); |
|
|
|
//[{"hash":"e0a40dac21103e92e0dc9311a0233640489afc5beb5ba3b009848a8e9151dc55","time":"2017-02-21T16:48:28+0000","confirmations":1,"is_coinbase":false,"value":4100000,"index":1,"address":"19rjYdJtRN3qoammX3r1gxy9bvh8p8DmRc","type":"pubkeyhash","multisig":null,"script":"OP_DUP OP_HASH160 6128e7459989d35d530bcd4066c9aaf1f925430a OP_EQUALVERIFY OP_CHECKSIG","script_hex":"76a9146128e7459989d35d530bcd4066c9aaf1f925430a88ac"}]
|
|
|
|
/*{
|
|
|
|
"txid" : "e95d3083baf733dfda2fcd1110fe2937cb3580f8b1b237aad547528440dfa873", |
|
|
|
"vout" : 1, |
|
|
|
"address" : "RNgdefRo2iRLWqDXEogJrsTw35MgDPQP4R", |
|
|
|
"account" : "", |
|
|
|
"scriptPubKey" : "76a91493088c5f3546225e0ef6ba9c9c6a74d4c2df877388ac", |
|
|
|
"amount" : 150.00000000, |
|
|
|
"interest" : 0.30000000, |
|
|
|
"confirmations" : 20599, |
|
|
|
"spendable" : true |
|
|
|
}*/ |
|
|
|
for (i=0; i<n; i++) |
|
|
|
{ |
|
|
|
item = jitem(data,i); |
|
|
|
txid = jbits256(item,"hash"); |
|
|
|
vout = jint(item,"index"); |
|
|
|
val = j64bits(item,"value"); |
|
|
|
coinaddr = jstr(item,"address"); |
|
|
|
script = jstr(item,"script_hex"); |
|
|
|
item3 = cJSON_CreateObject(); |
|
|
|
jaddbits256(item3,"txid",txid); |
|
|
|
jaddnum(item3,"vout",vout); |
|
|
|
jaddnum(item3,"amount",dstr(val)); |
|
|
|
jaddnum(item3,"value",dstr(val)); |
|
|
|
if ( coinaddr != 0 ) |
|
|
|
jaddstr(item3,"address",coinaddr); |
|
|
|
if ( script != 0 ) |
|
|
|
jaddstr(item3,"scriptPubKey",script); |
|
|
|
jaddnum(item3,"confirmations",jint(item,"confirmations")); |
|
|
|
jadd(item3,"spendable",jtrue()); |
|
|
|
jaddi(data3,item3); |
|
|
|
} |
|
|
|
free(retstr); |
|
|
|
retstr = jprint(data,0); |
|
|
|
retstr = jprint(data3,1); |
|
|
|
free_json(retjson); |
|
|
|
} |
|
|
|
return(retstr); |
|
|
|