Browse Source

Merge pull request #507 from jl777/spvdex

fix electrum unspent reset
etomic
jl777 7 years ago
committed by GitHub
parent
commit
9996fd66f1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      iguana/exchanges/LP_ordermatch.c
  2. 2
      iguana/exchanges/LP_socket.c
  3. 3
      iguana/exchanges/LP_utxo.c

6
iguana/exchanges/LP_ordermatch.c

@ -281,13 +281,13 @@ int32_t LP_nearest_utxovalue(struct iguana_info *coin,char *coinaddr,struct LP_a
if ( (backupep= ep->prev) == 0 ) if ( (backupep= ep->prev) == 0 )
backupep = ep; backupep = ep;
} }
//printf("LP_nearest_utxovalue %s utxos[%d] target %.8f\n",coin->symbol,n,dstr(targetval)); printf("LP_nearest_utxovalue %s %s utxos[%d] target %.8f\n",coin->symbol,coinaddr,n,dstr(targetval));
for (i=0; i<n; i++) for (i=0; i<n; i++)
{ {
if ( (up= utxos[i]) != 0 ) if ( (up= utxos[i]) != 0 )
{ {
dist = (up->U.value - targetval); dist = (up->U.value - targetval);
//printf("nearest i.%d target %.8f val %.8f dist %.8f mindist %.8f mini.%d spent.%d\n",i,dstr(targetval),dstr(up->U.value),dstr(dist),dstr(mindist),mini,up->spendheight); printf("nearest i.%d target %.8f val %.8f dist %.8f mindist %.8f mini.%d spent.%d\n",i,dstr(targetval),dstr(up->U.value),dstr(dist),dstr(mindist),mini,up->spendheight);
if ( up->spendheight <= 0 ) if ( up->spendheight <= 0 )
{ {
if ( dist >= 0 && dist < mindist ) if ( dist >= 0 && dist < mindist )
@ -325,7 +325,7 @@ int32_t LP_nearest_utxovalue(struct iguana_info *coin,char *coinaddr,struct LP_a
return(replacei); return(replacei);
} }
} }
//printf("return mini.%d\n",mini); printf("return mini.%d\n",mini);
return(mini); return(mini);
} }

2
iguana/exchanges/LP_socket.c

@ -401,6 +401,8 @@ int32_t electrum_kickstart(struct electrum_info *ep)
return(0); return(0);
} }
int32_t zeroval();
cJSON *electrum_submit(char *symbol,struct electrum_info *ep,cJSON **retjsonp,char *method,char *params,int32_t timeout) cJSON *electrum_submit(char *symbol,struct electrum_info *ep,cJSON **retjsonp,char *method,char *params,int32_t timeout)
{ {
// queue id and string and callback // queue id and string and callback

3
iguana/exchanges/LP_utxo.c

@ -427,6 +427,7 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin)
{ {
struct LP_address *ap; struct LP_address_utxo *up,*tmp; int32_t i,n,m,vout,height; cJSON *array,*item,*txobj; int64_t value; bits256 txid; uint32_t now; struct LP_address *ap; struct LP_address_utxo *up,*tmp; int32_t i,n,m,vout,height; cJSON *array,*item,*txobj; int64_t value; bits256 txid; uint32_t now;
LP_address(coin,coin->smartaddr); LP_address(coin,coin->smartaddr);
printf("call listunspent issue %s (%s)\n",coin->symbol,coin->smartaddr);
LP_listunspent_issue(coin->symbol,coin->smartaddr,2); LP_listunspent_issue(coin->symbol,coin->smartaddr,2);
if ( (ap= LP_addressfind(coin,coin->smartaddr)) == 0 ) if ( (ap= LP_addressfind(coin,coin->smartaddr)) == 0 )
{ {
@ -454,7 +455,7 @@ struct LP_address *LP_address_utxo_reset(struct iguana_info *coin)
//{"tx_hash":"38d1b7c73015e1b1d6cb7fc314cae402a635b7d7ea294970ab857df8777a66f4","tx_pos":0,"height":577975,"value":238700} //{"tx_hash":"38d1b7c73015e1b1d6cb7fc314cae402a635b7d7ea294970ab857df8777a66f4","tx_pos":0,"height":577975,"value":238700}
item = jitem(array,i); item = jitem(array,i);
value = LP_listunspent_parseitem(coin,&txid,&vout,&height,item); value = LP_listunspent_parseitem(coin,&txid,&vout,&height,item);
if ( (txobj= LP_gettxout(coin->symbol,coin->symbol,txid,vout)) == 0 ) if ( (txobj= LP_gettxout(coin->symbol,coin->smartaddr,txid,vout)) == 0 )
continue; continue;
else free_json(txobj); else free_json(txobj);
LP_address_utxoadd(now,"withdraw",coin,coin->smartaddr,txid,vout,value,height,-1); LP_address_utxoadd(now,"withdraw",coin,coin->smartaddr,txid,vout,value,height,-1);

Loading…
Cancel
Save