Browse Source

test

etomic
jl777 8 years ago
parent
commit
4e4c96eb17
  1. 39
      basilisk/basilisk_bitcoin.c
  2. 4
      basilisk/basilisk_swap.c
  3. 3
      iguana/dPoW.h
  4. 31
      iguana/dpow/dpow_network.c
  5. 2
      iguana/dpow/dpow_rpc.c
  6. 20
      iguana/iguana_payments.c

39
basilisk/basilisk_bitcoin.c

@ -584,8 +584,8 @@ char *basilisk_bitcoinrawtx(struct supernet_info *myinfo,struct iguana_info *coi
uint8_t buf[4096]; int32_t oplen,offset,minconf,spendlen; cJSON *vins,*addresses,*txobj = 0; uint32_t locktime; char *opreturn,*spendscriptstr,*changeaddr,*rawtx = 0; int64_t amount,txfee,burnamount;
if ( valsobj == 0 )
return(clonestr("{\"error\":\"null valsobj\"}"));
if ( myinfo->IAMNOTARY != 0 || myinfo->NOTARY.RELAYID >= 0 )
return(clonestr("{\"error\":\"special relays only do OUT and MSG\"}"));
//if ( myinfo->IAMNOTARY != 0 || myinfo->NOTARY.RELAYID >= 0 )
// return(clonestr("{\"error\":\"special relays only do OUT and MSG\"}"));
vins = 0;
changeaddr = jstr(valsobj,"changeaddr");
if ( (amount= j64bits(valsobj,"satoshis")) == 0 )
@ -882,11 +882,11 @@ cJSON *BTC_makeclaimfunc(struct supernet_info *myinfo,struct exchange_info *exch
HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr)
{
char *retstr=0,*symbol; uint32_t basilisktag; struct basilisk_item *ptr,Lptr; int32_t timeoutmillis;
char *retstr=0,*symbol,*coinaddr; cJSON *retjson,*txoutjson; uint32_t basilisktag,blocktime; bits256 txid,blockhash; struct basilisk_item *ptr,Lptr; uint64_t value; int32_t timeoutmillis,vout,height;
if ( vals == 0 )
return(clonestr("{\"error\":\"null valsobj\"}"));
if ( myinfo->IAMNOTARY != 0 || myinfo->NOTARY.RELAYID >= 0 )
return(clonestr("{\"error\":\"special relays only do OUT and MSG\"}"));
//if ( myinfo->IAMNOTARY != 0 || myinfo->NOTARY.RELAYID >= 0 )
// return(clonestr("{\"error\":\"special relays only do OUT and MSG\"}"));
//if ( coin == 0 )
{
if ( (symbol= jstr(vals,"symbol")) != 0 || (symbol= jstr(vals,"coin")) != 0 )
@ -896,6 +896,35 @@ HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr)
jaddnum(vals,"fanout",MAX(5,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+1));
if ( coin != 0 )
{
if ( coin->FULLNODE < 0 )
{
txid = jbits256(vals,"txid");
vout = jint(vals,"vout");
if ( (txoutjson= dpow_gettxout(myinfo,coin,txid,vout)) != 0 )
{
if ( (coinaddr= jstr(txoutjson,"address")) != 0 && (value= SATOSHIDEN*jdouble(txoutjson,"value")) != 0 )
{
retjson = cJSON_CreateObject();
jaddstr(retjson,"result","success");
jaddstr(retjson,"address",coinaddr);
jadd64bits(retjson,"satoshis",value);
jaddnum(retjson,"value",dstr(value));
height = dpow_getchaintip(myinfo,&blockhash,&blocktime,0,0,coin);
jaddnum(retjson,"height",height);
jaddnum(retjson,"numconfirms",jint(txoutjson,"confirmations"));
jaddbits256(retjson,"txid",txid);
jaddnum(retjson,"vout",vout);
jaddstr(retjson,"coin",coin->symbol);
}
else
{
free_json(txoutjson);
return(clonestr("{\"error\":\"return from gettxout missing fields\"}"));
}
free_json(txoutjson);
return(jprint(retjson,1));
} else return(clonestr("{\"error\":\"null return from gettxout\"}"));
}
if ( (basilisktag= juint(vals,"basilisktag")) == 0 )
basilisktag = rand();
if ( (timeoutmillis= juint(vals,"timeout")) <= 0 )

4
basilisk/basilisk_swap.c

@ -18,8 +18,8 @@
// more better LP commands
// depends on just three external functions:
// iguana_sendrawtransaction(myinfo,coin,signedtx);
// basilisk_value(myinfo,rawtx->coin,0,0,myinfo->myaddr.persistent,argjson,0)
// - iguana_sendrawtransaction(myinfo,coin,signedtx);
// - basilisk_value(myinfo,rawtx->coin,0,0,myinfo->myaddr.persistent,argjson,0)
// basilisk_bitcoinrawtx(myinfo,rawtx->coin,"",basilisktag,jint(valsobj,"timeout"),valsobj,V)

3
iguana/dPoW.h

@ -143,5 +143,8 @@ int32_t dpow_paxpending(uint8_t *hex,uint32_t *paxwdcrcp);
void dex_updateclient(struct supernet_info *myinfo);
int32_t dex_reqsend(struct supernet_info *myinfo,uint8_t *data,int32_t datalen);
char *basilisk_respond_addmessage(struct supernet_info *myinfo,uint8_t *key,int32_t keylen,uint8_t *data,int32_t datalen,int32_t sendping,uint32_t duration);
char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx);
cJSON *dpow_gettxout(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t vout);
int32_t dpow_getchaintip(struct supernet_info *myinfo,bits256 *blockhashp,uint32_t *blocktimep,bits256 *txs,uint32_t *numtxp,struct iguana_info *coin);
#endif

31
iguana/dpow/dpow_network.c

@ -483,7 +483,7 @@ void dpow_nanoutxoset(struct dpow_nanoutxo *np,struct dpow_block *bp,int32_t isr
}
else
{
//dpow_bestconsensus(bp);
dpow_bestconsensus(bp);
np->srcutxo = bp->notaries[bp->myind].src.prev_hash;
np->srcvout = bp->notaries[bp->myind].src.prev_vout;
np->destutxo = bp->notaries[bp->myind].dest.prev_hash;
@ -691,13 +691,19 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru
return;
if ( bp->isratify == 0 && bp->state != 0xffffffff && senderind >= 0 && senderind < bp->numnotaries && bits256_nonz(srcutxo) != 0 && bits256_nonz(destutxo) != 0 )
{
bp->notaries[senderind].src.prev_hash = srcutxo;
bp->notaries[senderind].src.prev_vout = srcvout;
bp->notaries[senderind].dest.prev_hash = destutxo;
bp->notaries[senderind].dest.prev_vout = destvout;
//if ( bestmask != 0 )
if ( bits256_nonz(srcutxo) != 0 )
{
bp->notaries[senderind].src.prev_hash = srcutxo;
bp->notaries[senderind].src.prev_vout = srcvout;
}
if ( bits256_nonz(destutxo) != 0 )
{
bp->notaries[senderind].dest.prev_hash = destutxo;
bp->notaries[senderind].dest.prev_vout = destvout;
}
if ( bestmask != 0 )
bp->notaries[senderind].bestmask = bestmask;
//if ( recvmask != 0 )
if ( recvmask != 0 )
bp->notaries[senderind].recvmask = recvmask;
if ( (bp->notaries[senderind].paxwdcrc= paxwdcrc) != 0 )
{
@ -720,13 +726,12 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru
else bp->destsigsmasks[bestk] &= ~(1LL << senderind);
}
}
if ( (bp->notaries[bp->myind].paxwdcrc= bp->paxwdcrc) != 0 )
dpow_bestconsensus(bp);
else
bp->notaries[bp->myind].paxwdcrc = bp->paxwdcrc;
if ( bp->bestmask == 0 )
{
//bp->recvmask |= (1LL << senderind) | (1LL << bp->myind);
//bp->bestmask = dpow_maskmin(bp->recvmask,bp,&bp->bestk);
dpow_bestconsensus(bp);
bp->recvmask |= (1LL << senderind) | (1LL << bp->myind);
bp->bestmask = dpow_maskmin(bp->recvmask,bp,&bp->bestk);
//dpow_bestconsensus(bp);
}
if ( bp->bestk >= 0 )
bp->notaries[bp->myind].bestk = bp->bestk;

2
iguana/dpow/dpow_rpc.c

@ -405,7 +405,7 @@ int32_t dpow_getchaintip(struct supernet_info *myinfo,bits256 *blockhashp,uint32
coin->lastbestheight = height;
if ( height > coin->longestchain )
coin->longestchain = height;
if ( (array= jarray(&n,json,"tx")) != 0 )
if ( txs != 0 && numtxp != 0 && (array= jarray(&n,json,"tx")) != 0 )
{
for (i=0; i<n&&i<maxtx; i++)
txs[i] = jbits256i(array,i);

20
iguana/iguana_payments.c

@ -288,11 +288,29 @@ char *iguana_signrawtx(struct supernet_info *myinfo,struct iguana_info *coin,int
bits256 iguana_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx)
{
bits256 txid; uint8_t *serialized; int32_t i,len,n; struct iguana_peer *addr; cJSON *vals; char *str;
bits256 txid,checktxid; uint8_t *serialized; int32_t i,len,n; struct iguana_peer *addr; cJSON *vals; char *str;
len = (int32_t)strlen(signedtx) >> 1;
serialized = calloc(1,sizeof(struct iguana_msghdr) + len);
decode_hex(&serialized[sizeof(struct iguana_msghdr)],len,signedtx);
txid = bits256_doublesha256(0,&serialized[sizeof(struct iguana_msghdr)],len);
if ( coin->FULLNODE < 0 )
{
if ( (str= dpow_sendrawtransaction(myinfo,coin,signedtx)) != 0 )
{
if ( is_hexstr(str,0) == sizeof(checktxid)*2 )
{
decode_hex(checktxid.bytes,sizeof(checktxid),str);
if ( bits256_cmp(txid,checktxid) == 0 )
{
free(str);
return(txid);
}
}
free(str);
memset(txid.bytes,0,sizeof(txid));
return(txid);
}
}
if ( coin->peers != 0 && (n= coin->peers->numranked) > 0 )
{
for (i=0; i<8 && i<n; i++)

Loading…
Cancel
Save