Browse Source

Test

etomic
jl777 7 years ago
parent
commit
7923b76d43
  1. 10
      iguana/exchanges/LP_commands.c
  2. 2
      iguana/exchanges/LP_nativeDEX.c
  3. 56
      iguana/exchanges/LP_transaction.c
  4. 1
      iguana/exchanges/LP_utxos.c

10
iguana/exchanges/LP_commands.c

@ -103,7 +103,7 @@ notarizations(coin)\n\
parselog()\n\
statsdisp(starttime=0, endtime=0, gui="", pubkey="")\n\
getrawtransaction(coin, txid)\n\
inventory(coin)\n\
inventory(coin, reset=0)\n\
bestfit(rel, relvolume)\n\
lastnonce()\n\
buy(base, rel, price, relvolume, timeout=10, duration=3600, nonce, destpubkey="")\n\
@ -484,10 +484,12 @@ bot_resume(botid)\n\
struct iguana_info *ptr;
if ( (ptr= LP_coinfind(coin)) != 0 )
{
//privkey = LP_privkeycalc(ctx,pubkey33,&pubkey,ptr,"",USERPASS_WIFSTR);
//LP_utxopurge(0);
LP_address(ptr,ptr->smartaddr);
LP_listunspent_issue(coin,ptr->smartaddr,2);
if ( jint(argjson,"reset") != 0 )
{
LP_address_utxo_reset(ptr);
LP_passphrase_init(G.PASSPHRASE,G.gui);
}
if ( bits256_nonz(G.LP_privkey) != 0 )
LP_privkey_init(-1,ptr,G.LP_privkey,G.LP_mypub25519);
else printf("no LP_privkey\n");

2
iguana/exchanges/LP_nativeDEX.c

@ -122,7 +122,7 @@ struct LP_globals
uint8_t LP_myrmd160[20],LP_pubsecp[33];
uint32_t LP_sessionid,counter;
int32_t LP_IAMLP,LP_pendingswaps,USERPASS_COUNTER,LP_numprivkeys,initializing,waiting,LP_numskips;
char USERPASS[65],USERPASS_WIFSTR[64],LP_myrmd160str[41],gui[16];
char USERPASS[65],USERPASS_WIFSTR[64],PASSPHRASE[1024],LP_myrmd160str[41],gui[16];
struct LP_privkey LP_privkeys[100];
} G;

56
iguana/exchanges/LP_transaction.c

@ -999,10 +999,40 @@ int32_t LP_vins_select(void *ctx,struct iguana_info *coin,int64_t *totalp,int64_
return(n);
}
struct LP_address *LP_address_utxo_reset(struct iguana_info *coin)
{
struct LP_address *ap; int32_t i,n; cJSON *array,*item; int64_t value; bits256 txid; int32_t vout,height;
LP_listunspent_issue(coin->symbol,coin->smartaddr,2);
if ( (ap= LP_addressfind(coin,coin->smartaddr)) == 0 )
{
printf("LP_createrawtransaction: cant find address data\n");
return(0);
}
if ( (array= LP_listunspent(coin->symbol,coin->smartaddr)) != 0 )
{
ap->utxos = 0;
if ( (n= cJSON_GetArraySize(array)) > 0 )
{
for (i=0; i<n; i++)
{
//{"tx_hash":"38d1b7c73015e1b1d6cb7fc314cae402a635b7d7ea294970ab857df8777a66f4","tx_pos":0,"height":577975,"value":238700}
item = jitem(array,i);
txid = jbits256(item,"tx_hash");
vout = juint(item,"tx_pos");
value = j64bits(item,"value");
height = jint(item,"height");
LP_address_utxoadd("withdraw",coin,coin->smartaddr,txid,vout,value,height,-1);
}
}
free_json(array);
}
return(ap);
}
char *LP_createrawtransaction(cJSON **txobjp,int32_t *numvinsp,struct iguana_info *coin,struct vin_info *V,int32_t max,bits256 privkey,cJSON *outputs,cJSON *vins,cJSON *privkeys,int64_t txfee,bits256 utxotxid,int32_t utxovout,uint32_t locktime)
{
static void *ctx;
cJSON *txobj,*item,*array; uint8_t addrtype,rmd160[20],script[64],spendscript[256]; char *coinaddr,*rawtxbytes; bits256 txid; uint32_t timestamp; int64_t change=0,adjust=0,total,value,amount = 0; int32_t i,n,dustcombine,scriptlen,spendlen,suppress_pubkeys,ignore_cltverr,numvouts=0,numvins=0,numutxos=0; struct LP_address_utxo *utxos[LP_MAXVINS]; struct LP_address *ap;
cJSON *txobj,*item; uint8_t addrtype,rmd160[20],script[64],spendscript[256]; char *coinaddr,*rawtxbytes; bits256 txid; uint32_t timestamp; int64_t change=0,adjust=0,total,value,amount = 0; int32_t i,dustcombine,scriptlen,spendlen,suppress_pubkeys,ignore_cltverr,numvouts=0,numvins=0,numutxos=0; struct LP_address_utxo *utxos[LP_MAXVINS]; struct LP_address *ap;
if ( ctx == 0 )
ctx = bitcoin_ctx();
*numvinsp = 0;
@ -1047,31 +1077,9 @@ char *LP_createrawtransaction(cJSON **txobjp,int32_t *numvinsp,struct iguana_inf
return(0);
}
}
LP_listunspent_issue(coin->symbol,coin->smartaddr,2);
if ( (ap= LP_addressfind(coin,coin->smartaddr)) == 0 )
{
printf("LP_createrawtransaction: cant find address data\n");
if ( (ap= LP_address_utxo_reset(coin)) == 0 )
return(0);
}
memset(utxos,0,sizeof(utxos));
if ( (array= LP_listunspent(coin->symbol,coin->smartaddr)) != 0 )
{
int32_t vout,height;
ap->utxos = 0;
if ( (n= cJSON_GetArraySize(array)) > 0 )
{
for (i=0; i<n; i++)
{
//{"tx_hash":"38d1b7c73015e1b1d6cb7fc314cae402a635b7d7ea294970ab857df8777a66f4","tx_pos":0,"height":577975,"value":238700}
item = jitem(array,i);
txid = jbits256(item,"tx_hash");
vout = juint(item,"tx_pos");
value = j64bits(item,"value");
height = jint(item,"height");
LP_address_utxoadd("withdraw",coin,coin->smartaddr,txid,vout,value,height,-1);
}
}
}
if ( (numutxos= LP_address_utxo_ptrs(coin,0,utxos,max,ap,coin->smartaddr)) <= 0 )
{
printf("LP_createrawtransaction: address_utxo_ptrs %d, error\n",numutxos);

1
iguana/exchanges/LP_utxos.c

@ -870,6 +870,7 @@ int32_t LP_passphrase_init(char *passphrase,char *gui)
}
}
memset(&G,0,sizeof(G));
strcpy(G.PASSPHRASE,passphrase);
LP_privkey_updates(ctx,LP_mypubsock,passphrase);
init_hexbytes_noT(G.LP_myrmd160str,G.LP_myrmd160,20);
G.LP_sessionid = (uint32_t)time(NULL);

Loading…
Cancel
Save