Browse Source

I originally wrote this function and we call it Hush DPoW around here

pull/305/head
Duke Leto 4 years ago
parent
commit
d02fdd4fe5
  1. 2
      src/cc/CCutils.cpp
  2. 2
      src/komodo_defs.h
  3. 2
      src/komodo_notary.h
  4. 8
      src/rpc/blockchain.cpp
  5. 6
      src/rpc/rawtransaction.cpp
  6. 4
      src/wallet/asyncrpcoperation_sendmany.cpp
  7. 26
      src/wallet/rpcwallet.cpp
  8. 4
      src/wallet/wallet.cpp

2
src/cc/CCutils.cpp

@ -26,7 +26,7 @@
#else
#define MIN_NON_NOTARIZED_CONFIRMS 101
#endif // TESTMODE
int32_t komodo_dpowconfs(int32_t height,int32_t numconfs);
int32_t hush_dpowconfs(int32_t height,int32_t numconfs);
struct komodo_state *komodo_stateptr(char *symbol,char *dest);
extern uint32_t KOMODO_DPOWCONFS;

2
src/komodo_defs.h

@ -477,7 +477,7 @@ int32_t komodo_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *fla
uint32_t komodo_blocktime(uint256 hash);
int32_t komodo_longestchain();
int32_t komodo_dpowconfs(int32_t height,int32_t numconfs);
int32_t hush_dpowconfs(int32_t height,int32_t numconfs);
int8_t komodo_segid(int32_t nocache,int32_t height);
int32_t komodo_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeight);
char *komodo_pricename(char *name,int32_t ind);

2
src/komodo_notary.h

