jl777 7 years ago
parent
commit
e56abd4562
  1. 3
      iguana/exchanges/LP_include.h
  2. 16
      iguana/exchanges/LP_socket.c
  3. 6
      iguana/exchanges/LP_utxo.c

3
iguana/exchanges/LP_include.h

@ -302,8 +302,9 @@ struct LP_transaction *LP_transactionfind(struct iguana_info *coin,bits256 txid)
int32_t LP_transactioninit(struct iguana_info *coin,bits256 txid,int32_t iter);
int32_t LP_mempoolscan(char *symbol,bits256 searchtxid);
int32_t LP_txheight(struct iguana_info *coin,bits256 txid);
void LP_address_utxoadd(struct iguana_info *coin,char *coinaddr,bits256 txid,int32_t vout,uint64_t value,int32_t height,int32_t spendheight);
int32_t LP_address_utxoadd(struct iguana_info *coin,char *coinaddr,bits256 txid,int32_t vout,uint64_t value,int32_t height,int32_t spendheight);
cJSON *LP_address_utxos(struct iguana_info *coin,char *coinaddr,int32_t electrumret);
void LP_postutxos(int32_t pubsock,char *symbol);
#endif

16
iguana/exchanges/LP_socket.c

@ -304,9 +304,9 @@ struct electrum_info *electrum_server(char *symbol,struct electrum_info *ep)
return(ep);
}
void electrum_process_array(struct iguana_info *coin,char *coinaddr,cJSON *array)
int32_t electrum_process_array(struct iguana_info *coin,char *coinaddr,cJSON *array)
{
int32_t i,v,n; char str[65]; uint64_t value; bits256 txid; cJSON *item; struct LP_transaction *tx;
int32_t i,v,n,flag = 0; char str[65]; uint64_t value; bits256 txid; cJSON *item; struct LP_transaction *tx;
if ( array != 0 && coin != 0 && (n= cJSON_GetArraySize(array)) > 0 )
{
for (i=0; i<n; i++)
@ -333,13 +333,14 @@ void electrum_process_array(struct iguana_info *coin,char *coinaddr,cJSON *array
{
printf(">>>>>>>>>> set %s/v%d <- %.8f vs %.8f\n",bits256_str(str,txid),v,dstr(value),dstr(tx->outpoints[v].value));
tx->outpoints[v].value = value;
LP_address_utxoadd(coin,coinaddr,txid,v,value,tx->height,-1);
flag += LP_address_utxoadd(coin,coinaddr,txid,v,value,tx->height,-1);
}
}
printf("v.%d numvouts.%d %.8f (%s)\n",jint(item,"tx_pos"),tx->numvouts,dstr(tx->outpoints[jint(item,"tx_pos")].value),jprint(item,0));
}
}
}
return(flag);
}
cJSON *electrum_submit(char *symbol,struct electrum_info *ep,cJSON **retjsonp,char *method,char *params,int32_t timeout)
@ -452,7 +453,7 @@ cJSON *electrum_address_getmempool(char *symbol,struct electrum_info *ep,cJSON *
{
cJSON *retjson; struct iguana_info *coin = LP_coinfind(symbol);
retjson = electrum_strarg(symbol,ep,retjsonp,"blockchain.address.get_mempool",addr,ELECTRUM_TIMEOUT);
printf("MEMPOOL.(%s)\n",jprint(retjson,0));
//printf("MEMPOOL.(%s)\n",jprint(retjson,0));
electrum_process_array(coin,addr,retjson);
return(retjson);
}
@ -465,8 +466,9 @@ cJSON *electrum_address_listunspent(char *symbol,struct electrum_info *ep,cJSON
{
if ( (retjson= electrum_strarg(symbol,ep,retjsonp,"blockchain.address.listunspent",addr,ELECTRUM_TIMEOUT)) != 0 )
{
printf("LISTUNSPENT.(%s)\n",jprint(retjson,0));
electrum_process_array(coin,addr,retjson);
//printf("LISTUNSPENT.(%s)\n",jprint(retjson,0));
if ( electrum_process_array(coin,addr,retjson) != 0 )
LP_postutxos(LP_mypubsock,coin->symbol);
strcpy(coin->lastunspent,addr);
coin->unspenttime = (uint32_t)time(NULL);
}
@ -614,7 +616,7 @@ int32_t LP_recvfunc(struct electrum_info *ep,char *str,int32_t len)
if ( (strjson= cJSON_Parse(str)) != 0 )
{
resultjson = jobj(strjson,"result");
printf("strjson.(%s)\n",jprint(strjson,0));
//printf("strjson.(%s)\n",jprint(strjson,0));
if ( (method= jstr(strjson,"method")) != 0 )
{
if ( strcmp(method,"blockchain.headers.subscribe") == 0 )

6
iguana/exchanges/LP_utxo.c

@ -96,9 +96,9 @@ struct LP_address *LP_addressfind(struct iguana_info *coin,char *coinaddr)
return(ap);
}
void LP_address_utxoadd(struct iguana_info *coin,char *coinaddr,bits256 txid,int32_t vout,uint64_t value,int32_t height,int32_t spendheight)
int32_t LP_address_utxoadd(struct iguana_info *coin,char *coinaddr,bits256 txid,int32_t vout,uint64_t value,int32_t height,int32_t spendheight)
{
struct LP_address *ap; struct LP_address_utxo *up,*tmp; int32_t flag;
struct LP_address *ap; struct LP_address_utxo *up,*tmp; int32_t flag,retval = 0;
portable_mutex_lock(&coin->txmutex);
if ( (ap= _LP_address(coin,coinaddr)) != 0 )
{
@ -124,12 +124,14 @@ void LP_address_utxoadd(struct iguana_info *coin,char *coinaddr,bits256 txid,int
up->U.value = value;
up->spendheight = spendheight;
DL_APPEND(ap->utxos,up);
retval = 1;
//char str[65];
//if ( height > 0 )
// printf(">>>>>>>>>> %s %s %s/v%d ht.%d %.8f\n",coin->symbol,coinaddr,bits256_str(str,txid),vout,height,dstr(value));
}
}
portable_mutex_unlock(&coin->txmutex);
return(retval);
}
cJSON *LP_address_item(struct iguana_info *coin,struct LP_address_utxo *up,int32_t electrumret)

Loading…
Cancel
Save