diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 5799f0b18..64fadd63f 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -334,6 +334,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran } void NSPV_CCunspents(std::vector > &unspentOutputs,char *coinaddr,bool ccflag); +void NSPV_CCtxids(std::vector > &txids,char *coinaddr,bool ccflag); void SetCCunspents(std::vector > &unspentOutputs,char *coinaddr,bool ccflag) { @@ -362,6 +363,11 @@ void SetCCunspents(std::vector > &addressIndex,char *coinaddr,bool ccflag) { int32_t type=0,i,n; char *ptr; std::string addrstr; uint160 hashBytes; std::vector > addresses; + if ( KOMODO_NSPV != 0 ) + { + NSPV_CCtxids(addressIndex,coinaddr,ccflag); + return; + } n = (int32_t)strlen(coinaddr); addrstr.resize(n+1); ptr = (char *)addrstr.data(); diff --git a/src/komodo_nSPV_wallet.h b/src/komodo_nSPV_wallet.h index d7ff5e1a7..df9fa1e36 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -468,10 +468,40 @@ void NSPV_utxos2CCunspents(struct NSPV_utxosresp *ptr,std::vector > &txids) +{ + CAddressIndexKey key; int64_t value; int32_t i,type; uint160 hashBytes; std::string addrstr(ptr->coinaddr); + if ( ptr->txids != NULL && ptr->numtxids > 0 ) + { + CBitcoinAddress address(addrstr); + if ( address.GetIndexKey(hashBytes, type, ptr->CCflag) == 0 ) + { + fprintf(stderr,"couldnt get indexkey\n"); + return; + } + for (i = 0; i < ptr->numtxids; i ++) + { + key.type = type; + key.hashBytes = hashBytes; + key.txhash = ptr->txids[i].txid; + key.index = ptr->txids[i].vout; + key.blockHeight = ptr->txids[i].height; + value = ptr->txids[i].satoshis; + txids.push_back(std::make_pair(key, value)); + } + } +} + void NSPV_CCunspents(std::vector > &outputs,char *coinaddr,bool ccflag) { NSPV_addressutxos(coinaddr,ccflag); NSPV_utxos2CCunspents(&NSPV_utxosresult,outputs); } +void NSPV_CCtxids(std::vector > &txids,char *coinaddr,bool ccflag) +{ + NSPV_addresstxids(coinaddr,ccflag); + NSPV_txids2CCtxids(&NSPV_txidsresult,txids); +} + #endif // KOMODO_NSPVWALLET_H