From b069d6a74a703778435c0bdcd3402f6761e980b2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 8 Jul 2019 07:03:35 -1100 Subject: [PATCH] Grab proof before overwritten --- src/komodo_nSPV_fullnode.h | 2 +- src/komodo_nSPV_superlite.h | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/komodo_nSPV_fullnode.h b/src/komodo_nSPV_fullnode.h index 2795e1c65..494c511e1 100644 --- a/src/komodo_nSPV_fullnode.h +++ b/src/komodo_nSPV_fullnode.h @@ -167,7 +167,7 @@ int32_t NSPV_getaddressutxos(struct NSPV_utxosresp *ptr,char *coinaddr) // check if ( len < maxlen ) { 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 ) { ptr->total = total; diff --git a/src/komodo_nSPV_superlite.h b/src/komodo_nSPV_superlite.h index feab3859c..ef67d86d9 100644 --- a/src/komodo_nSPV_superlite.h +++ b/src/komodo_nSPV_superlite.h @@ -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 i,offset,retval = 0; + int32_t i,offset,retval = 0; std::vector proof; for (i=0; i<3; i++) { NSPV_txproof(vout,txid,height); @@ -606,6 +606,11 @@ int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int retval = -21; 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 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); if ( (retval= NSPV_validatehdrs(&NSPV_ntzsproofresult)) == 0 ) { - std::vector txids; std::vector proof; uint256 proofroot; - proof.resize(NSPV_txproofresult.txprooflen); - memcpy(&proof[0],NSPV_txproofresult.txproof,NSPV_txproofresult.txprooflen); + std::vector txids; uint256 proofroot; proofroot = BitcoinGetProofMerkleRoot(proof,txids); if ( proofroot != NSPV_ntzsproofresult.common.hdrs[offset].hashMerkleRoot ) {