This commit is contained in:
jl777
2019-07-07 05:08:49 -11:00
parent b37111a2b0
commit 1eefc92892
3 changed files with 8 additions and 11 deletions

View File

@@ -412,7 +412,7 @@ int32_t NSPV_txextract(CTransaction &tx,uint8_t *data,int32_t datalen)
memcpy(&rawdata[0],data,datalen); memcpy(&rawdata[0],data,datalen);
if ( DecodeHexTx(tx,HexStr(rawdata)) != 0 ) if ( DecodeHexTx(tx,HexStr(rawdata)) != 0 )
{ {
fprintf(stderr,"extracted %s\n",tx.GetHash().GetHex().c_str()); //fprintf(stderr,"extracted %s\n",tx.GetHash().GetHex().c_str());
return(0); return(0);
} }
else return(-1); else return(-1);
@@ -432,8 +432,8 @@ uint256 NSPV_opretextract(int32_t *heightp,uint256 *blockhashp,char *symbol,std:
((uint8_t *)blockhashp)[i] = opret[i]; ((uint8_t *)blockhashp)[i] = opret[i];
for (i=0; i<32; i++) for (i=0; i<32; i++)
((uint8_t *)&desttxid)[i] = opret[4 + 32 + i]; ((uint8_t *)&desttxid)[i] = opret[4 + 32 + i];
if ( *heightp != 2690 ) if ( 0 && *heightp != 2690 )
fprintf(stderr," ntzht.%d %s <- txid.%s size.%d\n",*heightp,(*blockhashp).GetHex().c_str(),(txid).GetHex().c_str(),(int32_t)opret.size()); fprintf(stderr," ntzht.%d %s <- txid.%s size.%d\n",*heightp,(*blockhashp).GetHex().c_str(),(txid).GetHex().c_str(),(int32_t)opret.size());
return(desttxid); return(desttxid);
} }

View File

