Initial notarisation validation

This commit is contained in:
jl777
2019-07-07 00:37:07 -11:00
parent 2498cdfc88
commit 01fe40136f
2 changed files with 28 additions and 12 deletions

View File

@@ -421,8 +421,24 @@ uint256 NSPV_opretextract(int32_t *heightp,uint256 *blockhashp,char *symbol,std:
return(desttxid);
}
int32_t NSPV_notarizationextract(int32_t *heightp,uint256 *blockhashp,uint256 *txidp,int32_t *txidhtp,uint256 *desttxidp,CTransaction tx)
int32_t NSPV_pubkeysextract(uint8_t pubkeys[64][33],CTransaction tx,uint8_t elected[64][33])
{
return(0);
int32_t numsigs = 0;
return(numsigs);
}
int32_t NSPV_notarizationextract(int32_t *heightp,uint256 *blockhashp,uint256 *txidp,uint256 *desttxidp,CTransaction tx,int32_t ntzheight)
{
int32_t numsigs; uint8_t elected[64][33],sigkeys[64][33]; char *symbol; std::vector<uint8_t> opret;
if ( tx.vout.size() >= 2 )
{
symbol = (ASSETCHAINS_SYMBOL[0] == 0) ? (char *)"KMD" : ASSETCHAINS_SYMBOL;
komodo_notaries(pubkeys,ntzheight,0);
numsigs = NSPV_pubkeysextract(sigkeys,tx,elected);
GetOpReturnData(tx.vout[1].scriptPubKey,opret);
*desttxidp = NSPV_opretextract(heightp,blockhashp,symbol,opret);
*txidp = tx.GetHash();
return(0);
} else return(-1);
}
#endif // KOMODO_NSPV_H

View File

@@ -29,12 +29,12 @@ int32_t NSPV_validatehdrs(struct NSPV_ntzsproofresp *ptr)
return(-2);
else if ( tx.GetHash() != ptr->nexttxid )
return(-3);
else if ( NSPV_notarizationextract(&height,&blockhash,&txid,&txidht,&desttxid,tx) < 0 )
else if ( NSPV_notarizationextract(&height,&blockhash,&txid,&desttxid,tx,ptr->common.nextht) < 0 )
return(-4);
//else if ( height != ptr->common.nextht )
// return(-5);
//else if ( NSPV_doublesha256((uint8_t *)&ptr->common.hdrs[ptr->common.numhdrs-1],sizeof(*ptr->common.hdrs)) != blockhash )
// return(-6);
else if ( height != ptr->common.nextht )
return(-5);
else if ( NSPV_hdrhash(&ptr->common.hdrs[ptr->common.numhdrs-1]) != blockhash )
return(-6);
for (i=ptr->common.numhdrs-1; i>0; i--)
{
blockhash = NSPV_hdrhash(&ptr->common.hdrs[i-1]);
@@ -45,12 +45,12 @@ int32_t NSPV_validatehdrs(struct NSPV_ntzsproofresp *ptr)
return(-6);
else if ( tx.GetHash() != ptr->prevtxid )
return(-7);
else if ( NSPV_notarizationextract(&height,&blockhash,&txid,&txidht,&desttxid,tx) < 0 )
else if ( NSPV_notarizationextract(&height,&blockhash,&txid,&desttxid,tx,ptr->common.prevht) < 0 )
return(-8);
//else if ( height != ptr->common.prevht )
// return(-9);
//else if ( NSPV_doublesha256((uint8_t *)&ptr->common.hdrs[0],sizeof(*ptr->common.hdrs)) != blockhash )
// return(-10);
else if ( height != ptr->common.prevht )
return(-9);
else if ( NSPV_hdrhash(&ptr->common.hdrs[0]) != blockhash )
return(-10);
return(0);
}