From eb6c7bb831b7784cacafdf5b6a3fbdae5ae53d4b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 7 Apr 2018 22:46:38 +0300 Subject: [PATCH] Test --- src/komodo_bitcoind.h | 12 ------------ src/miner.cpp | 6 +++--- src/wallet/rpcwallet.cpp | 10 +++++++++- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 6933be624..46913d43e 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -988,15 +988,3 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_ return(0); } -void komodo_listunspent(); - -int32_t komodo_staked(uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig) -{ - *utxovaluep = 0; - memset(utxotxidp,0,sizeof(*utxotxidp)); - memset(utxovoutp,0,sizeof(*utxovoutp)); - memset(utxosig,0,72); - komodo_listunspent(); - return(72); -} - diff --git a/src/miner.cpp b/src/miner.cpp index e14338641..2e6305f26 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -120,7 +120,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *symbol,int32_t int32_t komodo_isrealtime(int32_t *kmdheightp); int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_t nTime,int32_t dispflag); uint64_t komodo_commission(const CBlock &block); -int32_t komodo_staked(uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig); +int32_t komodo_staked(uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig); CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) { @@ -387,8 +387,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) LogPrintf("CreateNewBlock(): total size %u\n", nBlockSize); if ( ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_STAKED != 0 && NOTARY_PUBKEY33[0] != 0 ) { - uint64_t txfees,utxovalue; uint256 utxotxid; int32_t i,siglen,numsigs,utxovout; uint8_t utxosig[128],*ptr; - if ( (siglen= komodo_staked(&utxotxid,&utxovout,&utxovalue,utxosig)) > 0 ) + uint64_t txfees,utxovalue; uint32_t txtime; uint256 utxotxid; int32_t i,siglen,numsigs,utxovout; uint8_t utxosig[128],*ptr; + if ( (siglen= komodo_staked(&txtime,&utxotxid,&utxovout,&utxovalue,utxosig)) > 0 ) { CMutableTransaction txStaked = CreateNewContextualCMutableTransaction(chainparams.GetConsensus(), nHeight); CAmount txfees = 10000; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index fee31efcd..c7cf5d52b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2691,11 +2691,15 @@ UniValue listunspent(const UniValue& params, bool fHelp) return results; } -void komodo_listunspent() +int32_t komodo_staked(uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig) { set setAddress; int32_t nMinDepth = 1,nMaxDepth = 9999999; vector vecOutputs; assert(pwalletMain != NULL); LOCK2(cs_main, pwalletMain->cs_wallet); + *utxovaluep = 0; + memset(utxotxidp,0,sizeof(*utxotxidp)); + memset(utxovoutp,0,sizeof(*utxovoutp)); + memset(utxosig,0,72); pwalletMain->AvailableCoins(vecOutputs, false, NULL, true); BOOST_FOREACH(const COutput& out, vecOutputs) { @@ -2712,6 +2716,10 @@ void komodo_listunspent() CAmount nValue = out.tx->vout[out.i].nValue; const CScript& pk = out.tx->vout[out.i].scriptPubKey; //entry.push_back(Pair("generated", out.tx->IsCoinBase())); + *utxovaluep = (uint64_t)nValue; + decode_hex(utxotxidp,32,out.tx->GetHash().GetHex().c_str()); + *utxovoutp = out.i; + *txtimep = (uint32_t)out.tx->nLockTime; CTxDestination address; if (ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) {