|
|
@ -525,10 +525,24 @@ cJSON *electrum_address_subscribe(char *symbol,struct electrum_info *ep,cJSON ** |
|
|
|
return(retjson); |
|
|
|
} |
|
|
|
|
|
|
|
cJSON *electrum_scripthash_cmd(char *symbol,uint8_t taddr,struct electrum_info *ep,cJSON **retjsonp,char *cmd,char *coinaddr) |
|
|
|
{ |
|
|
|
uint8_t addrtype,rmd160[20]; char scripthash[51],rmdstr[41],cmdbuf[128]; |
|
|
|
bitcoin_addr2rmd160(symbol,taddr,&addrtype,rmd160,coinaddr); |
|
|
|
init_hexbytes_noT(rmdstr,rmd160,20); |
|
|
|
sprintf(scripthash,"76a914%s88ac",rmdstr); |
|
|
|
sprintf(cmdbuf,"blockchain.scripthash.%s",cmd); |
|
|
|
return(electrum_strarg(symbol,ep,retjsonp,cmdbuf,scripthash,ELECTRUM_TIMEOUT)); |
|
|
|
} |
|
|
|
|
|
|
|
cJSON *electrum_address_gethistory(char *symbol,struct electrum_info *ep,cJSON **retjsonp,char *addr,bits256 reftxid) |
|
|
|
{ |
|
|
|
char str[65]; struct LP_transaction *tx; cJSON *retjson,*txobj,*item; int32_t i,n,height; bits256 txid; struct iguana_info *coin = LP_coinfind(symbol); |
|
|
|
retjson = electrum_strarg(symbol,ep,retjsonp,"blockchain.address.get_history",addr,ELECTRUM_TIMEOUT); |
|
|
|
if ( coin == 0 ) |
|
|
|
return(0); |
|
|
|
if ( strcmp(symbol,"BCH") == 0 ) |
|
|
|
retjson = electrum_scripthash_cmd(symbol,coin->taddr,ep,retjsonp,"get_history",addr); |
|
|
|
else retjson = electrum_strarg(symbol,ep,retjsonp,"blockchain.address.get_history",addr,ELECTRUM_TIMEOUT); |
|
|
|
//printf("history.(%s)\n",jprint(retjson,0));
|
|
|
|
if ( retjson != 0 && (n= cJSON_GetArraySize(retjson)) > 0 ) |
|
|
|
{ |
|
|
@ -574,7 +588,11 @@ int32_t LP_txheight_check(struct iguana_info *coin,char *coinaddr,bits256 txid) |
|
|
|
cJSON *electrum_address_getmempool(char *symbol,struct electrum_info *ep,cJSON **retjsonp,char *addr,bits256 reftxid,bits256 reftxid2) |
|
|
|
{ |
|
|
|
cJSON *retjson; struct iguana_info *coin = LP_coinfind(symbol); |
|
|
|
retjson = electrum_strarg(symbol,ep,retjsonp,"blockchain.address.get_mempool",addr,ELECTRUM_TIMEOUT); |
|
|
|
if ( coin == 0 ) |
|
|
|
return(0); |
|
|
|
if ( strcmp(symbol,"BCH") == 0 ) |
|
|
|
retjson = electrum_scripthash_cmd(symbol,coin->taddr,ep,retjsonp,"get_mempool",addr); |
|
|
|
else retjson = electrum_strarg(symbol,ep,retjsonp,"blockchain.address.get_mempool",addr,ELECTRUM_TIMEOUT); |
|
|
|
//printf("MEMPOOL.(%s)\n",jprint(retjson,0));
|
|
|
|
electrum_process_array(coin,ep,addr,retjson,1,reftxid,reftxid2); |
|
|
|
return(retjson); |
|
|
@ -601,7 +619,10 @@ cJSON *electrum_address_listunspent(char *symbol,struct electrum_info *ep,cJSON |
|
|
|
} |
|
|
|
if ( usecache == 0 || electrumflag > 1 ) |
|
|
|
{ |
|
|
|
if ( (retjson= electrum_strarg(symbol,ep,retjsonp,"blockchain.address.listunspent",addr,ELECTRUM_TIMEOUT)) != 0 ) |
|
|
|
if ( strcmp(symbol,"BCH") == 0 ) |
|
|
|
retjson = electrum_scripthash_cmd(symbol,coin->taddr,ep,retjsonp,"listunspent",addr); |
|
|
|
else retjson = electrum_strarg(symbol,ep,retjsonp,"blockchain.address.listunspent",addr,ELECTRUM_TIMEOUT); |
|
|
|
if ( retjson != 0 ) |
|
|
|
{ |
|
|
|
if ( jobj(retjson,"error") == 0 && is_cJSON_Array(retjson) != 0 ) |
|
|
|
{ |
|
|
@ -642,7 +663,9 @@ cJSON *electrum_address_listunspent(char *symbol,struct electrum_info *ep,cJSON |
|
|
|
|
|
|
|
cJSON *electrum_address_getbalance(char *symbol,struct electrum_info *ep,cJSON **retjsonp,char *addr) |
|
|
|
{ |
|
|
|
return(electrum_strarg(symbol,ep,retjsonp,"blockchain.address.get_balance",addr,ELECTRUM_TIMEOUT)); |
|
|
|
if ( strcmp(symbol,"BCH") == 0 ) |
|
|
|
return(electrum_scripthash_cmd(symbol,0,ep,retjsonp,"get_balance",addr)); |
|
|
|
else return(electrum_strarg(symbol,ep,retjsonp,"blockchain.address.get_balance",addr,ELECTRUM_TIMEOUT)); |
|
|
|
} |
|
|
|
|
|
|
|
cJSON *electrum_addpeer(char *symbol,struct electrum_info *ep,cJSON **retjsonp,char *endpoint) { return(electrum_strarg(symbol,ep,retjsonp,"server.add_peer",endpoint,ELECTRUM_TIMEOUT)); } |
|
|
@ -750,6 +773,8 @@ cJSON *electrum_transaction(int32_t *heightp,char *symbol,struct electrum_info * |
|
|
|
{ |
|
|
|
cJSON *retjson,*array; bits256 zero; struct LP_transaction *tx=0; struct iguana_info *coin; |
|
|
|
coin = LP_coinfind(symbol); |
|
|
|
if ( coin == 0 ) |
|
|
|
return(0); |
|
|
|
*heightp = 0; |
|
|
|
if ( ep != 0 ) |
|
|
|
portable_mutex_lock(&ep->txmutex); |
|
|
|