@ -342,7 +342,7 @@ int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *
} else return(0);
}
int32_t komodo_dpowconfs(int32_t txheight,int32_t numconfs)
int32_t hush_dpowconfs(int32_t txheight,int32_t numconfs)
{
static int32_t hadnotarization;
char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp;

8
src/rpc/blockchain.cpp

@ -145,7 +145,7 @@ UniValue blockheaderToJSON(const CBlockIndex* blockindex)
// Only report confirmations if the block is on the main chain
if (chainActive.Contains(blockindex))
confirmations = chainActive.Height() - blockindex->GetHeight() + 1;
result.push_back(Pair("confirmations", komodo_dpowconfs(blockindex->GetHeight(),confirmations)));
result.push_back(Pair("confirmations", hush_dpowconfs(blockindex->GetHeight(),confirmations)));
result.push_back(Pair("rawconfirmations", confirmations));
result.push_back(Pair("height", blockindex->GetHeight()));
result.push_back(Pair("version", blockindex->nVersion));
@ -178,7 +178,7 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex)
} else {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block is an orphan");
}
result.push_back(Pair("confirmations", komodo_dpowconfs(blockindex->GetHeight(),confirmations)));
result.push_back(Pair("confirmations", hush_dpowconfs(blockindex->GetHeight(),confirmations)));
result.push_back(Pair("rawconfirmations", confirmations));
result.push_back(Pair("size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION)));
result.push_back(Pair("height", blockindex->GetHeight()));
@ -299,7 +299,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx
// Only report confirmations if the block is on the main chain
if (chainActive.Contains(blockindex))
confirmations = chainActive.Height() - blockindex->GetHeight() + 1;
result.push_back(Pair("confirmations", komodo_dpowconfs(blockindex->GetHeight(),confirmations)));
result.push_back(Pair("confirmations", hush_dpowconfs(blockindex->GetHeight(),confirmations)));
result.push_back(Pair("rawconfirmations", confirmations));
result.push_back(Pair("size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION)));
result.push_back(Pair("height", blockindex->GetHeight()));
@ -1489,7 +1489,7 @@ UniValue gettxout(const UniValue& params, bool fHelp, const CPubKey& mypk)
ret.push_back(Pair("confirmations", 0));
ret.push_back(Pair("rawconfirmations", 0));
} else {
ret.push_back(Pair("confirmations", komodo_dpowconfs(coins.nHeight,pindex->GetHeight() - coins.nHeight + 1)));
ret.push_back(Pair("confirmations", hush_dpowconfs(coins.nHeight,pindex->GetHeight() - coins.nHeight + 1)));
ret.push_back(Pair("rawconfirmations", pindex->GetHeight() - coins.nHeight + 1));
}
ret.push_back(Pair("value", ValueFromAmount(coins.vout[n].nValue)));

6
src/rpc/rawtransaction.cpp

@ -57,7 +57,7 @@ int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *
using namespace std;
extern char ASSETCHAINS_SYMBOL[];
int32_t komodo_dpowconfs(int32_t height,int32_t numconfs);
int32_t hush_dpowconfs(int32_t height,int32_t numconfs);
void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex)
{
@ -266,7 +266,7 @@ void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue&
if (nConfirmations > 0) {
entry.push_back(Pair("height", nHeight));
entry.push_back(Pair("confirmations", komodo_dpowconfs(nHeight,nConfirmations)));
entry.push_back(Pair("confirmations", hush_dpowconfs(nHeight,nConfirmations)));
entry.push_back(Pair("rawconfirmations", nConfirmations));
entry.push_back(Pair("time", nBlockTime));
entry.push_back(Pair("blocktime", nBlockTime));
@ -350,7 +350,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
if (chainActive.Contains(pindex)) {
entry.push_back(Pair("height", pindex->GetHeight()));
entry.push_back(Pair("rawconfirmations", 1 + chainActive.Height() - pindex->GetHeight()));
entry.push_back(Pair("confirmations", komodo_dpowconfs(pindex->GetHeight(),1 + chainActive.Height() - pindex->GetHeight())));
entry.push_back(Pair("confirmations", hush_dpowconfs(pindex->GetHeight(),1 + chainActive.Height() - pindex->GetHeight())));
entry.push_back(Pair("time", pindex->GetBlockTime()));
entry.push_back(Pair("blocktime", pindex->GetBlockTime()));
} else {

4
src/wallet/asyncrpcoperation_sendmany.cpp

@ -55,7 +55,7 @@ using namespace libzcash;
extern char ASSETCHAINS_SYMBOL[65];
int32_t komodo_dpowconfs(int32_t height,int32_t numconfs);
int32_t hush_dpowconfs(int32_t height,int32_t numconfs);
int32_t komodo_blockheight(uint256 hash);
int tx_height( const uint256 &hash );
bool hush_hardfork_active(uint32_t time);
@ -621,7 +621,7 @@ bool AsyncRPCOperation_sendmany::find_utxos(bool fAcceptCoinbase=false) {
if( mindepth_ > 1 ) {
int nHeight = tx_height(out.tx->GetHash());
int dpowconfs = komodo_dpowconfs(nHeight, out.nDepth);
int dpowconfs = hush_dpowconfs(nHeight, out.nDepth);
if (dpowconfs < mindepth_) {
continue;
}

26
src/wallet/rpcwallet.cpp

@ -75,7 +75,7 @@ const std::string ADDR_TYPE_SAPLING = "sapling";
const std::string ADDR_TYPE_AMNESIA = "amnesia";
extern int32_t HUSH_INSYNC;
uint32_t komodo_segid32(char *coinaddr);
int32_t komodo_dpowconfs(int32_t height,int32_t numconfs);
int32_t hush_dpowconfs(int32_t height,int32_t numconfs);
int32_t komodo_isnotaryvout(char *coinaddr,uint32_t tiptime); // from ac_private chains only
CBlockIndex *komodo_getblockindex(uint256 hash);
extern string randomSietchZaddr();
@ -152,7 +152,7 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry)
entry.push_back(Pair("generated", true));
if (confirms > 0)
{
entry.push_back(Pair("confirmations", komodo_dpowconfs((int32_t)komodo_blockheight(wtx.hashBlock),confirms)));
entry.push_back(Pair("confirmations", hush_dpowconfs((int32_t)komodo_blockheight(wtx.hashBlock),confirms)));
entry.push_back(Pair("blockhash", wtx.hashBlock.GetHex()));
entry.push_back(Pair("blockindex", wtx.nIndex));
entry.push_back(Pair("blocktime", (uint64_t)komodo_blocktime(wtx.hashBlock)));
@ -986,7 +986,7 @@ UniValue getreceivedbyaddress(const UniValue& params, bool fHelp, const CPubKey&
int nDepth = wtx.GetDepthInMainChain();
if( nMinDepth > 1 ) {
int nHeight = tx_height(wtx.GetHash());
int dpowconfs = komodo_dpowconfs(nHeight, nDepth);
int dpowconfs = hush_dpowconfs(nHeight, nDepth);
if (dpowconfs >= nMinDepth) {
nAmount += txout.nValue; // komodo_interest?
}
@ -1076,7 +1076,7 @@ CAmount GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMi
int nDepth = wtx.GetDepthInMainChain();
if( nMinDepth > 1 ) {
int nHeight = tx_height(wtx.GetHash());
int dpowconfs = komodo_dpowconfs(nHeight, nDepth);
int dpowconfs = hush_dpowconfs(nHeight, nDepth);
if (nReceived != 0 && dpowconfs >= nMinDepth) {
nBalance += nReceived;
}
@ -1260,7 +1260,7 @@ UniValue getbalance(const UniValue& params, bool fHelp, const CPubKey& mypk)
int nDepth = wtx.GetDepthInMainChain();
if( nMinDepth > 1 ) {
int nHeight = tx_height(wtx.GetHash());
int dpowconfs = komodo_dpowconfs(nHeight, nDepth);
int dpowconfs = hush_dpowconfs(nHeight, nDepth);
if (dpowconfs >= nMinDepth) {
BOOST_FOREACH(const COutputEntry& r, listReceived)
nBalance += r.amount;
@ -1653,7 +1653,7 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts)
int nDepth = wtx.GetDepthInMainChain();
if( nMinDepth > 1 ) {
int nHeight = tx_height(wtx.GetHash());
int dpowconfs = komodo_dpowconfs(nHeight, nDepth);
int dpowconfs = hush_dpowconfs(nHeight, nDepth);
if (dpowconfs < nMinDepth)
continue;
} else {
@ -1720,7 +1720,7 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts)
obj.push_back(Pair("account", strAccount));
obj.push_back(Pair("amount", ValueFromAmount(nAmount)));
obj.push_back(Pair("rawconfirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf)));
obj.push_back(Pair("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : komodo_dpowconfs(nHeight, nConf))));
obj.push_back(Pair("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : hush_dpowconfs(nHeight, nConf))));
UniValue transactions(UniValue::VARR);
if (it != mapTally.end())
{
@ -1747,7 +1747,7 @@ UniValue ListReceived(const UniValue& params, bool fByAccounts)
obj.push_back(Pair("account", (*it).first));
obj.push_back(Pair("amount", ValueFromAmount(nAmount)));
obj.push_back(Pair("rawconfirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf)));
obj.push_back(Pair("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : komodo_dpowconfs(nHeight, nConf))));
obj.push_back(Pair("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : hush_dpowconfs(nHeight, nConf))));
ret.push_back(obj);
}
}
@ -2938,7 +2938,7 @@ UniValue listunspent(const UniValue& params, bool fHelp, const CPubKey& mypk)
int nDepth = out.tx->GetDepthInMainChain();
if( nMinDepth > 1 ) {
int nHeight = tx_height(out.tx->GetHash());
int dpowconfs = komodo_dpowconfs(nHeight, nDepth);
int dpowconfs = hush_dpowconfs(nHeight, nDepth);
if (dpowconfs < nMinDepth || dpowconfs > nMaxDepth)
continue;
} else {
@ -2992,7 +2992,7 @@ UniValue listunspent(const UniValue& params, bool fHelp, const CPubKey& mypk)
txheight = (chainActive.LastTip()->GetHeight() - out.nDepth - 1);
entry.push_back(Pair("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end())));
entry.push_back(Pair("rawconfirmations",out.nDepth));
entry.push_back(Pair("confirmations",komodo_dpowconfs(txheight,out.nDepth)));
entry.push_back(Pair("confirmations",hush_dpowconfs(txheight,out.nDepth)));
entry.push_back(Pair("spendable", out.fSpendable));
results.push_back(entry);
}
@ -3801,7 +3801,7 @@ UniValue z_listunspent(const UniValue& params, bool fHelp, const CPubKey& mypk)
UniValue obj(UniValue::VOBJ);
int nHeight = tx_height(entry.op.hash);
int dpowconfs = komodo_dpowconfs(nHeight, entry.confirmations);
int dpowconfs = hush_dpowconfs(nHeight, entry.confirmations);
// Only return notarized results when minconf>1
if (nMinDepth > 1 && dpowconfs == 1)
@ -4025,7 +4025,7 @@ CAmount getBalanceTaddr(std::string transparentAddress, int minDepth=1, bool ign
int nDepth = out.tx->GetDepthInMainChain();
if( minDepth > 1 ) {
int nHeight = tx_height(out.tx->GetHash());
int dpowconfs = komodo_dpowconfs(nHeight, nDepth);
int dpowconfs = hush_dpowconfs(nHeight, nDepth);
if (dpowconfs < minDepth) {
continue;
}
@ -4132,7 +4132,7 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp, const CPubK
for (SaplingNoteEntry & entry : saplingEntries) {
UniValue obj(UniValue::VOBJ);
int nHeight = tx_height(entry.op.hash);
int dpowconfs = komodo_dpowconfs(nHeight, entry.confirmations);
int dpowconfs = hush_dpowconfs(nHeight, entry.confirmations);
// Only return notarized results when minconf>1
if (nMinDepth > 1 && dpowconfs == 1)
continue;

4
src/wallet/wallet.cpp

@ -70,7 +70,7 @@ bool fPayAtLeastCustomFee = true;
CBlockIndex *komodo_chainactive(int32_t height);
extern std::string DONATION_PUBKEY;
int32_t komodo_dpowconfs(int32_t height,int32_t numconfs);
int32_t hush_dpowconfs(int32_t height,int32_t numconfs);
int tx_height( const uint256 &hash );
bool fTxDeleteEnabled = false;
bool fTxConflictDeleteEnabled = false;
@ -4867,7 +4867,7 @@ void CWallet::GetFilteredNotes(
continue;
}
int nDepth = wtx.GetDepthInMainChain();
int dpowconfs = komodo_dpowconfs(nHeight,nDepth);
int dpowconfs = hush_dpowconfs(nHeight,nDepth);
if ( dpowconfs < minDepth || dpowconfs > maxDepth) {
continue;
}

Loading…
Cancel
Save