Once men turned their thinking over to machines in the hope that this would set them free.
But that only permitted other men with machines to enslave them.
-- Reverend Mother Gaius Helen Mohiam
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
// Copyright (c) 2016-2020 The Hush developers
|
||||||
|
// Distributed under the GPLv3 software license, see the accompanying
|
||||||
|
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
* Copyright © 2014-2019 The SuperNET Developers. *
|
||||||
* *
|
* *
|
||||||
@@ -13,10 +16,7 @@
|
|||||||
* *
|
* *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
/*
|
// CCutils has low level functions that are universally useful for all contracts.
|
||||||
CCutils has low level functions that are universally useful for all contracts.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "CCinclude.h"
|
#include "CCinclude.h"
|
||||||
#include "hush_structs.h"
|
#include "hush_structs.h"
|
||||||
#include "key_io.h"
|
#include "key_io.h"
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
#endif // TESTMODE
|
#endif // TESTMODE
|
||||||
int32_t hush_dpowconfs(int32_t height,int32_t numconfs);
|
int32_t hush_dpowconfs(int32_t height,int32_t numconfs);
|
||||||
struct hush_state *hush_stateptr(char *symbol,char *dest);
|
struct hush_state *hush_stateptr(char *symbol,char *dest);
|
||||||
extern uint32_t KOMODO_DPOWCONFS;
|
extern uint32_t HUSH_DPOWCONFS;
|
||||||
|
|
||||||
void endiancpy(uint8_t *dest,uint8_t *src,int32_t len)
|
void endiancpy(uint8_t *dest,uint8_t *src,int32_t len)
|
||||||
{
|
{
|
||||||
@@ -823,12 +823,12 @@ int64_t TotalPubkeyCCInputs(const CTransaction &tx, const CPubKey &pubkey)
|
|||||||
bool ProcessCC(struct CCcontract_info *cp,Eval* eval, std::vector<uint8_t> paramsNull,const CTransaction &ctx, unsigned int nIn)
|
bool ProcessCC(struct CCcontract_info *cp,Eval* eval, std::vector<uint8_t> paramsNull,const CTransaction &ctx, unsigned int nIn)
|
||||||
{
|
{
|
||||||
CTransaction createTx; uint256 assetid,assetid2,hashBlock; uint8_t funcid; int32_t height,i,n,from_mempool = 0; int64_t amount; std::vector<uint8_t> origpubkey;
|
CTransaction createTx; uint256 assetid,assetid2,hashBlock; uint8_t funcid; int32_t height,i,n,from_mempool = 0; int64_t amount; std::vector<uint8_t> origpubkey;
|
||||||
height = KOMODO_CONNECTING;
|
height = HUSH_CONNECTING;
|
||||||
if ( KOMODO_CONNECTING < 0 ) // always comes back with > 0 for final confirmation
|
if ( HUSH_CONNECTING < 0 ) // always comes back with > 0 for final confirmation
|
||||||
return(true);
|
return(true);
|
||||||
if ( ASSETCHAINS_CC == 0 || (height & ~(1<<30)) < KOMODO_CCACTIVATE )
|
if ( ASSETCHAINS_CC == 0 || (height & ~(1<<30)) < KOMODO_CCACTIVATE )
|
||||||
return eval->Invalid("CC are disabled or not active yet");
|
return eval->Invalid("CC are disabled or not active yet");
|
||||||
if ( (KOMODO_CONNECTING & (1<<30)) != 0 )
|
if ( (HUSH_CONNECTING & (1<<30)) != 0 )
|
||||||
{
|
{
|
||||||
from_mempool = 1;
|
from_mempool = 1;
|
||||||
height &= ((1<<30) - 1);
|
height &= ((1<<30) - 1);
|
||||||
@@ -836,7 +836,7 @@ bool ProcessCC(struct CCcontract_info *cp,Eval* eval, std::vector<uint8_t> param
|
|||||||
if (cp->validate == NULL)
|
if (cp->validate == NULL)
|
||||||
return eval->Invalid("validation not supported for eval code");
|
return eval->Invalid("validation not supported for eval code");
|
||||||
|
|
||||||
//fprintf(stderr,"KOMODO_CONNECTING.%d mempool.%d vs CCactive.%d\n",height,from_mempool,KOMODO_CCACTIVATE);
|
//fprintf(stderr,"HUSH_CONNECTING.%d mempool.%d vs CCactive.%d\n",height,from_mempool,KOMODO_CCACTIVATE);
|
||||||
// there is a chance CC tx is valid in mempool, but invalid when in block, so we cant filter duplicate requests. if any of the vins are spent, for example
|
// there is a chance CC tx is valid in mempool, but invalid when in block, so we cant filter duplicate requests. if any of the vins are spent, for example
|
||||||
//txid = ctx.GetHash();
|
//txid = ctx.GetHash();
|
||||||
//if ( txid == cp->prevtxid )
|
//if ( txid == cp->prevtxid )
|
||||||
@@ -869,12 +869,12 @@ bool CClib_Dispatch(const CC *cond,Eval *eval,std::vector<uint8_t> paramsNull,co
|
|||||||
fprintf(stderr,"-ac_cclib=%s vs myname %s\n",ASSETCHAINS_CCLIB.c_str(),MYCCLIBNAME.c_str());
|
fprintf(stderr,"-ac_cclib=%s vs myname %s\n",ASSETCHAINS_CCLIB.c_str(),MYCCLIBNAME.c_str());
|
||||||
return eval->Invalid("-ac_cclib name mismatches myname");
|
return eval->Invalid("-ac_cclib name mismatches myname");
|
||||||
}
|
}
|
||||||
height = KOMODO_CONNECTING;
|
height = HUSH_CONNECTING;
|
||||||
if ( KOMODO_CONNECTING < 0 ) // always comes back with > 0 for final confirmation
|
if ( HUSH_CONNECTING < 0 ) // always comes back with > 0 for final confirmation
|
||||||
return(true);
|
return(true);
|
||||||
if ( ASSETCHAINS_CC == 0 || (height & ~(1<<30)) < KOMODO_CCACTIVATE )
|
if ( ASSETCHAINS_CC == 0 || (height & ~(1<<30)) < KOMODO_CCACTIVATE )
|
||||||
return eval->Invalid("CC are disabled or not active yet");
|
return eval->Invalid("CC are disabled or not active yet");
|
||||||
if ( (KOMODO_CONNECTING & (1<<30)) != 0 )
|
if ( (HUSH_CONNECTING & (1<<30)) != 0 )
|
||||||
{
|
{
|
||||||
from_mempool = 1;
|
from_mempool = 1;
|
||||||
height &= ((1<<30) - 1);
|
height &= ((1<<30) - 1);
|
||||||
|
|||||||
@@ -215,8 +215,8 @@ bool Eval::ImportPayout(const std::vector<uint8_t> params, const CTransaction &i
|
|||||||
|
|
||||||
// Check disputeTx solves momproof from vout[0]
|
// Check disputeTx solves momproof from vout[0]
|
||||||
{
|
{
|
||||||
NotarisationData data(0);
|
NotarizationData data(0);
|
||||||
if (!GetNotarisationData(proof.notarisationHash, data))
|
if (!GetNotarizationData(proof.notarisationHash, data))
|
||||||
return Invalid("coudnt-load-mom");
|
return Invalid("coudnt-load-mom");
|
||||||
|
|
||||||
if (data.MoM != proof.branch.Exec(disputeTx.GetHash()))
|
if (data.MoM != proof.branch.Exec(disputeTx.GetHash()))
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
// Copyright © 2019-2020 The Hush Developers
|
// Copyright (c) 2016-2020 The Hush developers
|
||||||
|
// Distributed under the GPLv3 software license, see the accompanying
|
||||||
|
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
* Copyright © 2014-2019 The SuperNET Developers. *
|
||||||
* *
|
* *
|
||||||
@@ -13,10 +15,8 @@
|
|||||||
* Removal or modification of this copyright notice is prohibited. *
|
* Removal or modification of this copyright notice is prohibited. *
|
||||||
* *
|
* *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <cryptoconditions.h>
|
#include <cryptoconditions.h>
|
||||||
|
|
||||||
#include "primitives/block.h"
|
#include "primitives/block.h"
|
||||||
#include "primitives/transaction.h"
|
#include "primitives/transaction.h"
|
||||||
#include "script/cc.h"
|
#include "script/cc.h"
|
||||||
@@ -27,15 +27,12 @@
|
|||||||
#include "chain.h"
|
#include "chain.h"
|
||||||
#include "core_io.h"
|
#include "core_io.h"
|
||||||
#include "crosschain.h"
|
#include "crosschain.h"
|
||||||
|
|
||||||
#define FAUCET2SIZE COIN
|
#define FAUCET2SIZE COIN
|
||||||
#define EVAL_FAUCET2 EVAL_FIRSTUSER
|
#define EVAL_FAUCET2 EVAL_FIRSTUSER
|
||||||
|
|
||||||
#ifdef BUILD_ROGUE
|
#ifdef BUILD_ROGUE
|
||||||
#define EVAL_ROGUE 17
|
#define EVAL_ROGUE 17
|
||||||
std::string MYCCLIBNAME = (char *)"rogue";
|
std::string MYCCLIBNAME = (char *)"rogue";
|
||||||
|
|
||||||
|
|
||||||
#elif BUILD_CUSTOMCC
|
#elif BUILD_CUSTOMCC
|
||||||
#include "customcc.h"
|
#include "customcc.h"
|
||||||
|
|
||||||
@@ -446,13 +443,12 @@ bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C
|
|||||||
else return eval->Invalid("invalid evalcode");
|
else return eval->Invalid("invalid evalcode");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
numvins = tx.vin.size();
|
numvins = tx.vin.size();
|
||||||
numvouts = tx.vout.size();
|
numvouts = tx.vout.size();
|
||||||
preventCCvins = preventCCvouts = -1;
|
preventCCvins = preventCCvouts = -1;
|
||||||
if ( numvouts < 1 )
|
if ( numvouts < 1 ) {
|
||||||
return eval->Invalid("no vouts");
|
return eval->Invalid("no vouts");
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
for (i=0; i<numvins; i++)
|
for (i=0; i<numvins; i++)
|
||||||
{
|
{
|
||||||
if ( IsCCInput(tx.vin[0].scriptSig) == 0 )
|
if ( IsCCInput(tx.vin[0].scriptSig) == 0 )
|
||||||
@@ -462,13 +458,10 @@ bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"check amounts\n");
|
//fprintf(stderr,"check amounts\n");
|
||||||
if ( CClibExactAmounts(cp,eval,tx,1,10000) == false )
|
if ( CClibExactAmounts(cp,eval,tx,1,10000) == false ) {
|
||||||
{
|
|
||||||
fprintf(stderr,"faucetget invalid amount\n");
|
fprintf(stderr,"faucetget invalid amount\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
preventCCvouts = 1;
|
preventCCvouts = 1;
|
||||||
if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) != 0 )
|
if ( IsCClibvout(cp,tx,0,cp->unspendableCCaddr) != 0 )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -181,13 +181,13 @@ bool Eval::CheckNotaryInputs(const CTransaction &tx, uint32_t height, uint32_t t
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get MoM from a notarisation tx hash (on HUSH)
|
// Get MoM from a notarisation tx hash (on HUSH)
|
||||||
bool Eval::GetNotarisationData(const uint256 notaryHash, NotarisationData &data) const
|
bool Eval::GetNotarizationData(const uint256 notaryHash, NotarizationData &data) const
|
||||||
{
|
{
|
||||||
CTransaction notarisationTx;
|
CTransaction notarisationTx;
|
||||||
CBlockIndex block;
|
CBlockIndex block;
|
||||||
if (!GetTxConfirmed(notaryHash, notarisationTx, block)) return false;
|
if (!GetTxConfirmed(notaryHash, notarisationTx, block)) return false;
|
||||||
if (!CheckNotaryInputs(notarisationTx, block.GetHeight(), block.nTime)) return false;
|
if (!CheckNotaryInputs(notarisationTx, block.GetHeight(), block.nTime)) return false;
|
||||||
if (!ParseNotarisationOpReturn(notarisationTx, data)) return false;
|
if (!ParseNotarizationOpReturn(notarisationTx, data)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,9 +205,9 @@ std::string Eval::GetAssetchainsSymbol() const
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Notarisation data, ie, OP_RETURN payload in notarisation transactions
|
* Notarization data, ie, OP_RETURN payload in notarisation transactions
|
||||||
*/
|
*/
|
||||||
bool ParseNotarisationOpReturn(const CTransaction &tx, NotarisationData &data)
|
bool ParseNotarizationOpReturn(const CTransaction &tx, NotarizationData &data)
|
||||||
{
|
{
|
||||||
if (tx.vout.size() < 2) return false;
|
if (tx.vout.size() < 2) return false;
|
||||||
std::vector<unsigned char> vdata;
|
std::vector<unsigned char> vdata;
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ typedef uint8_t EvalCode;
|
|||||||
|
|
||||||
|
|
||||||
class AppVM;
|
class AppVM;
|
||||||
class NotarisationData;
|
class NotarizationData;
|
||||||
|
|
||||||
|
|
||||||
class Eval
|
class Eval
|
||||||
@@ -110,7 +110,7 @@ public:
|
|||||||
virtual bool GetSpendsConfirmed(uint256 hash, std::vector<CTransaction> &spends) const;
|
virtual bool GetSpendsConfirmed(uint256 hash, std::vector<CTransaction> &spends) const;
|
||||||
virtual bool GetBlock(uint256 hash, CBlockIndex& blockIdx) const;
|
virtual bool GetBlock(uint256 hash, CBlockIndex& blockIdx) const;
|
||||||
virtual int32_t GetNotaries(uint8_t pubkeys[64][33], int32_t height, uint32_t timestamp) const;
|
virtual int32_t GetNotaries(uint8_t pubkeys[64][33], int32_t height, uint32_t timestamp) const;
|
||||||
virtual bool GetNotarisationData(uint256 notarisationHash, NotarisationData &data) const;
|
virtual bool GetNotarizationData(uint256 notarisationHash, NotarizationData &data) const;
|
||||||
virtual bool CheckNotaryInputs(const CTransaction &tx, uint32_t height, uint32_t timestamp) const;
|
virtual bool CheckNotaryInputs(const CTransaction &tx, uint32_t height, uint32_t timestamp) const;
|
||||||
virtual uint32_t GetAssetchainsCC() const;
|
virtual uint32_t GetAssetchainsCC() const;
|
||||||
virtual std::string GetAssetchainsSymbol() const;
|
virtual std::string GetAssetchainsSymbol() const;
|
||||||
@@ -160,10 +160,10 @@ extern char SMART_CHAIN_SYMBOL[65];
|
|||||||
/*
|
/*
|
||||||
* Data from notarisation OP_RETURN from chain being notarised
|
* Data from notarisation OP_RETURN from chain being notarised
|
||||||
*/
|
*/
|
||||||
class NotarisationData
|
class NotarizationData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int IsBackNotarisation = 0;
|
int IsBackNotarization = 0;
|
||||||
uint256 blockHash = uint256();
|
uint256 blockHash = uint256();
|
||||||
uint32_t height = 0;
|
uint32_t height = 0;
|
||||||
uint256 txHash = uint256();
|
uint256 txHash = uint256();
|
||||||
@@ -174,7 +174,7 @@ public:
|
|||||||
uint256 MoMoM = uint256();
|
uint256 MoMoM = uint256();
|
||||||
uint32_t MoMoMDepth = 0;
|
uint32_t MoMoMDepth = 0;
|
||||||
|
|
||||||
NotarisationData(int IsBack=2) : IsBackNotarisation(IsBack) {
|
NotarizationData(int IsBack=2) : IsBackNotarization(IsBack) {
|
||||||
symbol[0] = '\0';
|
symbol[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,8 +183,8 @@ public:
|
|||||||
template <typename Stream, typename Operation>
|
template <typename Stream, typename Operation>
|
||||||
inline void SerializationOp(Stream& s, Operation ser_action) {
|
inline void SerializationOp(Stream& s, Operation ser_action) {
|
||||||
|
|
||||||
bool IsBack = IsBackNotarisation;
|
bool IsBack = IsBackNotarization;
|
||||||
if (2 == IsBackNotarisation) IsBack = DetectBackNotarisation(s, ser_action);
|
if (2 == IsBackNotarization) IsBack = DetectBackNotarization(s, ser_action);
|
||||||
|
|
||||||
READWRITE(blockHash);
|
READWRITE(blockHash);
|
||||||
READWRITE(height);
|
READWRITE(height);
|
||||||
@@ -219,7 +219,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Stream>
|
template <typename Stream>
|
||||||
bool DetectBackNotarisation(Stream& s, CSerActionUnserialize act)
|
bool DetectBackNotarization(Stream& s, CSerActionUnserialize act)
|
||||||
{
|
{
|
||||||
if (SMART_CHAIN_SYMBOL[0]) return 1;
|
if (SMART_CHAIN_SYMBOL[0]) return 1;
|
||||||
if (s.size() >= 72) {
|
if (s.size() >= 72) {
|
||||||
@@ -230,14 +230,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Stream>
|
template <typename Stream>
|
||||||
bool DetectBackNotarisation(Stream& s, CSerActionSerialize act)
|
bool DetectBackNotarization(Stream& s, CSerActionSerialize act)
|
||||||
{
|
{
|
||||||
return !txHash.IsNull();
|
return !txHash.IsNull();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
bool ParseNotarisationOpReturn(const CTransaction &tx, NotarisationData &data);
|
bool ParseNotarizationOpReturn(const CTransaction &tx, NotarizationData &data);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -79,8 +79,8 @@ bool Eval::ImportPayout(const std::vector<uint8_t> params, const CTransaction &i
|
|||||||
|
|
||||||
// Check disputeTx solves momproof from vout[0]
|
// Check disputeTx solves momproof from vout[0]
|
||||||
{
|
{
|
||||||
NotarisationData data;
|
NotarizationData data;
|
||||||
if (!GetNotarisationData(proof.notarisationHash, data))
|
if (!GetNotarizationData(proof.notarisationHash, data))
|
||||||
return Invalid("coudnt-load-mom");
|
return Invalid("coudnt-load-mom");
|
||||||
|
|
||||||
if (data.MoM != proof.Exec(disputeTx.GetHash()))
|
if (data.MoM != proof.Exec(disputeTx.GetHash()))
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ CBlockIndex *komodo_getblockindex(uint256 hash);
|
|||||||
|
|
||||||
/* On KMD */
|
/* On KMD */
|
||||||
uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeight,
|
uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeight,
|
||||||
std::vector<uint256> &moms, uint256 &destNotarisationTxid)
|
std::vector<uint256> &moms, uint256 &destNotarizationTxid)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Notaries don't wait for confirmation on KMD before performing a backnotarisation,
|
* Notaries don't wait for confirmation on KMD before performing a backnotarisation,
|
||||||
@@ -67,33 +67,33 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh
|
|||||||
if (kmdHeight < 0 || kmdHeight > chainActive.Height())
|
if (kmdHeight < 0 || kmdHeight > chainActive.Height())
|
||||||
return uint256();
|
return uint256();
|
||||||
|
|
||||||
int seenOwnNotarisations = 0, i = 0;
|
int seenOwnNotarizations = 0, i = 0;
|
||||||
|
|
||||||
int authority = GetSymbolAuthority(symbol);
|
int authority = GetSymbolAuthority(symbol);
|
||||||
std::set<uint256> tmp_moms;
|
std::set<uint256> tmp_moms;
|
||||||
|
|
||||||
for (i=0; i<NOTARISATION_SCAN_LIMIT_BLOCKS; i++) {
|
for (i=0; i<NOTARISATION_SCAN_LIMIT_BLOCKS; i++) {
|
||||||
if (i > kmdHeight) break;
|
if (i > kmdHeight) break;
|
||||||
NotarisationsInBlock notarisations;
|
NotarizationsInBlock notarisations;
|
||||||
uint256 blockHash = *chainActive[kmdHeight-i]->phashBlock;
|
uint256 blockHash = *chainActive[kmdHeight-i]->phashBlock;
|
||||||
if (!GetBlockNotarisations(blockHash, notarisations))
|
if (!GetBlockNotarizations(blockHash, notarisations))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// See if we have an own notarisation in this block
|
// See if we have an own notarisation in this block
|
||||||
BOOST_FOREACH(Notarisation& nota, notarisations) {
|
BOOST_FOREACH(Notarization& nota, notarisations) {
|
||||||
if (strcmp(nota.second.symbol, symbol) == 0)
|
if (strcmp(nota.second.symbol, symbol) == 0)
|
||||||
{
|
{
|
||||||
seenOwnNotarisations++;
|
seenOwnNotarizations++;
|
||||||
if (seenOwnNotarisations == 1)
|
if (seenOwnNotarizations == 1)
|
||||||
destNotarisationTxid = nota.first;
|
destNotarizationTxid = nota.first;
|
||||||
else if (seenOwnNotarisations == 7)
|
else if (seenOwnNotarizations == 7)
|
||||||
goto end;
|
goto end;
|
||||||
//break;
|
//break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (seenOwnNotarisations >= 1) {
|
if (seenOwnNotarizations >= 1) {
|
||||||
BOOST_FOREACH(Notarisation& nota, notarisations) {
|
BOOST_FOREACH(Notarization& nota, notarisations) {
|
||||||
if (GetSymbolAuthority(nota.second.symbol) == authority)
|
if (GetSymbolAuthority(nota.second.symbol) == authority)
|
||||||
if (nota.second.ccId == targetCCid) {
|
if (nota.second.ccId == targetCCid) {
|
||||||
tmp_moms.insert(nota.second.MoM);
|
tmp_moms.insert(nota.second.MoM);
|
||||||
@@ -104,7 +104,7 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeigh
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Not enough own notarisations found to return determinate MoMoM
|
// Not enough own notarisations found to return determinate MoMoM
|
||||||
destNotarisationTxid = uint256();
|
destNotarizationTxid = uint256();
|
||||||
moms.clear();
|
moms.clear();
|
||||||
return uint256();
|
return uint256();
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ end:
|
|||||||
// add set to vector. Set makes sure there are no dupes included.
|
// add set to vector. Set makes sure there are no dupes included.
|
||||||
moms.clear();
|
moms.clear();
|
||||||
std::copy(tmp_moms.begin(), tmp_moms.end(), std::back_inserter(moms));
|
std::copy(tmp_moms.begin(), tmp_moms.end(), std::back_inserter(moms));
|
||||||
//fprintf(stderr, "SeenOwnNotarisations.%i moms.size.%li blocks scanned.%i\n",seenOwnNotarisations, moms.size(), i);
|
//fprintf(stderr, "SeenOwnNotarizations.%i moms.size.%li blocks scanned.%i\n",seenOwnNotarizations, moms.size(), i);
|
||||||
return GetMerkleRoot(moms);
|
return GetMerkleRoot(moms);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,15 +123,15 @@ end:
|
|||||||
* Will scan notarisations leveldb up to a limit
|
* Will scan notarisations leveldb up to a limit
|
||||||
*/
|
*/
|
||||||
template <typename IsTarget>
|
template <typename IsTarget>
|
||||||
int ScanNotarisationsFromHeight(int nHeight, const IsTarget f, Notarisation &found)
|
int ScanNotarizationsFromHeight(int nHeight, const IsTarget f, Notarization &found)
|
||||||
{
|
{
|
||||||
int limit = std::min(nHeight + NOTARISATION_SCAN_LIMIT_BLOCKS, chainActive.Height());
|
int limit = std::min(nHeight + NOTARISATION_SCAN_LIMIT_BLOCKS, chainActive.Height());
|
||||||
int start = std::max(nHeight, 1);
|
int start = std::max(nHeight, 1);
|
||||||
|
|
||||||
for (int h=start; h<limit; h++) {
|
for (int h=start; h<limit; h++) {
|
||||||
NotarisationsInBlock notarisations;
|
NotarizationsInBlock notarisations;
|
||||||
|
|
||||||
if (!GetBlockNotarisations(*chainActive[h]->phashBlock, notarisations))
|
if (!GetBlockNotarizations(*chainActive[h]->phashBlock, notarisations))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BOOST_FOREACH(found, notarisations) {
|
BOOST_FOREACH(found, notarisations) {
|
||||||
@@ -160,11 +160,11 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_
|
|||||||
// Get a kmd height for given notarisation Txid
|
// Get a kmd height for given notarisation Txid
|
||||||
int kmdHeight;
|
int kmdHeight;
|
||||||
{
|
{
|
||||||
CTransaction sourceNotarisation;
|
CTransaction sourceNotarization;
|
||||||
uint256 hashBlock;
|
uint256 hashBlock;
|
||||||
CBlockIndex blockIdx;
|
CBlockIndex blockIdx;
|
||||||
if (!eval->GetTxConfirmed(assetChainProof.first, sourceNotarisation, blockIdx))
|
if (!eval->GetTxConfirmed(assetChainProof.first, sourceNotarization, blockIdx))
|
||||||
throw std::runtime_error("Notarisation not found");
|
throw std::runtime_error("Notarization not found");
|
||||||
kmdHeight = blockIdx.GetHeight();
|
kmdHeight = blockIdx.GetHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,11 +174,11 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_
|
|||||||
// a notarisation from B, and it might not include our notarisation from A
|
// a notarisation from B, and it might not include our notarisation from A
|
||||||
// at all. So, the thing we need to do is scan forwards to find the notarisation for B,
|
// at all. So, the thing we need to do is scan forwards to find the notarisation for B,
|
||||||
// that is inclusive of A.
|
// that is inclusive of A.
|
||||||
Notarisation nota;
|
Notarization nota;
|
||||||
auto isTarget = [&](Notarisation ¬a) {
|
auto isTarget = [&](Notarization ¬a) {
|
||||||
return strcmp(nota.second.symbol, targetSymbol) == 0;
|
return strcmp(nota.second.symbol, targetSymbol) == 0;
|
||||||
};
|
};
|
||||||
kmdHeight = ScanNotarisationsFromHeight(kmdHeight, isTarget, nota);
|
kmdHeight = ScanNotarizationsFromHeight(kmdHeight, isTarget, nota);
|
||||||
if (!kmdHeight)
|
if (!kmdHeight)
|
||||||
throw std::runtime_error("Cannot find notarisation for target inclusive of source");
|
throw std::runtime_error("Cannot find notarisation for target inclusive of source");
|
||||||
|
|
||||||
@@ -187,8 +187,8 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_
|
|||||||
|
|
||||||
// Get MoMs for kmd height and symbol
|
// Get MoMs for kmd height and symbol
|
||||||
std::vector<uint256> moms;
|
std::vector<uint256> moms;
|
||||||
uint256 targetChainNotarisationTxid;
|
uint256 targetChainNotarizationTxid;
|
||||||
uint256 MoMoM = CalculateProofRoot(targetSymbol, targetCCid, kmdHeight, moms, targetChainNotarisationTxid);
|
uint256 MoMoM = CalculateProofRoot(targetSymbol, targetCCid, kmdHeight, moms, targetChainNotarizationTxid);
|
||||||
if (MoMoM.IsNull())
|
if (MoMoM.IsNull())
|
||||||
throw std::runtime_error("No MoMs found");
|
throw std::runtime_error("No MoMs found");
|
||||||
|
|
||||||
@@ -222,7 +222,7 @@ cont:
|
|||||||
if (newBranch.Exec(txid) != MoMoM)
|
if (newBranch.Exec(txid) != MoMoM)
|
||||||
throw std::runtime_error("Proof check failed");
|
throw std::runtime_error("Proof check failed");
|
||||||
|
|
||||||
return std::make_pair(targetChainNotarisationTxid,newBranch);
|
return std::make_pair(targetChainNotarizationTxid,newBranch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -251,21 +251,21 @@ void CompleteImportTransaction(CTransaction &importTx, int32_t offset)
|
|||||||
importTx = MakeImportCoinTransaction(newProof, burnTx, payouts);
|
importTx = MakeImportCoinTransaction(newProof, burnTx, payouts);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsSameAssetChain(const Notarisation ¬a) {
|
bool IsSameAssetChain(const Notarization ¬a) {
|
||||||
return strcmp(nota.second.symbol, SMART_CHAIN_SYMBOL) == 0;
|
return strcmp(nota.second.symbol, SMART_CHAIN_SYMBOL) == 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* On assetchain */
|
/* On assetchain */
|
||||||
bool GetNextBacknotarisation(uint256 kmdNotarisationTxid, Notarisation &out)
|
bool GetNextBacknotarisation(uint256 kmdNotarizationTxid, Notarization &out)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Here we are given a txid, and a proof.
|
* Here we are given a txid, and a proof.
|
||||||
* We go from the KMD notarisation txid to the backnotarisation,
|
* We go from the KMD notarisation txid to the backnotarisation,
|
||||||
* then jump to the next backnotarisation, which contains the corresponding MoMoM.
|
* then jump to the next backnotarisation, which contains the corresponding MoMoM.
|
||||||
*/
|
*/
|
||||||
Notarisation bn;
|
Notarization bn;
|
||||||
if (!GetBackNotarisation(kmdNotarisationTxid, bn))
|
if (!GetBackNotarization(kmdNotarizationTxid, bn))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Need to get block height of that backnotarisation
|
// Need to get block height of that backnotarisation
|
||||||
@@ -277,11 +277,11 @@ bool GetNextBacknotarisation(uint256 kmdNotarisationTxid, Notarisation &out)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (bool) ScanNotarisationsFromHeight(block.GetHeight()+1, &IsSameAssetChain, out);
|
return (bool) ScanNotarizationsFromHeight(block.GetHeight()+1, &IsSameAssetChain, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CheckMoMoM(uint256 kmdNotarisationHash, uint256 momom)
|
bool CheckMoMoM(uint256 kmdNotarizationHash, uint256 momom)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Given a notarisation hash and an MoMoM. Backnotarisations may arrive out of order
|
* Given a notarisation hash and an MoMoM. Backnotarisations may arrive out of order
|
||||||
@@ -290,8 +290,8 @@ bool CheckMoMoM(uint256 kmdNotarisationHash, uint256 momom)
|
|||||||
* This is a sledgehammer approach...
|
* This is a sledgehammer approach...
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Notarisation bn;
|
Notarization bn;
|
||||||
if (!GetBackNotarisation(kmdNotarisationHash, bn))
|
if (!GetBackNotarization(kmdNotarizationHash, bn))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Need to get block height of that backnotarisation
|
// Need to get block height of that backnotarisation
|
||||||
@@ -303,12 +303,12 @@ bool CheckMoMoM(uint256 kmdNotarisationHash, uint256 momom)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Notarisation nota;
|
Notarization nota;
|
||||||
auto checkMoMoM = [&](Notarisation ¬a) {
|
auto checkMoMoM = [&](Notarization ¬a) {
|
||||||
return nota.second.MoMoM == momom;
|
return nota.second.MoMoM == momom;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (bool) ScanNotarisationsFromHeight(block.GetHeight()-100, checkMoMoM, nota);
|
return (bool) ScanNotarizationsFromHeight(block.GetHeight()-100, checkMoMoM, nota);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -428,7 +428,7 @@ TxProof GetAssetchainProof(uint256 hash,CTransaction burnTx)
|
|||||||
{
|
{
|
||||||
int nIndex;
|
int nIndex;
|
||||||
CBlockIndex* blockIndex;
|
CBlockIndex* blockIndex;
|
||||||
Notarisation nota;
|
Notarization nota;
|
||||||
std::vector<uint256> branch;
|
std::vector<uint256> branch;
|
||||||
{
|
{
|
||||||
uint256 blockHash;
|
uint256 blockHash;
|
||||||
@@ -444,11 +444,11 @@ TxProof GetAssetchainProof(uint256 hash,CTransaction burnTx)
|
|||||||
// The assumption here is that the first notarisation for a height GTE than
|
// The assumption here is that the first notarisation for a height GTE than
|
||||||
// the transaction block height will contain the corresponding MoM. If there
|
// the transaction block height will contain the corresponding MoM. If there
|
||||||
// are sequence issues with the notarisations this may fail.
|
// are sequence issues with the notarisations this may fail.
|
||||||
auto isTarget = [&](Notarisation ¬a) {
|
auto isTarget = [&](Notarization ¬a) {
|
||||||
if (!IsSameAssetChain(nota)) return false;
|
if (!IsSameAssetChain(nota)) return false;
|
||||||
return nota.second.height >= blockIndex->GetHeight();
|
return nota.second.height >= blockIndex->GetHeight();
|
||||||
};
|
};
|
||||||
if (!ScanNotarisationsFromHeight(blockIndex->GetHeight(), isTarget, nota))
|
if (!ScanNotarizationsFromHeight(blockIndex->GetHeight(), isTarget, nota))
|
||||||
throw std::runtime_error("backnotarisation not yet confirmed");
|
throw std::runtime_error("backnotarisation not yet confirmed");
|
||||||
|
|
||||||
// index of block in MoM leaves
|
// index of block in MoM leaves
|
||||||
|
|||||||
@@ -36,13 +36,13 @@ TxProof GetAssetchainProof(uint256 hash,CTransaction burnTx);
|
|||||||
|
|
||||||
/* On HUSH */
|
/* On HUSH */
|
||||||
uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeight,
|
uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int kmdHeight,
|
||||||
std::vector<uint256> &moms, uint256 &destNotarisationTxid);
|
std::vector<uint256> &moms, uint256 &destNotarizationTxid);
|
||||||
TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_t targetCCid,
|
TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_t targetCCid,
|
||||||
const TxProof assetChainProof,int32_t offset);
|
const TxProof assetChainProof,int32_t offset);
|
||||||
void CompleteImportTransaction(CTransaction &importTx,int32_t offset);
|
void CompleteImportTransaction(CTransaction &importTx,int32_t offset);
|
||||||
|
|
||||||
/* On assetchain */
|
/* On assetchain */
|
||||||
bool CheckMoMoM(uint256 kmdNotarisationHash, uint256 momom);
|
bool CheckMoMoM(uint256 kmdNotarizationHash, uint256 momom);
|
||||||
bool CheckNotariesApproval(uint256 burntxid, const std::vector<uint256> & notaryTxids);
|
bool CheckNotariesApproval(uint256 burntxid, const std::vector<uint256> & notaryTxids);
|
||||||
|
|
||||||
#endif /* CROSSCHAIN_H */
|
#endif /* CROSSCHAIN_H */
|
||||||
|
|||||||
16
src/hush.h
16
src/hush.h
@@ -15,17 +15,15 @@
|
|||||||
* Removal or modification of this copyright notice is prohibited. *
|
* Removal or modification of this copyright notice is prohibited. *
|
||||||
* *
|
* *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
#ifndef H_HUSH_H
|
||||||
#ifndef H_KOMODO_H
|
#define H_HUSH_H
|
||||||
#define H_KOMODO_H
|
|
||||||
#include "hush_defs.h"
|
#include "hush_defs.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define printf(...)
|
#define printf(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Todo: verify: reorgs
|
// Todo: verify: reorgs, lollerskates
|
||||||
|
|
||||||
#define HUSH_SMART_CHAINS_WAITNOTARIZE
|
#define HUSH_SMART_CHAINS_WAITNOTARIZE
|
||||||
#define KOMODO_PAXMAX (10000 * COIN)
|
#define KOMODO_PAXMAX (10000 * COIN)
|
||||||
extern int32_t NOTARIZED_HEIGHT;
|
extern int32_t NOTARIZED_HEIGHT;
|
||||||
@@ -59,7 +57,7 @@ int32_t komodo_parsestatefile(struct hush_state *sp,FILE *fp,char *symbol,char *
|
|||||||
#include "komodo_events.h"
|
#include "komodo_events.h"
|
||||||
#include "komodo_ccdata.h"
|
#include "komodo_ccdata.h"
|
||||||
|
|
||||||
void komodo_currentheight_set(int32_t height)
|
void hush_currentheight_set(int32_t height)
|
||||||
{
|
{
|
||||||
char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct hush_state *sp;
|
char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct hush_state *sp;
|
||||||
if ( (sp= hush_stateptr(symbol,dest)) != 0 )
|
if ( (sp= hush_stateptr(symbol,dest)) != 0 )
|
||||||
@@ -525,11 +523,11 @@ int32_t komodo_validate_chain(uint256 srchash,int32_t notarized_height)
|
|||||||
else if ( notarized_height > 101 )
|
else if ( notarized_height > 101 )
|
||||||
rewindtarget = notarized_height - 101;
|
rewindtarget = notarized_height - 101;
|
||||||
else rewindtarget = 0;
|
else rewindtarget = 0;
|
||||||
if ( rewindtarget != 0 && rewindtarget > KOMODO_REWIND && rewindtarget > last_rewind )
|
if ( rewindtarget != 0 && rewindtarget > HUSH_REWIND && rewindtarget > last_rewind )
|
||||||
{
|
{
|
||||||
if ( last_rewind != 0 )
|
if ( last_rewind != 0 )
|
||||||
{
|
{
|
||||||
//KOMODO_REWIND = rewindtarget;
|
//HUSH_REWIND = rewindtarget;
|
||||||
fprintf(stderr,"%s FORK detected. notarized.%d %s not in this chain! last notarization %d -> rewindtarget.%d\n",SMART_CHAIN_SYMBOL,notarized_height,srchash.ToString().c_str(),sp->NOTARIZED_HEIGHT,rewindtarget);
|
fprintf(stderr,"%s FORK detected. notarized.%d %s not in this chain! last notarization %d -> rewindtarget.%d\n",SMART_CHAIN_SYMBOL,notarized_height,srchash.ToString().c_str(),sp->NOTARIZED_HEIGHT,rewindtarget);
|
||||||
}
|
}
|
||||||
last_rewind = rewindtarget;
|
last_rewind = rewindtarget;
|
||||||
@@ -848,7 +846,7 @@ int32_t hush_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block)
|
|||||||
hush_stateupdate(pindex->GetHeight(),0,0,0,zero,0,0,0,0,-pindex->GetHeight(),pindex->nTime,0,0,0,0,zero,0);
|
hush_stateupdate(pindex->GetHeight(),0,0,0,zero,0,0,0,0,-pindex->GetHeight(),pindex->nTime,0,0,0,0,zero,0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
komodo_currentheight_set(chainActive.LastTip()->GetHeight());
|
hush_currentheight_set(chainActive.LastTip()->GetHeight());
|
||||||
int transaction = 0;
|
int transaction = 0;
|
||||||
if ( pindex != 0 )
|
if ( pindex != 0 )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -513,7 +513,7 @@ extern std::vector<std::string> ASSETCHAINS_PRICES,ASSETCHAINS_STOCKS;
|
|||||||
|
|
||||||
extern uint256 KOMODO_EARLYTXID;
|
extern uint256 KOMODO_EARLYTXID;
|
||||||
|
|
||||||
extern int32_t KOMODO_CONNECTING,KOMODO_CCACTIVATE,KOMODO_DEALERNODE;
|
extern int32_t HUSH_CONNECTING,KOMODO_CCACTIVATE,KOMODO_DEALERNODE;
|
||||||
extern uint32_t ASSETCHAINS_CC;
|
extern uint32_t ASSETCHAINS_CC;
|
||||||
extern std::string CCerror,ASSETCHAINS_CCLIB;
|
extern std::string CCerror,ASSETCHAINS_CCLIB;
|
||||||
extern uint8_t ASSETCHAINS_CCDISABLES[256];
|
extern uint8_t ASSETCHAINS_CCDISABLES[256];
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "hush_defs.h"
|
#include "hush_defs.h"
|
||||||
|
|
||||||
void komodo_prefetch(FILE *fp);
|
void komodo_prefetch(FILE *fp);
|
||||||
uint32_t komodo_heightstamp(int32_t height);
|
uint32_t komodo_heightstamp(int32_t height);
|
||||||
void hush_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t kheight,uint32_t ktime,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth);
|
void hush_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t kheight,uint32_t ktime,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth);
|
||||||
@@ -33,7 +32,6 @@ int32_t hush_longestchain();
|
|||||||
uint64_t komodo_maxallowed(int32_t baseid);
|
uint64_t komodo_maxallowed(int32_t baseid);
|
||||||
int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max);
|
int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max);
|
||||||
int32_t komodo_checkvout(int32_t vout,int32_t k,int32_t indallvouts);
|
int32_t komodo_checkvout(int32_t vout,int32_t k,int32_t indallvouts);
|
||||||
|
|
||||||
pthread_mutex_t komodo_mutex,staked_mutex;
|
pthread_mutex_t komodo_mutex,staked_mutex;
|
||||||
|
|
||||||
#define KOMODO_ELECTION_GAP 2000 //((SMART_CHAIN_SYMBOL[0] == 0) ? 2000 : 100)
|
#define KOMODO_ELECTION_GAP 2000 //((SMART_CHAIN_SYMBOL[0] == 0) ? 2000 : 100)
|
||||||
@@ -42,7 +40,6 @@ pthread_mutex_t komodo_mutex,staked_mutex;
|
|||||||
struct pax_transaction *PAX;
|
struct pax_transaction *PAX;
|
||||||
int32_t NUM_PRICES; uint32_t *PVALS;
|
int32_t NUM_PRICES; uint32_t *PVALS;
|
||||||
struct knotaries_entry *Pubkeys;
|
struct knotaries_entry *Pubkeys;
|
||||||
|
|
||||||
struct hush_state KOMODO_STATES[34];
|
struct hush_state KOMODO_STATES[34];
|
||||||
|
|
||||||
#define _COINBASE_MATURITY 100
|
#define _COINBASE_MATURITY 100
|
||||||
@@ -50,7 +47,7 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100;
|
|||||||
unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+10;
|
unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+10;
|
||||||
uint256 KOMODO_EARLYTXID;
|
uint256 KOMODO_EARLYTXID;
|
||||||
|
|
||||||
int32_t HUSH_MININGTHREADS = -1,IS_HUSH_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,HUSH_PASSPORT_INITDONE,KOMODO_PAX,HUSH_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS,ASSETCHAINS_CBMATURITY,KOMODO_NSPV;
|
int32_t HUSH_MININGTHREADS = -1,IS_HUSH_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,HUSH_PASSPORT_INITDONE,KOMODO_PAX,HUSH_EXCHANGEWALLET,HUSH_REWIND,HUSH_CONNECTING = -1,KOMODO_DEALERNODE,HUSH_EXTRASATOSHI,ASSETCHAINS_FOUNDERS,ASSETCHAINS_CBMATURITY,KOMODO_NSPV;
|
||||||
int32_t HUSH_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1;
|
int32_t HUSH_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1;
|
||||||
std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,ASSETCHAINS_SELFIMPORT,ASSETCHAINS_CCLIB;
|
std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,ASSETCHAINS_SELFIMPORT,ASSETCHAINS_CCLIB;
|
||||||
uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_MARMARA;
|
uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_MARMARA;
|
||||||
@@ -62,7 +59,7 @@ char NOTARY_ADDRESSES[NUM_HUSH_SEASONS][64][64];
|
|||||||
|
|
||||||
char SMART_CHAIN_SYMBOL[HUSH_SMART_CHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096];
|
char SMART_CHAIN_SYMBOL[HUSH_SMART_CHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096];
|
||||||
uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_BEAMPORT,ASSETCHAINS_CODAPORT;
|
uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_BEAMPORT,ASSETCHAINS_CODAPORT;
|
||||||
uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC,KOMODO_STOPAT,KOMODO_DPOWCONFS = 1,STAKING_MIN_DIFF;
|
uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC,KOMODO_STOPAT,HUSH_DPOWCONFS = 1,STAKING_MIN_DIFF;
|
||||||
uint32_t ASSETCHAINS_MAGIC = 2387029918;
|
uint32_t ASSETCHAINS_MAGIC = 2387029918;
|
||||||
int64_t ASSETCHAINS_GENESISTXVAL = 5000000000;
|
int64_t ASSETCHAINS_GENESISTXVAL = 5000000000;
|
||||||
|
|
||||||
@@ -101,7 +98,7 @@ uint64_t ASSETCHAINS_COMMISSION,ASSETCHAINS_SUPPLY = 10,ASSETCHAINS_FOUNDERS_REW
|
|||||||
uint32_t HUSH_INITDONE;
|
uint32_t HUSH_INITDONE;
|
||||||
char KMDUSERPASS[8192+512+1],BTCUSERPASS[8192]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771;
|
char KMDUSERPASS[8192+512+1],BTCUSERPASS[8192]; uint16_t KMD_PORT = 7771,BITCOIND_RPCPORT = 7771;
|
||||||
uint64_t PENDING_KOMODO_TX;
|
uint64_t PENDING_KOMODO_TX;
|
||||||
extern int32_t KOMODO_LOADINGBLOCKS;
|
extern int32_t HUSH_LOADINGBLOCKS;
|
||||||
unsigned int MAX_BLOCK_SIGOPS = 20000;
|
unsigned int MAX_BLOCK_SIGOPS = 20000;
|
||||||
int32_t HUSH_TESTNODE, KOMODO_SNAPSHOT_INTERVAL;
|
int32_t HUSH_TESTNODE, KOMODO_SNAPSHOT_INTERVAL;
|
||||||
CScript KOMODO_EARLYTXID_SCRIPTPUB;
|
CScript KOMODO_EARLYTXID_SCRIPTPUB;
|
||||||
@@ -131,7 +128,7 @@ int32_t komodo_baseid(char *origbase)
|
|||||||
#ifndef SATOSHIDEN
|
#ifndef SATOSHIDEN
|
||||||
#define SATOSHIDEN ((uint64_t)100000000L)
|
#define SATOSHIDEN ((uint64_t)100000000L)
|
||||||
#endif
|
#endif
|
||||||
uint64_t komodo_current_supply(uint32_t nHeight)
|
uint64_t hush_current_supply(uint32_t nHeight)
|
||||||
{
|
{
|
||||||
uint64_t cur_money;
|
uint64_t cur_money;
|
||||||
int32_t baseid;
|
int32_t baseid;
|
||||||
@@ -255,9 +252,7 @@ uint64_t komodo_current_supply(uint32_t nHeight)
|
|||||||
|
|
||||||
// add more for the base rectangle if lowest subsidy is not 0
|
// add more for the base rectangle if lowest subsidy is not 0
|
||||||
cur_money += lowestSubsidy * (curEnd - lastEnd);
|
cur_money += lowestSubsidy * (curEnd - lastEnd);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
for ( int k = lastEnd; k < curEnd; k += period )
|
for ( int k = lastEnd; k < curEnd; k += period )
|
||||||
{
|
{
|
||||||
cur_money += period * reward;
|
cur_money += period * reward;
|
||||||
@@ -272,8 +267,7 @@ uint64_t komodo_current_supply(uint32_t nHeight)
|
|||||||
}
|
}
|
||||||
if ( KOMODO_BIT63SET(cur_money) != 0 )
|
if ( KOMODO_BIT63SET(cur_money) != 0 )
|
||||||
return(KOMODO_MAXNVALUE);
|
return(KOMODO_MAXNVALUE);
|
||||||
if ( ASSETCHAINS_COMMISSION != 0 )
|
if ( ASSETCHAINS_COMMISSION != 0 ) {
|
||||||
{
|
|
||||||
uint64_t newval = (cur_money + (cur_money/COIN * ASSETCHAINS_COMMISSION));
|
uint64_t newval = (cur_money + (cur_money/COIN * ASSETCHAINS_COMMISSION));
|
||||||
if ( KOMODO_BIT63SET(newval) != 0 )
|
if ( KOMODO_BIT63SET(newval) != 0 )
|
||||||
return(KOMODO_MAXNVALUE);
|
return(KOMODO_MAXNVALUE);
|
||||||
|
|||||||
@@ -317,7 +317,7 @@ int32_t hush_dpowconfs(int32_t txheight,int32_t numconfs)
|
|||||||
{
|
{
|
||||||
static int32_t hadnotarization;
|
static int32_t hadnotarization;
|
||||||
char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct hush_state *sp;
|
char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct hush_state *sp;
|
||||||
if ( KOMODO_DPOWCONFS != 0 && txheight > 0 && numconfs > 0 && (sp= hush_stateptr(symbol,dest)) != 0 )
|
if ( HUSH_DPOWCONFS != 0 && txheight > 0 && numconfs > 0 && (sp= hush_stateptr(symbol,dest)) != 0 )
|
||||||
{
|
{
|
||||||
if ( sp->NOTARIZED_HEIGHT > 0 )
|
if ( sp->NOTARIZED_HEIGHT > 0 )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1541,7 +1541,7 @@ char *argv0names[] = {
|
|||||||
// Large total supplies lead to numerical errors, beware!
|
// Large total supplies lead to numerical errors, beware!
|
||||||
uint64_t hush_max_money()
|
uint64_t hush_max_money()
|
||||||
{
|
{
|
||||||
return komodo_current_supply(10000000);
|
return hush_current_supply(10000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1859,9 +1859,9 @@ void hush_args(char *argv0)
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (KOMODO_REWIND= GetArg("-rewind",0)) != 0 )
|
if ( (HUSH_REWIND= GetArg("-rewind",0)) != 0 )
|
||||||
{
|
{
|
||||||
printf("KOMODO_REWIND %d\n",KOMODO_REWIND);
|
printf("HUSH_REWIND %d\n",HUSH_REWIND);
|
||||||
}
|
}
|
||||||
KOMODO_EARLYTXID = Parseuint256(GetArg("-earlytxid","0").c_str());
|
KOMODO_EARLYTXID = Parseuint256(GetArg("-earlytxid","0").c_str());
|
||||||
ASSETCHAINS_EARLYTXIDCONTRACT = GetArg("-ac_earlytxidcontract",0);
|
ASSETCHAINS_EARLYTXIDCONTRACT = GetArg("-ac_earlytxidcontract",0);
|
||||||
@@ -2433,7 +2433,7 @@ fprintf(stderr,"extralen.%d before disable bits\n",extralen);
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int32_t dpowconfs = KOMODO_DPOWCONFS;
|
int32_t dpowconfs = HUSH_DPOWCONFS;
|
||||||
if ( SMART_CHAIN_SYMBOL[0] != 0 )
|
if ( SMART_CHAIN_SYMBOL[0] != 0 )
|
||||||
{
|
{
|
||||||
BITCOIND_RPCPORT = GetArg("-rpcport", ASSETCHAINS_RPCPORT);
|
BITCOIND_RPCPORT = GetArg("-rpcport", ASSETCHAINS_RPCPORT);
|
||||||
@@ -2502,9 +2502,9 @@ fprintf(stderr,"extralen.%d before disable bits\n",extralen);
|
|||||||
CCENABLE(EVAL_ORACLES);
|
CCENABLE(EVAL_ORACLES);
|
||||||
}
|
}
|
||||||
} else BITCOIND_RPCPORT = GetArg("-rpcport", BaseParams().RPCPort());
|
} else BITCOIND_RPCPORT = GetArg("-rpcport", BaseParams().RPCPort());
|
||||||
KOMODO_DPOWCONFS = GetArg("-dpowconfs",dpowconfs);
|
HUSH_DPOWCONFS = GetArg("-dpowconfs",dpowconfs);
|
||||||
if ( SMART_CHAIN_SYMBOL[0] == 0 || strcmp(SMART_CHAIN_SYMBOL,"SUPERNET") == 0 || strcmp(SMART_CHAIN_SYMBOL,"DEX") == 0 || strcmp(SMART_CHAIN_SYMBOL,"COQUI") == 0 || strcmp(SMART_CHAIN_SYMBOL,"PIRATE") == 0 || strcmp(SMART_CHAIN_SYMBOL,"KMDICE") == 0 )
|
if ( SMART_CHAIN_SYMBOL[0] == 0 || strcmp(SMART_CHAIN_SYMBOL,"SUPERNET") == 0 || strcmp(SMART_CHAIN_SYMBOL,"DEX") == 0 || strcmp(SMART_CHAIN_SYMBOL,"COQUI") == 0 || strcmp(SMART_CHAIN_SYMBOL,"PIRATE") == 0 || strcmp(SMART_CHAIN_SYMBOL,"KMDICE") == 0 )
|
||||||
KOMODO_EXTRASATOSHI = 1;
|
HUSH_EXTRASATOSHI = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void komodo_nameset(char *symbol,char *dest,char *source)
|
void komodo_nameset(char *symbol,char *dest,char *source)
|
||||||
|
|||||||
16
src/init.cpp
16
src/init.cpp
@@ -90,7 +90,7 @@ using namespace std;
|
|||||||
#include "hush_defs.h"
|
#include "hush_defs.h"
|
||||||
extern void ThreadSendAlert();
|
extern void ThreadSendAlert();
|
||||||
extern bool komodo_dailysnapshot(int32_t height);
|
extern bool komodo_dailysnapshot(int32_t height);
|
||||||
extern int32_t KOMODO_LOADINGBLOCKS;
|
extern int32_t HUSH_LOADINGBLOCKS;
|
||||||
extern char SMART_CHAIN_SYMBOL[];
|
extern char SMART_CHAIN_SYMBOL[];
|
||||||
extern int32_t KOMODO_SNAPSHOT_INTERVAL;
|
extern int32_t KOMODO_SNAPSHOT_INTERVAL;
|
||||||
extern void komodo_init(int32_t height);
|
extern void komodo_init(int32_t height);
|
||||||
@@ -693,7 +693,7 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
|
|||||||
LogPrintf("Reindexing finished\n");
|
LogPrintf("Reindexing finished\n");
|
||||||
// To avoid ending up in a situation without genesis block, re-try initializing (no-op if reindexing worked):
|
// To avoid ending up in a situation without genesis block, re-try initializing (no-op if reindexing worked):
|
||||||
InitBlockIndex();
|
InitBlockIndex();
|
||||||
KOMODO_LOADINGBLOCKS = 0;
|
HUSH_LOADINGBLOCKS = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// hardcoded $DATADIR/bootstrap.dat
|
// hardcoded $DATADIR/bootstrap.dat
|
||||||
@@ -943,7 +943,7 @@ bool AppInitServers(boost::thread_group& threadGroup)
|
|||||||
/** Initialize Hush.
|
/** Initialize Hush.
|
||||||
* @pre Parameters should be parsed and config file should be read.
|
* @pre Parameters should be parsed and config file should be read.
|
||||||
*/
|
*/
|
||||||
extern int32_t KOMODO_REWIND;
|
extern int32_t HUSH_REWIND;
|
||||||
|
|
||||||
bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||||
{
|
{
|
||||||
@@ -1792,7 +1792,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
strLoadError = _("Error initializing block database");
|
strLoadError = _("Error initializing block database");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
KOMODO_LOADINGBLOCKS = 0;
|
HUSH_LOADINGBLOCKS = 0;
|
||||||
// Check for changed -txindex state
|
// Check for changed -txindex state
|
||||||
if (fTxIndex != GetBoolArg("-txindex", true)) {
|
if (fTxIndex != GetBoolArg("-txindex", true)) {
|
||||||
strLoadError = _("You need to rebuild the database using -reindex to change -txindex");
|
strLoadError = _("You need to rebuild the database using -reindex to change -txindex");
|
||||||
@@ -1834,7 +1834,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
LogPrintf("Prune: pruned datadir may not have more than %d blocks; -checkblocks=%d may fail\n",
|
LogPrintf("Prune: pruned datadir may not have more than %d blocks; -checkblocks=%d may fail\n",
|
||||||
MIN_BLOCKS_TO_KEEP, GetArg("-checkblocks", 288));
|
MIN_BLOCKS_TO_KEEP, GetArg("-checkblocks", 288));
|
||||||
}
|
}
|
||||||
if ( KOMODO_REWIND == 0 )
|
if ( HUSH_REWIND == 0 )
|
||||||
{
|
{
|
||||||
LogPrintf("Verifying block DB...");
|
LogPrintf("Verifying block DB...");
|
||||||
if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3), GetArg("-checkblocks", 288))) {
|
if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3), GetArg("-checkblocks", 288))) {
|
||||||
@@ -1870,7 +1870,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
KOMODO_LOADINGBLOCKS = 0;
|
HUSH_LOADINGBLOCKS = 0;
|
||||||
|
|
||||||
// As LoadBlockIndex can take several minutes, it's possible the user
|
// As LoadBlockIndex can take several minutes, it's possible the user
|
||||||
// requested to kill the GUI during the last operation. If so, exit.
|
// requested to kill the GUI during the last operation. If so, exit.
|
||||||
@@ -2145,7 +2145,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
uiInterface.NotifyBlockTip.connect(BlockNotifyCallback);
|
uiInterface.NotifyBlockTip.connect(BlockNotifyCallback);
|
||||||
if (mapArgs.count("-txexpirynotify"))
|
if (mapArgs.count("-txexpirynotify"))
|
||||||
uiInterface.NotifyTxExpiration.connect(TxExpiryNotifyCallback);
|
uiInterface.NotifyTxExpiration.connect(TxExpiryNotifyCallback);
|
||||||
if ( KOMODO_REWIND >= 0 )
|
if ( HUSH_REWIND >= 0 )
|
||||||
{
|
{
|
||||||
uiInterface.InitMessage(_("Activating best chain..."));
|
uiInterface.InitMessage(_("Activating best chain..."));
|
||||||
// scan for better chains in the block chain database, that are not yet connected in the active best chain
|
// scan for better chains in the block chain database, that are not yet connected in the active best chain
|
||||||
@@ -2153,7 +2153,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
if ( !ActivateBestChain(true,state))
|
if ( !ActivateBestChain(true,state))
|
||||||
strErrors << "Failed to connect best block";
|
strErrors << "Failed to connect best block";
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"KOMODO_REWIND < 0\n");
|
fprintf(stderr,"HUSH_REWIND < 0\n");
|
||||||
}
|
}
|
||||||
std::vector<boost::filesystem::path> vImportFiles;
|
std::vector<boost::filesystem::path> vImportFiles;
|
||||||
if (mapArgs.count("-loadblock"))
|
if (mapArgs.count("-loadblock"))
|
||||||
|
|||||||
@@ -754,7 +754,7 @@ int32_t komodo_is_notarytx(const CTransaction& tx)
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t komodo_block2height(CBlock *block)
|
int32_t hush_block2height(CBlock *block)
|
||||||
{
|
{
|
||||||
static uint32_t match,mismatch;
|
static uint32_t match,mismatch;
|
||||||
int32_t i,n,height2=-1,height = 0; uint8_t *ptr; CBlockIndex *pindex = NULL;
|
int32_t i,n,height2=-1,height = 0; uint8_t *ptr; CBlockIndex *pindex = NULL;
|
||||||
@@ -796,7 +796,7 @@ int32_t komodo_block2height(CBlock *block)
|
|||||||
int32_t komodo_block2pubkey33(uint8_t *pubkey33,CBlock *block)
|
int32_t komodo_block2pubkey33(uint8_t *pubkey33,CBlock *block)
|
||||||
{
|
{
|
||||||
int32_t n;
|
int32_t n;
|
||||||
if ( KOMODO_LOADINGBLOCKS == 0 )
|
if ( HUSH_LOADINGBLOCKS == 0 )
|
||||||
memset(pubkey33,0xff,33);
|
memset(pubkey33,0xff,33);
|
||||||
else memset(pubkey33,0,33);
|
else memset(pubkey33,0,33);
|
||||||
if ( block->vtx[0].vout.size() > 0 )
|
if ( block->vtx[0].vout.size() > 0 )
|
||||||
@@ -872,7 +872,7 @@ uint32_t komodo_heightstamp(int32_t height)
|
|||||||
if ( pindex->didinit == 0 )
|
if ( pindex->didinit == 0 )
|
||||||
{
|
{
|
||||||
pindex->notaryid = -1;
|
pindex->notaryid = -1;
|
||||||
if ( KOMODO_LOADINGBLOCKS == 0 )
|
if ( HUSH_LOADINGBLOCKS == 0 )
|
||||||
memset(pindex->pubkey33,0xff,33);
|
memset(pindex->pubkey33,0xff,33);
|
||||||
else memset(pindex->pubkey33,0,33);
|
else memset(pindex->pubkey33,0,33);
|
||||||
if ( komodo_blockload(block,pindex) == 0 )
|
if ( komodo_blockload(block,pindex) == 0 )
|
||||||
@@ -882,7 +882,7 @@ uint32_t komodo_heightstamp(int32_t height)
|
|||||||
// fprintf(stderr,"%02x",pindex->pubkey33[i]);
|
// fprintf(stderr,"%02x",pindex->pubkey33[i]);
|
||||||
//fprintf(stderr," set pubkey at height %d/%d\n",pindex->GetHeight(),height);
|
//fprintf(stderr," set pubkey at height %d/%d\n",pindex->GetHeight(),height);
|
||||||
//if ( pindex->pubkey33[0] == 2 || pindex->pubkey33[0] == 3 )
|
//if ( pindex->pubkey33[0] == 2 || pindex->pubkey33[0] == 3 )
|
||||||
// pindex->didinit = (KOMODO_LOADINGBLOCKS == 0);
|
// pindex->didinit = (HUSH_LOADINGBLOCKS == 0);
|
||||||
} // else fprintf(stderr,"error loading block at %d/%d",pindex->GetHeight(),height);
|
} // else fprintf(stderr,"error loading block at %d/%d",pindex->GetHeight(),height);
|
||||||
}
|
}
|
||||||
if ( pindex->didinit != 0 && pindex->GetHeight() >= 0 && (num= hush_notaries(pubkeys,(int32_t)pindex->GetHeight(),(uint32_t)pindex->nTime)) > 0 )
|
if ( pindex->didinit != 0 && pindex->GetHeight() >= 0 && (num= hush_notaries(pubkeys,(int32_t)pindex->GetHeight(),(uint32_t)pindex->nTime)) > 0 )
|
||||||
@@ -1203,7 +1203,7 @@ int32_t komodo_isrealtime(int32_t *kmdheightp)
|
|||||||
int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_t cmptime,int32_t dispflag)
|
int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_t cmptime,int32_t dispflag)
|
||||||
{
|
{
|
||||||
dispflag = 1;
|
dispflag = 1;
|
||||||
if ( KOMODO_REWIND == 0 && SMART_CHAIN_SYMBOL[0] == 0 && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD ) //1473793441 )
|
if ( HUSH_REWIND == 0 && SMART_CHAIN_SYMBOL[0] == 0 && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD ) //1473793441 )
|
||||||
{
|
{
|
||||||
if ( txheight > 246748 )
|
if ( txheight > 246748 )
|
||||||
{
|
{
|
||||||
@@ -1838,7 +1838,7 @@ int32_t komodo_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *sc
|
|||||||
return(notarizedheight);
|
return(notarizedheight);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector<int8_t> &NotarisationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len)
|
uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector<int8_t> &NotarizationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len)
|
||||||
{
|
{
|
||||||
// fetch notary pubkey array.
|
// fetch notary pubkey array.
|
||||||
uint64_t total = 0, AmountToPay = 0;
|
uint64_t total = 0, AmountToPay = 0;
|
||||||
@@ -1855,16 +1855,16 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector<int8_t> &Notar
|
|||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
// resize coinbase vouts to number of notary nodes +1 for coinbase itself.
|
// resize coinbase vouts to number of notary nodes +1 for coinbase itself.
|
||||||
txNew.vout.resize(NotarisationNotaries.size()+1);
|
txNew.vout.resize(NotarizationNotaries.size()+1);
|
||||||
|
|
||||||
// Calcualte the amount to pay according to the current era.
|
// Calcualte the amount to pay according to the current era.
|
||||||
AmountToPay = komodo_notarypayamount(height,NotarisationNotaries.size());
|
AmountToPay = komodo_notarypayamount(height,NotarizationNotaries.size());
|
||||||
if ( AmountToPay == 0 )
|
if ( AmountToPay == 0 )
|
||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
// loop over notarisation vins and add transaction to coinbase.
|
// loop over notarisation vins and add transaction to coinbase.
|
||||||
// Commented prints here can be used to verify manually the pubkeys match.
|
// Commented prints here can be used to verify manually the pubkeys match.
|
||||||
for (int8_t n = 0; n < NotarisationNotaries.size(); n++)
|
for (int8_t n = 0; n < NotarizationNotaries.size(); n++)
|
||||||
{
|
{
|
||||||
uint8_t *ptr;
|
uint8_t *ptr;
|
||||||
txNew.vout[n+1].scriptPubKey.resize(35);
|
txNew.vout[n+1].scriptPubKey.resize(35);
|
||||||
@@ -1872,18 +1872,18 @@ uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector<int8_t> &Notar
|
|||||||
ptr[0] = 33;
|
ptr[0] = 33;
|
||||||
for (int8_t i=0; i<33; i++)
|
for (int8_t i=0; i<33; i++)
|
||||||
{
|
{
|
||||||
ptr[i+1] = notarypubkeys[NotarisationNotaries[n]][i];
|
ptr[i+1] = notarypubkeys[NotarizationNotaries[n]][i];
|
||||||
//fprintf(stderr,"%02x",ptr[i+1]);
|
//fprintf(stderr,"%02x",ptr[i+1]);
|
||||||
}
|
}
|
||||||
ptr[34] = OP_CHECKSIG;
|
ptr[34] = OP_CHECKSIG;
|
||||||
//fprintf(stderr," set notary %i PUBKEY33 into vout[%i] amount.%lu\n",NotarisationNotaries[n],n+1,AmountToPay);
|
//fprintf(stderr," set notary %i PUBKEY33 into vout[%i] amount.%lu\n",NotarizationNotaries[n],n+1,AmountToPay);
|
||||||
txNew.vout[n+1].nValue = AmountToPay;
|
txNew.vout[n+1].nValue = AmountToPay;
|
||||||
total += txNew.vout[n+1].nValue;
|
total += txNew.vout[n+1].nValue;
|
||||||
}
|
}
|
||||||
return(total);
|
return(total);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetNotarisationNotaries(uint8_t notarypubkeys[64][33], int8_t &numNN, const std::vector<CTxIn> &vin, std::vector<int8_t> &NotarisationNotaries)
|
bool GetNotarizationNotaries(uint8_t notarypubkeys[64][33], int8_t &numNN, const std::vector<CTxIn> &vin, std::vector<int8_t> &NotarizationNotaries)
|
||||||
{
|
{
|
||||||
uint8_t *script; int32_t scriptlen;
|
uint8_t *script; int32_t scriptlen;
|
||||||
if ( notarypubkeys[0][0] == 0 )
|
if ( notarypubkeys[0][0] == 0 )
|
||||||
@@ -1898,7 +1898,7 @@ bool GetNotarisationNotaries(uint8_t notarypubkeys[64][33], int8_t &numNN, const
|
|||||||
script = (uint8_t *)&tx1.vout[txin.prevout.n].scriptPubKey[0];
|
script = (uint8_t *)&tx1.vout[txin.prevout.n].scriptPubKey[0];
|
||||||
scriptlen = (int32_t)tx1.vout[txin.prevout.n].scriptPubKey.size();
|
scriptlen = (int32_t)tx1.vout[txin.prevout.n].scriptPubKey.size();
|
||||||
if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,notarypubkeys[i],33) == 0 )
|
if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,notarypubkeys[i],33) == 0 )
|
||||||
NotarisationNotaries.push_back(i);
|
NotarizationNotaries.push_back(i);
|
||||||
}
|
}
|
||||||
} else return false;
|
} else return false;
|
||||||
}
|
}
|
||||||
@@ -1907,16 +1907,16 @@ bool GetNotarisationNotaries(uint8_t notarypubkeys[64][33], int8_t &numNN, const
|
|||||||
|
|
||||||
uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height)
|
uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height)
|
||||||
{
|
{
|
||||||
std::vector<int8_t> NotarisationNotaries; uint8_t *script; int32_t scriptlen;
|
std::vector<int8_t> NotarizationNotaries; uint8_t *script; int32_t scriptlen;
|
||||||
uint64_t timestamp = pblock->nTime;
|
uint64_t timestamp = pblock->nTime;
|
||||||
int8_t numSN = 0; uint8_t notarypubkeys[64][33] = {0};
|
int8_t numSN = 0; uint8_t notarypubkeys[64][33] = {0};
|
||||||
numSN = hush_notaries(notarypubkeys, height, timestamp);
|
numSN = hush_notaries(notarypubkeys, height, timestamp);
|
||||||
if ( !GetNotarisationNotaries(notarypubkeys, numSN, pblock->vtx[1].vin, NotarisationNotaries) )
|
if ( !GetNotarizationNotaries(notarypubkeys, numSN, pblock->vtx[1].vin, NotarizationNotaries) )
|
||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
// check a notary didnt sign twice (this would be an invalid notarisation later on and cause problems)
|
// check a notary didnt sign twice (this would be an invalid notarisation later on and cause problems)
|
||||||
std::set<int> checkdupes( NotarisationNotaries.begin(), NotarisationNotaries.end() );
|
std::set<int> checkdupes( NotarizationNotaries.begin(), NotarizationNotaries.end() );
|
||||||
if ( checkdupes.size() != NotarisationNotaries.size() ) {
|
if ( checkdupes.size() != NotarizationNotaries.size() ) {
|
||||||
fprintf(stderr, "Possible notarisation is signed multiple times by same notary. It is invalid.\n");
|
fprintf(stderr, "Possible notarisation is signed multiple times by same notary. It is invalid.\n");
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
@@ -1933,7 +1933,7 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height)
|
|||||||
{
|
{
|
||||||
// Create the coinbase tx again, using the extracted data, this is the same function the miner uses, with the same data.
|
// Create the coinbase tx again, using the extracted data, this is the same function the miner uses, with the same data.
|
||||||
// This allows us to know exactly that the coinbase is correct.
|
// This allows us to know exactly that the coinbase is correct.
|
||||||
totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime, height, script, scriptlen);
|
totalsats = komodo_notarypay(txNew, NotarizationNotaries, pblock->nTime, height, script, scriptlen);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1968,20 +1968,20 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height)
|
|||||||
// Check the pubkeys match the pubkeys in the notarisation.
|
// Check the pubkeys match the pubkeys in the notarisation.
|
||||||
script = (uint8_t *)&txout.scriptPubKey[0];
|
script = (uint8_t *)&txout.scriptPubKey[0];
|
||||||
scriptlen = (int32_t)txout.scriptPubKey.size();
|
scriptlen = (int32_t)txout.scriptPubKey.size();
|
||||||
if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,notarypubkeys[NotarisationNotaries[n-1]],33) == 0 )
|
if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,notarypubkeys[NotarizationNotaries[n-1]],33) == 0 )
|
||||||
{
|
{
|
||||||
// check the value is correct
|
// check the value is correct
|
||||||
if ( pblock->vtx[0].vout[n].nValue == AmountToPay )
|
if ( pblock->vtx[0].vout[n].nValue == AmountToPay )
|
||||||
{
|
{
|
||||||
matches++;
|
matches++;
|
||||||
total += txout.nValue;
|
total += txout.nValue;
|
||||||
//fprintf(stderr, "MATCHED AmountPaid.%lu notaryid.%i\n",AmountToPay,NotarisationNotaries[n-1]);
|
//fprintf(stderr, "MATCHED AmountPaid.%lu notaryid.%i\n",AmountToPay,NotarizationNotaries[n-1]);
|
||||||
}
|
}
|
||||||
else fprintf(stderr, "NOT MATCHED AmountPaid.%llu AmountToPay.%llu notaryid.%i\n", (long long)pblock->vtx[0].vout[n].nValue, (long long)AmountToPay, NotarisationNotaries[n-1]);
|
else fprintf(stderr, "NOT MATCHED AmountPaid.%llu AmountToPay.%llu notaryid.%i\n", (long long)pblock->vtx[0].vout[n].nValue, (long long)AmountToPay, NotarizationNotaries[n-1]);
|
||||||
}
|
}
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
if ( matches != 0 && matches == NotarisationNotaries.size() && totalsats == total )
|
if ( matches != 0 && matches == NotarizationNotaries.size() && totalsats == total )
|
||||||
{
|
{
|
||||||
//fprintf(stderr, "Validated coinbase matches notarisation in tx position 1.\n" );
|
//fprintf(stderr, "Validated coinbase matches notarisation in tx position 1.\n" );
|
||||||
return(totalsats);
|
return(totalsats);
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// Copyright (c) 2019-2020 The Hush developers
|
||||||
|
// Distributed under the GPLv3 software license, see the accompanying
|
||||||
|
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
* Copyright © 2014-2019 The SuperNET Developers. *
|
||||||
* *
|
* *
|
||||||
@@ -13,8 +16,8 @@
|
|||||||
* *
|
* *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#ifndef H_KOMODOEVENTS_H
|
#ifndef H_HUSHEVENTS_H
|
||||||
#define H_KOMODOEVENTS_H
|
#define H_HUSHEVENTS_H
|
||||||
#include "hush_defs.h"
|
#include "hush_defs.h"
|
||||||
|
|
||||||
struct komodo_event *komodo_eventadd(struct hush_state *sp,int32_t height,char *symbol,uint8_t type,uint8_t *data,uint16_t datalen)
|
struct komodo_event *komodo_eventadd(struct hush_state *sp,int32_t height,char *symbol,uint8_t type,uint8_t *data,uint16_t datalen)
|
||||||
@@ -169,16 +172,13 @@ void komodo_setkmdheight(struct hush_state *sp,int32_t kmdheight,uint32_t timest
|
|||||||
void komodo_eventadd_kmdheight(struct hush_state *sp,char *symbol,int32_t height,int32_t kmdheight,uint32_t timestamp)
|
void komodo_eventadd_kmdheight(struct hush_state *sp,char *symbol,int32_t height,int32_t kmdheight,uint32_t timestamp)
|
||||||
{
|
{
|
||||||
uint32_t buf[2];
|
uint32_t buf[2];
|
||||||
if ( kmdheight > 0 )
|
if ( kmdheight > 0 ) {
|
||||||
{
|
|
||||||
buf[0] = (uint32_t)kmdheight;
|
buf[0] = (uint32_t)kmdheight;
|
||||||
buf[1] = timestamp;
|
buf[1] = timestamp;
|
||||||
komodo_eventadd(sp,height,symbol,KOMODO_EVENT_KMDHEIGHT,(uint8_t *)buf,sizeof(buf));
|
komodo_eventadd(sp,height,symbol,KOMODO_EVENT_KMDHEIGHT,(uint8_t *)buf,sizeof(buf));
|
||||||
if ( sp != 0 )
|
if ( sp != 0 )
|
||||||
komodo_setkmdheight(sp,kmdheight,timestamp);
|
komodo_setkmdheight(sp,kmdheight,timestamp);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
//fprintf(stderr,"REWIND kmdheight.%d\n",kmdheight);
|
//fprintf(stderr,"REWIND kmdheight.%d\n",kmdheight);
|
||||||
kmdheight = -kmdheight;
|
kmdheight = -kmdheight;
|
||||||
komodo_eventadd(sp,height,symbol,KOMODO_EVENT_REWIND,(uint8_t *)&height,sizeof(height));
|
komodo_eventadd(sp,height,symbol,KOMODO_EVENT_REWIND,(uint8_t *)&height,sizeof(height));
|
||||||
@@ -188,31 +188,4 @@ void komodo_eventadd_kmdheight(struct hush_state *sp,char *symbol,int32_t height
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*void komodo_eventadd_deposit(int32_t actionflag,char *symbol,int32_t height,uint64_t komodoshis,char *fiat,uint64_t fiatoshis,uint8_t rmd160[20],bits256 kmdtxid,uint16_t kmdvout,uint64_t price)
|
|
||||||
{
|
|
||||||
uint8_t opret[512]; uint16_t opretlen;
|
|
||||||
komodo_eventadd_opreturn(symbol,height,KOMODO_OPRETURN_DEPOSIT,kmdtxid,komodoshis,kmdvout,opret,opretlen);
|
|
||||||
}
|
|
||||||
|
|
||||||
void komodo_eventadd_issued(int32_t actionflag,char *symbol,int32_t height,int32_t fiatheight,bits256 fiattxid,uint16_t fiatvout,bits256 kmdtxid,uint16_t kmdvout,uint64_t fiatoshis)
|
|
||||||
{
|
|
||||||
uint8_t opret[512]; uint16_t opretlen;
|
|
||||||
komodo_eventadd_opreturn(symbol,height,KOMODO_OPRETURN_ISSUED,fiattxid,fiatoshis,fiatvout,opret,opretlen);
|
|
||||||
}
|
|
||||||
|
|
||||||
void komodo_eventadd_withdraw(int32_t actionflag,char *symbol,int32_t height,uint64_t komodoshis,char *fiat,uint64_t fiatoshis,uint8_t rmd160[20],bits256 fiattxid,int32_t fiatvout,uint64_t price)
|
|
||||||
{
|
|
||||||
uint8_t opret[512]; uint16_t opretlen;
|
|
||||||
komodo_eventadd_opreturn(symbol,height,KOMODO_OPRETURN_WITHDRAW,fiattxid,fiatoshis,fiatvout,opret,opretlen);
|
|
||||||
}
|
|
||||||
|
|
||||||
void komodo_eventadd_redeemed(int32_t actionflag,char *symbol,int32_t height,bits256 kmdtxid,uint16_t kmdvout,int32_t fiatheight,bits256 fiattxid,uint16_t fiatvout,uint64_t komodoshis)
|
|
||||||
{
|
|
||||||
uint8_t opret[512]; uint16_t opretlen;
|
|
||||||
komodo_eventadd_opreturn(symbol,height,KOMODO_OPRETURN_REDEEMED,kmdtxid,komodoshis,kmdvout,opret,opretlen);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// process events
|
|
||||||
//
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -36,12 +36,12 @@ struct NSPV_ntzargs
|
|||||||
|
|
||||||
int32_t NSPV_notarization_find(struct NSPV_ntzargs *args,int32_t height,int32_t dir)
|
int32_t NSPV_notarization_find(struct NSPV_ntzargs *args,int32_t height,int32_t dir)
|
||||||
{
|
{
|
||||||
int32_t ntzheight = 0; uint256 hashBlock; CTransaction tx; Notarisation nota; char *symbol; std::vector<uint8_t> opret;
|
int32_t ntzheight = 0; uint256 hashBlock; CTransaction tx; Notarization nota; char *symbol; std::vector<uint8_t> opret;
|
||||||
symbol = (SMART_CHAIN_SYMBOL[0] == 0) ? (char *)"KMD" : SMART_CHAIN_SYMBOL;
|
symbol = (SMART_CHAIN_SYMBOL[0] == 0) ? (char *)"KMD" : SMART_CHAIN_SYMBOL;
|
||||||
memset(args,0,sizeof(*args));
|
memset(args,0,sizeof(*args));
|
||||||
if ( dir > 0 )
|
if ( dir > 0 )
|
||||||
height += 10;
|
height += 10;
|
||||||
if ( (args->txidht= ScanNotarisationsDB(height,symbol,1440,nota)) == 0 )
|
if ( (args->txidht= ScanNotarizationsDB(height,symbol,1440,nota)) == 0 )
|
||||||
return(-1);
|
return(-1);
|
||||||
args->txid = nota.first;
|
args->txid = nota.first;
|
||||||
if ( !GetTransaction(args->txid,tx,hashBlock,false) || tx.vout.size() < 2 )
|
if ( !GetTransaction(args->txid,tx,hashBlock,false) || tx.vout.size() < 2 )
|
||||||
|
|||||||
195
src/main.cpp
195
src/main.cpp
@@ -65,24 +65,22 @@ using namespace std;
|
|||||||
# error "Hush cannot be compiled without assertions, lulz"
|
# error "Hush cannot be compiled without assertions, lulz"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// which fork? lulzzzzzzz
|
||||||
#include "librustzcash.h"
|
#include "librustzcash.h"
|
||||||
|
|
||||||
/**
|
// Global state
|
||||||
* Global state
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define TMPFILE_START 100000000
|
#define TMPFILE_START 100000000
|
||||||
CCriticalSection cs_main;
|
CCriticalSection cs_main;
|
||||||
extern uint8_t NOTARY_PUBKEY33[33];
|
extern uint8_t NOTARY_PUBKEY33[33];
|
||||||
extern int32_t KOMODO_LOADINGBLOCKS,HUSH_LONGESTCHAIN,HUSH_INSYNC,KOMODO_CONNECTING,KOMODO_EXTRASATOSHI;
|
extern int32_t HUSH_LOADINGBLOCKS,HUSH_LONGESTCHAIN,HUSH_INSYNC,HUSH_CONNECTING,HUSH_EXTRASATOSHI;
|
||||||
int32_t KOMODO_NEWBLOCKS;
|
int32_t HUSH_NEWBLOCKS;
|
||||||
int32_t komodo_block2pubkey33(uint8_t *pubkey33,CBlock *block);
|
int32_t komodo_block2pubkey33(uint8_t *pubkey33,CBlock *block);
|
||||||
//void komodo_broadcast(CBlock *pblock,int32_t limit);
|
//void komodo_broadcast(CBlock *pblock,int32_t limit);
|
||||||
bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey);
|
bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey);
|
||||||
void hush_setactivation(int32_t height);
|
void hush_setactivation(int32_t height);
|
||||||
void hush_changeblocktime();
|
void hush_changeblocktime();
|
||||||
void komodo_pricesupdate(int32_t height,CBlock *pblock);
|
void komodo_pricesupdate(int32_t height,CBlock *pblock);
|
||||||
|
|
||||||
BlockMap mapBlockIndex;
|
BlockMap mapBlockIndex;
|
||||||
CChain chainActive;
|
CChain chainActive;
|
||||||
CBlockIndex *pindexBestHeader = NULL;
|
CBlockIndex *pindexBestHeader = NULL;
|
||||||
@@ -679,9 +677,9 @@ bool komodo_dailysnapshot(int32_t height)
|
|||||||
{
|
{
|
||||||
// we are on chain init, and need to scan all the way back to the correct height, other wise our node will have a diffrent snapshot to online nodes.
|
// we are on chain init, and need to scan all the way back to the correct height, other wise our node will have a diffrent snapshot to online nodes.
|
||||||
// use the notarizationsDB to scan back from the consesnus height to get the offset we need.
|
// use the notarizationsDB to scan back from the consesnus height to get the offset we need.
|
||||||
std::string symbol; Notarisation nota;
|
std::string symbol; Notarization nota;
|
||||||
symbol.assign(SMART_CHAIN_SYMBOL);
|
symbol.assign(SMART_CHAIN_SYMBOL);
|
||||||
if ( ScanNotarisationsDB(height-extraoffset, symbol, 100, nota) == 0 )
|
if ( ScanNotarizationsDB(height-extraoffset, symbol, 100, nota) == 0 )
|
||||||
undo_height = height-extraoffset-reorglimit;
|
undo_height = height-extraoffset-reorglimit;
|
||||||
else undo_height = nota.second.height;
|
else undo_height = nota.second.height;
|
||||||
//fprintf(stderr, "height.%i-extraoffset.%i = startscanfrom.%i to get undo_height.%i\n", height, extraoffset, height-extraoffset, undo_height);
|
//fprintf(stderr, "height.%i-extraoffset.%i = startscanfrom.%i to get undo_height.%i\n", height, extraoffset, height-extraoffset, undo_height);
|
||||||
@@ -2009,20 +2007,20 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
|||||||
// invalid blocks, however allowing such transactions into the mempool
|
// invalid blocks, however allowing such transactions into the mempool
|
||||||
// can be exploited as a DoS attack.
|
// can be exploited as a DoS attack.
|
||||||
// XXX: is this neccesary for CryptoConditions?
|
// XXX: is this neccesary for CryptoConditions?
|
||||||
if ( KOMODO_CONNECTING <= 0 && chainActive.LastTip() != 0 )
|
if ( HUSH_CONNECTING <= 0 && chainActive.LastTip() != 0 )
|
||||||
{
|
{
|
||||||
flag = 1;
|
flag = 1;
|
||||||
KOMODO_CONNECTING = (1<<30) + (int32_t)chainActive.LastTip()->GetHeight() + 1;
|
HUSH_CONNECTING = (1<<30) + (int32_t)chainActive.LastTip()->GetHeight() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId))
|
if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId))
|
||||||
{
|
{
|
||||||
if ( flag != 0 )
|
if ( flag != 0 )
|
||||||
KOMODO_CONNECTING = -1;
|
HUSH_CONNECTING = -1;
|
||||||
return error("AcceptToMemoryPool: BUG! PLEASE REPORT THIS! ConnectInputs failed against MANDATORY but not STANDARD flags %s", hash.ToString());
|
return error("AcceptToMemoryPool: BUG! PLEASE REPORT THIS! ConnectInputs failed against MANDATORY but not STANDARD flags %s", hash.ToString());
|
||||||
}
|
}
|
||||||
if ( flag != 0 )
|
if ( flag != 0 )
|
||||||
KOMODO_CONNECTING = -1;
|
HUSH_CONNECTING = -1;
|
||||||
|
|
||||||
{
|
{
|
||||||
LOCK(pool.cs);
|
LOCK(pool.cs);
|
||||||
@@ -2908,11 +2906,11 @@ static bool ApplyTxInUndo(const CTxInUndo& undo, CCoinsViewCache& view, const CO
|
|||||||
|
|
||||||
void ConnectNotarizations(const CBlock &block, int height)
|
void ConnectNotarizations(const CBlock &block, int height)
|
||||||
{
|
{
|
||||||
NotarisationsInBlock notarisations = ScanBlockNotarizations(block, height);
|
NotarizationsInBlock notarisations = ScanBlockNotarizations(block, height);
|
||||||
if (notarisations.size() > 0) {
|
if (notarisations.size() > 0) {
|
||||||
CDBBatch batch = CDBBatch(*pnotarizations);
|
CDBBatch batch = CDBBatch(*pnotarizations);
|
||||||
batch.Write(block.GetHash(), notarisations);
|
batch.Write(block.GetHash(), notarisations);
|
||||||
WriteBackNotarisations(notarisations, batch);
|
WriteBackNotarizations(notarisations, batch);
|
||||||
pnotarizations->WriteBatch(batch, true);
|
pnotarizations->WriteBatch(batch, true);
|
||||||
LogPrintf("ConnectBlock: wrote %i block notarizations in block: %s\n",
|
LogPrintf("ConnectBlock: wrote %i block notarizations in block: %s\n",
|
||||||
notarisations.size(), block.GetHash().GetHex().data());
|
notarisations.size(), block.GetHash().GetHex().data());
|
||||||
@@ -2921,11 +2919,11 @@ void ConnectNotarizations(const CBlock &block, int height)
|
|||||||
|
|
||||||
void DisconnectNotarizations(const CBlock &block)
|
void DisconnectNotarizations(const CBlock &block)
|
||||||
{
|
{
|
||||||
NotarisationsInBlock nibs;
|
NotarizationsInBlock nibs;
|
||||||
if (GetBlockNotarisations(block.GetHash(), nibs)) {
|
if (GetBlockNotarizations(block.GetHash(), nibs)) {
|
||||||
CDBBatch batch = CDBBatch(*pnotarizations);
|
CDBBatch batch = CDBBatch(*pnotarizations);
|
||||||
batch.Erase(block.GetHash());
|
batch.Erase(block.GetHash());
|
||||||
EraseBackNotarisations(nibs, batch);
|
EraseBackNotarizations(nibs, batch);
|
||||||
pnotarizations->WriteBatch(batch, true);
|
pnotarizations->WriteBatch(batch, true);
|
||||||
LogPrintf("DisconnectTip: deleted %i block notarizations in block: %s\n",
|
LogPrintf("DisconnectTip: deleted %i block notarizations in block: %s\n",
|
||||||
nibs.size(), block.GetHash().GetHex().data());
|
nibs.size(), block.GetHash().GetHex().data());
|
||||||
@@ -3594,7 +3592,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||||||
return state.DoS(100, error("ConnectBlock(): coinbase for block 1 pays wrong amount (actual=%d vs correct=%d)", block.vtx[0].GetValueOut(), blockReward),
|
return state.DoS(100, error("ConnectBlock(): coinbase for block 1 pays wrong amount (actual=%d vs correct=%d)", block.vtx[0].GetValueOut(), blockReward),
|
||||||
REJECT_INVALID, "bad-cb-amount");
|
REJECT_INVALID, "bad-cb-amount");
|
||||||
}
|
}
|
||||||
if ( block.vtx[0].GetValueOut() > blockReward+KOMODO_EXTRASATOSHI )
|
if ( block.vtx[0].GetValueOut() > blockReward+HUSH_EXTRASATOSHI )
|
||||||
{
|
{
|
||||||
if ( SMART_CHAIN_SYMBOL[0] != 0 || pindex->GetHeight() >= KOMODO_NOTARIES_HEIGHT1 || block.vtx[0].vout[0].nValue > blockReward )
|
if ( SMART_CHAIN_SYMBOL[0] != 0 || pindex->GetHeight() >= KOMODO_NOTARIES_HEIGHT1 || block.vtx[0].vout[0].nValue > blockReward )
|
||||||
{
|
{
|
||||||
@@ -3844,7 +3842,7 @@ void static UpdateTip(CBlockIndex *pindexNew) {
|
|||||||
// New best block
|
// New best block
|
||||||
nTimeBestReceived = GetTime();
|
nTimeBestReceived = GetTime();
|
||||||
mempool.AddTransactionsUpdated(1);
|
mempool.AddTransactionsUpdated(1);
|
||||||
KOMODO_NEWBLOCKS++;
|
HUSH_NEWBLOCKS++;
|
||||||
double progress;
|
double progress;
|
||||||
if ( SMART_CHAIN_SYMBOL[0] == 0 ) {
|
if ( SMART_CHAIN_SYMBOL[0] == 0 ) {
|
||||||
progress = Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), chainActive.LastTip());
|
progress = Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), chainActive.LastTip());
|
||||||
@@ -4044,7 +4042,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
|
|||||||
return AbortNode(state, "Failed to read block");
|
return AbortNode(state, "Failed to read block");
|
||||||
pblock = █
|
pblock = █
|
||||||
}
|
}
|
||||||
KOMODO_CONNECTING = (int32_t)pindexNew->GetHeight();
|
HUSH_CONNECTING = (int32_t)pindexNew->GetHeight();
|
||||||
//fprintf(stderr,"%s connecting ht.%d maxsize.%d vs %d\n",SMART_CHAIN_SYMBOL,(int32_t)pindexNew->GetHeight(),MAX_BLOCK_SIZE(pindexNew->GetHeight()),(int32_t)::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION));
|
//fprintf(stderr,"%s connecting ht.%d maxsize.%d vs %d\n",SMART_CHAIN_SYMBOL,(int32_t)pindexNew->GetHeight(),MAX_BLOCK_SIZE(pindexNew->GetHeight()),(int32_t)::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION));
|
||||||
|
|
||||||
// Apply the block atomically to the chain state.
|
// Apply the block atomically to the chain state.
|
||||||
@@ -4054,7 +4052,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
|
|||||||
{
|
{
|
||||||
CCoinsViewCache view(pcoinsTip);
|
CCoinsViewCache view(pcoinsTip);
|
||||||
bool rv = ConnectBlock(*pblock, state, pindexNew, view, false, true);
|
bool rv = ConnectBlock(*pblock, state, pindexNew, view, false, true);
|
||||||
KOMODO_CONNECTING = -1;
|
HUSH_CONNECTING = -1;
|
||||||
GetMainSignals().BlockChecked(*pblock, state);
|
GetMainSignals().BlockChecked(*pblock, state);
|
||||||
if (!rv) {
|
if (!rv) {
|
||||||
if (state.IsInvalid())
|
if (state.IsInvalid())
|
||||||
@@ -4322,11 +4320,11 @@ static bool ActivateBestChainStep(bool fSkipdpow, CValidationState &state, CBloc
|
|||||||
return false;
|
return false;
|
||||||
fBlocksDisconnected = true;
|
fBlocksDisconnected = true;
|
||||||
}
|
}
|
||||||
if ( KOMODO_REWIND != 0 )
|
if ( HUSH_REWIND != 0 )
|
||||||
{
|
{
|
||||||
CBlockIndex *tipindex;
|
CBlockIndex *tipindex;
|
||||||
fprintf(stderr,">>>>>>>>>>> rewind start ht.%d -> KOMODO_REWIND.%d\n",chainActive.LastTip()->GetHeight(),KOMODO_REWIND);
|
fprintf(stderr,">>>>>>>>>>> rewind start ht.%d -> HUSH_REWIND.%d\n",chainActive.LastTip()->GetHeight(),HUSH_REWIND);
|
||||||
while ( KOMODO_REWIND > 0 && (tipindex= chainActive.LastTip()) != 0 && tipindex->GetHeight() > KOMODO_REWIND )
|
while ( HUSH_REWIND > 0 && (tipindex= chainActive.LastTip()) != 0 && tipindex->GetHeight() > HUSH_REWIND )
|
||||||
{
|
{
|
||||||
fBlocksDisconnected = true;
|
fBlocksDisconnected = true;
|
||||||
fprintf(stderr,"%d ",(int32_t)tipindex->GetHeight());
|
fprintf(stderr,"%d ",(int32_t)tipindex->GetHeight());
|
||||||
@@ -4334,10 +4332,10 @@ static bool ActivateBestChainStep(bool fSkipdpow, CValidationState &state, CBloc
|
|||||||
if ( !DisconnectTip(state) )
|
if ( !DisconnectTip(state) )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fprintf(stderr,"reached rewind.%d, best to do: ./komodo-cli -ac_name=%s stop\n",KOMODO_REWIND,SMART_CHAIN_SYMBOL);
|
fprintf(stderr,"reached rewind.%d, best to do: ./komodo-cli -ac_name=%s stop\n",HUSH_REWIND,SMART_CHAIN_SYMBOL);
|
||||||
sleep(20);
|
sleep(20);
|
||||||
fprintf(stderr,"resuming normal operations\n");
|
fprintf(stderr,"resuming normal operations\n");
|
||||||
KOMODO_REWIND = 0;
|
HUSH_REWIND = 0;
|
||||||
//return(true);
|
//return(true);
|
||||||
}
|
}
|
||||||
// Build list of new blocks to connect.
|
// Build list of new blocks to connect.
|
||||||
@@ -5185,7 +5183,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C
|
|||||||
for (uint32_t i = 0; i < block.vtx.size(); i++)
|
for (uint32_t i = 0; i < block.vtx.size(); i++)
|
||||||
{
|
{
|
||||||
const CTransaction& tx = block.vtx[i];
|
const CTransaction& tx = block.vtx[i];
|
||||||
if ( komodo_validate_interest(tx,height == 0 ? komodo_block2height((CBlock *)&block) : height,block.nTime,0) < 0 )
|
if ( komodo_validate_interest(tx,height == 0 ? hush_block2height((CBlock *)&block) : height,block.nTime,0) < 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "validate intrest failed for txnum.%i tx.%s\n", i, tx.ToString().c_str());
|
fprintf(stderr, "validate intrest failed for txnum.%i tx.%s\n", i, tx.ToString().c_str());
|
||||||
return error("CheckBlock: komodo_validate_interest failed");
|
return error("CheckBlock: komodo_validate_interest failed");
|
||||||
@@ -5241,9 +5239,14 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
|
|||||||
int nHeight = pindexPrev->GetHeight()+1;
|
int nHeight = pindexPrev->GetHeight()+1;
|
||||||
|
|
||||||
// Check Proof-of-Work
|
// Check Proof-of-Work
|
||||||
if ( (SMART_CHAIN_SYMBOL[0] != 0 || nHeight < 235300 || nHeight > 236000) && block.nBits != GetNextWorkRequired(pindexPrev, &block, consensusParams))
|
if ( (SMART_CHAIN_SYMBOL[0] != 0 || nHeight < 235300 || nHeight > 236000) && block.nBits != GetNextWorkRequired(pindexPrev, &block, consensusParams)) {
|
||||||
{
|
cout << "Incorrect Proof-of-Work! " <<
|
||||||
cout "Incorrect Proof-of-Work! " << block.nBits << " block.nBits vs. calc " << GetNextWorkRequired(pindexPrev, &block, consensusParams) << " for height " << nHeight << " " << block.GetHash().ToString() << " with time " << block.GetBlockTime() << endl;
|
block.nBits << " block.nBits vs. calc " <<
|
||||||
|
GetNextWorkRequired(pindexPrev, &block, consensusParams) <<
|
||||||
|
" for height " << nHeight << " " <<
|
||||||
|
block.GetHash().ToString() << " with time " <<
|
||||||
|
block.GetBlockTime() << endl;
|
||||||
|
|
||||||
return state.DoS(100, error("%s: Incorrect Proof-of-Work at height %d", __func__, nHeight), REJECT_INVALID, "bad-diffbits");
|
return state.DoS(100, error("%s: Incorrect Proof-of-Work at height %d", __func__, nHeight), REJECT_INVALID, "bad-diffbits");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5361,9 +5364,8 @@ bool AcceptBlockHeader(int32_t *futureblockp,const CBlockHeader& block, CValidat
|
|||||||
miSelf->second = pindex = AddToBlockIndex(block);
|
miSelf->second = pindex = AddToBlockIndex(block);
|
||||||
if (ppindex)
|
if (ppindex)
|
||||||
*ppindex = pindex;
|
*ppindex = pindex;
|
||||||
if ( pindex != 0 && (pindex->nStatus & BLOCK_FAILED_MASK) != 0 )
|
if ( pindex != 0 && (pindex->nStatus & BLOCK_FAILED_MASK) != 0 ) {
|
||||||
{
|
if ( ASSETCHAINS_CC == 0 ) {
|
||||||
if ( ASSETCHAINS_CC == 0 )//&& (ASSETCHAINS_PRIVATE == 0 || HUSH_INSYNC >= Params().GetConsensus().vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight) )
|
|
||||||
return state.Invalid(error("%s: block is marked invalid", __func__), 0, "duplicate");
|
return state.Invalid(error("%s: block is marked invalid", __func__), 0, "duplicate");
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"reconsider block %s\n",hash.GetHex().c_str());
|
fprintf(stderr,"reconsider block %s\n",hash.GetHex().c_str());
|
||||||
@@ -5372,11 +5374,9 @@ bool AcceptBlockHeader(int32_t *futureblockp,const CBlockHeader& block, CValidat
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!CheckBlockHeader(futureblockp,*ppindex!=0?(*ppindex)->GetHeight():0,*ppindex, block, state,0))
|
if (!CheckBlockHeader(futureblockp,*ppindex!=0?(*ppindex)->GetHeight():0,*ppindex, block, state,0)) {
|
||||||
{
|
if ( *futureblockp == 0 ) {
|
||||||
if ( *futureblockp == 0 )
|
LogPrintf("%s: CheckBlockHeader futureblock=0\n", __func__);
|
||||||
{
|
|
||||||
LogPrintf("AcceptBlockHeader CheckBlockHeader error\n");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5387,7 +5387,7 @@ bool AcceptBlockHeader(int32_t *futureblockp,const CBlockHeader& block, CValidat
|
|||||||
BlockMap::iterator mi = mapBlockIndex.find(block.hashPrevBlock);
|
BlockMap::iterator mi = mapBlockIndex.find(block.hashPrevBlock);
|
||||||
if (mi == mapBlockIndex.end())
|
if (mi == mapBlockIndex.end())
|
||||||
{
|
{
|
||||||
LogPrintf("AcceptBlockHeader hashPrevBlock %s not found\n",block.hashPrevBlock.ToString().c_str());
|
LogPrintf("%s: hashPrevBlock %s not found\n",__func__, block.hashPrevBlock.ToString().c_str());
|
||||||
//*futureblockp = 1;
|
//*futureblockp = 1;
|
||||||
return(false);
|
return(false);
|
||||||
//return state.DoS(10, error("%s: prev block not found", __func__), 0, "bad-prevblk");
|
//return state.DoS(10, error("%s: prev block not found", __func__), 0, "bad-prevblk");
|
||||||
@@ -5395,7 +5395,7 @@ bool AcceptBlockHeader(int32_t *futureblockp,const CBlockHeader& block, CValidat
|
|||||||
pindexPrev = (*mi).second;
|
pindexPrev = (*mi).second;
|
||||||
if (pindexPrev == 0 )
|
if (pindexPrev == 0 )
|
||||||
{
|
{
|
||||||
LogPrintf("AcceptBlockHeader hashPrevBlock %s no pindexPrev\n",block.hashPrevBlock.ToString().c_str());
|
LogPrintf("%s: hashPrevBlock %s no pindexPrev\n",__func__,block.hashPrevBlock.ToString().c_str());
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
if ( (pindexPrev->nStatus & BLOCK_FAILED_MASK) )
|
if ( (pindexPrev->nStatus & BLOCK_FAILED_MASK) )
|
||||||
@@ -5404,7 +5404,7 @@ bool AcceptBlockHeader(int32_t *futureblockp,const CBlockHeader& block, CValidat
|
|||||||
if (!ContextualCheckBlockHeader(block, state, pindexPrev))
|
if (!ContextualCheckBlockHeader(block, state, pindexPrev))
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"AcceptBlockHeader ContextualCheckBlockHeader failed\n");
|
//fprintf(stderr,"AcceptBlockHeader ContextualCheckBlockHeader failed\n");
|
||||||
LogPrintf("AcceptBlockHeader ContextualCheckBlockHeader failed\n");
|
LogPrintf("%s: ContextualCheckBlockHeader failed\n",__func__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (pindex == NULL)
|
if (pindex == NULL)
|
||||||
@@ -5434,13 +5434,13 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C
|
|||||||
{
|
{
|
||||||
if ( *futureblockp == 0 )
|
if ( *futureblockp == 0 )
|
||||||
{
|
{
|
||||||
LogPrintf("AcceptBlock AcceptBlockHeader error\n");
|
LogPrintf("%s: AcceptBlockHeader error\n",__func__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( pindex == 0 )
|
if ( pindex == 0 )
|
||||||
{
|
{
|
||||||
LogPrintf("AcceptBlock null pindex\n");
|
LogPrintf("%s: null pindex\n", __func__);
|
||||||
*futureblockp = true;
|
*futureblockp = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -5556,7 +5556,7 @@ static bool IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned
|
|||||||
return (nFound >= nRequired);
|
return (nFound >= nRequired);
|
||||||
}
|
}
|
||||||
|
|
||||||
void komodo_currentheight_set(int32_t height);
|
void hush_currentheight_set(int32_t height);
|
||||||
|
|
||||||
CBlockIndex *komodo_ensure(CBlock *pblock, uint256 hash)
|
CBlockIndex *komodo_ensure(CBlock *pblock, uint256 hash)
|
||||||
{
|
{
|
||||||
@@ -5595,26 +5595,23 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo
|
|||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
if ( chainActive.LastTip() != 0 )
|
if ( chainActive.LastTip() != 0 )
|
||||||
komodo_currentheight_set(chainActive.LastTip()->GetHeight());
|
hush_currentheight_set(chainActive.LastTip()->GetHeight());
|
||||||
checked = CheckBlock(&futureblock,height!=0?height:komodo_block2height(pblock),0,*pblock, state, verifier,0);
|
checked = CheckBlock(&futureblock,height!=0?height:hush_block2height(pblock),0,*pblock, state, verifier,0);
|
||||||
bool fRequested = MarkBlockAsReceived(hash);
|
bool fRequested = MarkBlockAsReceived(hash);
|
||||||
// Test thing on LABS to test viability of rejecting a node pushing a chain.
|
// Reject nodes which push malicious chainforks.
|
||||||
// Supposed to stop malicious forks being pushed. Untested. Disabled incase of problems it may cause.
|
// Originally researched and written by blackjok3r, core dev of KMD+LABS
|
||||||
if ( 0 && pfrom && !fRequested && vNodes.size() > 1 )
|
// Optimized by Hush developers ;)
|
||||||
{
|
if ( GetArg("-debugchainforks",false) && (pfrom && !fRequested && vNodes.size() > 1) ) {
|
||||||
pfrom->nBlocksinARow += 1;
|
pfrom->nBlocksinARow += 1;
|
||||||
if ( pfrom->nBlocksinARow >= 10 )
|
if ( pfrom->nBlocksinARow >= 10 )
|
||||||
{
|
{
|
||||||
pfrom->nBlocksinARow2 += 1;
|
pfrom->nBlocksinARow2 += 1;
|
||||||
if ( pfrom->nBlocksinARow2 > 5 )
|
if ( pfrom->nBlocksinARow2 > 5 ) {
|
||||||
{
|
pfrom->nBlocksinARow = 0;
|
||||||
pfrom->nBlocksinARow = 0;
|
|
||||||
pfrom->nBlocksinARow2 = 0;
|
pfrom->nBlocksinARow2 = 0;
|
||||||
fprintf(stderr, "reset node.%i\n",(int32_t)pfrom->GetId());
|
fprintf(stderr, "%s: reset node.%i\n",__func__, (int32_t)pfrom->GetId());
|
||||||
}
|
} else {
|
||||||
else
|
fprintf(stderr, "%s: Requesting new peer node.%i blocksinrow.%i blocsinrow2.%i\n",__func__, (int32_t)pfrom->GetId(),pfrom->nBlocksinARow,pfrom->nBlocksinARow2);
|
||||||
{
|
|
||||||
fprintf(stderr, "Requesting new peer node.%i blocksinrow.%i blocsinrow2.%i\n",(int32_t)pfrom->GetId(),pfrom->nBlocksinARow,pfrom->nBlocksinARow2);
|
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5661,7 +5658,7 @@ bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex
|
|||||||
CBlockIndex indexDummy(block);
|
CBlockIndex indexDummy(block);
|
||||||
indexDummy.pprev = pindexPrev;
|
indexDummy.pprev = pindexPrev;
|
||||||
indexDummy.SetHeight(pindexPrev->GetHeight() + 1);
|
indexDummy.SetHeight(pindexPrev->GetHeight() + 1);
|
||||||
// JoinSplit proofs are verified in ConnectBlock
|
// zk proofs are verified in ConnectBlock
|
||||||
auto verifier = libzcash::ProofVerifier::Disabled();
|
auto verifier = libzcash::ProofVerifier::Disabled();
|
||||||
// NOTE: CheckBlockHeader is called by CheckBlock
|
// NOTE: CheckBlockHeader is called by CheckBlock
|
||||||
if (!ContextualCheckBlockHeader(block, state, pindexPrev))
|
if (!ContextualCheckBlockHeader(block, state, pindexPrev))
|
||||||
@@ -5691,10 +5688,7 @@ bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// BLOCK PRUNING CODE
|
||||||
* BLOCK PRUNING CODE
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Calculate the amount of disk space the block & undo files currently use */
|
/* Calculate the amount of disk space the block & undo files currently use */
|
||||||
uint64_t CalculateCurrentUsage()
|
uint64_t CalculateCurrentUsage()
|
||||||
{
|
{
|
||||||
@@ -5899,12 +5893,10 @@ CBlockIndex * InsertBlockIndex(uint256 hash)
|
|||||||
return pindexNew;
|
return pindexNew;
|
||||||
}
|
}
|
||||||
|
|
||||||
//void komodo_pindex_init(CBlockIndex *pindex,int32_t height);
|
|
||||||
|
|
||||||
bool static LoadBlockIndexDB()
|
bool static LoadBlockIndexDB()
|
||||||
{
|
{
|
||||||
const CChainParams& chainparams = Params();
|
const CChainParams& chainparams = Params();
|
||||||
LogPrintf("%s: start loading guts\n", __func__);
|
//LogPrintf("%s: start loading guts\n", __func__);
|
||||||
if (!pblocktree->LoadBlockIndexGuts())
|
if (!pblocktree->LoadBlockIndexGuts())
|
||||||
return false;
|
return false;
|
||||||
LogPrintf("%s: loaded guts\n", __func__);
|
LogPrintf("%s: loaded guts\n", __func__);
|
||||||
@@ -5917,11 +5909,13 @@ bool static LoadBlockIndexDB()
|
|||||||
{
|
{
|
||||||
CBlockIndex* pindex = item.second;
|
CBlockIndex* pindex = item.second;
|
||||||
vSortedByHeight.push_back(make_pair(pindex->GetHeight(), pindex));
|
vSortedByHeight.push_back(make_pair(pindex->GetHeight(), pindex));
|
||||||
//komodo_pindex_init(pindex,(int32_t)pindex->GetHeight());
|
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"load blockindexDB paired %u\n",(uint32_t)time(NULL));
|
if(fDebug)
|
||||||
|
fprintf(stderr,"load blockindexDB paired %u\n",(uint32_t)time(NULL));
|
||||||
sort(vSortedByHeight.begin(), vSortedByHeight.end());
|
sort(vSortedByHeight.begin(), vSortedByHeight.end());
|
||||||
//fprintf(stderr,"load blockindexDB sorted %u\n",(uint32_t)time(NULL));
|
if(fDebug)
|
||||||
|
fprintf(stderr,"load blockindexDB sorted %u\n",(uint32_t)time(NULL));
|
||||||
|
|
||||||
BOOST_FOREACH(const PAIRTYPE(int, CBlockIndex*)& item, vSortedByHeight)
|
BOOST_FOREACH(const PAIRTYPE(int, CBlockIndex*)& item, vSortedByHeight)
|
||||||
{
|
{
|
||||||
CBlockIndex* pindex = item.second;
|
CBlockIndex* pindex = item.second;
|
||||||
@@ -6015,7 +6009,6 @@ bool static LoadBlockIndexDB()
|
|||||||
pindex->BuildSkip();
|
pindex->BuildSkip();
|
||||||
if (pindex->IsValid(BLOCK_VALID_TREE) && (pindexBestHeader == NULL || CBlockIndexWorkComparator()(pindexBestHeader, pindex)))
|
if (pindex->IsValid(BLOCK_VALID_TREE) && (pindexBestHeader == NULL || CBlockIndexWorkComparator()(pindexBestHeader, pindex)))
|
||||||
pindexBestHeader = pindex;
|
pindexBestHeader = pindex;
|
||||||
//komodo_pindex_init(pindex,(int32_t)pindex->GetHeight());
|
|
||||||
}
|
}
|
||||||
fprintf(stderr,"load blockindexDB chained %u\n",(uint32_t)time(NULL));
|
fprintf(stderr,"load blockindexDB chained %u\n",(uint32_t)time(NULL));
|
||||||
|
|
||||||
@@ -6098,7 +6091,6 @@ bool static LoadBlockIndexDB()
|
|||||||
if (pindex->pprev) {
|
if (pindex->pprev) {
|
||||||
pindex->pprev->hashFinalSproutRoot = pindex->hashSproutAnchor;
|
pindex->pprev->hashFinalSproutRoot = pindex->hashSproutAnchor;
|
||||||
}
|
}
|
||||||
//komodo_pindex_init(pindex,(int32_t)pindex->GetHeight());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load pointer to end of best chain
|
// Load pointer to end of best chain
|
||||||
@@ -6422,10 +6414,10 @@ void UnloadBlockIndex()
|
|||||||
bool LoadBlockIndex()
|
bool LoadBlockIndex()
|
||||||
{
|
{
|
||||||
// Load block index from databases
|
// Load block index from databases
|
||||||
KOMODO_LOADINGBLOCKS = 1;
|
HUSH_LOADINGBLOCKS = 1;
|
||||||
if (!fReindex && !LoadBlockIndexDB())
|
if (!fReindex && !LoadBlockIndexDB())
|
||||||
{
|
{
|
||||||
KOMODO_LOADINGBLOCKS = 0;
|
HUSH_LOADINGBLOCKS = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
fprintf(stderr,"finished loading blocks %s\n",SMART_CHAIN_SYMBOL);
|
fprintf(stderr,"finished loading blocks %s\n",SMART_CHAIN_SYMBOL);
|
||||||
@@ -6951,7 +6943,7 @@ void static ProcessGetData(CNode* pfrom)
|
|||||||
//hash = block.GetHash();
|
//hash = block.GetHash();
|
||||||
//for (z=31; z>=0; z--)
|
//for (z=31; z>=0; z--)
|
||||||
// fprintf(stderr,"%02x",((uint8_t *)&hash)[z]);
|
// fprintf(stderr,"%02x",((uint8_t *)&hash)[z]);
|
||||||
//fprintf(stderr," send block %d\n",komodo_block2height(&block));
|
//fprintf(stderr," send block %d\n",hush_block2height(&block));
|
||||||
pfrom->PushMessage("block", block);
|
pfrom->PushMessage("block", block);
|
||||||
}
|
}
|
||||||
else // MSG_FILTERED_BLOCK)
|
else // MSG_FILTERED_BLOCK)
|
||||||
@@ -8136,9 +8128,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
|||||||
if (pto->nVersion == 0)
|
if (pto->nVersion == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
//
|
|
||||||
// Message: ping
|
// Message: ping
|
||||||
//
|
|
||||||
bool pingSend = false;
|
bool pingSend = false;
|
||||||
if (pto->fPingQueued) {
|
if (pto->fPingQueued) {
|
||||||
// RPC ping request by user
|
// RPC ping request by user
|
||||||
@@ -8187,9 +8177,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
|||||||
nLastRebroadcast = GetTime();
|
nLastRebroadcast = GetTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Message: addr
|
// Message: addr
|
||||||
//
|
|
||||||
if (fSendTrickle)
|
if (fSendTrickle)
|
||||||
{
|
{
|
||||||
vector<CAddress> vAddr;
|
vector<CAddress> vAddr;
|
||||||
@@ -8215,9 +8203,9 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
|||||||
|
|
||||||
CNodeState &state = *State(pto->GetId());
|
CNodeState &state = *State(pto->GetId());
|
||||||
if (state.fShouldBan) {
|
if (state.fShouldBan) {
|
||||||
if (pto->fWhitelisted)
|
if (pto->fWhitelisted) {
|
||||||
LogPrintf("Warning: not punishing whitelisted peer %s!\n", pto->addr.ToString());
|
LogPrintf("Warning: not punishing whitelisted peer %s!\n", pto->addr.ToString());
|
||||||
else {
|
} else {
|
||||||
pto->fDisconnect = true;
|
pto->fDisconnect = true;
|
||||||
if (pto->addr.IsLocal())
|
if (pto->addr.IsLocal())
|
||||||
LogPrintf("Warning: not banning local peer %s!\n", pto->addr.ToString());
|
LogPrintf("Warning: not banning local peer %s!\n", pto->addr.ToString());
|
||||||
@@ -8260,9 +8248,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
|||||||
GetMainSignals().Broadcast(nTimeBestReceived);
|
GetMainSignals().Broadcast(nTimeBestReceived);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Message: inventory
|
// Message: inventory
|
||||||
//
|
|
||||||
vector<CInv> vInv;
|
vector<CInv> vInv;
|
||||||
vector<CInv> vInvWait;
|
vector<CInv> vInvWait;
|
||||||
{
|
{
|
||||||
@@ -8340,9 +8326,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Message: getdata (blocks)
|
// Message: getdata (blocks)
|
||||||
//
|
|
||||||
static uint256 zero;
|
static uint256 zero;
|
||||||
vector<CInv> vGetData;
|
vector<CInv> vGetData;
|
||||||
if (!pto->fDisconnect && !pto->fClient && (fFetch || !IsInitialBlockDownload()) && state.nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
|
if (!pto->fDisconnect && !pto->fClient && (fFetch || !IsInitialBlockDownload()) && state.nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
|
||||||
@@ -8352,8 +8336,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
|||||||
BOOST_FOREACH(CBlockIndex *pindex, vToDownload) {
|
BOOST_FOREACH(CBlockIndex *pindex, vToDownload) {
|
||||||
vGetData.push_back(CInv(MSG_BLOCK, pindex->GetBlockHash()));
|
vGetData.push_back(CInv(MSG_BLOCK, pindex->GetBlockHash()));
|
||||||
MarkBlockAsInFlight(pto->GetId(), pindex->GetBlockHash(), consensusParams, pindex);
|
MarkBlockAsInFlight(pto->GetId(), pindex->GetBlockHash(), consensusParams, pindex);
|
||||||
LogPrint("net", "Requesting block %s (%d) peer=%d\n", pindex->GetBlockHash().ToString(),
|
LogPrint("net", "Requesting block %s (%d) peer=%d\n", pindex->GetBlockHash().ToString(), pindex->GetHeight(), pto->id);
|
||||||
pindex->GetHeight(), pto->id);
|
|
||||||
}
|
}
|
||||||
if (state.nBlocksInFlight == 0 && staller != -1) {
|
if (state.nBlocksInFlight == 0 && staller != -1) {
|
||||||
if (State(staller)->nStallingSince == 0) {
|
if (State(staller)->nStallingSince == 0) {
|
||||||
@@ -8362,24 +8345,8 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*CBlockIndex *pindex;
|
|
||||||
if ( komodo_requestedhash != zero && komodo_requestedcount < 16 && (pindex= komodo_getblockindex(komodo_requestedhash)) != 0 )
|
|
||||||
{
|
|
||||||
LogPrint("net","komodo_requestedhash.%d request %s to nodeid.%d\n",komodo_requestedcount,komodo_requestedhash.ToString().c_str(),pto->GetId());
|
|
||||||
fprintf(stderr,"komodo_requestedhash.%d request %s to nodeid.%d\n",komodo_requestedcount,komodo_requestedhash.ToString().c_str(),pto->GetId());
|
|
||||||
vGetData.push_back(CInv(MSG_BLOCK, komodo_requestedhash));
|
|
||||||
MarkBlockAsInFlight(pto->GetId(), komodo_requestedhash, consensusParams, pindex);
|
|
||||||
komodo_requestedcount++;
|
|
||||||
if ( komodo_requestedcount > 16 )
|
|
||||||
{
|
|
||||||
memset(&komodo_requestedhash,0,sizeof(komodo_requestedhash));
|
|
||||||
komodo_requestedcount = 0;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//
|
|
||||||
// Message: getdata (non-blocks)
|
// Message: getdata (non-blocks)
|
||||||
//
|
|
||||||
while (!pto->fDisconnect && !pto->mapAskFor.empty() && (*pto->mapAskFor.begin()).first <= nNow)
|
while (!pto->fDisconnect && !pto->mapAskFor.empty() && (*pto->mapAskFor.begin()).first <= nNow)
|
||||||
{
|
{
|
||||||
const CInv& inv = (*pto->mapAskFor.begin()).second;
|
const CInv& inv = (*pto->mapAskFor.begin()).second;
|
||||||
@@ -8441,28 +8408,24 @@ CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Para
|
|||||||
CMutableTransaction mtx;
|
CMutableTransaction mtx;
|
||||||
if ( KOMODO_NSPV_SUPERLITE )
|
if ( KOMODO_NSPV_SUPERLITE )
|
||||||
{
|
{
|
||||||
mtx.fOverwintered = true;
|
mtx.fOverwintered = true;
|
||||||
mtx.nExpiryHeight = 0;
|
mtx.nExpiryHeight = 0;
|
||||||
mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID;
|
mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID;
|
||||||
mtx.nVersion = SAPLING_TX_VERSION;
|
mtx.nVersion = SAPLING_TX_VERSION;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
bool isOverwintered = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_OVERWINTER);
|
bool isOverwintered = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_OVERWINTER);
|
||||||
if (isOverwintered)
|
if (isOverwintered)
|
||||||
{
|
{
|
||||||
mtx.fOverwintered = true;
|
mtx.fOverwintered = true;
|
||||||
mtx.nExpiryHeight = nHeight + expiryDelta;
|
mtx.nExpiryHeight = nHeight + expiryDelta;
|
||||||
if (NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING))
|
if (NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING))
|
||||||
{
|
{
|
||||||
mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID;
|
mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID;
|
||||||
mtx.nVersion = SAPLING_TX_VERSION;
|
mtx.nVersion = SAPLING_TX_VERSION;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID;
|
mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID;
|
||||||
mtx.nVersion = OVERWINTER_TX_VERSION;
|
mtx.nVersion = OVERWINTER_TX_VERSION;
|
||||||
mtx.nExpiryHeight = std::min(mtx.nExpiryHeight,static_cast<uint32_t>(consensusParams.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight - 1));
|
mtx.nExpiryHeight = std::min(mtx.nExpiryHeight,static_cast<uint32_t>(consensusParams.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ uint64_t the_commission(const CBlock *block,int32_t height);
|
|||||||
int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33, void *ptr);
|
int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33, void *ptr);
|
||||||
int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex);
|
int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex);
|
||||||
int32_t komodo_is_notarytx(const CTransaction& tx);
|
int32_t komodo_is_notarytx(const CTransaction& tx);
|
||||||
uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector<int8_t> &NotarisationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len);
|
uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector<int8_t> &NotarizationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len);
|
||||||
int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);
|
int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);
|
||||||
int32_t komodo_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *script, int32_t len);
|
int32_t komodo_getnotarizedheight(uint32_t timestamp,int32_t height, uint8_t *script, int32_t len);
|
||||||
CScript komodo_mineropret(int32_t nHeight);
|
CScript komodo_mineropret(int32_t nHeight);
|
||||||
@@ -175,7 +175,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
} else pk = _pk;
|
} else pk = _pk;
|
||||||
|
|
||||||
uint64_t deposits,voutsum=0; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params();
|
uint64_t deposits,voutsum=0; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params();
|
||||||
bool fNotarisationBlock = false; std::vector<int8_t> NotarisationNotaries;
|
bool fNotarizationBlock = false; std::vector<int8_t> NotarizationNotaries;
|
||||||
|
|
||||||
//fprintf(stderr,"create new block\n");
|
//fprintf(stderr,"create new block\n");
|
||||||
// Create new block
|
// Create new block
|
||||||
@@ -276,7 +276,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
vecPriority.reserve(mempool.mapTx.size() + 1);
|
vecPriority.reserve(mempool.mapTx.size() + 1);
|
||||||
|
|
||||||
// now add transactions from the mem pool
|
// now add transactions from the mem pool
|
||||||
int32_t Notarisations = 0; uint64_t txvalue;
|
int32_t Notarizations = 0; uint64_t txvalue;
|
||||||
for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin();
|
for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin();
|
||||||
mi != mempool.mapTx.end(); ++mi)
|
mi != mempool.mapTx.end(); ++mi)
|
||||||
{
|
{
|
||||||
@@ -307,15 +307,15 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
double dPriority = 0;
|
double dPriority = 0;
|
||||||
CAmount nTotalIn = 0;
|
CAmount nTotalIn = 0;
|
||||||
bool fMissingInputs = false;
|
bool fMissingInputs = false;
|
||||||
bool fNotarisation = false;
|
bool fNotarization = false;
|
||||||
std::vector<int8_t> TMP_NotarisationNotaries;
|
std::vector<int8_t> TMP_NotarizationNotaries;
|
||||||
if (tx.IsCoinImport())
|
if (tx.IsCoinImport())
|
||||||
{
|
{
|
||||||
CAmount nValueIn = GetCoinImportValue(tx); // burn amount
|
CAmount nValueIn = GetCoinImportValue(tx); // burn amount
|
||||||
nTotalIn += nValueIn;
|
nTotalIn += nValueIn;
|
||||||
dPriority += (double)nValueIn * 1000; // flat multiplier... max = 1e16.
|
dPriority += (double)nValueIn * 1000; // flat multiplier... max = 1e16.
|
||||||
} else {
|
} else {
|
||||||
TMP_NotarisationNotaries.clear();
|
TMP_NotarizationNotaries.clear();
|
||||||
bool fToCryptoAddress = false;
|
bool fToCryptoAddress = false;
|
||||||
if ( numSN != 0 && notarypubkeys[0][0] != 0 && komodo_is_notarytx(tx) == 1 )
|
if ( numSN != 0 && notarypubkeys[0][0] != 0 && komodo_is_notarytx(tx) == 1 )
|
||||||
fToCryptoAddress = true;
|
fToCryptoAddress = true;
|
||||||
@@ -376,20 +376,20 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,notarypubkeys[i],33) == 0 )
|
if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,notarypubkeys[i],33) == 0 )
|
||||||
{
|
{
|
||||||
// We can add the index of each notary to vector, and clear it if this notarisation is not valid later on.
|
// We can add the index of each notary to vector, and clear it if this notarisation is not valid later on.
|
||||||
TMP_NotarisationNotaries.push_back(i);
|
TMP_NotarizationNotaries.push_back(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dPriority += (double)nValueIn * nConf;
|
dPriority += (double)nValueIn * nConf;
|
||||||
}
|
}
|
||||||
if ( numSN != 0 && notarypubkeys[0][0] != 0 && TMP_NotarisationNotaries.size() >= numSN / 5 )
|
if ( numSN != 0 && notarypubkeys[0][0] != 0 && TMP_NotarizationNotaries.size() >= numSN / 5 )
|
||||||
{
|
{
|
||||||
// check a notary didnt sign twice (this would be an invalid notarisation later on and cause problems)
|
// check a notary didnt sign twice (this would be an invalid notarisation later on and cause problems)
|
||||||
std::set<int> checkdupes( TMP_NotarisationNotaries.begin(), TMP_NotarisationNotaries.end() );
|
std::set<int> checkdupes( TMP_NotarizationNotaries.begin(), TMP_NotarizationNotaries.end() );
|
||||||
if ( checkdupes.size() != TMP_NotarisationNotaries.size() )
|
if ( checkdupes.size() != TMP_NotarizationNotaries.size() )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "possible notarisation is signed multiple times by same notary, passed as normal transaction.\n");
|
fprintf(stderr, "possible notarisation is signed multiple times by same notary, passed as normal transaction.\n");
|
||||||
} else fNotarisation = true;
|
} else fNotarization = true;
|
||||||
}
|
}
|
||||||
nTotalIn += tx.GetShieldedValueIn();
|
nTotalIn += tx.GetShieldedValueIn();
|
||||||
}
|
}
|
||||||
@@ -405,7 +405,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
|
|
||||||
CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize);
|
CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize);
|
||||||
|
|
||||||
if ( fNotarisation )
|
if ( fNotarization )
|
||||||
{
|
{
|
||||||
// Special miner for notary pay chains. Can only enter this if numSN/notarypubkeys is set higher up.
|
// Special miner for notary pay chains. Can only enter this if numSN/notarypubkeys is set higher up.
|
||||||
if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 )
|
if ( tx.vout.size() == 2 && tx.vout[1].nValue == 0 )
|
||||||
@@ -415,10 +415,10 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
int32_t scriptlen = (int32_t)tx.vout[1].scriptPubKey.size();
|
int32_t scriptlen = (int32_t)tx.vout[1].scriptPubKey.size();
|
||||||
if ( script[0] == OP_RETURN )
|
if ( script[0] == OP_RETURN )
|
||||||
{
|
{
|
||||||
Notarisations++;
|
Notarizations++;
|
||||||
if ( Notarisations > 1 )
|
if ( Notarizations > 1 )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "skipping notarization.%d\n",Notarisations);
|
fprintf(stderr, "skipping notarization.%d\n",Notarizations);
|
||||||
// Any attempted notarization needs to be in its own block!
|
// Any attempted notarization needs to be in its own block!
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -426,10 +426,10 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
if ( notarizedheight != 0 )
|
if ( notarizedheight != 0 )
|
||||||
{
|
{
|
||||||
// this is the first one we see, add it to the block as TX1
|
// this is the first one we see, add it to the block as TX1
|
||||||
NotarisationNotaries = TMP_NotarisationNotaries;
|
NotarizationNotaries = TMP_NotarizationNotaries;
|
||||||
dPriority = 1e16;
|
dPriority = 1e16;
|
||||||
fNotarisationBlock = true;
|
fNotarizationBlock = true;
|
||||||
//fprintf(stderr, "Notarisation %s set to maximum priority\n",hash.ToString().c_str());
|
//fprintf(stderr, "Notarization %s set to maximum priority\n",hash.ToString().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -673,14 +673,14 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
LEAVE_CRITICAL_SECTION(mempool.cs);
|
LEAVE_CRITICAL_SECTION(mempool.cs);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
else if ( fNotarisationBlock && ASSETCHAINS_NOTARY_PAY[0] != 0 && pblock->vtx[1].vout.size() == 2 && pblock->vtx[1].vout[1].nValue == 0 )
|
else if ( fNotarizationBlock && ASSETCHAINS_NOTARY_PAY[0] != 0 && pblock->vtx[1].vout.size() == 2 && pblock->vtx[1].vout[1].nValue == 0 )
|
||||||
{
|
{
|
||||||
// Get the OP_RETURN for the notarisation
|
// Get the OP_RETURN for the notarisation
|
||||||
uint8_t *script = (uint8_t *)&pblock->vtx[1].vout[1].scriptPubKey[0];
|
uint8_t *script = (uint8_t *)&pblock->vtx[1].vout[1].scriptPubKey[0];
|
||||||
int32_t scriptlen = (int32_t)pblock->vtx[1].vout[1].scriptPubKey.size();
|
int32_t scriptlen = (int32_t)pblock->vtx[1].vout[1].scriptPubKey.size();
|
||||||
if ( script[0] == OP_RETURN )
|
if ( script[0] == OP_RETURN )
|
||||||
{
|
{
|
||||||
uint64_t totalsats = komodo_notarypay(txNew, NotarisationNotaries, pblock->nTime, nHeight, script, scriptlen);
|
uint64_t totalsats = komodo_notarypay(txNew, NotarizationNotaries, pblock->nTime, nHeight, script, scriptlen);
|
||||||
if ( totalsats == 0 )
|
if ( totalsats == 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Could not create notary payment, trying again.\n");
|
fprintf(stderr, "Could not create notary payment, trying again.\n");
|
||||||
|
|||||||
@@ -12,66 +12,64 @@
|
|||||||
NotarizationDB *pnotarizations;
|
NotarizationDB *pnotarizations;
|
||||||
NotarizationDB::NotarizationDB(size_t nCacheSize, bool fMemory, bool fWipe) : CDBWrapper(GetDataDir() / "notarizations", nCacheSize, fMemory, fWipe, false, 64) { }
|
NotarizationDB::NotarizationDB(size_t nCacheSize, bool fMemory, bool fWipe) : CDBWrapper(GetDataDir() / "notarizations", nCacheSize, fMemory, fWipe, false, 64) { }
|
||||||
|
|
||||||
NotarisationsInBlock ScanBlockNotarizations(const CBlock &block, int nHeight)
|
NotarizationsInBlock ScanBlockNotarizations(const CBlock &block, int nHeight)
|
||||||
{
|
{
|
||||||
EvalRef eval;
|
EvalRef eval;
|
||||||
NotarisationsInBlock vNotarisations;
|
NotarizationsInBlock vNotarizations;
|
||||||
int timestamp = block.nTime;
|
int timestamp = block.nTime;
|
||||||
bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false;
|
bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false;
|
||||||
|
|
||||||
// No valid ntz's before this height on HUSH3
|
// No valid ntz's before this height
|
||||||
if(ishush3 && (nHeight <= 360000)) {
|
int minheight = ishush3 ? 360000 : 1;
|
||||||
return vNotarisations;
|
if(ishush3 && (nHeight <= GetArg("-dpow_height",minheight))) {
|
||||||
|
return vNotarizations;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < block.vtx.size(); i++) {
|
for (unsigned int i = 0; i < block.vtx.size(); i++) {
|
||||||
CTransaction tx = block.vtx[i];
|
CTransaction tx = block.vtx[i];
|
||||||
|
|
||||||
NotarisationData data;
|
NotarizationData data;
|
||||||
bool parsed = ParseNotarisationOpReturn(tx, data);
|
bool parsed = ParseNotarizationOpReturn(tx, data);
|
||||||
if (!parsed) data = NotarisationData();
|
if (!parsed) data = NotarizationData();
|
||||||
if (strlen(data.symbol) == 0)
|
if (strlen(data.symbol) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//printf("Checked notarisation data for %s \n",data.symbol);
|
//printf("Checked notarization data for %s \n",data.symbol);
|
||||||
int authority = GetSymbolAuthority(data.symbol);
|
int authority = GetSymbolAuthority(data.symbol);
|
||||||
|
|
||||||
if (authority == CROSSCHAIN_HUSH) {
|
if (authority == CROSSCHAIN_HUSH) {
|
||||||
if (!eval->CheckNotaryInputs(tx, nHeight, block.nTime))
|
if (!eval->CheckNotaryInputs(tx, nHeight, block.nTime))
|
||||||
continue;
|
continue;
|
||||||
//printf("Authorised notarisation data for %s \n",data.symbol);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parsed) {
|
if (parsed) {
|
||||||
vNotarisations.push_back(std::make_pair(tx.GetHash(), data));
|
vNotarizations.push_back(std::make_pair(tx.GetHash(), data));
|
||||||
//printf("Parsed a notarisation for: %s, txid:%s, ccid:%i, momdepth:%i\n",
|
if(fDebug) {
|
||||||
// data.symbol, tx.GetHash().GetHex().data(), data.ccId, data.MoMDepth);
|
printf("Parsed a notarization for: %s, txid:%s, ccid:%i, momdepth:%i\n", data.symbol, tx.GetHash().GetHex().data(), data.ccId, data.MoMDepth);
|
||||||
//if (!data.MoMoM.IsNull()) printf("MoMoM:%s\n", data.MoMoM.GetHex().data());
|
if (!data.MoMoM.IsNull()) printf("MoMoM:%s\n", data.MoMoM.GetHex().data());
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
LogPrintf("WARNING: Couldn't parse notarisation for tx: %s at height %i\n", tx.GetHash().GetHex().data(), nHeight);
|
LogPrintf("WARNING: Couldn't parse notarization for tx: %s at height %i\n", tx.GetHash().GetHex().data(), nHeight);
|
||||||
}
|
}
|
||||||
return vNotarisations;
|
return vNotarizations;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetBlockNotarisations(uint256 blockHash, NotarisationsInBlock &nibs)
|
bool GetBlockNotarizations(uint256 blockHash, NotarizationsInBlock &nibs)
|
||||||
{
|
{
|
||||||
return pnotarizations->Read(blockHash, nibs);
|
return pnotarizations->Read(blockHash, nibs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool GetBackNotarisation(uint256 notarisationHash, Notarisation &n)
|
bool GetBackNotarization(uint256 notarisationHash, Notarization &n)
|
||||||
{
|
{
|
||||||
return pnotarizations->Read(notarisationHash, n);
|
return pnotarizations->Read(notarisationHash, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write an index of HUSH notarisation id -> backnotarisation
|
||||||
/*
|
void WriteBackNotarizations(const NotarizationsInBlock notarisations, CDBBatch &batch)
|
||||||
* Write an index of HUSH notarisation id -> backnotarisation
|
|
||||||
*/
|
|
||||||
void WriteBackNotarisations(const NotarisationsInBlock notarisations, CDBBatch &batch)
|
|
||||||
{
|
{
|
||||||
int wrote = 0;
|
int wrote = 0;
|
||||||
BOOST_FOREACH(const Notarisation &n, notarisations)
|
BOOST_FOREACH(const Notarization &n, notarisations)
|
||||||
{
|
{
|
||||||
if (!n.second.txHash.IsNull()) {
|
if (!n.second.txHash.IsNull()) {
|
||||||
batch.Write(n.second.txHash, n);
|
batch.Write(n.second.txHash, n);
|
||||||
@@ -80,33 +78,30 @@ void WriteBackNotarisations(const NotarisationsInBlock notarisations, CDBBatch &
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EraseBackNotarizations(const NotarizationsInBlock notarisations, CDBBatch &batch)
|
||||||
void EraseBackNotarisations(const NotarisationsInBlock notarisations, CDBBatch &batch)
|
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(const Notarisation &n, notarisations)
|
BOOST_FOREACH(const Notarization &n, notarisations)
|
||||||
{
|
{
|
||||||
if (!n.second.txHash.IsNull())
|
if (!n.second.txHash.IsNull())
|
||||||
batch.Erase(n.second.txHash);
|
batch.Erase(n.second.txHash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Scan notarisationsdb backwards for blocks containing a notarisation
|
||||||
* Scan notarisationsdb backwards for blocks containing a notarisation
|
// for given symbol. Return height of matched notarisation or 0.
|
||||||
* for given symbol. Return height of matched notarisation or 0.
|
int ScanNotarizationsDB(int height, std::string symbol, int scanLimitBlocks, Notarization& out)
|
||||||
*/
|
|
||||||
int ScanNotarisationsDB(int height, std::string symbol, int scanLimitBlocks, Notarisation& out)
|
|
||||||
{
|
{
|
||||||
if (height < 0 || height > chainActive.Height())
|
if (height < 0 || height > chainActive.Height())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (int i=0; i<scanLimitBlocks; i++) {
|
for (int i=0; i<scanLimitBlocks; i++) {
|
||||||
if (i > height) break;
|
if (i > height) break;
|
||||||
NotarisationsInBlock notarisations;
|
NotarizationsInBlock notarisations;
|
||||||
uint256 blockHash = *chainActive[height-i]->phashBlock;
|
uint256 blockHash = *chainActive[height-i]->phashBlock;
|
||||||
if (!GetBlockNotarisations(blockHash, notarisations))
|
if (!GetBlockNotarizations(blockHash, notarisations))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BOOST_FOREACH(Notarisation& nota, notarisations) {
|
BOOST_FOREACH(Notarization& nota, notarisations) {
|
||||||
if (strcmp(nota.second.symbol, symbol.data()) == 0) {
|
if (strcmp(nota.second.symbol, symbol.data()) == 0) {
|
||||||
out = nota;
|
out = nota;
|
||||||
return height-i;
|
return height-i;
|
||||||
@@ -115,30 +110,3 @@ int ScanNotarisationsDB(int height, std::string symbol, int scanLimitBlocks, Not
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ScanNotarisationsDB2(int height, std::string symbol, int scanLimitBlocks, Notarisation& out)
|
|
||||||
{
|
|
||||||
int32_t i,maxheight,ht;
|
|
||||||
maxheight = chainActive.Height();
|
|
||||||
if ( height < 0 || height > maxheight )
|
|
||||||
return false;
|
|
||||||
for (i=0; i<scanLimitBlocks; i++)
|
|
||||||
{
|
|
||||||
ht = height+i;
|
|
||||||
if ( ht > maxheight )
|
|
||||||
break;
|
|
||||||
NotarisationsInBlock notarisations;
|
|
||||||
uint256 blockHash = *chainActive[ht]->phashBlock;
|
|
||||||
if ( !GetBlockNotarisations(blockHash,notarisations) )
|
|
||||||
continue;
|
|
||||||
BOOST_FOREACH(Notarisation& nota,notarisations)
|
|
||||||
{
|
|
||||||
if ( strcmp(nota.second.symbol,symbol.data()) == 0 )
|
|
||||||
{
|
|
||||||
out = nota;
|
|
||||||
return(ht);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,15 +15,14 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern NotarizationDB *pnotarizations;
|
extern NotarizationDB *pnotarizations;
|
||||||
typedef std::pair<uint256,NotarisationData> Notarisation;
|
typedef std::pair<uint256,NotarizationData> Notarization;
|
||||||
typedef std::vector<Notarisation> NotarisationsInBlock;
|
typedef std::vector<Notarization> NotarizationsInBlock;
|
||||||
|
|
||||||
NotarisationsInBlock ScanBlockNotarizations(const CBlock &block, int nHeight);
|
NotarizationsInBlock ScanBlockNotarizations(const CBlock &block, int nHeight);
|
||||||
bool GetBlockNotarisations(uint256 blockHash, NotarisationsInBlock &nibs);
|
bool GetBlockNotarizations(uint256 blockHash, NotarizationsInBlock &nibs);
|
||||||
bool GetBackNotarisation(uint256 notarisationHash, Notarisation &n);
|
bool GetBackNotarization(uint256 notarisationHash, Notarization &n);
|
||||||
void WriteBackNotarisations(const NotarisationsInBlock notarisations, CDBBatch &batch);
|
void WriteBackNotarizations(const NotarizationsInBlock notarisations, CDBBatch &batch);
|
||||||
void EraseBackNotarisations(const NotarisationsInBlock notarisations, CDBBatch &batch);
|
void EraseBackNotarizations(const NotarizationsInBlock notarisations, CDBBatch &batch);
|
||||||
int ScanNotarisationsDB(int height, std::string symbol, int scanLimitBlocks, Notarisation& out);
|
int ScanNotarizationsDB(int height, std::string symbol, int scanLimitBlocks, Notarization& out);
|
||||||
int ScanNotarisationsDB2(int height, std::string symbol, int scanLimitBlocks, Notarisation& out);
|
|
||||||
|
|
||||||
#endif /* HUSH_NOTARISATIONDB_H */
|
#endif /* HUSH_NOTARISATIONDB_H */
|
||||||
|
|||||||
@@ -661,13 +661,13 @@ extern char SMART_CHAIN_SYMBOL[HUSH_SMART_CHAIN_MAXLEN];
|
|||||||
#define KOMODO_ELECTION_GAP 2000
|
#define KOMODO_ELECTION_GAP 2000
|
||||||
|
|
||||||
int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t blocktimes[66],int32_t *nonzpkeysp,int32_t height);
|
int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t blocktimes[66],int32_t *nonzpkeysp,int32_t height);
|
||||||
int32_t KOMODO_LOADINGBLOCKS = 1;
|
int32_t HUSH_LOADINGBLOCKS = 1;
|
||||||
|
|
||||||
extern std::string NOTARY_PUBKEY;
|
extern std::string NOTARY_PUBKEY;
|
||||||
|
|
||||||
bool CheckProofOfWork(const CBlockHeader &blkHeader, uint8_t *pubkey33, int32_t height, const Consensus::Params& params)
|
bool CheckProofOfWork(const CBlockHeader &blkHeader, uint8_t *pubkey33, int32_t height, const Consensus::Params& params)
|
||||||
{
|
{
|
||||||
extern int32_t KOMODO_REWIND;
|
extern int32_t HUSH_REWIND;
|
||||||
uint256 hash;
|
uint256 hash;
|
||||||
bool fNegative,fOverflow; uint8_t origpubkey33[33]; int32_t i,nonzpkeys=0,nonz=0,special=0,special2=0,notaryid=-1,flag = 0, mids[66]; uint32_t tiptime,blocktimes[66];
|
bool fNegative,fOverflow; uint8_t origpubkey33[33]; int32_t i,nonzpkeys=0,nonz=0,special=0,special2=0,notaryid=-1,flag = 0, mids[66]; uint32_t tiptime,blocktimes[66];
|
||||||
arith_uint256 bnTarget; uint8_t pubkeys[66][33];
|
arith_uint256 bnTarget; uint8_t pubkeys[66][33];
|
||||||
@@ -733,7 +733,7 @@ bool CheckProofOfWork(const CBlockHeader &blkHeader, uint8_t *pubkey33, int32_t
|
|||||||
// Check proof of work matches claimed amount
|
// Check proof of work matches claimed amount
|
||||||
if ( UintToArith256(hash = blkHeader.GetHash()) > bnTarget )
|
if ( UintToArith256(hash = blkHeader.GetHash()) > bnTarget )
|
||||||
{
|
{
|
||||||
if ( KOMODO_LOADINGBLOCKS != 0 )
|
if ( HUSH_LOADINGBLOCKS != 0 )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if ( SMART_CHAIN_SYMBOL[0] != 0 || height > 792000 )
|
if ( SMART_CHAIN_SYMBOL[0] != 0 || height > 792000 )
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
|||||||
{ "assetchainproof", 1},
|
{ "assetchainproof", 1},
|
||||||
{ "crosschainproof", 1},
|
{ "crosschainproof", 1},
|
||||||
{ "getproofroot", 2},
|
{ "getproofroot", 2},
|
||||||
{ "getNotarisationsForBlock", 0},
|
{ "getNotarizationsForBlock", 0},
|
||||||
{ "height_MoM", 1},
|
{ "height_MoM", 1},
|
||||||
{ "calc_MoM", 2},
|
{ "calc_MoM", 2},
|
||||||
{ "migrate_completeimporttransaction", 1},
|
{ "migrate_completeimporttransaction", 1},
|
||||||
|
|||||||
@@ -143,14 +143,14 @@ UniValue MoMoMdata(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
|||||||
ret.push_back(Pair("kmdheight",kmdheight-5));
|
ret.push_back(Pair("kmdheight",kmdheight-5));
|
||||||
ret.push_back(Pair("ccid", (int) ccid));
|
ret.push_back(Pair("ccid", (int) ccid));
|
||||||
|
|
||||||
uint256 destNotarisationTxid;
|
uint256 destNotarizationTxid;
|
||||||
std::vector<uint256> moms;
|
std::vector<uint256> moms;
|
||||||
uint256 MoMoM = CalculateProofRoot(symbol, ccid, kmdheight-5, moms, destNotarisationTxid);
|
uint256 MoMoM = CalculateProofRoot(symbol, ccid, kmdheight-5, moms, destNotarizationTxid);
|
||||||
|
|
||||||
UniValue valMoms(UniValue::VARR);
|
UniValue valMoms(UniValue::VARR);
|
||||||
for (int i=0; i<moms.size(); i++) valMoms.push_back(moms[i].GetHex());
|
for (int i=0; i<moms.size(); i++) valMoms.push_back(moms[i].GetHex());
|
||||||
ret.push_back(Pair("MoMs", valMoms));
|
ret.push_back(Pair("MoMs", valMoms));
|
||||||
ret.push_back(Pair("notarization_hash", destNotarisationTxid.GetHex()));
|
ret.push_back(Pair("notarization_hash", destNotarizationTxid.GetHex()));
|
||||||
ret.push_back(Pair("MoMoM", MoMoM.GetHex()));
|
ret.push_back(Pair("MoMoM", MoMoM.GetHex()));
|
||||||
auto vmomomdata = E_MARSHAL(ss << MoMoM; ss << ((uint32_t)0));
|
auto vmomomdata = E_MARSHAL(ss << MoMoM; ss << ((uint32_t)0));
|
||||||
ret.push_back(Pair("data", HexStr(vmomomdata)));
|
ret.push_back(Pair("data", HexStr(vmomomdata)));
|
||||||
@@ -789,7 +789,7 @@ UniValue selfimport(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetNotarisationNotaries(uint8_t notarypubkeys[64][33], int8_t &numNN, const std::vector<CTxIn> &vin, std::vector<int8_t> &NotarisationNotaries);
|
bool GetNotarizationNotaries(uint8_t notarypubkeys[64][33], int8_t &numNN, const std::vector<CTxIn> &vin, std::vector<int8_t> &NotarizationNotaries);
|
||||||
|
|
||||||
|
|
||||||
UniValue importdual(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
UniValue importdual(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||||
@@ -1121,11 +1121,11 @@ UniValue importgatewaydumpprivkey(const UniValue& params, bool fHelp, const CPub
|
|||||||
return(ImportGatewayDumpPrivKey(bindtxid,vchSecret));
|
return(ImportGatewayDumpPrivKey(bindtxid,vchSecret));
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue getNotarisationsForBlock(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
UniValue getNotarizationsForBlock(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||||
{
|
{
|
||||||
// TODO take timestamp as param, and loop blockindex to get starting/finish height.
|
// TODO take timestamp as param, and loop blockindex to get starting/finish height.
|
||||||
if (fHelp || params.size() != 1)
|
if (fHelp || params.size() != 1)
|
||||||
throw runtime_error("getNotarisationsForBlock height\n\n"
|
throw runtime_error("getNotarizationsForBlock height\n\n"
|
||||||
"Takes a block height and returns notarisation information "
|
"Takes a block height and returns notarisation information "
|
||||||
"within the block");
|
"within the block");
|
||||||
|
|
||||||
@@ -1136,21 +1136,21 @@ UniValue getNotarisationsForBlock(const UniValue& params, bool fHelp, const CPub
|
|||||||
|
|
||||||
uint256 blockHash = chainActive[height]->GetBlockHash();
|
uint256 blockHash = chainActive[height]->GetBlockHash();
|
||||||
|
|
||||||
NotarisationsInBlock nibs;
|
NotarizationsInBlock nibs;
|
||||||
GetBlockNotarisations(blockHash, nibs);
|
GetBlockNotarizations(blockHash, nibs);
|
||||||
UniValue out(UniValue::VOBJ);
|
UniValue out(UniValue::VOBJ);
|
||||||
//out.push_back(make_pair("blocktime",(int)));
|
//out.push_back(make_pair("blocktime",(int)));
|
||||||
UniValue hush(UniValue::VARR);
|
UniValue hush(UniValue::VARR);
|
||||||
int8_t numNN = 0; uint8_t notarypubkeys[64][33] = {0};
|
int8_t numNN = 0; uint8_t notarypubkeys[64][33] = {0};
|
||||||
numNN = hush_notaries(notarypubkeys, height, chainActive[height]->nTime);
|
numNN = hush_notaries(notarypubkeys, height, chainActive[height]->nTime);
|
||||||
|
|
||||||
BOOST_FOREACH(const Notarisation& n, nibs)
|
BOOST_FOREACH(const Notarization& n, nibs)
|
||||||
{
|
{
|
||||||
UniValue item(UniValue::VOBJ); UniValue notaryarr(UniValue::VARR); std::vector<int8_t> NotarisationNotaries;
|
UniValue item(UniValue::VOBJ); UniValue notaryarr(UniValue::VARR); std::vector<int8_t> NotarizationNotaries;
|
||||||
uint256 hash; CTransaction tx;
|
uint256 hash; CTransaction tx;
|
||||||
if ( myGetTransaction(n.first,tx,hash) )
|
if ( myGetTransaction(n.first,tx,hash) )
|
||||||
{
|
{
|
||||||
if ( !GetNotarisationNotaries(notarypubkeys, numNN, tx.vin, NotarisationNotaries) )
|
if ( !GetNotarizationNotaries(notarypubkeys, numNN, tx.vin, NotarizationNotaries) )
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
item.push_back(make_pair("txid", n.first.GetHex()));
|
item.push_back(make_pair("txid", n.first.GetHex()));
|
||||||
@@ -1159,7 +1159,7 @@ UniValue getNotarisationsForBlock(const UniValue& params, bool fHelp, const CPub
|
|||||||
item.push_back(make_pair("blockhash", n.second.blockHash.GetHex()));
|
item.push_back(make_pair("blockhash", n.second.blockHash.GetHex()));
|
||||||
//item.push_back(make_pair("HUSH_height", height)); // for when timstamp input is used.
|
//item.push_back(make_pair("HUSH_height", height)); // for when timstamp input is used.
|
||||||
|
|
||||||
for ( auto notary : NotarisationNotaries )
|
for ( auto notary : NotarizationNotaries )
|
||||||
notaryarr.push_back(notary);
|
notaryarr.push_back(notary);
|
||||||
item.push_back(make_pair("notaries",notaryarr));
|
item.push_back(make_pair("notaries",notaryarr));
|
||||||
hush.push_back(item);
|
hush.push_back(item);
|
||||||
@@ -1168,19 +1168,19 @@ UniValue getNotarisationsForBlock(const UniValue& params, bool fHelp, const CPub
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*UniValue getNotarisationsForBlock(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
/*UniValue getNotarizationsForBlock(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 1)
|
if (fHelp || params.size() != 1)
|
||||||
throw runtime_error("getNotarisationsForBlock blockHash\n\n"
|
throw runtime_error("getNotarizationsForBlock blockHash\n\n"
|
||||||
"Takes a block hash and returns notarisation transactions "
|
"Takes a block hash and returns notarisation transactions "
|
||||||
"within the block");
|
"within the block");
|
||||||
|
|
||||||
uint256 blockHash = uint256S(params[0].get_str());
|
uint256 blockHash = uint256S(params[0].get_str());
|
||||||
|
|
||||||
NotarisationsInBlock nibs;
|
NotarizationsInBlock nibs;
|
||||||
GetBlockNotarisations(blockHash, nibs);
|
GetBlockNotarizations(blockHash, nibs);
|
||||||
UniValue out(UniValue::VARR);
|
UniValue out(UniValue::VARR);
|
||||||
BOOST_FOREACH(const Notarisation& n, nibs)
|
BOOST_FOREACH(const Notarization& n, nibs)
|
||||||
{
|
{
|
||||||
UniValue item(UniValue::VARR);
|
UniValue item(UniValue::VARR);
|
||||||
item.push_back(n.first.GetHex());
|
item.push_back(n.first.GetHex());
|
||||||
@@ -1191,10 +1191,10 @@ UniValue getNotarisationsForBlock(const UniValue& params, bool fHelp, const CPub
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
||||||
UniValue scanNotarisationsDB(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
UniValue scanNotarizationsDB(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() < 2 || params.size() > 3)
|
if (fHelp || params.size() < 2 || params.size() > 3)
|
||||||
throw runtime_error("scanNotarisationsDB blockHeight symbol [blocksLimit=1440]\n\n"
|
throw runtime_error("scanNotarizationsDB blockHeight symbol [blocksLimit=1440]\n\n"
|
||||||
"Scans notarisationsdb backwards from height for a notarisation"
|
"Scans notarisationsdb backwards from height for a notarisation"
|
||||||
" of given symbol");
|
" of given symbol");
|
||||||
int height = atoi(params[0].get_str().c_str());
|
int height = atoi(params[0].get_str().c_str());
|
||||||
@@ -1209,8 +1209,8 @@ UniValue scanNotarisationsDB(const UniValue& params, bool fHelp, const CPubKey&
|
|||||||
height = chainActive.Height();
|
height = chainActive.Height();
|
||||||
}
|
}
|
||||||
|
|
||||||
Notarisation nota;
|
Notarization nota;
|
||||||
int matchedHeight = ScanNotarisationsDB(height, symbol, limit, nota);
|
int matchedHeight = ScanNotarizationsDB(height, symbol, limit, nota);
|
||||||
if (!matchedHeight) return NullUniValue;
|
if (!matchedHeight) return NullUniValue;
|
||||||
UniValue out(UniValue::VOBJ);
|
UniValue out(UniValue::VOBJ);
|
||||||
out.pushKV("height", matchedHeight);
|
out.pushKV("height", matchedHeight);
|
||||||
|
|||||||
@@ -354,8 +354,8 @@ static const CRPCCommand vRPCCommands[] =
|
|||||||
{ "crosschain", "height_MoM", &height_MoM, true },
|
{ "crosschain", "height_MoM", &height_MoM, true },
|
||||||
{ "crosschain", "assetchainproof", &assetchainproof, true },
|
{ "crosschain", "assetchainproof", &assetchainproof, true },
|
||||||
{ "crosschain", "crosschainproof", &crosschainproof, true },
|
{ "crosschain", "crosschainproof", &crosschainproof, true },
|
||||||
{ "crosschain", "getNotarisationsForBlock", &getNotarisationsForBlock, true },
|
{ "crosschain", "getNotarizationsForBlock", &getNotarizationsForBlock, true },
|
||||||
{ "crosschain", "scanNotarisationsDB", &scanNotarisationsDB, true },
|
{ "crosschain", "scanNotarizationsDB", &scanNotarizationsDB, true },
|
||||||
{ "crosschain", "getimports", &getimports, true },
|
{ "crosschain", "getimports", &getimports, true },
|
||||||
{ "crosschain", "getwalletburntransactions", &getwalletburntransactions, true },
|
{ "crosschain", "getwalletburntransactions", &getwalletburntransactions, true },
|
||||||
{ "crosschain", "migrate_converttoexport", &migrate_converttoexport, true },
|
{ "crosschain", "migrate_converttoexport", &migrate_converttoexport, true },
|
||||||
|
|||||||
@@ -495,8 +495,8 @@ extern UniValue calc_MoM(const UniValue& params, bool fHelp, const CPubKey& mypk
|
|||||||
extern UniValue height_MoM(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
extern UniValue height_MoM(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||||
extern UniValue assetchainproof(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
extern UniValue assetchainproof(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||||
extern UniValue crosschainproof(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
extern UniValue crosschainproof(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||||
extern UniValue getNotarisationsForBlock(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
extern UniValue getNotarizationsForBlock(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||||
extern UniValue scanNotarisationsDB(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
extern UniValue scanNotarizationsDB(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||||
extern UniValue getimports(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
extern UniValue getimports(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||||
extern UniValue getwalletburntransactions(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
extern UniValue getwalletburntransactions(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||||
extern UniValue migrate_converttoexport(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
extern UniValue migrate_converttoexport(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||||
|
|||||||
@@ -123,16 +123,16 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetNotarisationData(uint256 notarisationHash, NotarisationData &data) const
|
bool GetNotarizationData(uint256 notarisationHash, NotarizationData &data) const
|
||||||
{
|
{
|
||||||
if (notarisationHash == NotarisationHash()) {
|
if (notarisationHash == NotarizationHash()) {
|
||||||
data.MoM = MoM;
|
data.MoM = MoM;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint256 NotarisationHash()
|
static uint256 NotarizationHash()
|
||||||
{
|
{
|
||||||
uint256 h;
|
uint256 h;
|
||||||
h.begin()[0] = 123;
|
h.begin()[0] = 123;
|
||||||
@@ -206,7 +206,7 @@ public:
|
|||||||
int nIndex = 5;
|
int nIndex = 5;
|
||||||
std::vector<uint256> vBranch;
|
std::vector<uint256> vBranch;
|
||||||
vBranch.resize(3);
|
vBranch.resize(3);
|
||||||
return {MerkleBranch(nIndex, vBranch), EvalMock::NotarisationHash()};
|
return {MerkleBranch(nIndex, vBranch), EvalMock::NotarizationHash()};
|
||||||
}
|
}
|
||||||
|
|
||||||
CMutableTransaction ImportPayoutTx()
|
CMutableTransaction ImportPayoutTx()
|
||||||
@@ -562,7 +562,7 @@ TEST_F(TestBet, testImportPayoutMangleSessionId)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_F(TestBet, testImportPayoutInvalidNotarisationHash)
|
TEST_F(TestBet, testImportPayoutInvalidNotarizationHash)
|
||||||
{
|
{
|
||||||
EvalMock eval = ebet.SetEvalMock(12);
|
EvalMock eval = ebet.SetEvalMock(12);
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
extern int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);
|
extern int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);
|
||||||
|
|
||||||
|
|
||||||
namespace TestEvalNotarisation {
|
namespace TestEvalNotarization {
|
||||||
|
|
||||||
|
|
||||||
class EvalMock : public Eval
|
class EvalMock : public Eval
|
||||||
@@ -96,14 +96,14 @@ namespace TestEvalNotarisation {
|
|||||||
static auto vMomProof = ParseHex("0303faecbdd4b3da128c2cd2701bb143820a967069375b2ec5b612f39bbfe78a8611978871c193457ab1e21b9520f4139f113b8d75892eb93ee247c18bccfd067efed7eacbfcdc8946cf22de45ad536ec0719034fb9bc825048fe6ab61fee5bd6e9aae0bb279738d46673c53d68eb2a72da6dbff215ee41a4d405a74ff7cd355805b"); // $ fiat/bots txMoMproof $proofTxHash
|
static auto vMomProof = ParseHex("0303faecbdd4b3da128c2cd2701bb143820a967069375b2ec5b612f39bbfe78a8611978871c193457ab1e21b9520f4139f113b8d75892eb93ee247c18bccfd067efed7eacbfcdc8946cf22de45ad536ec0719034fb9bc825048fe6ab61fee5bd6e9aae0bb279738d46673c53d68eb2a72da6dbff215ee41a4d405a74ff7cd355805b"); // $ fiat/bots txMoMproof $proofTxHash
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TEST(TestEvalNotarisation, testGetNotarisation)
|
TEST(TestEvalNotarization, testGetNotarization)
|
||||||
{
|
{
|
||||||
EvalMock eval;
|
EvalMock eval;
|
||||||
CMutableTransaction notary(notaryTx);
|
CMutableTransaction notary(notaryTx);
|
||||||
SetupEval(eval, notary, noop);
|
SetupEval(eval, notary, noop);
|
||||||
|
|
||||||
NotarisationData data;
|
NotarizationData data;
|
||||||
ASSERT_TRUE(eval.GetNotarisationData(notary.GetHash(), data));
|
ASSERT_TRUE(eval.GetNotarizationData(notary.GetHash(), data));
|
||||||
EXPECT_EQ(data.height, 77455);
|
EXPECT_EQ(data.height, 77455);
|
||||||
EXPECT_EQ(data.blockHash.GetHex(), "000030ef29d072f417cec86ad5a5ab4f8c413c7f96f572a098e45d6e3e0f8eae");
|
EXPECT_EQ(data.blockHash.GetHex(), "000030ef29d072f417cec86ad5a5ab4f8c413c7f96f572a098e45d6e3e0f8eae");
|
||||||
EXPECT_STREQ(data.symbol, "BOTS");
|
EXPECT_STREQ(data.symbol, "BOTS");
|
||||||
@@ -116,7 +116,7 @@ namespace TestEvalNotarisation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(TestEvalNotarisation, testInvalidNotaryPubkey)
|
TEST(TestEvalNotarization, testInvalidNotaryPubkey)
|
||||||
{
|
{
|
||||||
EvalMock eval;
|
EvalMock eval;
|
||||||
CMutableTransaction notary(notaryTx);
|
CMutableTransaction notary(notaryTx);
|
||||||
@@ -124,13 +124,13 @@ TEST(TestEvalNotarisation, testInvalidNotaryPubkey)
|
|||||||
|
|
||||||
memset(eval.notaries[10], 0, 33);
|
memset(eval.notaries[10], 0, 33);
|
||||||
|
|
||||||
NotarisationData data;
|
NotarizationData data;
|
||||||
ASSERT_FALSE(eval.GetNotarisationData(notary.GetHash(), data));
|
ASSERT_FALSE(eval.GetNotarizationData(notary.GetHash(), data));
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
TEST(TestEvalNotarisation, testInvalidNotarisationBadOpReturn)
|
TEST(TestEvalNotarization, testInvalidNotarizationBadOpReturn)
|
||||||
{
|
{
|
||||||
EvalMock eval;
|
EvalMock eval;
|
||||||
CMutableTransaction notary(notaryTx);
|
CMutableTransaction notary(notaryTx);
|
||||||
@@ -138,12 +138,12 @@ TEST(TestEvalNotarisation, testInvalidNotarisationBadOpReturn)
|
|||||||
notary.vout[1].scriptPubKey = CScript() << OP_RETURN << 0;
|
notary.vout[1].scriptPubKey = CScript() << OP_RETURN << 0;
|
||||||
SetupEval(eval, notary, noop);
|
SetupEval(eval, notary, noop);
|
||||||
|
|
||||||
NotarisationData data(0);
|
NotarizationData data(0);
|
||||||
ASSERT_FALSE(eval.GetNotarisationData(notary.GetHash(), data));
|
ASSERT_FALSE(eval.GetNotarizationData(notary.GetHash(), data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(TestEvalNotarisation, testInvalidNotarisationTxNotEnoughSigs)
|
TEST(TestEvalNotarization, testInvalidNotarizationTxNotEnoughSigs)
|
||||||
{
|
{
|
||||||
EvalMock eval;
|
EvalMock eval;
|
||||||
CMutableTransaction notary(notaryTx);
|
CMutableTransaction notary(notaryTx);
|
||||||
@@ -152,24 +152,24 @@ TEST(TestEvalNotarisation, testInvalidNotarisationTxNotEnoughSigs)
|
|||||||
tx.vin.resize(10);
|
tx.vin.resize(10);
|
||||||
});
|
});
|
||||||
|
|
||||||
NotarisationData data(0);
|
NotarizationData data(0);
|
||||||
ASSERT_FALSE(eval.GetNotarisationData(notary.GetHash(), data));
|
ASSERT_FALSE(eval.GetNotarizationData(notary.GetHash(), data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(TestEvalNotarisation, testInvalidNotarisationTxDoesntExist)
|
TEST(TestEvalNotarization, testInvalidNotarizationTxDoesntExist)
|
||||||
{
|
{
|
||||||
EvalMock eval;
|
EvalMock eval;
|
||||||
CMutableTransaction notary(notaryTx);
|
CMutableTransaction notary(notaryTx);
|
||||||
|
|
||||||
SetupEval(eval, notary, noop);
|
SetupEval(eval, notary, noop);
|
||||||
|
|
||||||
NotarisationData data(0);
|
NotarizationData data(0);
|
||||||
ASSERT_FALSE(eval.GetNotarisationData(uint256(), data));
|
ASSERT_FALSE(eval.GetNotarizationData(uint256(), data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(TestEvalNotarisation, testInvalidNotarisationDupeNotary)
|
TEST(TestEvalNotarization, testInvalidNotarizationDupeNotary)
|
||||||
{
|
{
|
||||||
EvalMock eval;
|
EvalMock eval;
|
||||||
CMutableTransaction notary(notaryTx);
|
CMutableTransaction notary(notaryTx);
|
||||||
@@ -178,12 +178,12 @@ TEST(TestEvalNotarisation, testInvalidNotarisationDupeNotary)
|
|||||||
tx.vin[1] = tx.vin[3];
|
tx.vin[1] = tx.vin[3];
|
||||||
});
|
});
|
||||||
|
|
||||||
NotarisationData data(0);
|
NotarizationData data(0);
|
||||||
ASSERT_FALSE(eval.GetNotarisationData(notary.GetHash(), data));
|
ASSERT_FALSE(eval.GetNotarizationData(notary.GetHash(), data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(TestEvalNotarisation, testInvalidNotarisationInputNotCheckSig)
|
TEST(TestEvalNotarization, testInvalidNotarizationInputNotCheckSig)
|
||||||
{
|
{
|
||||||
EvalMock eval;
|
EvalMock eval;
|
||||||
CMutableTransaction notary(notaryTx);
|
CMutableTransaction notary(notaryTx);
|
||||||
@@ -197,10 +197,10 @@ TEST(TestEvalNotarisation, testInvalidNotarisationInputNotCheckSig)
|
|||||||
eval.txs[txIn.GetHash()] = CTransaction(txIn);
|
eval.txs[txIn.GetHash()] = CTransaction(txIn);
|
||||||
});
|
});
|
||||||
|
|
||||||
NotarisationData data(0);
|
NotarizationData data(0);
|
||||||
ASSERT_FALSE(eval.GetNotarisationData(notary.GetHash(), data));
|
ASSERT_FALSE(eval.GetNotarizationData(notary.GetHash(), data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} /* namespace TestEvalNotarisation */
|
} /* namespace TestEvalNotarization */
|
||||||
@@ -10,42 +10,42 @@
|
|||||||
#include "testutils.h"
|
#include "testutils.h"
|
||||||
|
|
||||||
|
|
||||||
namespace TestParseNotarisation {
|
namespace TestParseNotarization {
|
||||||
|
|
||||||
class TestParseNotarisation : public ::testing::Test, public Eval {};
|
class TestParseNotarization : public ::testing::Test, public Eval {};
|
||||||
|
|
||||||
|
|
||||||
TEST(TestParseNotarisation, test_ee2fa)
|
TEST(TestParseNotarization, test_ee2fa)
|
||||||
{
|
{
|
||||||
// ee2fa47820a31a979f9f21cb3fedbc484bf9a8957cb6c9acd0af28ced29bdfe1
|
// ee2fa47820a31a979f9f21cb3fedbc484bf9a8957cb6c9acd0af28ced29bdfe1
|
||||||
std::vector<uint8_t> opret = ParseHex("c349ff90f3bce62c1b7b49d1da0423b1a3d9b733130cce825b95b9e047c729066e020d00743a06fdb95ad5775d032b30bbb3680dac2091a0f800cf54c79fd3461ce9b31d4b4d4400");
|
std::vector<uint8_t> opret = ParseHex("c349ff90f3bce62c1b7b49d1da0423b1a3d9b733130cce825b95b9e047c729066e020d00743a06fdb95ad5775d032b30bbb3680dac2091a0f800cf54c79fd3461ce9b31d4b4d4400");
|
||||||
NotarisationData nd;
|
NotarizationData nd;
|
||||||
ASSERT_TRUE(E_UNMARSHAL(opret, ss >> nd));
|
ASSERT_TRUE(E_UNMARSHAL(opret, ss >> nd));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TestParseNotarisation, test__)
|
TEST(TestParseNotarization, test__)
|
||||||
{
|
{
|
||||||
// 576e910a1f704207bcbcf724124ff9adc5237f45cb6919589cd0aa152caec424
|
// 576e910a1f704207bcbcf724124ff9adc5237f45cb6919589cd0aa152caec424
|
||||||
std::vector<uint8_t> opret = ParseHex("b3ed7fbbfbc027caeeeec81e65489ec5d9cd47cda675a5cbb75b4a845e67cf0ef6330300b5a6bd8385feb833f3be961c9d8a46fcecd36dcdfa42ad81a20a892433722f0b4b4d44004125a06024eae24c11f36ea110acd707b041d5355b6e1b42de5e2614357999c6aa02000d26ad0300000000404b4c000000000005130300500d000061f22ba7d19fe29ac3baebd839af8b7127d1f90755534400");
|
std::vector<uint8_t> opret = ParseHex("b3ed7fbbfbc027caeeeec81e65489ec5d9cd47cda675a5cbb75b4a845e67cf0ef6330300b5a6bd8385feb833f3be961c9d8a46fcecd36dcdfa42ad81a20a892433722f0b4b4d44004125a06024eae24c11f36ea110acd707b041d5355b6e1b42de5e2614357999c6aa02000d26ad0300000000404b4c000000000005130300500d000061f22ba7d19fe29ac3baebd839af8b7127d1f90755534400");
|
||||||
NotarisationData nd;
|
NotarizationData nd;
|
||||||
// We can't parse this one
|
// We can't parse this one
|
||||||
ASSERT_FALSE(E_UNMARSHAL(opret, ss >> nd));
|
ASSERT_FALSE(E_UNMARSHAL(opret, ss >> nd));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TestParseNotarisation, test__a)
|
TEST(TestParseNotarization, test__a)
|
||||||
{
|
{
|
||||||
// be55101e6c5a93fb3611a44bd66217ad8714d204275ea4e691cfff9d65dff85c TXSCL
|
// be55101e6c5a93fb3611a44bd66217ad8714d204275ea4e691cfff9d65dff85c TXSCL
|
||||||
std::vector<uint8_t> opret = ParseHex("fb9ea2818eec8b07f8811bab49d64379db074db478997f8114666f239bd79803cc460000d0fac4e715b7e2b917a5d79f85ece0c423d27bd3648fd39ac1dc7db8e1bd4b16545853434c00a69eab9f23d7fb63c4624973e7a9079d6ada2f327040936356d7af5e849f6d670a0003001caf7b7b9e1c9bc59d0c7a619c9683ab1dd0794b6f3ea184a19f8fda031150e700000000");
|
std::vector<uint8_t> opret = ParseHex("fb9ea2818eec8b07f8811bab49d64379db074db478997f8114666f239bd79803cc460000d0fac4e715b7e2b917a5d79f85ece0c423d27bd3648fd39ac1dc7db8e1bd4b16545853434c00a69eab9f23d7fb63c4624973e7a9079d6ada2f327040936356d7af5e849f6d670a0003001caf7b7b9e1c9bc59d0c7a619c9683ab1dd0794b6f3ea184a19f8fda031150e700000000");
|
||||||
NotarisationData nd(1);
|
NotarizationData nd(1);
|
||||||
bool res = E_UNMARSHAL(opret, ss >> nd);
|
bool res = E_UNMARSHAL(opret, ss >> nd);
|
||||||
ASSERT_TRUE(res);
|
ASSERT_TRUE(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TestParseNotarisation, test__b)
|
TEST(TestParseNotarization, test__b)
|
||||||
{
|
{
|
||||||
// 03085dafed656aaebfda25bf43ffe9d1fb72565bb1fc8b2a12a631659f28f877 TXSCL
|
// 03085dafed656aaebfda25bf43ffe9d1fb72565bb1fc8b2a12a631659f28f877 TXSCL
|
||||||
std::vector<uint8_t> opret = ParseHex("48c71a10aa060eab1a43f52acefac3b81fb2a2ce310186b06141884c0501d403c246000052e6d49afd82d9ab3d97c996dd9b6a78a554ffa1625e8dadf0494bd1f8442e3e545853434c007cc5c07e3b67520fd14e23cd5b49f2aa022f411500fd3326ff91e6dc0544a1c90c0003008b69117bb1376ac8df960f785d8c208c599d3a36248c98728256bb6d4737e59600000000");
|
std::vector<uint8_t> opret = ParseHex("48c71a10aa060eab1a43f52acefac3b81fb2a2ce310186b06141884c0501d403c246000052e6d49afd82d9ab3d97c996dd9b6a78a554ffa1625e8dadf0494bd1f8442e3e545853434c007cc5c07e3b67520fd14e23cd5b49f2aa022f411500fd3326ff91e6dc0544a1c90c0003008b69117bb1376ac8df960f785d8c208c599d3a36248c98728256bb6d4737e59600000000");
|
||||||
NotarisationData nd(1);
|
NotarizationData nd(1);
|
||||||
bool res = E_UNMARSHAL(opret, ss >> nd);
|
bool res = E_UNMARSHAL(opret, ss >> nd);
|
||||||
ASSERT_TRUE(res);
|
ASSERT_TRUE(res);
|
||||||
}
|
}
|
||||||
@@ -918,7 +918,7 @@ void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex)
|
|||||||
{
|
{
|
||||||
LOCK(cs_wallet);
|
LOCK(cs_wallet);
|
||||||
|
|
||||||
extern int32_t KOMODO_REWIND;
|
extern int32_t HUSH_REWIND;
|
||||||
|
|
||||||
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) {
|
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) {
|
||||||
//Sapling
|
//Sapling
|
||||||
@@ -937,7 +937,7 @@ void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(KOMODO_REWIND != 0 || WITNESS_CACHE_SIZE != _COINBASE_MATURITY+10);
|
assert(HUSH_REWIND != 0 || WITNESS_CACHE_SIZE != _COINBASE_MATURITY+10);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename NoteData>
|
template<typename NoteData>
|
||||||
|
|||||||
Reference in New Issue
Block a user