Browse Source

do_autofill_merge queued

pass-iguana-arg
jl777 7 years ago
parent
commit
b90399c8fb
  1. 2
      iguana/exchanges/LP_include.h
  2. 24
      iguana/exchanges/LP_nativeDEX.c
  3. 22
      iguana/exchanges/LP_ordermatch.c

2
iguana/exchanges/LP_include.h

@ -303,7 +303,7 @@ struct iguana_info
{
UT_hash_handle hh;
portable_mutex_t txmutex,addrmutex,addressutxo_mutex; struct LP_transaction *transactions; struct LP_address *addresses;
uint64_t txfee;
uint64_t txfee,do_autofill_merge;
int32_t numutxos,notarized,longestchain,firstrefht,firstscanht,lastscanht,height; uint16_t busport,did_addrutxo_reset;
uint32_t txversion,dPoWtime,lastautosplit,lastresetutxo,loadedcache,electrumlist,lastunspent,importedprivkey,lastpushtime,lastutxosync,addr_listunspent_requested,lastutxos,updaterate,counter,inactive,lastmempool,lastgetinfo,ratetime,heighttime,lastmonitor,obooktime;
uint8_t pubtype,p2shtype,isPoS,wiftype,wiftaddr,taddr,noimportprivkey_flag,userconfirms,isassetchain,maxconfirms;

24
iguana/exchanges/LP_nativeDEX.c

@ -513,7 +513,7 @@ void command_rpcloop(void *ctx)
void LP_coinsloop(void *_coins)
{
static int32_t didfilescreate;
struct LP_address *ap=0; struct LP_transaction *tx; cJSON *retjson; struct LP_address_utxo *up,*tmp; struct iguana_info *coin,*ctmp; char str[65]; struct electrum_info *ep,*backupep=0; bits256 zero; int32_t notarized,oldht,j,nonz; char *coins = _coins;
struct LP_address *ap=0; struct LP_transaction *tx; cJSON *retjson; struct LP_address_utxo *up,*tmp; struct iguana_info *coin,*ctmp; char str[65],*retstr,*hexstr,*txidstr; struct electrum_info *ep,*backupep=0; bits256 zero; int32_t notarized,oldht,j,nonz; char *coins = _coins;
if ( strcmp("BTC",coins) == 0 )
{
strcpy(LP_coinsloopBTC_stats.name,"BTC coin loop");
@ -576,6 +576,28 @@ void LP_coinsloop(void *_coins)
LP_address_utxo_reset(&num,coin);
coin->did_addrutxo_reset = 1;
}
if ( coin->do_autofill_merge != 0 )
{
if ( (retstr= LP_autofillbob(coin,coin->do_autofill_merge*1.02)) != 0 )
{
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
if ( (hexstr= jstr(retjson,"hex")) != 0 )
{
if ( (txidstr= LP_sendrawtransaction(coin->symbol,hexstr,0)) != 0 )
{
printf("autofill created %s\n",txidstr);
free(txidstr);
coin->do_autofill_merge = 0;
coin->fillsatoshis = satoshis;
coin->bobfillheight = LP_getheight(&notarized,coin);
}
}
free_json(retjson);
}
free(retstr);
}
}
if ( coin->longestchain == 1 ) // special init value
coin->longestchain = LP_getheight(&notarized,coin);
if ( (ep= coin->electrum) != 0 )

22
iguana/exchanges/LP_ordermatch.c

@ -1163,26 +1163,10 @@ printf("bob %s received REQUEST.(%s) mpnet.%d fill.%d gtc.%d\n",bits256_str(str,
{
LP_address_utxo_reset(&num,coin);
satoshis = LP_basesatoshis(dstr(qp->destsatoshis),price,qp->txfee,qp->desttxfee) + 3*qp->txfee;
if ( LP_getheight(&notarized,coin) > coin->bobfillheight+3 && fabs(coin->fillsatoshis - satoshis)/satoshis > 0.1 )
if ( LP_getheight(&notarized,coin) > coin->bobfillheight+3 && fabs((double)coin->fillsatoshis - satoshis)/satoshis > 0.1 )
{
if ( (retstr= LP_autofillbob(coin,satoshis*1.02)) != 0 )
{
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
if ( (hexstr= jstr(retjson,"hex")) != 0 )
{
if ( (txidstr= LP_sendrawtransaction(coin->symbol,hexstr,0)) != 0 )
{
printf("autofill created %s\n",txidstr);
free(txidstr);
coin->fillsatoshis = satoshis;
coin->bobfillheight = LP_getheight(&notarized,coin);
}
}
free_json(retjson);
}
free(retstr);
}
printf("queue up do_autofill_merge %.8f\n",dstr(satoshis));
coin->do_autofill_merge = satoshis;
}
}
return(0);

Loading…
Cancel
Save