Browse Source

Test

etomic
jl777 7 years ago
parent
commit
5ec88a2e15
  1. 2
      iguana/exchanges/LP_rpc.c
  2. 10
      iguana/exchanges/LP_scan.c
  3. 9
      iguana/exchanges/LP_transaction.c

2
iguana/exchanges/LP_rpc.c

@ -326,7 +326,7 @@ cJSON *LP_gettxout(char *symbol,bits256 txid,int32_t vout)
"coinbase": false "coinbase": false
}*/ }*/
if ( value != j64bits(item,"value") ) if ( value != j64bits(item,"value") )
printf("value %llu != %llu\n",(long long)value,(long long)j64bits(item,"value")); printf("LP_gettxout: value %llu != %llu\n",(long long)value,(long long)j64bits(item,"value"));
jaddnum(retjson,"value",dstr(value)); jaddnum(retjson,"value",dstr(value));
jaddbits256(retjson,"txid",t); jaddbits256(retjson,"txid",t);
jaddnum(retjson,"vout",v); jaddnum(retjson,"vout",v);

10
iguana/exchanges/LP_scan.c

@ -78,13 +78,18 @@ int32_t LP_undospends(struct iguana_info *coin,int32_t lastheight)
uint64_t LP_txinterestvalue(uint64_t *interestp,char *destaddr,struct iguana_info *coin,bits256 txid,int32_t vout) uint64_t LP_txinterestvalue(uint64_t *interestp,char *destaddr,struct iguana_info *coin,bits256 txid,int32_t vout)
{ {
uint64_t interest,value = 0; cJSON *txobj,*sobj,*array; int32_t n=0; uint64_t interest,value = 0; double val; cJSON *txobj,*sobj,*array; int32_t n=0;
*interestp = 0; *interestp = 0;
destaddr[0] = 0; destaddr[0] = 0;
if ( (txobj= LP_gettxout(coin->symbol,txid,vout)) != 0 ) if ( (txobj= LP_gettxout(coin->symbol,txid,vout)) != 0 )
{ {
// GETTXOUT.({"value":0.01200000,"txid":"6f5adfefad102e39f62a6bacb222ebace6ce5c084116c08a62cac1182729dd46","vout":1,"scriptPubkey":{"reqSigs":1,"type":"pubkey","addresses":["19Cq6MBaD8LY7trqs99ypqKAms3GcLs6J9"]}}) // GETTXOUT.({"value":0.01200000,"txid":"6f5adfefad102e39f62a6bacb222ebace6ce5c084116c08a62cac1182729dd46","vout":1,"scriptPubkey":{"reqSigs":1,"type":"pubkey","addresses":["19Cq6MBaD8LY7trqs99ypqKAms3GcLs6J9"]}})
if ( (value= jdouble(txobj,"amount")*SATOSHIDEN) == 0 && (value= jdouble(txobj,"value")*SATOSHIDEN) == 0 ) if ( (val= jdouble(txobj,"amount")) < SMALLVAL )
val = jdouble(txobj,"value");
if ( val > SMALLVAL )
value = (val * SATOSHIDEN + 0.0000000049);
else value = 0;
if ( value == 0 )
{ {
char str[65]; printf("%s LP_txvalue.%s strange utxo.(%s) vout.%d\n",coin->symbol,bits256_str(str,txid),jprint(txobj,0),vout); char str[65]; printf("%s LP_txvalue.%s strange utxo.(%s) vout.%d\n",coin->symbol,bits256_str(str,txid),jprint(txobj,0),vout);
} }
@ -99,6 +104,7 @@ uint64_t LP_txinterestvalue(uint64_t *interestp,char *destaddr,struct iguana_inf
if ( (sobj= jobj(txobj,"scriptPubKey")) != 0 && (array= jarray(&n,sobj,"addresses")) != 0 ) if ( (sobj= jobj(txobj,"scriptPubKey")) != 0 && (array= jarray(&n,sobj,"addresses")) != 0 )
{ {
strcpy(destaddr,jstri(array,0)); strcpy(destaddr,jstri(array,0));
printf("set destaddr.(%s)\n",destaddr);
if ( n > 1 ) if ( n > 1 )
printf("LP_txinterestvalue warning: violation of 1 output assumption n.%d\n",n); printf("LP_txinterestvalue warning: violation of 1 output assumption n.%d\n",n);
} else printf("LP_txinterestvalue no addresses found?\n"); } else printf("LP_txinterestvalue no addresses found?\n");

9
iguana/exchanges/LP_transaction.c

@ -1073,7 +1073,7 @@ int32_t basilisk_bobdeposit_refund(struct basilisk_swap *swap,int32_t delay)
void LP_swap_coinaddr(struct iguana_info *coin,char *coinaddr,uint64_t *valuep,uint8_t *data,int32_t datalen,int32_t v) void LP_swap_coinaddr(struct iguana_info *coin,char *coinaddr,uint64_t *valuep,uint8_t *data,int32_t datalen,int32_t v)
{ {
cJSON *txobj,*vouts,*vout,*addresses,*item,*skey; uint8_t extraspace[32768]; bits256 signedtxid; struct iguana_msgtx msgtx; char *addr; int32_t n,m,suppress_pubkeys = 0; cJSON *txobj,*vouts,*vout,*addresses,*item,*skey; uint8_t extraspace[32768]; bits256 signedtxid; struct iguana_msgtx msgtx; char *addr; double val; int32_t n,m,suppress_pubkeys = 0;
if ( valuep != 0 ) if ( valuep != 0 )
*valuep = 0; *valuep = 0;
if ( (txobj= bitcoin_data2json(coin->taddr,coin->pubtype,coin->p2shtype,coin->isPoS,coin->longestchain,&signedtxid,&msgtx,extraspace,sizeof(extraspace),data,datalen,0,suppress_pubkeys)) != 0 ) if ( (txobj= bitcoin_data2json(coin->taddr,coin->pubtype,coin->p2shtype,coin->isPoS,coin->longestchain,&signedtxid,&msgtx,extraspace,sizeof(extraspace),data,datalen,0,suppress_pubkeys)) != 0 )
@ -1084,8 +1084,11 @@ void LP_swap_coinaddr(struct iguana_info *coin,char *coinaddr,uint64_t *valuep,u
vout = jitem(vouts,v); vout = jitem(vouts,v);
if ( valuep != 0 ) if ( valuep != 0 )
{ {
if ( (*valuep= SATOSHIDEN * jdouble(vout,"value")) == 0 ) *valuep = 0;
*valuep= SATOSHIDEN * jdouble(vout,"amount"); if ( (val= jdouble(vout,"value")) < SMALLVAL )
val = jdouble(vout,"amount");
if ( val > SMALLVAL )
*valuep = (val * SATOSHIDEN + 0.0000000049);
} }
//printf("VOUT.(%s)\n",jprint(vout,0)); //printf("VOUT.(%s)\n",jprint(vout,0));
if ( (skey= jobj(vout,"scriptPubKey")) != 0 && (addresses= jarray(&m,skey,"addresses")) != 0 ) if ( (skey= jobj(vout,"scriptPubKey")) != 0 && (addresses= jarray(&m,skey,"addresses")) != 0 )

Loading…
Cancel
Save