@@ -233,12 +233,12 @@ int32_t NSPV_gettxproof(struct NSPV_txproof *ptr,int32_t vout,uint256 txid,int32
ssMB << mb; ssMB << mb;
std::vector<uint8_t> proof(ssMB.begin(), ssMB.end()); std::vector<uint8_t> proof(ssMB.begin(), ssMB.end());
ptr->txprooflen = (int32_t)proof.size(); ptr->txprooflen = (int32_t)proof.size();
fprintf(stderr,"%s txproof.(%s)\n",txid.GetHex().c_str(),HexStr(proof));
if ( ptr->txprooflen > 0 ) if ( ptr->txprooflen > 0 )
{ {
ptr->txproof = (uint8_t *)calloc(1,ptr->txprooflen); ptr->txproof = (uint8_t *)calloc(1,ptr->txprooflen);
memcpy(ptr->txproof,&proof[0],ptr->txprooflen); memcpy(ptr->txproof,&proof[0],ptr->txprooflen);
} }
//int64_t CCgettxout(uint256 txid,int32_t vout,int32_t mempoolflag,int32_t lockflag);
ptr->unspentvalue = CCgettxout(txid,vout,1,1); ptr->unspentvalue = CCgettxout(txid,vout,1,1);
//fprintf(stderr,"gettxproof slen.%d\n",(int32_t)(sizeof(*ptr) - sizeof(ptr->tx) - sizeof(ptr->txproof) + ptr->txlen + ptr->txprooflen)); //fprintf(stderr,"gettxproof slen.%d\n",(int32_t)(sizeof(*ptr) - sizeof(ptr->tx) - sizeof(ptr->txproof) + ptr->txlen + ptr->txprooflen));
return(sizeof(*ptr) - sizeof(ptr->tx) - sizeof(ptr->txproof) + ptr->txlen + ptr->txprooflen); return(sizeof(*ptr) - sizeof(ptr->tx) - sizeof(ptr->txproof) + ptr->txlen + ptr->txprooflen);
@@ -291,7 +291,7 @@ int32_t NSPV_getntzsproofresp(struct NSPV_ntzsproofresp *ptr,uint256 prevntztxid
fprintf(stderr,"illegal prevht.%d nextht.%d\n",ptr->common.prevht,ptr->common.nextht); fprintf(stderr,"illegal prevht.%d nextht.%d\n",ptr->common.prevht,ptr->common.nextht);
return(-7); return(-7);
} }
fprintf(stderr,"%s -> prevht.%d, %s -> nexht.%d\n",ptr->prevtxid.GetHex().c_str(),ptr->common.prevht,ptr->nexttxid.GetHex().c_str(),ptr->common.nextht); //fprintf(stderr,"%s -> prevht.%d, %s -> nexht.%d\n",ptr->prevtxid.GetHex().c_str(),ptr->common.prevht,ptr->nexttxid.GetHex().c_str(),ptr->common.nextht);
ptr->common.numhdrs = (ptr->common.nextht - ptr->common.prevht + 1); ptr->common.numhdrs = (ptr->common.nextht - ptr->common.prevht + 1);
ptr->common.hdrs = (struct NSPV_equihdr *)calloc(ptr->common.numhdrs,sizeof(*ptr->common.hdrs)); ptr->common.hdrs = (struct NSPV_equihdr *)calloc(ptr->common.numhdrs,sizeof(*ptr->common.hdrs));
//fprintf(stderr,"prev.%d next.%d allocate numhdrs.%d\n",prevht,nextht,ptr->common.numhdrs); //fprintf(stderr,"prev.%d next.%d allocate numhdrs.%d\n",prevht,nextht,ptr->common.numhdrs);
@@ -417,7 +417,7 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
iguana_rwbignum(0,&request[1],sizeof(prevntz),(uint8_t *)&prevntz); iguana_rwbignum(0,&request[1],sizeof(prevntz),(uint8_t *)&prevntz);
iguana_rwbignum(0,&request[1+sizeof(prevntz)],sizeof(nextntz),(uint8_t *)&nextntz); iguana_rwbignum(0,&request[1+sizeof(prevntz)],sizeof(nextntz),(uint8_t *)&nextntz);
memset(&P,0,sizeof(P)); memset(&P,0,sizeof(P));
fprintf(stderr,"msg prev.%s next.%s\n",prevntz.GetHex().c_str(),nextntz.GetHex().c_str()); //fprintf(stderr,"msg prev.%s next.%s\n",prevntz.GetHex().c_str(),nextntz.GetHex().c_str());
if ( (slen= NSPV_getntzsproofresp(&P,prevntz,nextntz)) > 0 ) if ( (slen= NSPV_getntzsproofresp(&P,prevntz,nextntz)) > 0 )
{ {
response.resize(1 + slen); response.resize(1 + slen);
@@ -442,7 +442,7 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
iguana_rwnum(0,&request[1],sizeof(height),&height); iguana_rwnum(0,&request[1],sizeof(height),&height);
iguana_rwnum(0,&request[1+sizeof(height)],sizeof(vout),&vout); iguana_rwnum(0,&request[1+sizeof(height)],sizeof(vout),&vout);
iguana_rwbignum(0,&request[1+sizeof(height)+sizeof(vout)],sizeof(txid),(uint8_t *)&txid); iguana_rwbignum(0,&request[1+sizeof(height)+sizeof(vout)],sizeof(txid),(uint8_t *)&txid);
fprintf(stderr,"got txid %s/v%d ht.%d\n",txid.GetHex().c_str(),vout,height); //fprintf(stderr,"got txid %s/v%d ht.%d\n",txid.GetHex().c_str(),vout,height);
memset(&P,0,sizeof(P)); memset(&P,0,sizeof(P));
if ( (slen= NSPV_gettxproof(&P,vout,txid,height)) > 0 ) if ( (slen= NSPV_gettxproof(&P,vout,txid,height)) > 0 )
{ {

View File

@@ -34,10 +34,7 @@ int32_t NSPV_validatehdrs(struct NSPV_ntzsproofresp *ptr)
else if ( height != ptr->common.nextht ) else if ( height != ptr->common.nextht )
return(-5); return(-5);
else if ( NSPV_hdrhash(&ptr->common.hdrs[ptr->common.numhdrs-1]) != blockhash ) else if ( NSPV_hdrhash(&ptr->common.hdrs[ptr->common.numhdrs-1]) != blockhash )
{
//fprintf(stderr,"hdr.%s vs blockhash.%s\n",NSPV_hdrhash(&ptr->common.hdrs[ptr->common.numhdrs-1]).GetHex().c_str(),blockhash.GetHex().c_str());
return(-6); return(-6);
}
for (i=ptr->common.numhdrs-1; i>0; i--) for (i=ptr->common.numhdrs-1; i>0; i--)
{ {
blockhash = NSPV_hdrhash(&ptr->common.hdrs[i-1]); blockhash = NSPV_hdrhash(&ptr->common.hdrs[i-1]);
@@ -77,7 +74,7 @@ int32_t NSPV_gettransaction(int32_t vout,uint256 txid,int32_t height,CTransactio
} }
if ( NSPV_ntzsresult.prevntz.height != 0 && NSPV_ntzsresult.prevntz.height <= NSPV_ntzsresult.nextntz.height ) if ( NSPV_ntzsresult.prevntz.height != 0 && NSPV_ntzsresult.prevntz.height <= NSPV_ntzsresult.nextntz.height )
{ {
fprintf(stderr,"gettx ht.%d prev.%d next.%d\n",height,NSPV_ntzsresult.prevntz.height, NSPV_ntzsresult.nextntz.height); //fprintf(stderr,"gettx ht.%d prev.%d next.%d\n",height,NSPV_ntzsresult.prevntz.height, NSPV_ntzsresult.nextntz.height);
offset = (height - NSPV_ntzsresult.prevntz.height); offset = (height - NSPV_ntzsresult.prevntz.height);
if ( offset >= 0 && height <= NSPV_ntzsresult.nextntz.height ) if ( offset >= 0 && height <= NSPV_ntzsresult.nextntz.height )
{ {