nSPV support for CCtxids
This commit is contained in:
@@ -334,6 +334,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
|
||||
}
|
||||
|
||||
void NSPV_CCunspents(std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > &unspentOutputs,char *coinaddr,bool ccflag);
|
||||
void NSPV_CCtxids(std::vector<std::pair<CAddressIndexKey, CAmount> > &txids,char *coinaddr,bool ccflag);
|
||||
|
||||
void SetCCunspents(std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > &unspentOutputs,char *coinaddr,bool ccflag)
|
||||
{
|
||||
@@ -362,6 +363,11 @@ void SetCCunspents(std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValu
|
||||
void SetCCtxids(std::vector<std::pair<CAddressIndexKey, CAmount> > &addressIndex,char *coinaddr,bool ccflag)
|
||||
{
|
||||
int32_t type=0,i,n; char *ptr; std::string addrstr; uint160 hashBytes; std::vector<std::pair<uint160, int> > addresses;
|
||||
if ( KOMODO_NSPV != 0 )
|
||||
{
|
||||
NSPV_CCtxids(addressIndex,coinaddr,ccflag);
|
||||
return;
|
||||
}
|
||||
n = (int32_t)strlen(coinaddr);
|
||||
addrstr.resize(n+1);
|
||||
ptr = (char *)addrstr.data();
|
||||
|
||||
@@ -468,10 +468,40 @@ void NSPV_utxos2CCunspents(struct NSPV_utxosresp *ptr,std::vector<std::pair<CAdd
|
||||
}
|
||||
}
|
||||
|
||||
void NSPV_txids2CCtxids(struct NSPV_txidsresp *ptr,std::vector<std::pair<CAddressIndexKey, CAmount> > &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<std::pair<CAddressUnspentKey, CAddressUnspentValue> > &outputs,char *coinaddr,bool ccflag)
|
||||
{
|
||||
NSPV_addressutxos(coinaddr,ccflag);
|
||||
NSPV_utxos2CCunspents(&NSPV_utxosresult,outputs);
|
||||
}
|
||||
|
||||
void NSPV_CCtxids(std::vector<std::pair<CAddressIndexKey, CAmount> > &txids,char *coinaddr,bool ccflag)
|
||||
{
|
||||
NSPV_addresstxids(coinaddr,ccflag);
|
||||
NSPV_txids2CCtxids(&NSPV_txidsresult,txids);
|
||||
}
|
||||
|
||||
#endif // KOMODO_NSPVWALLET_H
|
||||
|
||||
Reference in New Issue
Block a user