diff --git a/basilisk/basilisk_bitcoin.c b/basilisk/basilisk_bitcoin.c index b56a0e7fd..7c59c74c3 100755 --- a/basilisk/basilisk_bitcoin.c +++ b/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 ) diff --git a/basilisk/basilisk_swap.c b/basilisk/basilisk_swap.c index 7699bef8e..48751990e 100755 --- a/basilisk/basilisk_swap.c +++ b/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) diff --git a/iguana/dPoW.h b/iguana/dPoW.h index 4e0574bb7..f621e8eba 100755 --- a/iguana/dPoW.h +++ b/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 diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index e442898a4..763a2831a 100755 --- a/iguana/dpow/dpow_network.c +++ b/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; diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 48bf4be3b..ec3356c98 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/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> 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