Grab proof before overwritten

This commit is contained in:
jl777
2019-07-08 07:03:35 -11:00
parent 927aca6f01
commit b069d6a74a
2 changed files with 8 additions and 5 deletions

View File

@@ -167,7 +167,7 @@ int32_t NSPV_getaddressutxos(struct NSPV_utxosresp *ptr,char *coinaddr) // check
if ( len < maxlen ) if ( len < maxlen )
{ {
len = (int32_t)(sizeof(*ptr) + sizeof(*ptr->utxos)*ptr->numutxos - sizeof(ptr->utxos)); len = (int32_t)(sizeof(*ptr) + sizeof(*ptr->utxos)*ptr->numutxos - sizeof(ptr->utxos));
fprintf(stderr,"getaddressutxos for %s -> n.%d:%d total %.8f interest %.8f len.%d\n",coinaddr,n,ptr->numutxos,dstr(total),dstr(interest),len); //fprintf(stderr,"getaddressutxos for %s -> n.%d:%d total %.8f interest %.8f len.%d\n",coinaddr,n,ptr->numutxos,dstr(total),dstr(interest),len);
if ( n == ptr->numutxos ) if ( n == ptr->numutxos )
{ {
ptr->total = total; ptr->total = total;

View File

@@ -587,7 +587,7 @@ int32_t NSPV_validatehdrs(struct NSPV_ntzsproofresp *ptr)
int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int32_t height,CTransaction &tx) int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int32_t height,CTransaction &tx)
{ {
int32_t i,offset,retval = 0; int32_t i,offset,retval = 0; std::vector<uint8_t> proof;
for (i=0; i<3; i++) for (i=0; i<3; i++)
{ {
NSPV_txproof(vout,txid,height); NSPV_txproof(vout,txid,height);
@@ -606,6 +606,11 @@ int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int
retval = -21; retval = -21;
else if ( skipvalidation == 0 ) else if ( skipvalidation == 0 )
{ {
if ( NSPV_txproofresult.txprooflen > 0 )
{
proof.resize(NSPV_txproofresult.txprooflen);
memcpy(&proof[0],NSPV_txproofresult.txproof,txprooflen);
}
NSPV_notarizations(height); // gets the prev and next notarizations NSPV_notarizations(height); // gets the prev and next notarizations
if ( NSPV_inforesult.notarization.height >= height && (NSPV_ntzsresult.prevntz.height == 0 || NSPV_ntzsresult.prevntz.height >= NSPV_ntzsresult.nextntz.height) ) if ( NSPV_inforesult.notarization.height >= height && (NSPV_ntzsresult.prevntz.height == 0 || NSPV_ntzsresult.prevntz.height >= NSPV_ntzsresult.nextntz.height) )
{ {
@@ -623,9 +628,7 @@ int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int
NSPV_txidhdrsproof(NSPV_ntzsresult.prevntz.txid,NSPV_ntzsresult.nextntz.txid); NSPV_txidhdrsproof(NSPV_ntzsresult.prevntz.txid,NSPV_ntzsresult.nextntz.txid);
if ( (retval= NSPV_validatehdrs(&NSPV_ntzsproofresult)) == 0 ) if ( (retval= NSPV_validatehdrs(&NSPV_ntzsproofresult)) == 0 )
{ {
std::vector<uint256> txids; std::vector<uint8_t> proof; uint256 proofroot; std::vector<uint256> txids; uint256 proofroot;
proof.resize(NSPV_txproofresult.txprooflen);
memcpy(&proof[0],NSPV_txproofresult.txproof,NSPV_txproofresult.txprooflen);
proofroot = BitcoinGetProofMerkleRoot(proof,txids); proofroot = BitcoinGetProofMerkleRoot(proof,txids);
if ( proofroot != NSPV_ntzsproofresult.common.hdrs[offset].hashMerkleRoot ) if ( proofroot != NSPV_ntzsproofresult.common.hdrs[offset].hashMerkleRoot )
{ {