Browse Source

test

release/v0.1
jl777 8 years ago
committed by Christopher Valerio
parent
commit
8ddb3dca5a
  1. 11
      iguana/iguana_payments.c
  2. 27
      iguana/iguana_realtime.c
  3. 9
      iguana/iguana_spendvectors.c
  4. 10
      iguana/iguana_unspents.c
  5. 2
      iguana/tests/decoderawtransaction
  6. 2
      iguana/tests/signrawtransaction
  7. 2
      includes/iguana_funcs.h
  8. 2
      includes/iguana_structs.h

11
iguana/iguana_payments.c

@ -218,7 +218,7 @@ cJSON *iguana_inputjson(bits256 txid,int32_t vout,uint8_t *spendscript,int32_t s
cJSON *iguana_RTinputsjson(struct supernet_info *myinfo,struct iguana_info *coin,uint64_t *totalp,uint64_t amount,struct iguana_outpoint *unspents,int32_t num)
{
cJSON *vins; uint8_t spendscript[IGUANA_MAXSCRIPTSIZE]; struct iguana_txid *T; struct iguana_unspent *U,*u; struct iguana_bundle *bp; struct iguana_ramchain *ramchain; char coinaddr[64]; int32_t vout,height,abovei,belowi,i,spendlen,ind; uint32_t txidind; struct iguana_ramchaindata *rdata; bits256 txid; int64_t above,below,total = 0,remains = amount; struct iguana_outpoint outpt,outpt2; //uint64_t RTspent;
struct iguana_outpoint outpt; cJSON *vins; int32_t abovei,belowi,i,ind; int64_t above,below,total = 0,remains = amount;
*totalp = 0;
vins = cJSON_CreateArray();
for (i=0; i<num; i++)
@ -235,6 +235,13 @@ cJSON *iguana_RTinputsjson(struct supernet_info *myinfo,struct iguana_info *coin
else ind = belowi;
outpt = unspents[ind];
memset(&unspents[ind],0,sizeof(unspents[ind]));
jaddi(vins,iguana_inputjson(outpt.txid,outpt.vout,outpt.spendscript,outpt.spendlen));
total += outpt.value;
remains -= outpt.value;
//printf("%s value %.8f -> remains %.8f\n",coinaddr,dstr(value),dstr(remains));
if ( remains <= 0 )
break;
/*continue;
if ( coin->FULLNODE == 0 && coin->VALIDATENODE == 0 )
{
if ( (spendlen= basilisk_unspentfind(myinfo,coin,&txid,&vout,spendscript,outpt,outpt.value)) > 0 )
@ -302,7 +309,7 @@ cJSON *iguana_RTinputsjson(struct supernet_info *myinfo,struct iguana_info *coin
printf("%s illegal unspentind.u%d [%d]\n",coin->symbol,outpt.unspentind,outpt.hdrsi);
free_json(vins);
return(0);
}
}*/
}
*totalp = total;
return(vins);

27
iguana/iguana_realtime.c

@ -838,25 +838,18 @@ int32_t iguana_RTunspentindfind(struct supernet_info *myinfo,struct iguana_info
}
}
int32_t iguana_outptset(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_outpoint *outpt,bits256 txid,int32_t vout)
int32_t iguana_outptset(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_outpoint *outpt,bits256 txid,int32_t vout,int64_t value,char *spendscriptstr)
{
int32_t scriptlen,height; uint64_t RTspend; char coinaddr[64]; uint64_t value = 0; struct iguana_RTtxid *RTptr;
int32_t spendlen;
memset(outpt,0,sizeof(*outpt));
HASH_FIND(hh,coin->RTdataset,txid.bytes,sizeof(txid),RTptr);
if ( RTptr != 0 )
{
outpt->isptr = 1;
outpt->ptr = RTptr;
}
else
{
if ( (outpt->unspentind= iguana_unspentindfind(myinfo,coin,&RTspend,coinaddr,0,&scriptlen,&value,&height,txid,vout,coin->bundlescount-1,0)) != 0 )
{
outpt->hdrsi = (height / coin->chain->bundlesize);
if ( outpt->value == 0 )
outpt->value = (value == 0) ? RTspend : value;
} else return(-1);
}
spendlen = (int32_t)strlen(spendscriptstr) >> 1;
if ( spendlen > sizeof(outpt->spendscript) )
return(-1);
outpt->spendlen = spendlen;
decode_hex(outpt->spendscript,spendlen,spendscriptstr);
outpt->txid = txid;
outpt->vout = vout;
outpt->value = value;
return(0);
}

9
iguana/iguana_spendvectors.c

@ -843,7 +843,14 @@ int32_t iguana_balanceflush(struct supernet_info *myinfo,struct iguana_info *coi
Aptr = 0;
Uptr = 0;
numunspents = numpkinds = 0;
if ( (bp= coin->bundles[hdrsi]) != 0 && bp->ramchain.H.data != 0 && (numpkinds= bp->ramchain.H.data->numpkinds) > 0 && (numunspents= bp->ramchain.H.data->numunspents) > 0 && (Aptr= bp->ramchain.A2) != 0 && (Uptr= bp->ramchain.Uextras) != 0 )
if ( (bp= coin->bundles[hdrsi]) == 0 )
continue;
if ( iter == 0 )
{
iguana_volatilespurge(coin,&bp->ramchain);
iguana_volatilesalloc(coin,&bp->ramchain,1);
}
if ( bp != 0 && bp->ramchain.H.data != 0 && (numpkinds= bp->ramchain.H.data->numpkinds) > 0 && (numunspents= bp->ramchain.H.data->numunspents) > 0 && (Aptr= bp->ramchain.A2) != 0 && (Uptr= bp->ramchain.Uextras) != 0 )
{
sprintf(fname,"%s/%s/debits.%d_N%d",GLOBAL_TMPDIR,coin->symbol,bp->hdrsi,numhdrsi);
sprintf(fname2,"%s/%s/lastspends.%d_N%d",GLOBAL_TMPDIR,coin->symbol,bp->hdrsi,numhdrsi);

10
iguana/iguana_unspents.c

@ -951,7 +951,7 @@ cJSON *iguana_RTlistunspent(struct supernet_info *myinfo,struct iguana_info *coi
int32_t iguana_RTunspentslists(struct supernet_info *myinfo,struct iguana_info *coin,uint64_t *totalp,struct iguana_outpoint *unspents,int32_t max,uint64_t required,int32_t minconf,cJSON *addresses,char *remoteaddr)
{
uint64_t sum = 0; int32_t i,n,numunspents,numaddrs; uint8_t pubkey[65]; char *coinaddr; struct iguana_outpoint outpt; cJSON *array,*item; //struct iguana_waddress *waddr; struct iguana_waccount *wacct;
uint64_t sum = 0; int32_t i,n,numunspents,numaddrs; uint8_t pubkey[65]; char *coinaddr,*spendscriptstr; struct iguana_outpoint outpt; cJSON *array,*item;
*totalp = 0;
numunspents = 0;
if ( (numaddrs= cJSON_GetArraySize(addresses)) == 0 )
@ -980,8 +980,12 @@ int32_t iguana_RTunspentslists(struct supernet_info *myinfo,struct iguana_info *
for (i=0; i<n; i++)
{
item = jitem(array,i);
iguana_outptset(myinfo,coin,&outpt,jbits256(item,"txid"),jint(item,"vout"));
outpt.value = jdouble(item,"amount") * SATOSHIDEN;
if ( (spendscriptstr= jstr(item,"scriptPubKey")) == 0 )
{
printf("no spendscriptstr.(%s)\n",jprint(item,0));
continue;
}
iguana_outptset(myinfo,coin,&outpt,jbits256(item,"txid"),jint(item,"vout"),jdouble(item,"amount") * SATOSHIDEN,spendscriptstr);
*unspents = outpt;
sum += outpt.value;
printf("ITEM.(%s) %.8f\n",jprint(item,0),dstr(outpt.value));

2
iguana/tests/decoderawtransaction

@ -1 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"decoderawtransaction\",\"params\":[\"010000007b9bce5701005c445e7ca6abe0b172178084d3b35771250da81e5c203784530907983f3ecb01000000fd0000ffffffff02bcf60100000000001976a9142b4cf64627268ac24effd9aad5895e8ca862114288acd432e405000000001976a914b7128d2ee837cf03e30a2c0e3e0181f7b9669bb688ac00000000\", 1]}"
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"decoderawtransaction\",\"params\":[\"0100000083bbd75701007b32687744a8ec1cadeda58b7db9bc8b089484820fe010aaaaae42784be24e0000000000ffffffff02bcf60100000000001976a9142b4cf64627268ac24effd9aad5895e8ca862114288ac43123b00000000001976a914b7128d2ee837cf03e30a2c0e3e0181f7b9669bb688ac00000000\", 1]}"

2
iguana/tests/signrawtransaction

@ -1,2 +1,2 @@
curl --url "http://127.0.0.1:7778" --data "{\"method\":\"signrawtransaction\",\"params\":[\"0100000093b7325701f6d17d847b7096cdd9b79e4df4b74aabb9ac34b7abd4f9fce19d761e97cca0e80000000000ffffffff0240420f00000000001976a91410acba3a841fae68aba4b5ff162714c493bcc04e88acd0300e00000000001976a914d8b8c039206af6cec82bca950f592801e62808cb88ac00000000\", [{\"txid\":\"e8a0cc971e769de1fcf9d4abb734acb9ab4ab7f44d9eb7d9cd96707b847dd1f6\",\"vout\":0,\"scriptPubKey\":\"2102d14a195654f536df6dfe5a38278d1b470d00f17de78eeb5ce9e9eea9edb2c212ac\"}], [\"UqvuZXEAVXDXJkL4j4Xq6qoMdeJfPF1aNsCzmzfZaQ1ZgBTwfmWn\"], \"ALL\"] }"
curl --url "http://127.0.0.1:7778" --data "{\"method\":\"signrawtransaction\",\"params\":[\"0100000083bbd75701007b32687744a8ec1cadeda58b7db9bc8b089484820fe010aaaaae42784be24e0000000000ffffffff02bcf60100000000001976a9142b4cf64627268ac24effd9aad5895e8ca862114288ac43123b00000000001976a914b7128d2ee837cf03e30a2c0e3e0181f7b9669bb688ac00000000\", [{\"txid\":\"4ee24b7842aeaaaa10e00f828494088bbcb97d8ba5edad1ceca8447768327bc4\",\"vout\":0,\"scriptPubKey\":\"76a91442947a6941767b71f61fd9fec6514d96fef700e988ac\"}], [], \"ALL\"] }"

2
includes/iguana_funcs.h

@ -413,7 +413,7 @@ void iguana_volatilesalloc(struct iguana_info *coin,struct iguana_ramchain *ramc
int32_t iguana_send_ping(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr);
int32_t iguana_process_msgrequestQ(struct supernet_info *myinfo,struct iguana_info *coin);
uint32_t iguana_fastfindinit(struct iguana_info *coin);
int32_t iguana_outptset(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_outpoint *outpt,bits256 txid,int32_t vout);
int32_t iguana_outptset(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_outpoint *outpt,bits256 txid,int32_t vout,int64_t value,char *spendscriptstr);
int32_t iguana_unspentindfind(struct supernet_info *myinfo,struct iguana_info *coin,uint64_t *spentamountp,char *coinaddr,uint8_t *spendscript,int32_t *scriptlenp,uint64_t *valuep,int32_t *heightp,bits256 txid,int32_t vout,int32_t lasthdrsi,int32_t mempool);
int32_t iguana_RTunspentindfind(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_outpoint *outpt,char *coinaddr,uint8_t *spendscript,int32_t *scriptlenp,uint64_t *valuep,int32_t *heightp,bits256 txid,int32_t vout,int32_t lasthdrsi,int32_t mempool);
int32_t iguana_addressvalidate(struct iguana_info *coin,uint8_t *addrtypep,char *address);

2
includes/iguana_structs.h

@ -508,7 +508,7 @@ struct bitcoin_spend
struct bitcoin_unspent inputs[];
};
struct iguana_outpoint { void *ptr; int64_t value; uint32_t unspentind:31,isptr:1; int16_t hdrsi; };
struct iguana_outpoint { void *ptr; bits256 txid; int64_t value; uint32_t unspentind; int16_t hdrsi,vout,spendlen:15,isptr:1; uint8_t spendscript[512]; };
struct exchange_quote { uint64_t satoshis,orderid,offerNXT,exchangebits; double price,volume; uint32_t timestamp,val; };

Loading…
Cancel
Save