diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 96b22adad..c29856d1c 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -325,9 +325,16 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran else return("0"); } +void NSPV_CCunspents(std::vector > &unspentOutputs,char *coinaddr,bool ccflag); + void SetCCunspents(std::vector > &unspentOutputs,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_CCunspents(unspentOutputs,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 3dc4b23f0..2e883a439 100644 --- a/src/komodo_nSPV_wallet.h +++ b/src/komodo_nSPV_wallet.h @@ -442,4 +442,31 @@ int64_t NSPV_AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total } else return(0); } +void NSPV_utxos2CCunspents(struct NSPV_utxosresp *ptr,std::vector > &outputs) +{ + CAddressUnspentKey key; CAddressUnspentValue value; int32_t i,type; uint160 hashBytes; std::string addrstr(ptr->coinaddr); + if ( ptr->utxos != NULL && ptr->numutxos > 0 ) + { + CBitcoinAddress address(addrstr); + if (address.GetIndexKey(hashBytes, type, ptr->CCflag) == 0) + return; + for (i = 0; i < ptr->numutxos; i ++) + { + key.type = type; + key.hashBytes = hashBytes; + key.txhash = ptr->utxos[i].txid; + key.index = ptr->utxos[i].vout; + value.satoshis = ptr->utxos[i].satoshis; + value.blockHeight = ptr->utxos[i].height; + outputs.push_back(std::make_pair(key, value)); + } + } +} + +void NSPV_CCunspents(std::vector > &outputs,char *coinaddr,bool ccflag) +{ + UniValue NSPV_addressutxos(coinaddr,ccflag); + NSPV_utxos2CCunspents(&NSPV_utxosresult,outputs); +} + #endif // KOMODO_NSPVWALLET_H