Browse Source

Test

etomic
jl777 7 years ago
parent
commit
7ed99b955c
  1. 6
      iguana/exchanges/LP_rpc.c
  2. 36
      iguana/exchanges/LP_utxos.c

6
iguana/exchanges/LP_rpc.c

@ -383,7 +383,7 @@ cJSON *LP_getblockhashstr(char *symbol,char *blockhashstr)
cJSON *LP_listunspent(char *symbol,char *coinaddr) cJSON *LP_listunspent(char *symbol,char *coinaddr)
{ {
char buf[128]; struct iguana_info *coin = LP_coinfind(symbol); char buf[128]; cJSON *retjson; struct iguana_info *coin = LP_coinfind(symbol);
if ( coin == 0 ) if ( coin == 0 )
return(cJSON_Parse("{\"error\":\"no coin\"}")); return(cJSON_Parse("{\"error\":\"no coin\"}"));
if ( coin->electrum == 0 ) if ( coin->electrum == 0 )
@ -394,7 +394,9 @@ cJSON *LP_listunspent(char *symbol,char *coinaddr)
else else
{ {
sprintf(buf,"[\"%s\"]",coinaddr); sprintf(buf,"[\"%s\"]",coinaddr);
return(bitcoin_json(coin,"blockchain.address.listunspent",buf)); if ( (retjson= bitcoin_json(coin,"blockchain.address.listunspent",buf)) != 0 )
printf("LISTUNSPENT.(%s)\n",jprint(retjson,0));
return(retjson);
} }
} }

36
iguana/exchanges/LP_utxos.c

@ -808,7 +808,7 @@ int32_t LP_nearestvalue(int32_t iambob,uint64_t *values,int32_t n,uint64_t targe
uint64_t LP_privkey_init(int32_t mypubsock,struct iguana_info *coin,bits256 myprivkey,bits256 mypub) uint64_t LP_privkey_init(int32_t mypubsock,struct iguana_info *coin,bits256 myprivkey,bits256 mypub)
{ {
char *script; struct LP_utxoinfo *utxo; cJSON *array,*item; bits256 txid,deposittxid; int32_t used,i,n,iambob,vout,depositvout; uint64_t *values=0,satoshis,txfee,depositval,targetval,value,total = 0; char *script; struct LP_utxoinfo *utxo; cJSON *array,*item; bits256 txid,deposittxid; int32_t used,i,n,cmpflag,iambob,vout,depositvout; uint64_t *values=0,satoshis,txfee,depositval,targetval,value,total = 0;
if ( coin == 0 ) if ( coin == 0 )
{ {
printf("coin not active\n"); printf("coin not active\n");
@ -831,6 +831,8 @@ uint64_t LP_privkey_init(int32_t mypubsock,struct iguana_info *coin,bits256 mypr
for (i=0; i<n; i++) for (i=0; i<n; i++)
{ {
item = jitem(array,i); item = jitem(array,i);
if ( coin->electrum == 0 )
{
satoshis = SATOSHIDEN * jdouble(item,"amount"); satoshis = SATOSHIDEN * jdouble(item,"amount");
if ( satoshis == 0 ) if ( satoshis == 0 )
satoshis = SATOSHIDEN * jdouble(item,"value"); satoshis = SATOSHIDEN * jdouble(item,"value");
@ -839,6 +841,17 @@ uint64_t LP_privkey_init(int32_t mypubsock,struct iguana_info *coin,bits256 mypr
//printf("%s\n",jprint(item,0)); //printf("%s\n",jprint(item,0));
values[i] = satoshis; values[i] = satoshis;
} else used++; } else used++;
}
else
{
//{"value":1000000,"tx_hash":"4e4f818c53486c0576693b4cd379849e5ff95538b38e4100f48884073a4e7636","tx_pos":0,"height":484877}
satoshis = j64bits(item,"value");
if ( LP_inventory_prevent(iambob,jbits256(item,"tx_hash"),juint(item,"tx_pos")) == 0 && jint(item,"height") < coin->height )
{
printf("%s\n",jprint(item,0));
values[i] = satoshis;
} else used++;
}
//printf("%.8f ",dstr(satoshis)); //printf("%.8f ",dstr(satoshis));
} }
//printf("array.%d\n",n); //printf("array.%d\n",n);
@ -850,9 +863,18 @@ uint64_t LP_privkey_init(int32_t mypubsock,struct iguana_info *coin,bits256 mypr
if ( (i= LP_maxvalue(values,n)) >= 0 ) if ( (i= LP_maxvalue(values,n)) >= 0 )
{ {
item = jitem(array,i); item = jitem(array,i);
if ( coin->electrum == 0 )
{
deposittxid = jbits256(item,"txid"); deposittxid = jbits256(item,"txid");
depositvout = juint(item,"vout"); depositvout = juint(item,"vout");
script = jstr(item,"scriptPubKey"); script = jstr(item,"scriptPubKey");
}
else
{
deposittxid = jbits256(item,"tx_hash");
depositvout = juint(item,"tx_pos");
script = coin->smartaddr;
}
depositval = values[i]; depositval = values[i];
values[i] = 0, used++; values[i] = 0, used++;
if ( iambob == 0 ) if ( iambob == 0 )
@ -872,9 +894,21 @@ uint64_t LP_privkey_init(int32_t mypubsock,struct iguana_info *coin,bits256 mypr
if ( i >= 0 || (i= LP_nearestvalue(iambob,values,n,targetval)) >= 0 ) if ( i >= 0 || (i= LP_nearestvalue(iambob,values,n,targetval)) >= 0 )
{ {
item = jitem(array,i); item = jitem(array,i);
cmpflag = 0;
if ( coin->electrum == 0 )
{
txid = jbits256(item,"txid"); txid = jbits256(item,"txid");
vout = juint(item,"vout"); vout = juint(item,"vout");
if ( jstr(item,"scriptPubKey") != 0 && strcmp(script,jstr(item,"scriptPubKey")) == 0 ) if ( jstr(item,"scriptPubKey") != 0 && strcmp(script,jstr(item,"scriptPubKey")) == 0 )
cmpflag = 1;
}
else
{
txid = jbits256(item,"tx_hash");
vout = juint(item,"tx_pos");
cmpflag = 1;
}
if ( cmpflag != 0 )
{ {
value = values[i]; value = values[i];
values[i] = 0, used++; values[i] = 0, used++;

Loading…
Cancel
Save