Stuck in the grind
This commit is contained in:
130
src/alert.cpp
130
src/alert.cpp
@@ -3,7 +3,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. *
|
||||
* *
|
||||
@@ -18,20 +17,16 @@
|
||||
* Removal or modification of this copyright notice is prohibited. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include "alert.h"
|
||||
|
||||
#include "clientversion.h"
|
||||
#include "net.h"
|
||||
#include "pubkey.h"
|
||||
#include "timedata.h"
|
||||
#include "ui_interface.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
@@ -118,7 +113,7 @@ uint256 CAlert::GetHash() const
|
||||
|
||||
bool CAlert::IsInEffect() const
|
||||
{
|
||||
return (GetTime() < nExpiration);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CAlert::Cancels(const CAlert& alert) const
|
||||
@@ -138,146 +133,31 @@ bool CAlert::AppliesTo(int nVersion, const std::string& strSubVerIn) const
|
||||
|
||||
bool CAlert::AppliesToMe() const
|
||||
{
|
||||
return AppliesTo(PROTOCOL_VERSION, FormatSubVersion(GetArg("-clientname","MagicBean"), CLIENT_VERSION, std::vector<std::string>()));
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CAlert::RelayTo(CNode* pnode) const
|
||||
{
|
||||
if (!IsInEffect())
|
||||
return false;
|
||||
// don't relay to nodes which haven't sent their version message
|
||||
if (pnode->nVersion == 0)
|
||||
return false;
|
||||
// returns true if wasn't already contained in the set
|
||||
if (pnode->setKnown.insert(GetHash()).second)
|
||||
{
|
||||
if (AppliesTo(pnode->nVersion, pnode->strSubVer) ||
|
||||
AppliesToMe() ||
|
||||
GetTime() < nRelayUntil)
|
||||
{
|
||||
pnode->PushMessage("alert", *this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CAlert::CheckSignature(const std::vector<unsigned char>& alertKey) const
|
||||
{
|
||||
CPubKey key(alertKey);
|
||||
if (!key.Verify(Hash(vchMsg.begin(), vchMsg.end()), vchSig))
|
||||
return error("CAlert::CheckSignature(): verify signature failed");
|
||||
|
||||
// Now unserialize the data
|
||||
CDataStream sMsg(vchMsg, SER_NETWORK, PROTOCOL_VERSION);
|
||||
sMsg >> *(CUnsignedAlert*)this;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
CAlert CAlert::getAlertByHash(const uint256 &hash)
|
||||
{
|
||||
CAlert retval;
|
||||
{
|
||||
LOCK(cs_mapAlerts);
|
||||
map<uint256, CAlert>::iterator mi = mapAlerts.find(hash);
|
||||
if(mi != mapAlerts.end())
|
||||
retval = mi->second;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool CAlert::ProcessAlert(const std::vector<unsigned char>& alertKey, bool fThread)
|
||||
{
|
||||
if (!CheckSignature(alertKey))
|
||||
return false;
|
||||
if (!IsInEffect())
|
||||
return false;
|
||||
|
||||
// alert.nID=max is reserved for if the alert key is
|
||||
// compromised. It must have a pre-defined message,
|
||||
// must never expire, must apply to all versions,
|
||||
// and must cancel all previous
|
||||
// alerts or it will be ignored (so an attacker can't
|
||||
// send an "everything is OK, don't panic" version that
|
||||
// cannot be overridden):
|
||||
int maxInt = std::numeric_limits<int>::max();
|
||||
if (nID == maxInt)
|
||||
{
|
||||
if (!(
|
||||
nExpiration == maxInt &&
|
||||
nCancel == (maxInt-1) &&
|
||||
nMinVer == 0 &&
|
||||
nMaxVer == maxInt &&
|
||||
setSubVer.empty() &&
|
||||
nPriority == maxInt &&
|
||||
strStatusBar == "URGENT: Alert key compromised, upgrade required"
|
||||
))
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
LOCK(cs_mapAlerts);
|
||||
// Cancel previous alerts
|
||||
for (map<uint256, CAlert>::iterator mi = mapAlerts.begin(); mi != mapAlerts.end();)
|
||||
{
|
||||
const CAlert& alert = (*mi).second;
|
||||
if (Cancels(alert))
|
||||
{
|
||||
LogPrint("alert", "cancelling alert %d\n", alert.nID);
|
||||
uiInterface.NotifyAlertChanged((*mi).first, CT_DELETED);
|
||||
mapAlerts.erase(mi++);
|
||||
}
|
||||
else if (!alert.IsInEffect())
|
||||
{
|
||||
LogPrint("alert", "expiring alert %d\n", alert.nID);
|
||||
uiInterface.NotifyAlertChanged((*mi).first, CT_DELETED);
|
||||
mapAlerts.erase(mi++);
|
||||
}
|
||||
else
|
||||
mi++;
|
||||
}
|
||||
|
||||
// Check if this alert has been cancelled
|
||||
BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts)
|
||||
{
|
||||
const CAlert& alert = item.second;
|
||||
if (alert.Cancels(*this))
|
||||
{
|
||||
LogPrint("alert", "alert already cancelled by %d\n", alert.nID);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Add to mapAlerts
|
||||
mapAlerts.insert(make_pair(GetHash(), *this));
|
||||
// Notify UI and -alertnotify if it applies to me
|
||||
if(AppliesToMe())
|
||||
{
|
||||
uiInterface.NotifyAlertChanged(GetHash(), CT_NEW);
|
||||
Notify(strStatusBar, fThread);
|
||||
}
|
||||
}
|
||||
|
||||
LogPrint("alert", "accepted alert %d, AppliesToMe()=%d\n", nID, AppliesToMe());
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
CAlert::Notify(const std::string& strMessage, bool fThread)
|
||||
void CAlert::Notify(const std::string& strMessage, bool fThread)
|
||||
{
|
||||
std::string strCmd = GetArg("-alertnotify", "");
|
||||
if (strCmd.empty()) return;
|
||||
|
||||
// Alert text should be plain ascii coming from a trusted source, but to
|
||||
// be safe we first strip anything not in safeChars, then add single quotes around
|
||||
// the whole string before passing it to the shell:
|
||||
std::string singleQuote("'");
|
||||
std::string safeStatus = SanitizeString(strMessage);
|
||||
safeStatus = singleQuote+safeStatus+singleQuote;
|
||||
boost::replace_all(strCmd, "%s", safeStatus);
|
||||
|
||||
if (fThread)
|
||||
boost::thread t(runCommand, strCmd); // thread runs free
|
||||
else
|
||||
runCommand(strCmd);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
int32_t komodo_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblocks);
|
||||
extern void GetKomodoEarlytxidScriptPub();
|
||||
extern CScript KOMODO_EARLYTXID_SCRIPTPUB;
|
||||
extern CScript HUSH_EARLYTXID_SCRIPTPUB;
|
||||
|
||||
// #define PRICES_DAYWINDOW ((3600*24/ASSETCHAINS_BLOCKTIME) + 1) // defined in hush_defs.h
|
||||
#define PRICES_TXFEE 10000
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
* Removal or modification of this copyright notice is prohibited. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef CC_INCLUDE_H
|
||||
#define CC_INCLUDE_H
|
||||
|
||||
@@ -32,7 +31,7 @@ Details.
|
||||
/// this script's hash is what the p2sh address was.
|
||||
/// All of the above are the standard bitcoin vout types and there should be plenty of materials about it.
|
||||
///
|
||||
/// What I did with the cryptoconditions (CC) contracts (now rebranded as Antara modules) is created a fourth type of vout, the CC vout. This is using the cryptoconditions standard and it is even a different signature mechanism,
|
||||
/// Cryptoconditions (CC) contracts created a fourth type of vout, the CC vout. This is using the cryptoconditions standard and it is even a different signature mechanism,
|
||||
/// ed25519 instead of secp256k1. It is basically a big extension to the bitcoin script. There is a special opcode that is added that says it is a CC script.
|
||||
///
|
||||
/// But it gets more interesting. Each CC script has an evalcode.
|
||||
@@ -49,7 +48,7 @@ Details.
|
||||
/// However, it is a CC output, so in addition to the signature, whatever constraints a CC contract implements must also be satistifed.
|
||||
/// This allows funds to be locked and yet anybody is able to spend it, assuming they satisfy the CC's rules.
|
||||
///
|
||||
/// One other technical note is that komodod has the insight-explorer extensions built in
|
||||
/// One other technical note is that Hush has the insight-explorer extensions built in
|
||||
/// so it can lookup directly all transactions to any address.
|
||||
/// This is a key performance boosting thing as if it wasnt there, trying to get all the utxo for an address not in the wallet is quite time consuming.
|
||||
///
|
||||
@@ -101,12 +100,12 @@ Details.
|
||||
enum opretid : uint8_t {
|
||||
// cc contracts data:
|
||||
OPRETID_NONFUNGIBLEDATA = 0x11, //!< NFT data id
|
||||
OPRETID_ASSETSDATA = 0x12, //!< assets contract data id
|
||||
OPRETID_GATEWAYSDATA = 0x13, //!< gateways contract data id
|
||||
OPRETID_CHANNELSDATA = 0x14, //!< channels contract data id
|
||||
OPRETID_HEIRDATA = 0x15, //!< heir contract data id
|
||||
OPRETID_ROGUEGAMEDATA = 0x16, //!< rogue contract data id
|
||||
OPRETID_PEGSDATA = 0x17, //!< pegs contract data id
|
||||
OPRETID_ASSETSDATA = 0x12, //!< assets contract data id
|
||||
OPRETID_GATEWAYSDATA = 0x13, //!< gateways contract data id
|
||||
OPRETID_CHANNELSDATA = 0x14, //!< channels contract data id
|
||||
OPRETID_HEIRDATA = 0x15, //!< heir contract data id
|
||||
OPRETID_ROGUEGAMEDATA = 0x16, //!< rogue contract data id
|
||||
OPRETID_PEGSDATA = 0x17, //!< pegs contract data id
|
||||
|
||||
/*! \cond INTERNAL */
|
||||
// non cc contract data:
|
||||
@@ -138,8 +137,6 @@ struct CC_utxo
|
||||
/// \endcond
|
||||
|
||||
/// \cond INTERNAL
|
||||
// these are the parameters stored after Verus crypto-condition vouts. new versions may change
|
||||
// the format
|
||||
struct CC_meta
|
||||
{
|
||||
std::vector<unsigned char> version;
|
||||
@@ -774,7 +771,7 @@ bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey);
|
||||
/// @returns true if success
|
||||
bool GetCustomscriptaddress(char *destaddr,const CScript &scriptPubKey,uint8_t taddr,uint8_t prefix,uint8_t prefix2);
|
||||
|
||||
/// Returns my pubkey, that is set by -pubkey komodod parameter
|
||||
/// Returns my pubkey, that is set by -pubkey hushd parameter
|
||||
/// @returns public key as byte array
|
||||
std::vector<uint8_t> Mypubkey();
|
||||
|
||||
@@ -825,7 +822,7 @@ std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTr
|
||||
|
||||
/// FinalizeCCTx is a very useful function that will properly sign both CC and normal inputs, adds normal change and might add an opreturn output.
|
||||
/// This allows for Antara module transaction creation rpc functions to create an CMutableTransaction object, add the appropriate vins and vouts to it and use FinalizeCCTx to properly sign the transaction.
|
||||
/// By using -addressindex=1 of komodod daemon, it allows tracking of all the CC addresses.
|
||||
/// By using -addressindex=1 of hushd daemon, it allows tracking of all the CC addresses.
|
||||
///
|
||||
/// For signing the vins the function builds several default probe scriptPubKeys and checks them against the referred previous transactions (vintx) vouts.
|
||||
/// For cryptocondition vins the function creates a basic set of probe cryptconditions with mypk and module global pubkey, both for coins and tokens cases.
|
||||
@@ -893,7 +890,7 @@ int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int3
|
||||
int64_t AddNormalinputsLocal(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs);
|
||||
|
||||
/// AddNormalinputs2 adds normal (not cc) inputs to the transaction object vin array for the specified total amount using utxos on my pubkey's TX_PUBKEY address (my pubkey is set by -pubkey command line parameter), to fund the transaction.
|
||||
/// 'My pubkey' is the -pubkey parameter of komodod.
|
||||
/// 'My pubkey' is the -pubkey parameter of hushd.
|
||||
/// @param mtx mutable transaction object
|
||||
/// @param total amount of inputs to add. If total equals to 0 the function does not add inputs but returns amount of all available normal inputs in the wallet
|
||||
/// @param maxinputs maximum number of inputs to add
|
||||
@@ -972,7 +969,7 @@ void CCLogPrintStream(const char *category, int level, const char *functionName,
|
||||
}
|
||||
/// Macro for logging messages using bitcoin LogAcceptCategory and LogPrintStr functions.
|
||||
/// Supports error, info and three levels of debug messages.
|
||||
/// Logging category is set by -debug=category komodod param.
|
||||
/// Logging category is set by -debug=category hushd param.
|
||||
/// To set debug level pass -debug=category-1, -debug=category-2 or -debug=category-3 param. If some level is enabled lower level messages also will be printed.
|
||||
/// To print info-level messages pass just -debug=category parameter, with no level.
|
||||
/// Error-level messages will always be printed, even if -debug parameter is not set
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
extern std::string ASSETCHAINS_SELFIMPORT;
|
||||
extern uint16_t ASSETCHAINS_CODAPORT,ASSETCHAINS_BEAMPORT;
|
||||
extern uint8_t ASSETCHAINS_OVERRIDE_PUBKEY33[33];
|
||||
extern uint256 KOMODO_EARLYTXID;
|
||||
extern uint256 HUSH_EARLYTXID;
|
||||
|
||||
// utilities from gateways.cpp
|
||||
uint256 BitcoinGetProofMerkleRoot(const std::vector<uint8_t> &proofData, std::vector<uint256> &txids);
|
||||
@@ -364,9 +364,9 @@ int32_t CheckGATEWAYimport(CTransaction importTx,CTransaction burnTx,std::string
|
||||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
|
||||
|
||||
// ASSETCHAINS_SELFIMPORT is coin
|
||||
if (KOMODO_EARLYTXID!=zeroid && bindtxid!=KOMODO_EARLYTXID)
|
||||
if (HUSH_EARLYTXID!=zeroid && bindtxid!=HUSH_EARLYTXID)
|
||||
{
|
||||
LOGSTREAM("importgateway", CCLOG_INFO, stream << "CheckGATEWAYimport invalid import gateway. On this chain only valid import gateway is " << KOMODO_EARLYTXID.GetHex() << std::endl);
|
||||
LOGSTREAM("importgateway", CCLOG_INFO, stream << "CheckGATEWAYimport invalid import gateway. On this chain only valid import gateway is " << HUSH_EARLYTXID.GetHex() << std::endl);
|
||||
return(-1);
|
||||
}
|
||||
// check for valid burn from external coin blockchain and if valid return(0);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#define KMD_TADDR 0
|
||||
#define CC_MARKER_VALUE 10000
|
||||
|
||||
extern uint256 KOMODO_EARLYTXID;
|
||||
extern uint256 HUSH_EARLYTXID;
|
||||
|
||||
CScript EncodeImportGatewayBindOpRet(uint8_t funcid,std::string coin,uint256 oracletxid,uint8_t M,uint8_t N,std::vector<CPubKey> importgatewaypubkeys,uint8_t taddr,uint8_t prefix,uint8_t prefix2,uint8_t wiftype)
|
||||
{
|
||||
@@ -570,9 +570,9 @@ std::string ImportGatewayDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,
|
||||
int32_t i,m,n,numvouts; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::string coin; struct CCcontract_info *cp,C;
|
||||
std::vector<CPubKey> pubkeys,publishers; std::vector<uint256> txids; char str[128],burnaddr[64];
|
||||
|
||||
if (KOMODO_EARLYTXID!=zeroid && bindtxid!=KOMODO_EARLYTXID)
|
||||
if (HUSH_EARLYTXID!=zeroid && bindtxid!=HUSH_EARLYTXID)
|
||||
{
|
||||
CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",KOMODO_EARLYTXID.GetHex());
|
||||
CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",HUSH_EARLYTXID.GetHex());
|
||||
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
|
||||
return("");
|
||||
}
|
||||
@@ -649,9 +649,9 @@ std::string ImportGatewayWithdraw(uint64_t txfee,uint256 bindtxid,std::string re
|
||||
std::vector<CPubKey> msigpubkeys; char burnaddr[64],str[65],coinaddr[64]; struct CCcontract_info *cp,C;
|
||||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
|
||||
|
||||
if (KOMODO_EARLYTXID!=zeroid && bindtxid!=KOMODO_EARLYTXID)
|
||||
if (HUSH_EARLYTXID!=zeroid && bindtxid!=HUSH_EARLYTXID)
|
||||
{
|
||||
CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",KOMODO_EARLYTXID.GetHex());
|
||||
CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",HUSH_EARLYTXID.GetHex());
|
||||
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
|
||||
return("");
|
||||
}
|
||||
@@ -748,9 +748,9 @@ std::string ImportGatewayPartialSign(uint64_t txfee,uint256 lasttxid,std::string
|
||||
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
|
||||
return("");
|
||||
}
|
||||
else if (KOMODO_EARLYTXID!=zeroid && bindtxid!=KOMODO_EARLYTXID)
|
||||
else if (HUSH_EARLYTXID!=zeroid && bindtxid!=HUSH_EARLYTXID)
|
||||
{
|
||||
CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",KOMODO_EARLYTXID.GetHex());
|
||||
CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",HUSH_EARLYTXID.GetHex());
|
||||
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
|
||||
return("");
|
||||
}
|
||||
@@ -795,9 +795,9 @@ std::string ImportGatewayPartialSign(uint64_t txfee,uint256 lasttxid,std::string
|
||||
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
|
||||
return("");
|
||||
}
|
||||
else if (KOMODO_EARLYTXID!=zeroid && bindtxid!=KOMODO_EARLYTXID)
|
||||
else if (HUSH_EARLYTXID!=zeroid && bindtxid!=HUSH_EARLYTXID)
|
||||
{
|
||||
CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",KOMODO_EARLYTXID.GetHex());
|
||||
CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",HUSH_EARLYTXID.GetHex());
|
||||
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
|
||||
return("");
|
||||
}
|
||||
@@ -866,9 +866,9 @@ std::string ImportGatewayCompleteSigning(uint64_t txfee,uint256 lasttxid,std::st
|
||||
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
|
||||
return("");
|
||||
}
|
||||
else if (KOMODO_EARLYTXID!=zeroid && bindtxid!=KOMODO_EARLYTXID)
|
||||
else if (HUSH_EARLYTXID!=zeroid && bindtxid!=HUSH_EARLYTXID)
|
||||
{
|
||||
CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",KOMODO_EARLYTXID.GetHex());
|
||||
CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",HUSH_EARLYTXID.GetHex());
|
||||
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
|
||||
return("");
|
||||
}
|
||||
@@ -912,9 +912,9 @@ std::string ImportGatewayCompleteSigning(uint64_t txfee,uint256 lasttxid,std::st
|
||||
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
|
||||
return("");
|
||||
}
|
||||
else if (KOMODO_EARLYTXID!=zeroid && bindtxid!=KOMODO_EARLYTXID)
|
||||
else if (HUSH_EARLYTXID!=zeroid && bindtxid!=HUSH_EARLYTXID)
|
||||
{
|
||||
CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",KOMODO_EARLYTXID.GetHex());
|
||||
CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",HUSH_EARLYTXID.GetHex());
|
||||
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
|
||||
return("");
|
||||
}
|
||||
@@ -990,9 +990,9 @@ std::string ImportGatewayMarkDone(uint64_t txfee,uint256 completetxid,std::strin
|
||||
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
|
||||
return("");
|
||||
}
|
||||
else if (KOMODO_EARLYTXID!=zeroid && bindtxid!=KOMODO_EARLYTXID)
|
||||
else if (HUSH_EARLYTXID!=zeroid && bindtxid!=HUSH_EARLYTXID)
|
||||
{
|
||||
CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",KOMODO_EARLYTXID.GetHex());
|
||||
CCerror = strprintf("invalid import gateway. On this chain only valid import gateway is %s",HUSH_EARLYTXID.GetHex());
|
||||
LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl);
|
||||
return("");
|
||||
}
|
||||
|
||||
@@ -363,7 +363,7 @@ int32_t oracle_format(uint256 *hashp,int64_t *valp,char *str,uint8_t fmt,uint8_t
|
||||
{
|
||||
if ( str != 0 )
|
||||
{
|
||||
if ( slen < IGUANA_MAXSCRIPTSIZE && offset+slen <= datalen )
|
||||
if ( slen < DRAGON_MAXSCRIPTSIZE && offset+slen <= datalen )
|
||||
{
|
||||
for (i=0; i<slen; i++)
|
||||
str[i] = data[offset++];
|
||||
@@ -375,7 +375,7 @@ int32_t oracle_format(uint256 *hashp,int64_t *valp,char *str,uint8_t fmt,uint8_t
|
||||
{
|
||||
if ( str != 0 )
|
||||
{
|
||||
if ( dlen < IGUANA_MAXSCRIPTSIZE && offset+dlen <= datalen )
|
||||
if ( dlen < DRAGON_MAXSCRIPTSIZE && offset+dlen <= datalen )
|
||||
{
|
||||
for (i=0; i<dlen; i++)
|
||||
sprintf(&str[i<<1],"%02x",data[offset++]);
|
||||
@@ -1024,7 +1024,7 @@ UniValue OracleData(const CPubKey& pk, int64_t txfee,uint256 oracletxid,std::vec
|
||||
|
||||
UniValue OracleFormat(uint8_t *data,int32_t datalen,char *format,int32_t formatlen)
|
||||
{
|
||||
UniValue obj(UniValue::VARR); uint256 hash; int32_t i,j=0; int64_t val; char str[IGUANA_MAXSCRIPTSIZE*2+1];
|
||||
UniValue obj(UniValue::VARR); uint256 hash; int32_t i,j=0; int64_t val; char str[DRAGON_MAXSCRIPTSIZE*2+1];
|
||||
for (i=0; i<formatlen && j<datalen; i++)
|
||||
{
|
||||
str[0] = 0;
|
||||
|
||||
@@ -64,7 +64,7 @@ Restart the daemon with -earlytxid=<txid of opreturn_burn transaction> eg:
|
||||
mine the chain past block 100, preventing anyone else, creating another payments plan on chain before block 100.
|
||||
|
||||
We call the following in Validation and RPC where the address is needed.
|
||||
if ( ASSETCHAINS_EARLYTXIDCONTRACT == EVAL_PRICES && KOMODO_EARLYTXID_SCRIPTPUB.size() == 0 )
|
||||
if ( ASSETCHAINS_EARLYTXIDCONTRACT == EVAL_PRICES && HUSH_EARLYTXID_SCRIPTPUB.size() == 0 )
|
||||
GetKomodoEarlytxidScriptPub();
|
||||
|
||||
This will fetch the op_return, calculate the scriptPubKey and save it to the global.
|
||||
@@ -244,7 +244,7 @@ static bool ValidateBetTx(struct CCcontract_info *cp, Eval *eval, const CTransac
|
||||
std::vector<uint16_t> vec;
|
||||
|
||||
// check payment cc config:
|
||||
if ( ASSETCHAINS_EARLYTXIDCONTRACT == EVAL_PRICES && KOMODO_EARLYTXID_SCRIPTPUB.size() == 0 )
|
||||
if ( ASSETCHAINS_EARLYTXIDCONTRACT == EVAL_PRICES && HUSH_EARLYTXID_SCRIPTPUB.size() == 0 )
|
||||
GetKomodoEarlytxidScriptPub();
|
||||
|
||||
if (bettx.vout.size() < 6 || bettx.vout.size() > 7)
|
||||
@@ -263,7 +263,7 @@ static bool ValidateBetTx(struct CCcontract_info *cp, Eval *eval, const CTransac
|
||||
if (MakeCC1vout(cp->evalcode, bettx.vout[2].nValue, pricespk) != bettx.vout[2] )
|
||||
return eval->Invalid("cannot validate vout2 in bet tx with pk from opreturn");
|
||||
// This should be all you need to verify it, maybe also check amount?
|
||||
if ( bettx.vout[4].scriptPubKey != KOMODO_EARLYTXID_SCRIPTPUB )
|
||||
if ( bettx.vout[4].scriptPubKey != HUSH_EARLYTXID_SCRIPTPUB )
|
||||
return eval->Invalid("the fee was paid to wrong address.");
|
||||
|
||||
int64_t betamount = bettx.vout[2].nValue;
|
||||
@@ -297,7 +297,7 @@ static bool ValidateAddFundingTx(struct CCcontract_info *cp, Eval *eval, const C
|
||||
vscript_t vintxOpret;
|
||||
|
||||
// check payment cc config:
|
||||
if (ASSETCHAINS_EARLYTXIDCONTRACT == EVAL_PRICES && KOMODO_EARLYTXID_SCRIPTPUB.size() == 0)
|
||||
if (ASSETCHAINS_EARLYTXIDCONTRACT == EVAL_PRICES && HUSH_EARLYTXID_SCRIPTPUB.size() == 0)
|
||||
GetKomodoEarlytxidScriptPub();
|
||||
|
||||
if (addfundingtx.vout.size() < 4 || addfundingtx.vout.size() > 5)
|
||||
@@ -323,7 +323,7 @@ static bool ValidateAddFundingTx(struct CCcontract_info *cp, Eval *eval, const C
|
||||
return eval->Invalid("cannot validate vout1 in add funding tx with global pk");
|
||||
|
||||
// This should be all you need to verify it, maybe also check amount?
|
||||
if (addfundingtx.vout[2].scriptPubKey != KOMODO_EARLYTXID_SCRIPTPUB)
|
||||
if (addfundingtx.vout[2].scriptPubKey != HUSH_EARLYTXID_SCRIPTPUB)
|
||||
return eval->Invalid("the fee was paid to wrong address.");
|
||||
|
||||
int64_t betamount = addfundingtx.vout[1].nValue;
|
||||
@@ -1505,14 +1505,14 @@ UniValue PricesBet(int64_t txfee, int64_t amount, int16_t leverage, std::vector<
|
||||
mtx.vout.push_back(MakeCC1vout(cp->evalcode, txfee, pricespk)); // vout1 cc marker (NVOUT_CCMARKER)
|
||||
mtx.vout.push_back(MakeCC1vout(cp->evalcode, betamount, pricespk)); // vout2 betamount
|
||||
mtx.vout.push_back(CTxOut(txfee, CScript() << ParseHex(HexStr(pricespk)) << OP_CHECKSIG)); // vout3 normal marker NVOUT_NORMALMARKER - TODO: remove it as we have cc marker now, when move to the new chain
|
||||
if ( ASSETCHAINS_EARLYTXIDCONTRACT == EVAL_PRICES && KOMODO_EARLYTXID_SCRIPTPUB.size() == 0 )
|
||||
if ( ASSETCHAINS_EARLYTXIDCONTRACT == EVAL_PRICES && HUSH_EARLYTXID_SCRIPTPUB.size() == 0 )
|
||||
{
|
||||
// Lock here, as in validation we cannot call lock in the function itself.
|
||||
// may not be needed as the validation call to update the global, is called in a LOCK already, and it can only update there and here.
|
||||
LOCK(cs_main);
|
||||
GetKomodoEarlytxidScriptPub();
|
||||
}
|
||||
mtx.vout.push_back(CTxOut(amount-betamount, KOMODO_EARLYTXID_SCRIPTPUB));
|
||||
mtx.vout.push_back(CTxOut(amount-betamount, HUSH_EARLYTXID_SCRIPTPUB));
|
||||
//test: mtx.vout.push_back(CTxOut(amount - betamount, CScript() << ParseHex("037c803ec82d12da939ac04379bbc1130a9065c53d8244a61eece1db942cf0efa7") << OP_CHECKSIG)); // vout4 test revshare fee
|
||||
|
||||
rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, prices_betopret(mypk, nextheight - 1, amount, leverage, firstprice, vec, zeroid));
|
||||
@@ -1576,14 +1576,14 @@ UniValue PricesAddFunding(int64_t txfee, uint256 bettxid, int64_t amount)
|
||||
mtx.vout.push_back(MakeCC1vout(cp->evalcode, txfee, mypk)); // vout0 baton for total funding
|
||||
mtx.vout.push_back(MakeCC1vout(cp->evalcode, betamount, pricespk)); // vout1 added amount
|
||||
|
||||
if (ASSETCHAINS_EARLYTXIDCONTRACT == EVAL_PRICES && KOMODO_EARLYTXID_SCRIPTPUB.size() == 0)
|
||||
if (ASSETCHAINS_EARLYTXIDCONTRACT == EVAL_PRICES && HUSH_EARLYTXID_SCRIPTPUB.size() == 0)
|
||||
{
|
||||
// Lock here, as in validation we cannot call lock in the function itself.
|
||||
// may not be needed as the validation call to update the global, is called in a LOCK already, and it can only update there and here.
|
||||
LOCK(cs_main);
|
||||
GetKomodoEarlytxidScriptPub();
|
||||
}
|
||||
mtx.vout.push_back(CTxOut(amount - betamount, KOMODO_EARLYTXID_SCRIPTPUB));
|
||||
mtx.vout.push_back(CTxOut(amount - betamount, HUSH_EARLYTXID_SCRIPTPUB));
|
||||
// test: mtx.vout.push_back(CTxOut(amount - betamount, CScript() << ParseHex("037c803ec82d12da939ac04379bbc1130a9065c53d8244a61eece1db942cf0efa7") << OP_CHECKSIG)); //vout2 test revshare fee
|
||||
|
||||
rawtx = FinalizeCCTx(0, cp, mtx, mypk, txfee, prices_addopret(bettxid, mypk, amount));
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
* Removal or modification of this copyright notice is prohibited. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include "cc/eval.h"
|
||||
#include "crosschain.h"
|
||||
#include "importcoin.h"
|
||||
@@ -23,15 +22,14 @@
|
||||
#include "notarizationdb.h"
|
||||
#include "merkleblock.h"
|
||||
#include "cc/CCinclude.h"
|
||||
|
||||
/*
|
||||
* The crosschain workflow.
|
||||
*
|
||||
* 3 chains, A, B, and HUSH. We would like to prove TX on B.
|
||||
* There is a notarisation, nA0, which will include TX via an MoM.
|
||||
* The notarisation nA0 must fall between 2 notarisations of B,
|
||||
* There is a notarization, nA0, which will include TX via an MoM.
|
||||
* The notarization nA0 must fall between 2 notarizations of B,
|
||||
* ie, nB0 and nB1. An MoMoM including this range is propagated to
|
||||
* B in notarisation receipt (backnotarisation) bnB2.
|
||||
* B in notarization receipt (backnotarization) bnB2.
|
||||
*
|
||||
* A: TX bnA0
|
||||
* \ /
|
||||
@@ -42,10 +40,8 @@
|
||||
|
||||
// XXX: There are potential crashes wherever we access chainActive without a lock,
|
||||
// because it might be disconnecting blocks at the same time.
|
||||
|
||||
|
||||
// TODO: this assumes a blocktime of 60 seconds and limiting of 1 day of blocks
|
||||
int NOTARISATION_SCAN_LIMIT_BLOCKS = 1440;
|
||||
// TODO: this assumes a blocktime of 75 seconds for HUSH and 60 seconds for other chains
|
||||
int NOTARISATION_SCAN_LIMIT_BLOCKS = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? 1152 : 1440;
|
||||
CBlockIndex *komodo_getblockindex(uint256 hash);
|
||||
|
||||
/* On HUSH */
|
||||
@@ -53,12 +49,12 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int hushHeig
|
||||
std::vector<uint256> &moms, uint256 &destNotarizationTxid)
|
||||
{
|
||||
/*
|
||||
* Notaries don't wait for confirmation on HUSH before performing a backnotarisation,
|
||||
* Notaries don't wait for confirmation on HUSH before performing a backnotarization,
|
||||
* but we need a determinable range that will encompass all merkle roots. Include MoMs
|
||||
* including the block height of the last notarisation until the height before the
|
||||
* previous notarisation.
|
||||
* including the block height of the last notarization until the height before the
|
||||
* previous notarization.
|
||||
*
|
||||
* hushHeight notarisations-0 notarisations-1
|
||||
* hushHeight notarizations-0 notarizations-1
|
||||
* *********************|
|
||||
* > scan backwards >
|
||||
*/
|
||||
@@ -76,13 +72,13 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int hushHeig
|
||||
|
||||
for (i=0; i<NOTARISATION_SCAN_LIMIT_BLOCKS; i++) {
|
||||
if (i > hushHeight) break;
|
||||
NotarizationsInBlock notarisations;
|
||||
NotarizationsInBlock notarizations;
|
||||
uint256 blockHash = *chainActive[hushHeight-i]->phashBlock;
|
||||
if (!GetBlockNotarizations(blockHash, notarisations))
|
||||
if (!GetBlockNotarizations(blockHash, notarizations))
|
||||
continue;
|
||||
|
||||
// See if we have an own notarisation in this block
|
||||
BOOST_FOREACH(Notarization& nota, notarisations) {
|
||||
// See if we have an own notarization in this block
|
||||
BOOST_FOREACH(Notarization& nota, notarizations) {
|
||||
if (strcmp(nota.second.symbol, symbol) == 0)
|
||||
{
|
||||
seenOwnNotarizations++;
|
||||
@@ -95,7 +91,7 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int hushHeig
|
||||
}
|
||||
|
||||
if (seenOwnNotarizations >= 1) {
|
||||
BOOST_FOREACH(Notarization& nota, notarisations) {
|
||||
BOOST_FOREACH(Notarization& nota, notarizations) {
|
||||
if (GetSymbolAuthority(nota.second.symbol) == authority)
|
||||
if (nota.second.ccId == targetCCid) {
|
||||
tmp_moms.insert(nota.second.MoM);
|
||||
@@ -105,7 +101,7 @@ uint256 CalculateProofRoot(const char* symbol, uint32_t targetCCid, int hushHeig
|
||||
}
|
||||
}
|
||||
|
||||
// Not enough own notarisations found to return determinate MoMoM
|
||||
// Not enough own notarizations found to return determinate MoMoM
|
||||
destNotarizationTxid = uint256();
|
||||
moms.clear();
|
||||
return uint256();
|
||||
@@ -120,9 +116,9 @@ end:
|
||||
|
||||
|
||||
/*
|
||||
* Get a notarisation from a given height
|
||||
* Get a notarization from a given height
|
||||
*
|
||||
* Will scan notarisations leveldb up to a limit
|
||||
* Will scan notarizations leveldb up to a limit
|
||||
*/
|
||||
template <typename IsTarget>
|
||||
int ScanNotarizationsFromHeight(int nHeight, const IsTarget f, Notarization &found)
|
||||
@@ -131,12 +127,12 @@ int ScanNotarizationsFromHeight(int nHeight, const IsTarget f, Notarization &fou
|
||||
int start = std::max(nHeight, 1);
|
||||
|
||||
for (int h=start; h<limit; h++) {
|
||||
NotarizationsInBlock notarisations;
|
||||
NotarizationsInBlock notarizations;
|
||||
|
||||
if (!GetBlockNotarizations(*chainActive[h]->phashBlock, notarisations))
|
||||
if (!GetBlockNotarizations(*chainActive[h]->phashBlock, notarizations))
|
||||
continue;
|
||||
|
||||
BOOST_FOREACH(found, notarisations) {
|
||||
BOOST_FOREACH(found, notarizations) {
|
||||
if (f(found)) {
|
||||
return h;
|
||||
}
|
||||
@@ -152,14 +148,14 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_
|
||||
{
|
||||
/*
|
||||
* Here we are given a proof generated by an assetchain A which goes from given txid to
|
||||
* an assetchain MoM. We need to go from the notarisationTxid for A to the MoMoM range of the
|
||||
* backnotarisation for B (given by hushHeight of notarisation), find the MoM within the MoMs for
|
||||
* an assetchain MoM. We need to go from the notarizationTxid for A to the MoMoM range of the
|
||||
* backnotarization for B (given by hushHeight of notarization), find the MoM within the MoMs for
|
||||
* that range, and finally extend the proof to lead to the MoMoM (proof root).
|
||||
*/
|
||||
EvalRef eval;
|
||||
uint256 MoM = assetChainProof.second.Exec(txid);
|
||||
|
||||
// Get a Hush height for given notarisation Txid
|
||||
// Get a Hush height for given notarization Txid
|
||||
int hushHeight;
|
||||
{
|
||||
CTransaction sourceNotarization;
|
||||
@@ -170,11 +166,11 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_
|
||||
hushHeight = blockIdx.GetHeight();
|
||||
}
|
||||
|
||||
// We now have a hushHeight of the notarisation from chain A. So we know that a MoM exists
|
||||
// We now have a hushHeight of the notarization from chain A. So we know that a MoM exists
|
||||
// at that height.
|
||||
// If we call CalculateProofRoot with that height, it'll scan backwards, until it finds
|
||||
// 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,
|
||||
// a notarization from B, and it might not include our notarization from A
|
||||
// at all. So, the thing we need to do is scan forwards to find the notarization for B,
|
||||
// that is inclusive of A.
|
||||
Notarization nota;
|
||||
auto isTarget = [&](Notarization ¬a) {
|
||||
@@ -182,7 +178,7 @@ TxProof GetCrossChainProof(const uint256 txid, const char* targetSymbol, uint32_
|
||||
};
|
||||
hushHeight = ScanNotarizationsFromHeight(hushHeight, isTarget, nota);
|
||||
if (!hushHeight)
|
||||
throw std::runtime_error("Cannot find notarisation for target inclusive of source");
|
||||
throw std::runtime_error("Cannot find notarization for target inclusive of source");
|
||||
|
||||
if ( offset != 0 )
|
||||
hushHeight += offset;
|
||||
@@ -257,38 +253,36 @@ bool IsSameAssetChain(const Notarization ¬a) {
|
||||
return strcmp(nota.second.symbol, SMART_CHAIN_SYMBOL) == 0;
|
||||
};
|
||||
|
||||
|
||||
/* On assetchain */
|
||||
bool GetNextBacknotarisation(uint256 hushNotarizationTxid, Notarization &out)
|
||||
bool GetNextBacknotarization(uint256 hushNotarizationTxid, Notarization &out)
|
||||
{
|
||||
/*
|
||||
* Here we are given a txid, and a proof.
|
||||
* We go from the HUSH notarisation txid to the backnotarisation,
|
||||
* then jump to the next backnotarisation, which contains the corresponding MoMoM.
|
||||
* We go from the HUSH notarization txid to the backnotarization,
|
||||
* then jump to the next backnotarization, which contains the corresponding MoMoM.
|
||||
*/
|
||||
Notarization bn;
|
||||
if (!GetBackNotarization(hushNotarizationTxid, bn))
|
||||
return false;
|
||||
|
||||
// Need to get block height of that backnotarisation
|
||||
// Need to get block height of that backnotarization
|
||||
EvalRef eval;
|
||||
CBlockIndex block;
|
||||
CTransaction tx;
|
||||
if (!eval->GetTxConfirmed(bn.first, tx, block)){
|
||||
fprintf(stderr, "Can't get height of backnotarisation, this should not happen\n");
|
||||
fprintf(stderr, "Can't get height of backnotarization, this should not happen\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bool) ScanNotarizationsFromHeight(block.GetHeight()+1, &IsSameAssetChain, out);
|
||||
}
|
||||
|
||||
|
||||
bool CheckMoMoM(uint256 hushNotarizationHash, uint256 momom)
|
||||
{
|
||||
/*
|
||||
* Given a notarisation hash and an MoMoM. Backnotarisations may arrive out of order
|
||||
* or multiple in the same block. So dereference the notarisation hash to the corresponding
|
||||
* backnotarisation and scan around the hushheight to see if the MoMoM is a match.
|
||||
* Given a notarization hash and an MoMoM. Backnotarizations may arrive out of order
|
||||
* or multiple in the same block. So dereference the notarization hash to the corresponding
|
||||
* backnotarization and scan around the hushheight to see if the MoMoM is a match.
|
||||
* This is a sledgehammer approach...
|
||||
*/
|
||||
|
||||
@@ -296,12 +290,12 @@ bool CheckMoMoM(uint256 hushNotarizationHash, uint256 momom)
|
||||
if (!GetBackNotarization(hushNotarizationHash, bn))
|
||||
return false;
|
||||
|
||||
// Need to get block height of that backnotarisation
|
||||
// Need to get block height of that backnotarization
|
||||
EvalRef eval;
|
||||
CBlockIndex block;
|
||||
CTransaction tx;
|
||||
if (!eval->GetTxConfirmed(bn.first, tx, block)){
|
||||
fprintf(stderr, "Can't get height of backnotarisation, this should not happen\n");
|
||||
fprintf(stderr, "Can't get height of backnotarization, this should not happen\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -423,7 +417,7 @@ bool CheckNotariesApproval(uint256 burntxid, const std::vector<uint256> & notary
|
||||
/*
|
||||
* On assetchain
|
||||
* in: txid
|
||||
* out: pair<notarisationTxHash,merkleBranch>
|
||||
* out: pair<notarizationTxHash,merkleBranch>
|
||||
*/
|
||||
|
||||
TxProof GetAssetchainProof(uint256 hash,CTransaction burnTx)
|
||||
@@ -443,15 +437,15 @@ TxProof GetAssetchainProof(uint256 hash,CTransaction burnTx)
|
||||
|
||||
blockIndex = komodo_getblockindex(blockHash);
|
||||
int h = blockIndex->GetHeight();
|
||||
// The assumption here is that the first notarisation for a height GTE than
|
||||
// The assumption here is that the first notarization for a height GTE than
|
||||
// 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 notarizations this may fail.
|
||||
auto isTarget = [&](Notarization ¬a) {
|
||||
if (!IsSameAssetChain(nota)) return false;
|
||||
return nota.second.height >= blockIndex->GetHeight();
|
||||
};
|
||||
if (!ScanNotarizationsFromHeight(blockIndex->GetHeight(), isTarget, nota))
|
||||
throw std::runtime_error("backnotarisation not yet confirmed");
|
||||
throw std::runtime_error("backnotarization not yet confirmed");
|
||||
|
||||
// index of block in MoM leaves
|
||||
nIndex = nota.second.height - blockIndex->GetHeight();
|
||||
|
||||
@@ -31,8 +31,8 @@ TEST(noteencryption, NotePlaintext)
|
||||
auto ivk = fvk.in_viewing_key();
|
||||
SaplingPaymentAddress addr = *ivk.address({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
|
||||
std::array<unsigned char, ZC_MEMO_SIZE> memo;
|
||||
for (size_t i = 0; i < ZC_MEMO_SIZE; i++) {
|
||||
std::array<unsigned char, HUSH_MEMO_SIZE> memo;
|
||||
for (size_t i = 0; i < HUSH_MEMO_SIZE; i++) {
|
||||
// Fill the message with dummy data
|
||||
memo[i] = (unsigned char) i;
|
||||
}
|
||||
|
||||
@@ -359,7 +359,7 @@ void hush_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotarie
|
||||
struct hush_state *sp; char fname[512],symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; int32_t retval,ht,func; uint8_t num,pubkeys[64][33];
|
||||
if ( didinit == 0 )
|
||||
{
|
||||
portable_mutex_init(&KOMODO_KV_mutex);
|
||||
portable_mutex_init(&HUSH_KV_mutex);
|
||||
portable_mutex_init(&KOMODO_CC_mutex);
|
||||
didinit = 1;
|
||||
}
|
||||
|
||||
@@ -20,14 +20,14 @@
|
||||
#include "arith_uint256.h"
|
||||
#include "chain.h"
|
||||
#include "hush_nk.h"
|
||||
#define KOMODO_EARLYTXID_HEIGHT 100
|
||||
#define HUSH_EARLYTXID_HEIGHT 100
|
||||
#define ASSETCHAINS_MINHEIGHT 128
|
||||
#define ASSETCHAINS_MAX_ERAS 7
|
||||
#define KOMODO_ELECTION_GAP 2000
|
||||
#define ROUNDROBIN_DELAY 61
|
||||
#define HUSH_SMART_CHAIN_MAXLEN 65
|
||||
#define KOMODO_LIMITED_NETWORKSIZE 4
|
||||
#define IGUANA_MAXSCRIPTSIZE 10001
|
||||
#define DRAGON_MAXSCRIPTSIZE 10001
|
||||
#define KOMODO_MAXMEMPOOLTIME 3600 // affects consensus
|
||||
#define CRYPTO555_PUBSECPSTR "038a1bd41a08f38edda51042988022933c5775dfce81f7bae0b32a9179650352ac"
|
||||
#define CRYPTO555_HUSHADDR "RFetqf8WUfWnwNeXdknkm8ojk7EXnYFzrv"
|
||||
@@ -513,7 +513,7 @@ extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY,ASSETCHAINS_SCRIPTP
|
||||
extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_MARMARA;
|
||||
extern std::vector<std::string> ASSETCHAINS_PRICES,ASSETCHAINS_STOCKS;
|
||||
|
||||
extern uint256 KOMODO_EARLYTXID;
|
||||
extern uint256 HUSH_EARLYTXID;
|
||||
|
||||
extern int32_t HUSH_CONNECTING,KOMODO_CCACTIVATE,KOMODO_DEALERNODE;
|
||||
extern uint32_t ASSETCHAINS_CC;
|
||||
@@ -529,7 +529,6 @@ extern char NOTARYADDRS[64][64];
|
||||
extern char NOTARY_ADDRESSES[NUM_HUSH_SEASONS][64][64];
|
||||
extern int32_t HUSH_TESTNODE, HUSH_SNAPSHOT_INTERVAL;
|
||||
extern int32_t ASSETCHAINS_EARLYTXIDCONTRACT;
|
||||
extern int32_t ASSETCHAINS_STAKED_SPLIT_PERCENTAGE;
|
||||
int tx_height( const uint256 &hash );
|
||||
extern std::vector<std::string> vWhiteListAddress;
|
||||
extern std::map <std::int8_t, int32_t> mapHeightEvalActivate;
|
||||
@@ -537,9 +536,9 @@ void komodo_netevent(std::vector<uint8_t> payload);
|
||||
int32_t getacseason(uint32_t timestamp);
|
||||
int32_t gethushseason(int32_t height);
|
||||
|
||||
#define IGUANA_MAXSCRIPTSIZE 10001
|
||||
#define KOMODO_KVDURATION 1440
|
||||
#define KOMODO_KVBINARY 2
|
||||
#define DRAGON_MAXSCRIPTSIZE 10001
|
||||
#define HUSH_KVDURATION 1440
|
||||
#define HUSH_KVBINARY 2
|
||||
#define PRICES_SMOOTHWIDTH 1
|
||||
#define PRICES_MAXDATAPOINTS 8
|
||||
uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume);
|
||||
@@ -547,7 +546,7 @@ int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *bas
|
||||
int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);
|
||||
char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len);
|
||||
int32_t komodo_minerids(uint8_t *minerids,int32_t height,int32_t width);
|
||||
int32_t komodo_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[IGUANA_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen);
|
||||
int32_t komodo_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[DRAGON_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen);
|
||||
|
||||
uint32_t komodo_blocktime(uint256 hash);
|
||||
int32_t hush_longestchain();
|
||||
|
||||
@@ -45,7 +45,7 @@ struct hush_state KOMODO_STATES[34];
|
||||
#define _COINBASE_MATURITY 100
|
||||
int COINBASE_MATURITY = _COINBASE_MATURITY;//100;
|
||||
unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+10;
|
||||
uint256 KOMODO_EARLYTXID;
|
||||
uint256 HUSH_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,HUSH_REWIND,HUSH_CONNECTING = -1,KOMODO_DEALERNODE,HUSH_EXTRASATOSHI,ASSETCHAINS_FOUNDERS,ASSETCHAINS_CBMATURITY,HUSH_NSPV;
|
||||
int32_t HUSH_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1;
|
||||
@@ -101,11 +101,11 @@ uint64_t PENDING_KOMODO_TX;
|
||||
extern int32_t HUSH_LOADINGBLOCKS;
|
||||
unsigned int MAX_BLOCK_SIGOPS = 20000;
|
||||
int32_t HUSH_TESTNODE, HUSH_SNAPSHOT_INTERVAL;
|
||||
CScript KOMODO_EARLYTXID_SCRIPTPUB;
|
||||
CScript HUSH_EARLYTXID_SCRIPTPUB;
|
||||
int32_t ASSETCHAINS_EARLYTXIDCONTRACT;
|
||||
std::map <std::int8_t, int32_t> mapHeightEvalActivate;
|
||||
struct komodo_kv *KOMODO_KV;
|
||||
pthread_mutex_t KOMODO_KV_mutex,KOMODO_CC_mutex;
|
||||
struct komodo_kv *HUSH_KV;
|
||||
pthread_mutex_t HUSH_KV_mutex,KOMODO_CC_mutex;
|
||||
|
||||
#define MAX_CURRENCIES 32
|
||||
char CURRENCIES[][8] = { "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", // major currencies
|
||||
|
||||
@@ -45,9 +45,9 @@
|
||||
#define KOMODO_OPRETURN_WITHDRAW 'W' // assetchain
|
||||
#define KOMODO_OPRETURN_REDEEMED 'X'
|
||||
|
||||
#define KOMODO_KVPROTECTED 1
|
||||
#define KOMODO_KVBINARY 2
|
||||
#define KOMODO_KVDURATION 1440
|
||||
#define HUSH_KVPROTECTED 1
|
||||
#define HUSH_KVBINARY 2
|
||||
#define HUSH_KVDURATION 1440
|
||||
#define HUSH_SMART_CHAIN_MAXLEN 65
|
||||
|
||||
#ifndef _BITS256
|
||||
|
||||
@@ -1860,7 +1860,7 @@ void hush_args(char *argv0)
|
||||
{
|
||||
printf("HUSH_REWIND %d\n",HUSH_REWIND);
|
||||
}
|
||||
KOMODO_EARLYTXID = Parseuint256(GetArg("-earlytxid","0").c_str());
|
||||
HUSH_EARLYTXID = Parseuint256(GetArg("-earlytxid","0").c_str());
|
||||
ASSETCHAINS_EARLYTXIDCONTRACT = GetArg("-ac_earlytxidcontract",0);
|
||||
if ( name.c_str()[0] != 0 )
|
||||
{
|
||||
|
||||
@@ -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 (c) 2009 Dave Gamble
|
||||
|
||||
@@ -19,7 +22,6 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
||||
* *
|
||||
@@ -34,10 +36,8 @@
|
||||
* Removal or modification of this copyright notice is prohibited. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef komodo_cJSON__h
|
||||
#define komodo_cJSON__h
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
@@ -45,9 +45,7 @@
|
||||
#include <ctype.h>
|
||||
#include <float.h>
|
||||
#include <memory.h>
|
||||
|
||||
#include "cJSON.h"
|
||||
|
||||
//#include "../crypto555/OS_portable.h"
|
||||
|
||||
#define MAX_JSON_FIELD 4096 // on the big side
|
||||
|
||||
@@ -42,7 +42,7 @@ int32_t komodo_kvnumdays(uint32_t flags)
|
||||
|
||||
int32_t komodo_kvduration(uint32_t flags)
|
||||
{
|
||||
return(komodo_kvnumdays(flags) * KOMODO_KVDURATION);
|
||||
return(komodo_kvnumdays(flags) * HUSH_KVDURATION);
|
||||
}
|
||||
|
||||
uint64_t komodo_kvfee(uint32_t flags,int32_t opretlen,int32_t keylen)
|
||||
@@ -56,21 +56,21 @@ uint64_t komodo_kvfee(uint32_t flags,int32_t opretlen,int32_t keylen)
|
||||
return(fee);
|
||||
}
|
||||
|
||||
int32_t komodo_kvsearch(uint256 *pubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[IGUANA_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen)
|
||||
int32_t komodo_kvsearch(uint256 *pubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[DRAGON_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen)
|
||||
{
|
||||
struct komodo_kv *ptr; int32_t duration,retval = -1;
|
||||
*heightp = -1;
|
||||
*flagsp = 0;
|
||||
memset(pubkeyp,0,sizeof(*pubkeyp));
|
||||
portable_mutex_lock(&KOMODO_KV_mutex);
|
||||
HASH_FIND(hh,KOMODO_KV,key,keylen,ptr);
|
||||
portable_mutex_lock(&HUSH_KV_mutex);
|
||||
HASH_FIND(hh,HUSH_KV,key,keylen,ptr);
|
||||
if ( ptr != 0 )
|
||||
{
|
||||
duration = komodo_kvduration(ptr->flags);
|
||||
//fprintf(stderr,"duration.%d flags.%d current.%d ht.%d keylen.%d valuesize.%d\n",duration,ptr->flags,current_height,ptr->height,ptr->keylen,ptr->valuesize);
|
||||
if ( current_height > (ptr->height + duration) )
|
||||
{
|
||||
HASH_DELETE(hh,KOMODO_KV,ptr);
|
||||
HASH_DELETE(hh,HUSH_KV,ptr);
|
||||
if ( ptr->value != 0 )
|
||||
free(ptr->value);
|
||||
if ( ptr->key != 0 )
|
||||
@@ -92,7 +92,7 @@ int32_t komodo_kvsearch(uint256 *pubkeyp,int32_t current_height,uint32_t *flagsp
|
||||
memcpy(value,ptr->value,retval);
|
||||
}
|
||||
} //else fprintf(stderr,"couldnt find (%s)\n",(char *)key);
|
||||
portable_mutex_unlock(&KOMODO_KV_mutex);
|
||||
portable_mutex_unlock(&HUSH_KV_mutex);
|
||||
if ( retval < 0 )
|
||||
{
|
||||
// search rawmempool
|
||||
@@ -103,7 +103,7 @@ int32_t komodo_kvsearch(uint256 *pubkeyp,int32_t current_height,uint32_t *flagsp
|
||||
void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value)
|
||||
{
|
||||
static uint256 zeroes;
|
||||
uint32_t flags; uint256 pubkey,refpubkey,sig; int32_t i,refvaluesize,hassig,coresize,haspubkey,height,kvheight; uint16_t keylen,valuesize,newflag = 0; uint8_t *key,*valueptr,keyvalue[IGUANA_MAXSCRIPTSIZE*8]; struct komodo_kv *ptr; char *transferpubstr,*tstr; uint64_t fee;
|
||||
uint32_t flags; uint256 pubkey,refpubkey,sig; int32_t i,refvaluesize,hassig,coresize,haspubkey,height,kvheight; uint16_t keylen,valuesize,newflag = 0; uint8_t *key,*valueptr,keyvalue[DRAGON_MAXSCRIPTSIZE*8]; struct komodo_kv *ptr; char *transferpubstr,*tstr; uint64_t fee;
|
||||
if ( SMART_CHAIN_SYMBOL[0] == 0 ) // disable KV for KMD
|
||||
return;
|
||||
dragon_rwnum(0,&opretbuf[1],sizeof(keylen),&keylen);
|
||||
@@ -150,12 +150,12 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value)
|
||||
}
|
||||
}
|
||||
}
|
||||
portable_mutex_lock(&KOMODO_KV_mutex);
|
||||
HASH_FIND(hh,KOMODO_KV,key,keylen,ptr);
|
||||
portable_mutex_lock(&HUSH_KV_mutex);
|
||||
HASH_FIND(hh,HUSH_KV,key,keylen,ptr);
|
||||
if ( ptr != 0 )
|
||||
{
|
||||
//fprintf(stderr,"(%s) already there\n",(char *)key);
|
||||
//if ( (ptr->flags & KOMODO_KVPROTECTED) != 0 )
|
||||
//if ( (ptr->flags & HUSH_KVPROTECTED) != 0 )
|
||||
{
|
||||
tstr = (char *)"transfer:";
|
||||
transferpubstr = (char *)&valueptr[strlen(tstr)];
|
||||
@@ -174,10 +174,10 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value)
|
||||
ptr->keylen = keylen;
|
||||
memcpy(ptr->key,key,keylen);
|
||||
newflag = 1;
|
||||
HASH_ADD_KEYPTR(hh,KOMODO_KV,ptr->key,ptr->keylen,ptr);
|
||||
HASH_ADD_KEYPTR(hh,HUSH_KV,ptr->key,ptr->keylen,ptr);
|
||||
//fprintf(stderr,"KV add.(%s) (%s)\n",ptr->key,valueptr);
|
||||
}
|
||||
if ( newflag != 0 || (ptr->flags & KOMODO_KVPROTECTED) == 0 )
|
||||
if ( newflag != 0 || (ptr->flags & HUSH_KVPROTECTED) == 0 )
|
||||
{
|
||||
if ( ptr->value != 0 )
|
||||
free(ptr->value), ptr->value = 0;
|
||||
@@ -186,7 +186,7 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value)
|
||||
ptr->value = (uint8_t *)calloc(1,valuesize);
|
||||
memcpy(ptr->value,valueptr,valuesize);
|
||||
}
|
||||
} else fprintf(stderr,"newflag.%d zero or protected %d\n",newflag,(ptr->flags & KOMODO_KVPROTECTED));
|
||||
} else fprintf(stderr,"newflag.%d zero or protected %d\n",newflag,(ptr->flags & HUSH_KVPROTECTED));
|
||||
/*for (i=0; i<32; i++)
|
||||
printf("%02x",((uint8_t *)&ptr->pubkey)[i]);
|
||||
printf(" <- ");
|
||||
@@ -196,7 +196,7 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value)
|
||||
memcpy(&ptr->pubkey,&pubkey,sizeof(ptr->pubkey));
|
||||
ptr->height = height;
|
||||
ptr->flags = flags; // jl777 used to or in KVPROTECTED
|
||||
portable_mutex_unlock(&KOMODO_KV_mutex);
|
||||
portable_mutex_unlock(&HUSH_KV_mutex);
|
||||
} else fprintf(stderr,"KV update size mismatch %d vs %d\n",opretlen,coresize);
|
||||
} else fprintf(stderr,"not enough fee\n");
|
||||
}
|
||||
|
||||
208
src/main.cpp
208
src/main.cpp
@@ -837,7 +837,7 @@ unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans) EXCLUSIVE_LOCKS_REQUIRE
|
||||
bool IsStandardTx(const CTransaction& tx, string& reason, const int nHeight)
|
||||
{
|
||||
bool overwinterActive = NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER);
|
||||
bool saplingActive = NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING);
|
||||
bool saplingActive = NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING);
|
||||
|
||||
if (saplingActive) {
|
||||
// Sapling standard rules apply
|
||||
@@ -891,7 +891,7 @@ bool IsStandardTx(const CTransaction& tx, string& reason, const int nHeight)
|
||||
|
||||
if (whichType == TX_NULL_DATA)
|
||||
{
|
||||
if ( txout.scriptPubKey.size() > IGUANA_MAXSCRIPTSIZE )
|
||||
if ( txout.scriptPubKey.size() > DRAGON_MAXSCRIPTSIZE )
|
||||
{
|
||||
reason = "opreturn too big";
|
||||
return(false);
|
||||
@@ -1098,17 +1098,10 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& in
|
||||
return nSigOps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that a coinbase transaction is structured according to the consensus rules of the
|
||||
* chain
|
||||
*/
|
||||
// Ensure that a coinbase transaction is structured according to the consensus rules of the chain
|
||||
bool ContextualCheckCoinbaseTransaction(int32_t slowflag,const CBlock *block,CBlockIndex * const previndex,const CTransaction& tx, const int nHeight,int32_t validateprices)
|
||||
{
|
||||
if ( ASSETCHAINS_MARMARA != 0 && nHeight > 0 && (nHeight & 1) == 0 )
|
||||
{
|
||||
|
||||
}
|
||||
else if ( slowflag != 0 && ASSETCHAINS_CBOPRET != 0 && validateprices != 0 && nHeight > 0 && tx.vout.size() > 0 )
|
||||
if ( slowflag != 0 && ASSETCHAINS_CBOPRET != 0 && validateprices != 0 && nHeight > 0 && tx.vout.size() > 0 )
|
||||
{
|
||||
if ( komodo_opretvalidate(block,previndex,nHeight,tx.vout[tx.vout.size()-1].scriptPubKey) < 0 )
|
||||
return(false);
|
||||
@@ -1133,8 +1126,8 @@ bool ContextualCheckTransaction(int32_t slowflag,const CBlock *block, CBlockInde
|
||||
bool (*isInitBlockDownload)(),int32_t validateprices)
|
||||
{
|
||||
bool overwinterActive = NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER);
|
||||
bool saplingActive = NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING);
|
||||
bool isSprout = !overwinterActive;
|
||||
bool saplingActive = NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING);
|
||||
bool isSprout = !overwinterActive;
|
||||
|
||||
// If Sprout rules apply, reject transactions which are intended for Overwinter and beyond
|
||||
if (isSprout && tx.fOverwintered) {
|
||||
@@ -1361,21 +1354,19 @@ bool CheckTransaction(uint32_t tiptime,const CTransaction& tx, CValidationState
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t komodo_isnotaryvout(char *coinaddr,uint32_t tiptime) // from ac_private chains only
|
||||
{
|
||||
int32_t hush_isnotaryvout(char *coinaddr,uint32_t tiptime) {
|
||||
int32_t season = getacseason(tiptime);
|
||||
if ( NOTARY_ADDRESSES[season-1][0][0] == 0 )
|
||||
{
|
||||
if ( NOTARY_ADDRESSES[season-1][0][0] == 0 ) {
|
||||
uint8_t pubkeys[64][33];
|
||||
hush_notaries(pubkeys,0,tiptime);
|
||||
}
|
||||
if ( strcmp(coinaddr,CRYPTO555_HUSHADDR) == 0 )
|
||||
return(1);
|
||||
for (int32_t i = 0; i < NUM_HUSH_NOTARIES; i++)
|
||||
{
|
||||
if ( strcmp(coinaddr,NOTARY_ADDRESSES[season-1][i]) == 0 )
|
||||
{
|
||||
//fprintf(stderr, "coinaddr.%s notaryaddress[%i].%s\n",coinaddr,i,NOTARY_ADDRESSES[season-1][i]);
|
||||
for (int32_t i = 0; i < NUM_HUSH_NOTARIES; i++) {
|
||||
if ( strcmp(coinaddr,NOTARY_ADDRESSES[season-1][i]) == 0 ) {
|
||||
if(fDebug) {
|
||||
fprintf(stderr, "%s: coinaddr.%s notaryaddress[%i].%s\n",__func__, coinaddr,i,NOTARY_ADDRESSES[season-1][i]);
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
@@ -1471,14 +1462,14 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio
|
||||
//
|
||||
char destaddr[65];
|
||||
Getscriptaddress(destaddr,txout.scriptPubKey);
|
||||
if ( komodo_isnotaryvout(destaddr,tiptime) == 0 )
|
||||
if ( hush_isnotaryvout(destaddr,tiptime) == 0 )
|
||||
{
|
||||
invalid_private_taddr = 1;
|
||||
//return state.DoS(100, error("CheckTransaction(): this is a private chain, no public allowed"),REJECT_INVALID, "bad-txns-acprivacy-chain");
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( txout.scriptPubKey.size() > IGUANA_MAXSCRIPTSIZE )
|
||||
if ( txout.scriptPubKey.size() > DRAGON_MAXSCRIPTSIZE )
|
||||
return state.DoS(100, error("CheckTransaction(): txout.scriptPubKey.size() too big"),REJECT_INVALID, "bad-txns-opret-too-big");
|
||||
nValueOut += txout.nValue;
|
||||
if (!MoneyRange(nValueOut))
|
||||
@@ -2886,14 +2877,13 @@ static bool ApplyTxInUndo(const CTxInUndo& undo, CCoinsViewCache& view, const CO
|
||||
|
||||
void ConnectNotarizations(const CBlock &block, int height)
|
||||
{
|
||||
NotarizationsInBlock notarisations = ScanBlockNotarizations(block, height);
|
||||
if (notarisations.size() > 0) {
|
||||
NotarizationsInBlock notarizations = ScanBlockNotarizations(block, height);
|
||||
if (notarizations.size() > 0) {
|
||||
CDBBatch batch = CDBBatch(*pnotarizations);
|
||||
batch.Write(block.GetHash(), notarisations);
|
||||
WriteBackNotarizations(notarisations, batch);
|
||||
batch.Write(block.GetHash(), notarizations);
|
||||
WriteBackNotarizations(notarizations, batch);
|
||||
pnotarizations->WriteBatch(batch, true);
|
||||
LogPrintf("ConnectBlock: wrote %i block notarizations in block: %s\n",
|
||||
notarisations.size(), block.GetHash().GetHex().data());
|
||||
LogPrintf("ConnectBlock: wrote %i block notarizations in block: %s\n", notarizations.size(), block.GetHash().GetHex().data());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2905,8 +2895,7 @@ void DisconnectNotarizations(const CBlock &block)
|
||||
batch.Erase(block.GetHash());
|
||||
EraseBackNotarizations(nibs, batch);
|
||||
pnotarizations->WriteBatch(batch, true);
|
||||
LogPrintf("DisconnectTip: deleted %i block notarizations in block: %s\n",
|
||||
nibs.size(), block.GetHash().GetHex().data());
|
||||
LogPrintf("DisconnectTip: deleted %i block notarizations in block: %s\n", nibs.size(), block.GetHash().GetHex().data());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3268,22 +3257,21 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
||||
// Do this here before the block is moved to the main block files.
|
||||
if ( ASSETCHAINS_NOTARY_PAY[0] != 0 && pindex->GetHeight() > 10 )
|
||||
{
|
||||
// do a full block scan to get notarisation position and to enforce a valid notarization is in position 1.
|
||||
// if notarisation in the block, must be position 1 and the coinbase must pay notaries.
|
||||
int32_t notarisationTx = hush_connectblock(true,pindex,*(CBlock *)&block);
|
||||
// do a full block scan to get ntz position and to enforce a valid notarization is in position 1.
|
||||
// if ntz in the block, must be position 1 and the coinbase must pay notaries.
|
||||
int32_t notarizationTx = hush_connectblock(true,pindex,*(CBlock *)&block);
|
||||
// -1 means that the valid notarization isnt in position 1 or there are too many notarizations in this block.
|
||||
if ( notarisationTx == -1 )
|
||||
if ( notarizationTx == -1 )
|
||||
return state.DoS(100, error("ConnectBlock(): Notarization is not in TX position 1 or block contains more than 1 notarization! Invalid Block!"),
|
||||
REJECT_INVALID, "bad-notarization-position");
|
||||
// 1 means this block contains a valid notarisation and its in position 1.
|
||||
// 1 means this block contains a valid notarization and its in position 1.
|
||||
// its no longer possible for any attempted notarization to be in a block with a valid one!
|
||||
// if notaries create a notarisation even if its not in this chain it will need to be mined inside its own block!
|
||||
if ( notarisationTx == 1 )
|
||||
// if notaries create a notarization even if its not in this chain it will need to be mined inside its own block!
|
||||
if ( notarizationTx == 1 )
|
||||
{
|
||||
// Check if the notaries have been paid.
|
||||
if ( block.vtx[0].vout.size() == 1 )
|
||||
return state.DoS(100, error("ConnectBlock(): Notaries have not been paid!"),
|
||||
REJECT_INVALID, "bad-cb-amount");
|
||||
return state.DoS(100, error("ConnectBlock(): Notaries have not been paid!"), REJECT_INVALID, "bad-cb-amount");
|
||||
// calculate the notaries compensation and validate the amounts and pubkeys are correct.
|
||||
notarypaycheque = komodo_checknotarypay((CBlock *)&block,(int32_t)pindex->GetHeight());
|
||||
//fprintf(stderr, "notarypaycheque.%lu\n", notarypaycheque);
|
||||
@@ -3294,6 +3282,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
||||
REJECT_INVALID, "bad-cb-amount");
|
||||
}
|
||||
}
|
||||
|
||||
// Move the block to the main block file, we need this to create the TxIndex in the following loop.
|
||||
if ( (pindex->nStatus & BLOCK_IN_TMPFILE) != 0 )
|
||||
{
|
||||
@@ -3626,7 +3615,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
||||
setDirtyBlockIndex.insert(pindex);
|
||||
}
|
||||
|
||||
ConnectNotarizations(block, pindex->GetHeight()); // MoMoM notarisation DB.
|
||||
ConnectNotarizations(block, pindex->GetHeight()); // MoMoM notarization DB.
|
||||
|
||||
if (fTxIndex)
|
||||
if (!pblocktree->WriteTxIndex(vPos))
|
||||
@@ -7161,12 +7150,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
}
|
||||
}
|
||||
|
||||
// Relay alerts
|
||||
// Do Not Relay alerts
|
||||
/*
|
||||
{
|
||||
LOCK(cs_mapAlerts);
|
||||
BOOST_FOREACH(PAIRTYPE(const uint256, CAlert)& item, mapAlerts)
|
||||
item.second.RelayTo(pfrom);
|
||||
}
|
||||
*/
|
||||
|
||||
pfrom->fSuccessfullyConnected = true;
|
||||
|
||||
@@ -7183,17 +7174,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
//pfrom->nTimeOffset = nTimeOffset;
|
||||
//AddTimeData(pfrom->addr, nTimeOffset);
|
||||
pfrom->nTimeOffset = timeWarning.AddTimeData(pfrom->addr, nTime, GetTime());
|
||||
}
|
||||
|
||||
|
||||
else if (pfrom->nVersion == 0)
|
||||
{
|
||||
} else if (pfrom->nVersion == 0) {
|
||||
// Must have a version message before anything else
|
||||
Misbehaving(pfrom->GetId(), 1);
|
||||
return false;
|
||||
}
|
||||
else if ( strCommand == "events" )
|
||||
{
|
||||
} else if ( strCommand == "events" ) {
|
||||
if ( ASSETCHAINS_CCLIB != "gamescc" )
|
||||
{
|
||||
Misbehaving(pfrom->GetId(), 1);
|
||||
@@ -7203,9 +7188,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
vRecv >> payload;
|
||||
komodo_netevent(payload);
|
||||
return(true);
|
||||
}
|
||||
else if (strCommand == "verack")
|
||||
{
|
||||
} else if (strCommand == "verack") {
|
||||
pfrom->SetRecvVersion(min(pfrom->nVersion, PROTOCOL_VERSION));
|
||||
|
||||
if ( HUSH_NSPV_SUPERLITE )
|
||||
@@ -7224,26 +7207,18 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Disconnect existing peer connection when:
|
||||
// 1. The version message has been received
|
||||
// 2. Peer version is below the minimum version for the current epoch
|
||||
else if (pfrom->nVersion < chainparams.GetConsensus().vUpgrades[
|
||||
CurrentEpoch(GetHeight(), chainparams.GetConsensus())].nProtocolVersion)
|
||||
{
|
||||
LogPrintf("peer=%d using obsolete version %i vs %d; disconnecting\n", pfrom->id, pfrom->nVersion,(int32_t)chainparams.GetConsensus().vUpgrades[
|
||||
CurrentEpoch(GetHeight(), chainparams.GetConsensus())].nProtocolVersion);
|
||||
else if (pfrom->nVersion < chainparams.GetConsensus().vUpgrades[CurrentEpoch(GetHeight(), chainparams.GetConsensus())].nProtocolVersion) {
|
||||
LogPrintf("peer=%d using obsolete version %i vs %d; disconnecting\n", pfrom->id, pfrom->nVersion,(int32_t)chainparams.GetConsensus().vUpgrades[CurrentEpoch(GetHeight(), chainparams.GetConsensus())].nProtocolVersion);
|
||||
pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE,
|
||||
strprintf("Version must be %d or greater",
|
||||
chainparams.GetConsensus().vUpgrades[
|
||||
CurrentEpoch(GetHeight(), chainparams.GetConsensus())].nProtocolVersion));
|
||||
pfrom->fDisconnect = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
else if (strCommand == "addr")
|
||||
{
|
||||
} else if (strCommand == "addr") {
|
||||
vector<CAddress> vAddr;
|
||||
vRecv >> vAddr;
|
||||
|
||||
@@ -7490,11 +7465,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
|
||||
if (!vToFetch.empty())
|
||||
pfrom->PushMessage("getdata", vToFetch);
|
||||
}
|
||||
|
||||
|
||||
else if (strCommand == "getdata")
|
||||
{
|
||||
} else if (strCommand == "getdata") {
|
||||
vector<CInv> vInv;
|
||||
vRecv >> vInv;
|
||||
if (vInv.size() > MAX_INV_SZ)
|
||||
@@ -7511,11 +7482,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
|
||||
pfrom->vRecvGetData.insert(pfrom->vRecvGetData.end(), vInv.begin(), vInv.end());
|
||||
ProcessGetData(pfrom);
|
||||
}
|
||||
|
||||
|
||||
else if (strCommand == "getblocks")
|
||||
{
|
||||
} else if (strCommand == "getblocks") {
|
||||
CBlockLocator locator;
|
||||
uint256 hashStop;
|
||||
vRecv >> locator >> hashStop;
|
||||
@@ -7547,11 +7514,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
else if (strCommand == "getheaders")
|
||||
{
|
||||
} else if (strCommand == "getheaders") {
|
||||
CBlockLocator locator;
|
||||
uint256 hashStop;
|
||||
vRecv >> locator >> hashStop;
|
||||
@@ -7574,9 +7537,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
return true;
|
||||
}
|
||||
pindex = (*mi).second;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Find the last block the caller has in the main chain
|
||||
pindex = FindForkInGlobalIndex(chainActive, locator);
|
||||
if (pindex)
|
||||
@@ -7607,11 +7568,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
if ( counter++ < 3 )
|
||||
fprintf(stderr,"you can ignore redundant getheaders from peer.%d %d prev.%d\n",(int32_t)pfrom->id,(int32_t)(pindex ? pindex->GetHeight() : -1),pfrom->lasthdrsreq);
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
else if (strCommand == "tx")
|
||||
{
|
||||
} else if (strCommand == "tx") {
|
||||
if (IsInitialBlockDownload())
|
||||
return true;
|
||||
|
||||
@@ -7696,7 +7653,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
BOOST_FOREACH(uint256 hash, vEraseQueue)
|
||||
EraseOrphanTx(hash);
|
||||
}
|
||||
// TODO: currently, prohibit joinsplits and shielded spends/outputs from entering mapOrphans
|
||||
// TODO: currently, prohibit shielded spends/outputs from entering mapOrphans
|
||||
else if (fMissingInputs &&
|
||||
tx.vjoinsplit.empty() &&
|
||||
tx.vShieldedSpend.empty() &&
|
||||
@@ -7707,7 +7664,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
|
||||
// DoS prevention: do not allow mapOrphanTransactions to grow unbounded
|
||||
unsigned int nMaxOrphanTx = (unsigned int)std::max((int64_t)0, GetArg("-maxorphantx", DEFAULT_MAX_ORPHAN_TRANSACTIONS));
|
||||
unsigned int nEvicted = LimitOrphanTxSize(nMaxOrphanTx);
|
||||
unsigned int nEvicted = LimitOrphanTxSize(nMaxOrphanTx);
|
||||
if (nEvicted > 0)
|
||||
LogPrint("mempool", "mapOrphan overflow, removed %u tx\n", nEvicted);
|
||||
} else {
|
||||
@@ -7744,9 +7701,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
if (nDoS > 0)
|
||||
Misbehaving(pfrom->GetId(), nDoS);
|
||||
}
|
||||
}
|
||||
|
||||
else if (strCommand == "headers" && !fImporting && !fReindex) // Ignore headers received while importing
|
||||
} else if (strCommand == "headers" && !fImporting && !fReindex) // Ignore headers received while importing
|
||||
{
|
||||
std::vector<CBlockHeader> headers;
|
||||
|
||||
@@ -7809,9 +7764,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
}
|
||||
|
||||
CheckBlockIndex();
|
||||
}
|
||||
|
||||
else if (strCommand == "block" && !fImporting && !fReindex) // Ignore blocks received while importing
|
||||
} else if (strCommand == "block" && !fImporting && !fReindex) // Ignore blocks received while importing
|
||||
{
|
||||
CBlock block;
|
||||
vRecv >> block;
|
||||
@@ -7838,11 +7791,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
else if (strCommand == "mempool")
|
||||
{
|
||||
} else if (strCommand == "mempool") {
|
||||
LOCK2(cs_main, pfrom->cs_filter);
|
||||
|
||||
std::vector<uint256> vtxid;
|
||||
@@ -7864,17 +7813,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
}
|
||||
if (vInv.size() > 0)
|
||||
pfrom->PushMessage("inv", vInv);
|
||||
}
|
||||
else if (fAlerts && strCommand == "alert")
|
||||
{
|
||||
} else if (fAlerts && strCommand == "alert") {
|
||||
//TODO: probably completely ignore this
|
||||
CAlert alert;
|
||||
vRecv >> alert;
|
||||
|
||||
uint256 alertHash = alert.GetHash();
|
||||
if (pfrom->setKnown.count(alertHash) == 0)
|
||||
{
|
||||
if (alert.ProcessAlert(Params().AlertKey()))
|
||||
{
|
||||
if (pfrom->setKnown.count(alertHash) == 0) {
|
||||
if (alert.ProcessAlert(Params().AlertKey())) {
|
||||
// Relay
|
||||
pfrom->setKnown.insert(alertHash);
|
||||
{
|
||||
@@ -7882,8 +7828,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
BOOST_FOREACH(CNode* pnode, vNodes)
|
||||
alert.RelayTo(pnode);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Small DoS penalty so peers that send us lots of
|
||||
// duplicate/expired/invalid-signature/whatever alerts
|
||||
// eventually get banned.
|
||||
@@ -7893,12 +7838,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
Misbehaving(pfrom->GetId(), 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (!(nLocalServices & NODE_BLOOM) &&
|
||||
} else if (!(nLocalServices & NODE_BLOOM) &&
|
||||
(strCommand == "filterload" ||
|
||||
strCommand == "filteradd"))
|
||||
{
|
||||
strCommand == "filteradd")) {
|
||||
if (pfrom->nVersion >= NO_BLOOM_VERSION) {
|
||||
Misbehaving(pfrom->GetId(), 100);
|
||||
return false;
|
||||
@@ -7906,11 +7848,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
pfrom->fDisconnect = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
else if (strCommand == "filterload")
|
||||
{
|
||||
} else if (strCommand == "filterload") {
|
||||
CBloomFilter filter;
|
||||
vRecv >> filter;
|
||||
|
||||
@@ -7925,11 +7863,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
pfrom->pfilter->UpdateEmptyFull();
|
||||
}
|
||||
pfrom->fRelayTxes = true;
|
||||
}
|
||||
|
||||
|
||||
else if (strCommand == "filteradd")
|
||||
{
|
||||
} else if (strCommand == "filteradd") {
|
||||
vector<unsigned char> vData;
|
||||
vRecv >> vData;
|
||||
|
||||
@@ -7945,22 +7879,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
else
|
||||
Misbehaving(pfrom->GetId(), 100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
else if (strCommand == "filterclear")
|
||||
{
|
||||
} else if (strCommand == "filterclear") {
|
||||
LOCK(pfrom->cs_filter);
|
||||
if (nLocalServices & NODE_BLOOM) {
|
||||
delete pfrom->pfilter;
|
||||
pfrom->pfilter = new CBloomFilter();
|
||||
}
|
||||
pfrom->fRelayTxes = true;
|
||||
}
|
||||
|
||||
|
||||
else if (strCommand == "reject")
|
||||
{
|
||||
} else if (strCommand == "reject") {
|
||||
if (fDebug) {
|
||||
try {
|
||||
string strMsg; unsigned char ccode; string strReason;
|
||||
@@ -7981,19 +7907,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
LogPrint("net", "Unparseable reject message received\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (strCommand == "notfound") {
|
||||
} else if (strCommand == "notfound") {
|
||||
// We do not care about the NOTFOUND message, but logging an Unknown Command
|
||||
// message would be undesirable as we transmit it ourselves.
|
||||
}
|
||||
|
||||
else {
|
||||
} else {
|
||||
// Ignore unknown commands for extensibility
|
||||
LogPrint("net", "Unknown command \"%s\" from peer=%d\n", SanitizeString(strCommand), pfrom->id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -8117,7 +8038,6 @@ bool ProcessMessages(CNode* pfrom)
|
||||
return fOk;
|
||||
}
|
||||
|
||||
|
||||
bool SendMessages(CNode* pto, bool fSendTrickle)
|
||||
{
|
||||
const Consensus::Params& consensusParams = Params().GetConsensus();
|
||||
@@ -8375,8 +8295,6 @@ std::string CBlockFileInfo::ToString() const {
|
||||
return strprintf("CBlockFileInfo(blocks=%u, size=%u, heights=%u...%u, time=%s...%s)", nBlocks, nSize, nHeightFirst, nHeightLast, DateTimeStrFormat("%Y-%m-%d", nTimeFirst), DateTimeStrFormat("%Y-%m-%d", nTimeLast));
|
||||
}
|
||||
|
||||
|
||||
|
||||
static class CMainCleanup
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -47,12 +47,9 @@
|
||||
#ifdef ENABLE_WALLET
|
||||
#include "wallet/wallet.h"
|
||||
#endif
|
||||
|
||||
#include "zcash/Address.hpp"
|
||||
#include "transaction_builder.h"
|
||||
|
||||
#include "sodium.h"
|
||||
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
#ifdef ENABLE_MINING
|
||||
@@ -145,7 +142,7 @@ int32_t komodo_baseid(char *origbase);
|
||||
int32_t hush_longestchain();
|
||||
int64_t komodo_block_unlocktime(uint32_t nHeight);
|
||||
uint64_t the_commission(const CBlock *block,int32_t height);
|
||||
int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33, void *ptr);
|
||||
int32_t hush_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33, void *ptr);
|
||||
int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex);
|
||||
int32_t komodo_is_notarytx(const CTransaction& tx);
|
||||
uint64_t komodo_notarypay(CMutableTransaction &txNew, std::vector<int8_t> &NotarizationNotaries, uint32_t timestamp, int32_t height, uint8_t *script, int32_t len);
|
||||
@@ -364,7 +361,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
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 )
|
||||
{
|
||||
// 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 notarization is not valid later on.
|
||||
TMP_NotarizationNotaries.push_back(i);
|
||||
}
|
||||
}
|
||||
@@ -373,11 +370,11 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
}
|
||||
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 notarization later on and cause problems)
|
||||
std::set<int> checkdupes( TMP_NotarizationNotaries.begin(), TMP_NotarizationNotaries.end() );
|
||||
if ( checkdupes.size() != TMP_NotarizationNotaries.size() )
|
||||
{
|
||||
fprintf(stderr, "possible notarisation is signed multiple times by same notary, passed as normal transaction.\n");
|
||||
fprintf(stderr, "%s: WTFBBQ! possible notarization is signed multiple times by same notary, passed as normal transaction.\n", __func__);
|
||||
} else fNotarization = true;
|
||||
}
|
||||
nTotalIn += tx.GetShieldedValueIn();
|
||||
@@ -394,12 +391,11 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
|
||||
CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize);
|
||||
|
||||
if ( fNotarization )
|
||||
{
|
||||
if ( fNotarization ) {
|
||||
// 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 )
|
||||
{
|
||||
// Get the OP_RETURN for the notarisation
|
||||
// Get the OP_RETURN for the notarization
|
||||
uint8_t *script = (uint8_t *)&tx.vout[1].scriptPubKey[0];
|
||||
int32_t scriptlen = (int32_t)tx.vout[1].scriptPubKey.size();
|
||||
if ( script[0] == OP_RETURN )
|
||||
@@ -422,33 +418,29 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( dPriority == 1e16 )
|
||||
{
|
||||
} else if ( dPriority == 1e16 ) {
|
||||
dPriority -= 10;
|
||||
// make sure notarisation is tx[1] in block.
|
||||
// make sure notarization is tx[1] in block.
|
||||
}
|
||||
if (porphan)
|
||||
{
|
||||
if (porphan) {
|
||||
porphan->dPriority = dPriority;
|
||||
porphan->feeRate = feeRate;
|
||||
}
|
||||
else
|
||||
} else {
|
||||
vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx())));
|
||||
}
|
||||
}
|
||||
|
||||
// Collect transactions into block
|
||||
uint64_t nBlockSize = 1000;
|
||||
uint64_t nBlockTx = 0;
|
||||
int64_t interest;
|
||||
int nBlockSigOps = 100;
|
||||
bool fSortedByFee = (nBlockPrioritySize <= 0);
|
||||
uint64_t nBlockSize = 1000;
|
||||
uint64_t nBlockTx = 0;
|
||||
int nBlockSigOps = 100;
|
||||
bool fSortedByFee = (nBlockPrioritySize <= 0);
|
||||
|
||||
TxPriorityCompare comparer(fSortedByFee);
|
||||
std::make_heap(vecPriority.begin(), vecPriority.end(), comparer);
|
||||
|
||||
while (!vecPriority.empty())
|
||||
{
|
||||
while (!vecPriority.empty()) {
|
||||
// Take highest priority transaction off the priority queue:
|
||||
double dPriority = vecPriority.front().get<0>();
|
||||
CFeeRate feeRate = vecPriority.front().get<1>();
|
||||
@@ -625,7 +617,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
if ( ASSETCHAINS_SCRIPTPUB.size() > 1 )
|
||||
{
|
||||
static bool didinit = false;
|
||||
if ( !didinit && nHeight > KOMODO_EARLYTXID_HEIGHT && KOMODO_EARLYTXID != zeroid && komodo_appendACscriptpub() )
|
||||
if ( !didinit && nHeight > HUSH_EARLYTXID_HEIGHT && HUSH_EARLYTXID != zeroid && komodo_appendACscriptpub() )
|
||||
{
|
||||
fprintf(stderr, "appended ccopreturn to ASSETCHAINS_SCRIPTPUB.%s\n", ASSETCHAINS_SCRIPTPUB.c_str());
|
||||
didinit = true;
|
||||
@@ -637,9 +629,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
txNew.vout[1].scriptPubKey.resize(len);
|
||||
ptr = (uint8_t *)&txNew.vout[1].scriptPubKey[0];
|
||||
decode_hex(ptr,len,(char *)ASSETCHAINS_SCRIPTPUB.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
txNew.vout[1].scriptPubKey.resize(35);
|
||||
ptr = (uint8_t *)&txNew.vout[1].scriptPubKey[0];
|
||||
ptr[0] = 33;
|
||||
@@ -652,17 +642,13 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
//fprintf(stderr," set ASSETCHAINS_OVERRIDE_PUBKEY33 into vout[1]\n");
|
||||
}
|
||||
//printf("autocreate commision vout\n");
|
||||
}
|
||||
else if ( (uint64_t)(txNew.vout[0].nValue) >= ASSETCHAINS_TIMELOCKGTE)
|
||||
{
|
||||
} else if ( (uint64_t)(txNew.vout[0].nValue) >= ASSETCHAINS_TIMELOCKGTE) {
|
||||
fprintf(stderr,"timelocked chains not supported in this code!\n");
|
||||
LEAVE_CRITICAL_SECTION(cs_main);
|
||||
LEAVE_CRITICAL_SECTION(mempool.cs);
|
||||
return(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
|
||||
} 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 notarization
|
||||
uint8_t *script = (uint8_t *)&pblock->vtx[1].vout[1].scriptPubKey[0];
|
||||
int32_t scriptlen = (int32_t)pblock->vtx[1].vout[1].scriptPubKey.size();
|
||||
if ( script[0] == OP_RETURN )
|
||||
@@ -679,7 +665,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
return(0);
|
||||
}
|
||||
//fprintf(stderr, "Created notary payment coinbase totalsat.%lu\n",totalsats);
|
||||
} else fprintf(stderr, "vout 2 of notarisation is not OP_RETURN scriptlen.%i\n", scriptlen);
|
||||
} else fprintf(stderr, "vout 2 of notarization is not OP_RETURN scriptlen.%i\n", scriptlen);
|
||||
}
|
||||
if ( ASSETCHAINS_CBOPRET != 0 )
|
||||
{
|
||||
@@ -733,7 +719,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
memcpy(&r,&randvals,sizeof(r));
|
||||
pblock->nTime += (r % (33 - gpucount)*(33 - gpucount));
|
||||
}
|
||||
if ( komodo_notaryvin(txNotary,NOTARY_PUBKEY33,ptr) > 0 )
|
||||
if ( hush_notaryvin(txNotary,NOTARY_PUBKEY33,ptr) > 0 )
|
||||
{
|
||||
CAmount txfees = 5000;
|
||||
pblock->vtx.push_back(txNotary);
|
||||
|
||||
@@ -12,16 +12,15 @@
|
||||
NotarizationDB *pnotarizations;
|
||||
NotarizationDB::NotarizationDB(size_t nCacheSize, bool fMemory, bool fWipe) : CDBWrapper(GetDataDir() / "notarizations", nCacheSize, fMemory, fWipe, false, 64) { }
|
||||
|
||||
NotarizationsInBlock ScanBlockNotarizations(const CBlock &block, int nHeight)
|
||||
{
|
||||
NotarizationsInBlock ScanBlockNotarizations(const CBlock &block, int nHeight) {
|
||||
EvalRef eval;
|
||||
NotarizationsInBlock vNotarizations;
|
||||
int timestamp = block.nTime;
|
||||
bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false;
|
||||
|
||||
// No valid ntz's before this height
|
||||
int minheight = ishush3 ? 360000 : 1;
|
||||
if(ishush3 && (nHeight <= GetArg("-dpow_height",minheight))) {
|
||||
int minheight = ishush3 ? 365420 : 1;
|
||||
if(ishush3 && (nHeight <= GetArg("-dpow-start-height",minheight))) {
|
||||
return vNotarizations;
|
||||
}
|
||||
|
||||
@@ -48,28 +47,26 @@ NotarizationsInBlock ScanBlockNotarizations(const CBlock &block, int nHeight)
|
||||
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());
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
LogPrintf("WARNING: Couldn't parse notarization for tx: %s at height %i\n", tx.GetHash().GetHex().data(), nHeight);
|
||||
}
|
||||
}
|
||||
return vNotarizations;
|
||||
}
|
||||
|
||||
bool GetBlockNotarizations(uint256 blockHash, NotarizationsInBlock &nibs)
|
||||
{
|
||||
bool GetBlockNotarizations(uint256 blockHash, NotarizationsInBlock &nibs) {
|
||||
return pnotarizations->Read(blockHash, nibs);
|
||||
}
|
||||
|
||||
|
||||
bool GetBackNotarization(uint256 notarisationHash, Notarization &n)
|
||||
{
|
||||
return pnotarizations->Read(notarisationHash, n);
|
||||
bool GetBackNotarization(uint256 notarizationHash, Notarization &n) {
|
||||
return pnotarizations->Read(notarizationHash, n);
|
||||
}
|
||||
|
||||
// Write an index of HUSH notarisation id -> backnotarisation
|
||||
void WriteBackNotarizations(const NotarizationsInBlock notarisations, CDBBatch &batch)
|
||||
{
|
||||
// Write an index of HUSH notarization id -> backnotarization
|
||||
void WriteBackNotarizations(const NotarizationsInBlock notarizations, CDBBatch &batch) {
|
||||
int wrote = 0;
|
||||
BOOST_FOREACH(const Notarization &n, notarisations)
|
||||
BOOST_FOREACH(const Notarization &n, notarizations)
|
||||
{
|
||||
if (!n.second.txHash.IsNull()) {
|
||||
batch.Write(n.second.txHash, n);
|
||||
@@ -78,30 +75,28 @@ void WriteBackNotarizations(const NotarizationsInBlock notarisations, CDBBatch &
|
||||
}
|
||||
}
|
||||
|
||||
void EraseBackNotarizations(const NotarizationsInBlock notarisations, CDBBatch &batch)
|
||||
{
|
||||
BOOST_FOREACH(const Notarization &n, notarisations)
|
||||
void EraseBackNotarizations(const NotarizationsInBlock notarizations, CDBBatch &batch) {
|
||||
BOOST_FOREACH(const Notarization &n, notarizations)
|
||||
{
|
||||
if (!n.second.txHash.IsNull())
|
||||
batch.Erase(n.second.txHash);
|
||||
}
|
||||
}
|
||||
|
||||
// Scan notarisationsdb backwards for blocks containing a notarisation
|
||||
// for given symbol. Return height of matched notarisation or 0.
|
||||
int ScanNotarizationsDB(int height, std::string symbol, int scanLimitBlocks, Notarization& out)
|
||||
{
|
||||
// Scan notarizationsdb backwards for blocks containing a notarization
|
||||
// for given symbol. Return height of matched notarization or 0.
|
||||
int ScanNotarizationsDB(int height, std::string symbol, int scanLimitBlocks, Notarization& out) {
|
||||
if (height < 0 || height > chainActive.Height())
|
||||
return false;
|
||||
|
||||
for (int i=0; i<scanLimitBlocks; i++) {
|
||||
if (i > height) break;
|
||||
NotarizationsInBlock notarisations;
|
||||
NotarizationsInBlock notarizations;
|
||||
uint256 blockHash = *chainActive[height-i]->phashBlock;
|
||||
if (!GetBlockNotarizations(blockHash, notarisations))
|
||||
if (!GetBlockNotarizations(blockHash, notarizations))
|
||||
continue;
|
||||
|
||||
BOOST_FOREACH(Notarization& nota, notarisations) {
|
||||
BOOST_FOREACH(Notarization& nota, notarizations) {
|
||||
if (strcmp(nota.second.symbol, symbol.data()) == 0) {
|
||||
out = nota;
|
||||
return height-i;
|
||||
|
||||
55
src/pow.cpp
55
src/pow.cpp
@@ -509,14 +509,12 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
||||
// changes consensus. Have fun -- Duke
|
||||
int64_t AveragingWindowTimespan(int32_t height) {
|
||||
int64_t AWT = 2550;
|
||||
if (height >= 340000) {
|
||||
//trying to emulate 3.5.0 behavior
|
||||
//AWT = 1275;
|
||||
/*
|
||||
int32_t forkHeight = 0;
|
||||
if (height >= forkHeight) {
|
||||
AWT = 1275;
|
||||
}
|
||||
// TODO:
|
||||
//if (height >= XXX){
|
||||
// AWT = 1275;
|
||||
//}
|
||||
*/
|
||||
return AWT;
|
||||
}
|
||||
|
||||
@@ -703,48 +701,10 @@ bool CheckProofOfWork(const CBlockHeader &blkHeader, uint8_t *pubkey33, int32_t
|
||||
memset(blocktimes,0,sizeof(blocktimes));
|
||||
tiptime = komodo_chainactive_timestamp();
|
||||
bnTarget.SetCompact(blkHeader.nBits, &fNegative, &fOverflow);
|
||||
if ( height == 0 )
|
||||
{
|
||||
if ( height == 0 ) {
|
||||
height = komodo_currentheight() + 1;
|
||||
//fprintf(stderr,"set height to %d\n",height);
|
||||
}
|
||||
if ( height > 34000 && SMART_CHAIN_SYMBOL[0] == 0 ) // 0 -> non-special notary
|
||||
{
|
||||
special = hush_chosennotary(¬aryid,height,pubkey33,tiptime);
|
||||
for (i=0; i<33; i++)
|
||||
{
|
||||
if ( pubkey33[i] != 0 )
|
||||
nonz++;
|
||||
}
|
||||
if ( nonz == 0 )
|
||||
{
|
||||
//fprintf(stderr,"ht.%d null pubkey checkproof return\n",height);
|
||||
return(true); // will come back via different path with pubkey set
|
||||
}
|
||||
flag = komodo_eligiblenotary(pubkeys,mids,blocktimes,&nonzpkeys,height);
|
||||
special2 = komodo_is_special(pubkeys,mids,blocktimes,height,pubkey33,blkHeader.nTime);
|
||||
if ( notaryid >= 0 )
|
||||
{
|
||||
if ( height > 10000 && height < 80000 && (special != 0 || special2 > 0) )
|
||||
flag = 1;
|
||||
else if ( height >= 80000 && height < 108000 && special2 > 0 )
|
||||
flag = 1;
|
||||
else if ( height >= 108000 && special2 > 0 )
|
||||
flag = (height > 1000000 || (height % KOMODO_ELECTION_GAP) > 64 || (height % KOMODO_ELECTION_GAP) == 0);
|
||||
else if ( height == 790833 )
|
||||
flag = 1;
|
||||
else if ( special2 < 0 )
|
||||
{
|
||||
if ( height > 792000 )
|
||||
flag = 0;
|
||||
else fprintf(stderr,"ht.%d notaryid.%d special.%d flag.%d special2.%d\n",height,notaryid,special,flag,special2);
|
||||
}
|
||||
if ( (flag != 0 || special2 > 0) && special2 != -2 )
|
||||
{
|
||||
bnTarget.SetCompact(HUSH_MINDIFF_NBITS,&fNegative,&fOverflow);
|
||||
}
|
||||
}
|
||||
}
|
||||
arith_uint256 bnLimit = (height <= 1 || ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH) ? UintToArith256(params.powLimit) : UintToArith256(params.powAlternate);
|
||||
if (fNegative || bnTarget == 0 || fOverflow || bnTarget > bnLimit)
|
||||
return error("CheckProofOfWork(): nBits below minimum work");
|
||||
@@ -760,9 +720,9 @@ bool CheckProofOfWork(const CBlockHeader &blkHeader, uint8_t *pubkey33, int32_t
|
||||
if ( HUSH_LOADINGBLOCKS != 0 )
|
||||
return true;
|
||||
|
||||
/*
|
||||
if ( SMART_CHAIN_SYMBOL[0] != 0 || height > 792000 )
|
||||
{
|
||||
//if ( 0 && height > 792000 )
|
||||
if ( Params().NetworkIDString() != "regtest" )
|
||||
{
|
||||
for (i=31; i>=0; i--)
|
||||
@@ -780,6 +740,7 @@ bool CheckProofOfWork(const CBlockHeader &blkHeader, uint8_t *pubkey33, int32_t
|
||||
}
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
||||
/*for (i=31; i>=0; i--)
|
||||
fprintf(stderr,"%02x",((uint8_t *)&hash)[i]);
|
||||
|
||||
@@ -859,7 +859,7 @@ UniValue gettxoutsetinfo(const UniValue& params, bool fHelp, const CPubKey& mypk
|
||||
|
||||
UniValue kvsearch(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
UniValue ret(UniValue::VOBJ); uint32_t flags; uint8_t value[IGUANA_MAXSCRIPTSIZE*8],key[IGUANA_MAXSCRIPTSIZE*8]; int32_t duration,j,height,valuesize,keylen; uint256 refpubkey; static uint256 zeroes;
|
||||
UniValue ret(UniValue::VOBJ); uint32_t flags; uint8_t value[DRAGON_MAXSCRIPTSIZE*8],key[DRAGON_MAXSCRIPTSIZE*8]; int32_t duration,j,height,valuesize,keylen; uint256 refpubkey; static uint256 zeroes;
|
||||
if (fHelp || params.size() != 1 )
|
||||
throw runtime_error(
|
||||
"kvsearch key\n"
|
||||
@@ -902,7 +902,7 @@ UniValue kvsearch(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
if ( memcmp(&zeroes,&refpubkey,sizeof(refpubkey)) != 0 )
|
||||
ret.push_back(Pair("owner",refpubkey.GetHex()));
|
||||
ret.push_back(Pair("height",height));
|
||||
duration = ((flags >> 2) + 1) * KOMODO_KVDURATION;
|
||||
duration = ((flags >> 2) + 1) * HUSH_KVDURATION;
|
||||
ret.push_back(Pair("expiration", (int64_t)(height+duration)));
|
||||
ret.push_back(Pair("flags",(int64_t)flags));
|
||||
ret.push_back(Pair("value",val));
|
||||
|
||||
@@ -2,17 +2,13 @@
|
||||
// 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
|
||||
|
||||
//
|
||||
// Unit tests for alert system
|
||||
//
|
||||
|
||||
#include "alert.h"
|
||||
#include "chain.h"
|
||||
#include "chainparams.h"
|
||||
#include "clientversion.h"
|
||||
#include "data/alertTests.raw.h"
|
||||
|
||||
#include "main.h"
|
||||
#include "rpc/protocol.h"
|
||||
#include "rpc/server.h"
|
||||
@@ -20,15 +16,11 @@
|
||||
#include "streams.h"
|
||||
#include "util.h"
|
||||
#include "utilstrencodings.h"
|
||||
|
||||
#include "test/test_bitcoin.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include "key.h"
|
||||
#include "alertkeys.h"
|
||||
#include <iostream>
|
||||
|
||||
@@ -910,8 +910,8 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_parameters)
|
||||
"1 50.00000001"
|
||||
), runtime_error);
|
||||
|
||||
// memo bigger than allowed length of ZC_MEMO_SIZE
|
||||
std::vector<char> v (2 * (ZC_MEMO_SIZE+1)); // x2 for hexadecimal string format
|
||||
// memo bigger than allowed length of HUSH_MEMO_SIZE
|
||||
std::vector<char> v (2 * (HUSH_MEMO_SIZE+1)); // x2 for hexadecimal string format
|
||||
std::fill(v.begin(),v.end(), 'A');
|
||||
std::string badmemo(v.begin(), v.end());
|
||||
auto pa = pwalletMain->GenerateNewSproutZKey();
|
||||
@@ -1035,17 +1035,17 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals)
|
||||
TEST_FRIEND_AsyncRPCOperation_sendmany proxy(ptr);
|
||||
|
||||
std::string memo = "DEADBEEF";
|
||||
std::array<unsigned char, ZC_MEMO_SIZE> array = proxy.get_memo_from_hex_string(memo);
|
||||
std::array<unsigned char, HUSH_MEMO_SIZE> array = proxy.get_memo_from_hex_string(memo);
|
||||
BOOST_CHECK_EQUAL(array[0], 0xDE);
|
||||
BOOST_CHECK_EQUAL(array[1], 0xAD);
|
||||
BOOST_CHECK_EQUAL(array[2], 0xBE);
|
||||
BOOST_CHECK_EQUAL(array[3], 0xEF);
|
||||
for (int i=4; i<ZC_MEMO_SIZE; i++) {
|
||||
for (int i=4; i<HUSH_MEMO_SIZE; i++) {
|
||||
BOOST_CHECK_EQUAL(array[i], 0x00); // zero padding
|
||||
}
|
||||
|
||||
// memo is longer than allowed
|
||||
std::vector<char> v (2 * (ZC_MEMO_SIZE+1));
|
||||
std::vector<char> v (2 * (HUSH_MEMO_SIZE+1));
|
||||
std::fill(v.begin(),v.end(), 'A');
|
||||
std::string bigmemo(v.begin(), v.end());
|
||||
|
||||
@@ -1697,8 +1697,8 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_parameters)
|
||||
"0.0001 100 -1"
|
||||
), runtime_error);
|
||||
|
||||
// memo bigger than allowed length of ZC_MEMO_SIZE
|
||||
std::vector<char> v (2 * (ZC_MEMO_SIZE+1)); // x2 for hexadecimal string format
|
||||
// memo bigger than allowed length of HUSH_MEMO_SIZE
|
||||
std::vector<char> v (2 * (HUSH_MEMO_SIZE+1)); // x2 for hexadecimal string format
|
||||
std::fill(v.begin(),v.end(), 'A');
|
||||
std::string badmemo(v.begin(), v.end());
|
||||
auto pa = pwalletMain->GenerateNewSproutZKey();
|
||||
@@ -1806,17 +1806,17 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_internals)
|
||||
TEST_FRIEND_AsyncRPCOperation_mergetoaddress proxy(ptr);
|
||||
|
||||
std::string memo = "DEADBEEF";
|
||||
std::array<unsigned char, ZC_MEMO_SIZE> array = proxy.get_memo_from_hex_string(memo);
|
||||
std::array<unsigned char, HUSH_MEMO_SIZE> array = proxy.get_memo_from_hex_string(memo);
|
||||
BOOST_CHECK_EQUAL(array[0], 0xDE);
|
||||
BOOST_CHECK_EQUAL(array[1], 0xAD);
|
||||
BOOST_CHECK_EQUAL(array[2], 0xBE);
|
||||
BOOST_CHECK_EQUAL(array[3], 0xEF);
|
||||
for (int i=4; i<ZC_MEMO_SIZE; i++) {
|
||||
for (int i=4; i<HUSH_MEMO_SIZE; i++) {
|
||||
BOOST_CHECK_EQUAL(array[i], 0x00); // zero padding
|
||||
}
|
||||
|
||||
// memo is longer than allowed
|
||||
std::vector<char> v (2 * (ZC_MEMO_SIZE+1));
|
||||
std::vector<char> v (2 * (HUSH_MEMO_SIZE+1));
|
||||
std::fill(v.begin(),v.end(), 'A');
|
||||
std::string bigmemo(v.begin(), v.end());
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ void TransactionBuilder::AddSaplingOutput(
|
||||
uint256 ovk,
|
||||
libzcash::SaplingPaymentAddress to,
|
||||
CAmount value,
|
||||
std::array<unsigned char, ZC_MEMO_SIZE> memo)
|
||||
std::array<unsigned char, HUSH_MEMO_SIZE> memo)
|
||||
{
|
||||
auto note = libzcash::SaplingNote(to, value);
|
||||
outputs.emplace_back(ovk, note, memo);
|
||||
|
||||
@@ -36,12 +36,12 @@ struct SpendDescriptionInfo {
|
||||
struct OutputDescriptionInfo {
|
||||
uint256 ovk;
|
||||
libzcash::SaplingNote note;
|
||||
std::array<unsigned char, ZC_MEMO_SIZE> memo;
|
||||
std::array<unsigned char, HUSH_MEMO_SIZE> memo;
|
||||
|
||||
OutputDescriptionInfo(
|
||||
uint256 ovk,
|
||||
libzcash::SaplingNote note,
|
||||
std::array<unsigned char, ZC_MEMO_SIZE> memo) : ovk(ovk), note(note), memo(memo) {}
|
||||
std::array<unsigned char, HUSH_MEMO_SIZE> memo) : ovk(ovk), note(note), memo(memo) {}
|
||||
};
|
||||
|
||||
struct TransparentInputInfo {
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
uint256 ovk,
|
||||
libzcash::SaplingPaymentAddress to,
|
||||
CAmount value,
|
||||
std::array<unsigned char, ZC_MEMO_SIZE> memo = {{0}});
|
||||
std::array<unsigned char, HUSH_MEMO_SIZE> memo = {{0}});
|
||||
|
||||
// Assumes that the value correctly corresponds to the provided UTXO.
|
||||
void AddTransparentInput(COutPoint utxo, CScript scriptPubKey, CAmount value, uint32_t nSequence = 0xffffffff);
|
||||
|
||||
@@ -333,7 +333,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
||||
} else {
|
||||
std::string zaddr = std::get<0>(recipient_);
|
||||
std::string memo = std::get<1>(recipient_);
|
||||
std::array<unsigned char, ZC_MEMO_SIZE> hexMemo = get_memo_from_hex_string(memo);
|
||||
std::array<unsigned char, HUSH_MEMO_SIZE> hexMemo = get_memo_from_hex_string(memo);
|
||||
auto saplingPaymentAddress = boost::get<libzcash::SaplingPaymentAddress>(&toPaymentAddress_);
|
||||
if (saplingPaymentAddress == nullptr) {
|
||||
// This should never happen as we have already determined that the payment is to sapling
|
||||
@@ -486,9 +486,9 @@ void AsyncRPCOperation_mergetoaddress::sign_send_raw_transaction(UniValue obj)
|
||||
tx_ = tx;
|
||||
}
|
||||
|
||||
std::array<unsigned char, ZC_MEMO_SIZE> AsyncRPCOperation_mergetoaddress::get_memo_from_hex_string(std::string s)
|
||||
std::array<unsigned char, HUSH_MEMO_SIZE> AsyncRPCOperation_mergetoaddress::get_memo_from_hex_string(std::string s)
|
||||
{
|
||||
std::array<unsigned char, ZC_MEMO_SIZE> memo = {{0x00}};
|
||||
std::array<unsigned char, HUSH_MEMO_SIZE> memo = {{0x00}};
|
||||
|
||||
std::vector<unsigned char> rawMemo = ParseHex(s.c_str());
|
||||
|
||||
@@ -498,13 +498,13 @@ std::array<unsigned char, ZC_MEMO_SIZE> AsyncRPCOperation_mergetoaddress::get_me
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Memo must be in hexadecimal format");
|
||||
}
|
||||
|
||||
if (rawMemo.size() > ZC_MEMO_SIZE) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Memo size of %d is too big, maximum allowed is %d", rawMemo.size(), ZC_MEMO_SIZE));
|
||||
if (rawMemo.size() > HUSH_MEMO_SIZE) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Memo size of %d is too big, maximum allowed is %d", rawMemo.size(), HUSH_MEMO_SIZE));
|
||||
}
|
||||
|
||||
// copy vector into boost array
|
||||
int lenMemo = rawMemo.size();
|
||||
for (int i = 0; i < ZC_MEMO_SIZE && i < lenMemo; i++) {
|
||||
for (int i = 0; i < HUSH_MEMO_SIZE && i < lenMemo; i++) {
|
||||
memo[i] = rawMemo[i];
|
||||
}
|
||||
return memo;
|
||||
|
||||
@@ -99,7 +99,7 @@ private:
|
||||
TransactionBuilder builder_;
|
||||
CTransaction tx_;
|
||||
|
||||
std::array<unsigned char, ZC_MEMO_SIZE> get_memo_from_hex_string(std::string s);
|
||||
std::array<unsigned char, HUSH_MEMO_SIZE> get_memo_from_hex_string(std::string s);
|
||||
bool main_impl();
|
||||
|
||||
void sign_send_raw_transaction(UniValue obj); // throws exception if there was an error
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
|
||||
// Delegated methods
|
||||
|
||||
std::array<unsigned char, ZC_MEMO_SIZE> get_memo_from_hex_string(std::string s)
|
||||
std::array<unsigned char, HUSH_MEMO_SIZE> get_memo_from_hex_string(std::string s)
|
||||
{
|
||||
return delegate->get_memo_from_hex_string(s);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,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. *
|
||||
* *
|
||||
@@ -17,7 +16,6 @@
|
||||
* Removal or modification of this copyright notice is prohibited. *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
#include "asyncrpcoperation_sendmany.h"
|
||||
#include "asyncrpcqueue.h"
|
||||
#include "amount.h"
|
||||
@@ -40,15 +38,12 @@
|
||||
#include "zcash/IncrementalMerkleTree.hpp"
|
||||
#include "sodium.h"
|
||||
#include "miner.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include <string>
|
||||
|
||||
#include <boost/optional/optional_io.hpp>
|
||||
|
||||
using namespace libzcash;
|
||||
@@ -199,11 +194,16 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
||||
|
||||
assert(isfromtaddr_ != isfromzaddr_);
|
||||
|
||||
bool isSingleZaddrOutput = (t_outputs_.size()==0 && z_outputs_.size()==1);
|
||||
if(t_outputs_.size() > 0) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Extreme Privacy! You cannot send to a transparent address.");
|
||||
}
|
||||
|
||||
bool isSingleZaddrOutput = (t_outputs_.size()==0 && z_outputs_.size()==1);
|
||||
bool isMultipleZaddrOutput = (t_outputs_.size()==0 && z_outputs_.size()>=1);
|
||||
bool isPureTaddrOnlyTx = (isfromtaddr_ && z_outputs_.size() == 0);
|
||||
bool isPureTaddrOnlyTx = (isfromtaddr_ && z_outputs_.size() == 0);
|
||||
CAmount minersFee = fee_;
|
||||
|
||||
// TODO: fix this garbage ZEC prisoner mindset bullshit
|
||||
// When spending coinbase utxos, you can only specify a single zaddr as the change must go somewhere
|
||||
// and if there are multiple zaddrs, we don't know where to send it.
|
||||
if (isfromtaddr_) {
|
||||
@@ -243,12 +243,13 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
||||
t_outputs_total += std::get<1>(t);
|
||||
}
|
||||
|
||||
|
||||
CAmount z_outputs_total = 0;
|
||||
for (SendManyRecipient & t : z_outputs_) {
|
||||
z_outputs_total += std::get<1>(t);
|
||||
}
|
||||
|
||||
CAmount sendAmount = z_outputs_total + t_outputs_total;
|
||||
CAmount sendAmount = z_outputs_total + t_outputs_total;
|
||||
CAmount targetAmount = sendAmount + minersFee;
|
||||
|
||||
assert(!isfromtaddr_ || z_inputs_total == 0);
|
||||
@@ -302,7 +303,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
||||
FormatMoney(t_inputs_total), FormatMoney(dustThreshold - dustChange), FormatMoney(dustChange), FormatMoney(dustThreshold)));
|
||||
}
|
||||
|
||||
t_inputs_ = selectedTInputs;
|
||||
t_inputs_ = selectedTInputs;
|
||||
t_inputs_total = selectedUTXOAmount;
|
||||
|
||||
// Check mempooltxinputlimit to avoid creating a transaction which the local mempool rejects
|
||||
@@ -331,15 +332,8 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
||||
CAmount amount = std::get<2>(t);
|
||||
builder_.AddTransparentInput(COutPoint(txid, vout), scriptPubKey, amount);
|
||||
}
|
||||
// for Komodo, set lock time to accure interest, for other chains, set
|
||||
// locktime to spend time locked coinbases
|
||||
if (SMART_CHAIN_SYMBOL[0] == 0)
|
||||
{
|
||||
if ( !hush_hardfork_active((uint32_t)chainActive.LastTip()->nTime) )
|
||||
builder_.SetLockTime((uint32_t)time(NULL) - 60); // set lock time for Komodo interest
|
||||
else
|
||||
builder_.SetLockTime((uint32_t)chainActive.Tip()->GetMedianTimePast());
|
||||
}
|
||||
// for other chains, set locktime to spend time locked coinbases
|
||||
//builder_.SetLockTime((uint32_t)chainActive.Tip()->GetMedianTimePast());
|
||||
} else {
|
||||
CMutableTransaction rawTx(tx_);
|
||||
for (SendManyInputUTXO & t : t_inputs_) {
|
||||
@@ -349,13 +343,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
||||
CTxIn in(COutPoint(txid, vout));
|
||||
rawTx.vin.push_back(in);
|
||||
}
|
||||
if (SMART_CHAIN_SYMBOL[0] == 0)
|
||||
{
|
||||
if ( !hush_hardfork_active((uint32_t)chainActive.LastTip()->nTime) )
|
||||
rawTx.nLockTime = (uint32_t)time(NULL) - 60; // jl777
|
||||
else
|
||||
rawTx.nLockTime = (uint32_t)chainActive.Tip()->GetMedianTimePast();
|
||||
}
|
||||
//rawTx.nLockTime = (uint32_t)chainActive.Tip()->GetMedianTimePast();
|
||||
tx_ = CTransaction(rawTx);
|
||||
}
|
||||
}
|
||||
@@ -370,8 +358,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
||||
|
||||
|
||||
/**
|
||||
* SCENARIO #0
|
||||
*
|
||||
* SCENARIO #0 (All HUSH and Hush Smart Chains)
|
||||
* Sprout not involved, so we just use the TransactionBuilder and we're done.
|
||||
* We added the transparent inputs to the builder earlier.
|
||||
*/
|
||||
@@ -516,14 +503,11 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
||||
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* END SCENARIO #0
|
||||
*/
|
||||
|
||||
// END SCENARIO #0
|
||||
// No other scenarios, because Hush developers are elite.
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sign and send a raw transaction.
|
||||
* Raw transaction as hex string should be in object field "rawtxn"
|
||||
@@ -579,7 +563,6 @@ void AsyncRPCOperation_sendmany::sign_send_raw_transaction(UniValue obj)
|
||||
set_result(o);
|
||||
} else {
|
||||
// Test mode does not send the transaction to the network.
|
||||
|
||||
CDataStream stream(ParseHex(signedtxn), SER_NETWORK, PROTOCOL_VERSION);
|
||||
CTransaction tx;
|
||||
stream >> tx;
|
||||
@@ -751,9 +734,9 @@ void AsyncRPCOperation_sendmany::add_taddr_change_output_to_tx(CBitcoinAddress *
|
||||
tx_ = CTransaction(rawTx);
|
||||
}
|
||||
|
||||
std::array<unsigned char, ZC_MEMO_SIZE> AsyncRPCOperation_sendmany::get_memo_from_hex_string(std::string s) {
|
||||
std::array<unsigned char, HUSH_MEMO_SIZE> AsyncRPCOperation_sendmany::get_memo_from_hex_string(std::string s) {
|
||||
// initialize to default memo (no_memo), see section 5.5 of the protocol spec
|
||||
std::array<unsigned char, ZC_MEMO_SIZE> memo = {{0xF6}};
|
||||
std::array<unsigned char, HUSH_MEMO_SIZE> memo = {{0xF6}};
|
||||
|
||||
std::vector<unsigned char> rawMemo = ParseHex(s.c_str());
|
||||
|
||||
@@ -763,21 +746,19 @@ std::array<unsigned char, ZC_MEMO_SIZE> AsyncRPCOperation_sendmany::get_memo_fro
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Memo must be in hexadecimal format");
|
||||
}
|
||||
|
||||
if (rawMemo.size() > ZC_MEMO_SIZE) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Memo size of %d is too big, maximum allowed is %d", rawMemo.size(), ZC_MEMO_SIZE));
|
||||
if (rawMemo.size() > HUSH_MEMO_SIZE) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Memo size of %d is too big, maximum allowed is %d", rawMemo.size(), HUSH_MEMO_SIZE));
|
||||
}
|
||||
|
||||
// copy vector into boost array
|
||||
int lenMemo = rawMemo.size();
|
||||
for (int i = 0; i < ZC_MEMO_SIZE && i < lenMemo; i++) {
|
||||
for (int i = 0; i < HUSH_MEMO_SIZE && i < lenMemo; i++) {
|
||||
memo[i] = rawMemo[i];
|
||||
}
|
||||
return memo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override getStatus() to append the operation's input parameters to the default status object.
|
||||
*/
|
||||
// Override getStatus() to append the operation's input parameters to the default status object.
|
||||
UniValue AsyncRPCOperation_sendmany::getStatus() const {
|
||||
UniValue v = AsyncRPCOperation::getStatus();
|
||||
if (contextinfo_.isNull()) {
|
||||
|
||||
@@ -112,7 +112,7 @@ private:
|
||||
void add_taddr_outputs_to_tx();
|
||||
bool find_unspent_notes();
|
||||
bool find_utxos(bool fAcceptCoinbase);
|
||||
std::array<unsigned char, ZC_MEMO_SIZE> get_memo_from_hex_string(std::string s);
|
||||
std::array<unsigned char, HUSH_MEMO_SIZE> get_memo_from_hex_string(std::string s);
|
||||
bool main_impl();
|
||||
|
||||
void sign_send_raw_transaction(UniValue obj); // throws exception if there was an error
|
||||
@@ -152,7 +152,7 @@ public:
|
||||
return delegate->find_utxos(fAcceptCoinbase);
|
||||
}
|
||||
|
||||
std::array<unsigned char, ZC_MEMO_SIZE> get_memo_from_hex_string(std::string s) {
|
||||
std::array<unsigned char, HUSH_MEMO_SIZE> get_memo_from_hex_string(std::string s) {
|
||||
return delegate->get_memo_from_hex_string(s);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ const std::string ADDR_TYPE_AMNESIA = "amnesia";
|
||||
extern int32_t HUSH_INSYNC;
|
||||
uint32_t komodo_segid32(char *coinaddr);
|
||||
int32_t hush_dpowconfs(int32_t height,int32_t numconfs);
|
||||
int32_t komodo_isnotaryvout(char *coinaddr,uint32_t tiptime); // from ac_private chains only
|
||||
int32_t hush_isnotaryvout(char *coinaddr,uint32_t tiptime); // from ac_private chains only
|
||||
CBlockIndex *komodo_getblockindex(uint256 hash);
|
||||
extern string randomSietchZaddr();
|
||||
extern CAmount fConsolidationTxFee;
|
||||
@@ -83,7 +83,7 @@ UniValue z_getoperationstatus_IMPL(const UniValue&, bool);
|
||||
|
||||
#define PLAN_NAME_MAX 8
|
||||
#define VALID_PLAN_NAME(x) (strlen(x) <= PLAN_NAME_MAX)
|
||||
#define THROW_IF_SYNCING(INSYNC) if (INSYNC == 0) { throw runtime_error(strprintf("%s: Chain still syncing at height %d, aborting to prevent linkability analysis!",__FUNCTION__,chainActive.Tip()->GetHeight())); }
|
||||
#define THROW_IF_SYNCING(INSYNC) if (INSYNC == 0) { throw runtime_error(strprintf("%s: Extreme Privacy! Chain still syncing at height %d, aborting to prevent linkability analysis",__FUNCTION__,chainActive.Tip()->GetHeight())); }
|
||||
|
||||
int tx_height( const uint256 &hash );
|
||||
|
||||
@@ -526,7 +526,7 @@ UniValue sendtoaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
|
||||
if ( ASSETCHAINS_PRIVATE != 0 && AmountFromValue(params[1]) > 0 )
|
||||
{
|
||||
if ( komodo_isnotaryvout((char *)params[0].get_str().c_str(),chainActive.LastTip()->nTime) == 0 )
|
||||
if ( hush_isnotaryvout((char *)params[0].get_str().c_str(),chainActive.LastTip()->nTime) == 0 )
|
||||
{
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid " + strprintf("%s",komodo_chainname()) + " address");
|
||||
}
|
||||
@@ -563,10 +563,10 @@ UniValue sendtoaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
|
||||
#include "hush_defs.h"
|
||||
|
||||
#define KOMODO_KVPROTECTED 1
|
||||
#define KOMODO_KVBINARY 2
|
||||
#define KOMODO_KVDURATION 1440
|
||||
#define IGUANA_MAXSCRIPTSIZE 10001
|
||||
#define HUSH_KVPROTECTED 1
|
||||
#define HUSH_KVBINARY 2
|
||||
#define HUSH_KVDURATION 1440
|
||||
#define DRAGON_MAXSCRIPTSIZE 10001
|
||||
uint64_t PAX_fiatdest(uint64_t *seedp,int32_t tokomodo,char *destaddr,uint8_t pubkey37[37],char *coinaddr,int32_t height,char *base,int64_t fiatoshis);
|
||||
int32_t komodo_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_t opretlen);
|
||||
extern int32_t KOMODO_PAX;
|
||||
@@ -575,7 +575,7 @@ int32_t komodo_is_issuer();
|
||||
int32_t dragon_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp);
|
||||
int32_t komodo_isrealtime(int32_t *kmdheightp);
|
||||
int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base);
|
||||
int32_t komodo_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[IGUANA_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen);
|
||||
int32_t komodo_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[DRAGON_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen);
|
||||
int32_t komodo_kvcmp(uint8_t *refvalue,uint16_t refvaluesize,uint8_t *value,uint16_t valuesize);
|
||||
uint64_t komodo_kvfee(uint32_t flags,int32_t opretlen,int32_t keylen);
|
||||
uint256 komodo_kvsig(uint8_t *buf,int32_t len,uint256 privkey);
|
||||
@@ -587,7 +587,7 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
static uint256 zeroes;
|
||||
CWalletTx wtx; UniValue ret(UniValue::VOBJ);
|
||||
uint8_t keyvalue[IGUANA_MAXSCRIPTSIZE*8],opretbuf[IGUANA_MAXSCRIPTSIZE*8]; int32_t i,coresize,haveprivkey,duration,opretlen,height; uint16_t keylen=0,valuesize=0,refvaluesize=0; uint8_t *key,*value=0; uint32_t flags,tmpflags,n; struct komodo_kv *ptr; uint64_t fee; uint256 privkey,pubkey,refpubkey,sig;
|
||||
uint8_t keyvalue[DRAGON_MAXSCRIPTSIZE*8],opretbuf[DRAGON_MAXSCRIPTSIZE*8]; int32_t i,coresize,haveprivkey,duration,opretlen,height; uint16_t keylen=0,valuesize=0,refvaluesize=0; uint8_t *key,*value=0; uint32_t flags,tmpflags,n; struct komodo_kv *ptr; uint64_t fee; uint256 privkey,pubkey,refpubkey,sig;
|
||||
if (fHelp || params.size() < 3 )
|
||||
throw runtime_error(
|
||||
"kvupdate key \"value\" days passphrase\n"
|
||||
@@ -651,7 +651,7 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
memcpy(keyvalue,key,keylen);
|
||||
if ( (refvaluesize= komodo_kvsearch(&refpubkey,chainActive.LastTip()->GetHeight(),&tmpflags,&height,&keyvalue[keylen],key,keylen)) >= 0 )
|
||||
{
|
||||
if ( (tmpflags & KOMODO_KVPROTECTED) != 0 )
|
||||
if ( (tmpflags & HUSH_KVPROTECTED) != 0 )
|
||||
{
|
||||
if ( memcmp(&refpubkey,&pubkey,sizeof(refpubkey)) != 0 )
|
||||
{
|
||||
@@ -678,7 +678,7 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
if ( memcmp(&zeroes,&refpubkey,sizeof(refpubkey)) != 0 )
|
||||
ret.push_back(Pair("owner",refpubkey.GetHex()));
|
||||
ret.push_back(Pair("height", (int64_t)height));
|
||||
duration = komodo_kvduration(flags); //((flags >> 2) + 1) * KOMODO_KVDURATION;
|
||||
duration = komodo_kvduration(flags); //((flags >> 2) + 1) * HUSH_KVDURATION;
|
||||
ret.push_back(Pair("expiration", (int64_t)(height+duration)));
|
||||
ret.push_back(Pair("flags",(int64_t)flags));
|
||||
ret.push_back(Pair("key",params[0].get_str()));
|
||||
@@ -4290,7 +4290,7 @@ UniValue z_viewtransaction(const UniValue& params, bool fHelp, const CPubKey& my
|
||||
" \"outputPrev\" : n, (numeric) the index of the output within the vShieldedOutput\n"
|
||||
" \"address\" : \"zcashaddress\", (string) The Hush shielded address involved in the transaction\n"
|
||||
" \"value\" : x.xxx (numeric) The amount in " + CURRENCY_UNIT + "\n"
|
||||
" \"valueZat\" : xxxx (numeric) The amount in zatoshis\n"
|
||||
" \"valueZat\" : xxxx (numeric) The amount in puposhis\n"
|
||||
" }\n"
|
||||
" ,...\n"
|
||||
" ],\n"
|
||||
@@ -4301,7 +4301,7 @@ UniValue z_viewtransaction(const UniValue& params, bool fHelp, const CPubKey& my
|
||||
" \"address\" : \"hushaddress\", (string) The Hush address involved in the transaction\n"
|
||||
" \"outgoing\" : true|false (boolean) True if the output is not for an address in the wallet\n"
|
||||
" \"value\" : x.xxx (numeric) The amount in " + CURRENCY_UNIT + "\n"
|
||||
" \"valueZat\" : xxxx (numeric) The amount in zatoshis\n"
|
||||
" \"valueZat\" : xxxx (numeric) The amount in puposhis\n"
|
||||
" \"memo\" : \"hexmemo\", (string) Hexademical string representation of the memo field\n"
|
||||
" \"memoStr\" : \"memo\", (string) Only returned if memo contains valid UTF-8 text.\n"
|
||||
" }\n"
|
||||
@@ -4535,12 +4535,6 @@ UniValue z_getoperationstatus_IMPL(const UniValue& params, bool fRemoveFinishedO
|
||||
|
||||
|
||||
// JSDescription size depends on the transaction version
|
||||
#define V3_JS_DESCRIPTION_SIZE (GetSerializeSize(JSDescription(), SER_NETWORK, (OVERWINTER_TX_VERSION | (1 << 31))))
|
||||
// Here we define the maximum number of zaddr outputs that can be included in a transaction.
|
||||
// If input notes are small, we might actually require more than one joinsplit per zaddr output.
|
||||
// For now though, we assume we use one joinsplit per zaddr output (and the second output note is change).
|
||||
// We reduce the result by 1 to ensure there is room for non-joinsplit CTransaction data.
|
||||
#define Z_SENDMANY_MAX_ZADDR_OUTPUTS_BEFORE_SAPLING ((MAX_TX_SIZE_BEFORE_SAPLING / V3_JS_DESCRIPTION_SIZE) - 1)
|
||||
|
||||
// transaction.h comment: spending taddr output requires CTxIn >= 148 bytes and typical taddr txout is 34 bytes
|
||||
#define CTXIN_SPEND_DUST_SIZE 148
|
||||
@@ -4557,7 +4551,6 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
"\nSend multiple times. Amounts are decimal numbers with at most 8 digits of precision."
|
||||
"\nChange generated from a taddr flows to a new taddr address, while change generated from a zaddr returns to itself."
|
||||
"\nWhen sending coinbase UTXOs to a zaddr, change is not allowed. The entire value of the UTXO(s) must be consumed."
|
||||
+ strprintf("\nBefore Sapling activates, the maximum number of zaddr outputs is %d due to transaction size limits.\n", Z_SENDMANY_MAX_ZADDR_OUTPUTS_BEFORE_SAPLING)
|
||||
+ HelpRequiringPassphrase() + "\n"
|
||||
"\nArguments:\n"
|
||||
"1. \"fromaddress\" (string, required) The taddr or zaddr to send the funds from.\n"
|
||||
@@ -4579,11 +4572,12 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
|
||||
// Hilarious that Komodo commented this out, opening themselves up to metadata attackz, lulz
|
||||
THROW_IF_SYNCING(HUSH_INSYNC);
|
||||
|
||||
// Check that the from address is valid.
|
||||
auto fromaddress = params[0].get_str();
|
||||
bool fromTaddr = false;
|
||||
bool fromTaddr = false;
|
||||
bool fromSapling = false;
|
||||
|
||||
uint32_t branchId = CurrentEpochBranchId(chainActive.Height(), Params().GetConsensus());
|
||||
@@ -4642,9 +4636,9 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
} else {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, unknown address format: ")+address );
|
||||
}
|
||||
}
|
||||
//else if ( ASSETCHAINS_PRIVATE != 0 && komodo_isnotaryvout((char *)address.c_str()) == 0 )
|
||||
// throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "cant use transparent addresses in private chain");
|
||||
}// else if ( ASSETCHAINS_PRIVATE != 0 && hush_isnotaryvout((char *)address.c_str()) == 0 ) {
|
||||
// throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Extreme Privacy! You must send to a zaddr");
|
||||
//}
|
||||
|
||||
// Allowing duplicate receivers helps various HushList protocol operations
|
||||
//if (setAddress.count(address))
|
||||
@@ -4660,8 +4654,8 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
} else if (!IsHex(memo)) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected memo data in hexadecimal format.");
|
||||
}
|
||||
if (memo.length() > ZC_MEMO_SIZE*2) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid parameter, size of memo is larger than maximum allowed %d", ZC_MEMO_SIZE ));
|
||||
if (memo.length() > HUSH_MEMO_SIZE*2) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid parameter, size of memo is larger than maximum allowed %d", HUSH_MEMO_SIZE ));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4733,24 +4727,10 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
if (!NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) {
|
||||
if (NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) {
|
||||
mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID;
|
||||
mtx.nVersion = OVERWINTER_TX_VERSION;
|
||||
mtx.nVersion = OVERWINTER_TX_VERSION;
|
||||
} else {
|
||||
mtx.fOverwintered = false;
|
||||
mtx.nVersion = 2;
|
||||
}
|
||||
|
||||
max_tx_size = MAX_TX_SIZE_BEFORE_SAPLING;
|
||||
|
||||
// Check the number of zaddr outputs does not exceed the limit.
|
||||
if (zaddrRecipients.size() > Z_SENDMANY_MAX_ZADDR_OUTPUTS_BEFORE_SAPLING) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, too many zaddr outputs");
|
||||
}
|
||||
}
|
||||
|
||||
// If Sapling is not active, do not allow sending from or sending to Sapling addresses.
|
||||
if (!NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) {
|
||||
if (fromSapling || containsSaplingOutput) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, Sapling has not activated");
|
||||
mtx.nVersion = 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4829,13 +4809,9 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
boost::optional<TransactionBuilder> builder;
|
||||
builder = TransactionBuilder(Params().GetConsensus(), nextBlockHeight, pwalletMain);
|
||||
|
||||
// Contextual transaction we will build on
|
||||
// (used if no Sapling addresses are involved)
|
||||
CMutableTransaction contextualTx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), nextBlockHeight);
|
||||
bool isShielded = !fromTaddr || zaddrRecipients.size() > 0;
|
||||
if (contextualTx.nVersion == 1 && isShielded) {
|
||||
contextualTx.nVersion = 2; // Tx format should support vjoinsplits
|
||||
}
|
||||
// Contextual transaction
|
||||
CMutableTransaction contextualTx; // = CreateNewContextualCMutableTransaction(Params().GetConsensus(), nextBlockHeight);
|
||||
contextualTx.nVersion = 2;
|
||||
|
||||
// Create operation and add to global queue
|
||||
std::shared_ptr<AsyncRPCQueue> q = getAsyncRPCQueue();
|
||||
@@ -4860,7 +4836,6 @@ When estimating the number of coinbase utxos we can shield in a single transacti
|
||||
105 + 1 + 3*(73+1) = 328 bytes of scriptSig, rounded up to 400 based on testnet experiments.
|
||||
*/
|
||||
#define CTXIN_SPEND_P2SH_SIZE 400
|
||||
|
||||
#define SHIELD_COINBASE_DEFAULT_LIMIT 50
|
||||
|
||||
UniValue z_shieldcoinbase(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
@@ -4876,8 +4851,7 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp, const CPubKey& myp
|
||||
"\ncan be used to return a list of locked utxos. The number of coinbase utxos selected for shielding can be limited"
|
||||
"\nby the caller. If the limit parameter is set to zero, and Overwinter is not yet active, the -mempooltxinputlimit"
|
||||
"\noption will determine the number of uxtos. Any limit is constrained by the consensus rule defining a maximum"
|
||||
"\ntransaction size of "
|
||||
+ strprintf("%d bytes before Sapling, and %d bytes once Sapling activates.", MAX_TX_SIZE_BEFORE_SAPLING, MAX_TX_SIZE_AFTER_SAPLING)
|
||||
"\ntransaction size of " + strprintf("%d bytes.", MAX_TX_SIZE_AFTER_SAPLING)
|
||||
+ HelpRequiringPassphrase() + "\n"
|
||||
"\nArguments:\n"
|
||||
"1. \"fromaddress\" (string, required) The address is a taddr or \"*\" for all taddrs belonging to the wallet.\n"
|
||||
@@ -4901,6 +4875,7 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp, const CPubKey& myp
|
||||
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
|
||||
// Hilarious that Komodo commented this out, opening themselves up to metadata attackz, lulz
|
||||
THROW_IF_SYNCING(HUSH_INSYNC);
|
||||
|
||||
// Validate the from address
|
||||
@@ -4941,27 +4916,12 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp, const CPubKey& myp
|
||||
int nextBlockHeight = chainActive.Height() + 1;
|
||||
bool overwinterActive = NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER);
|
||||
unsigned int max_tx_size = MAX_TX_SIZE_AFTER_SAPLING;
|
||||
if (!NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) {
|
||||
max_tx_size = MAX_TX_SIZE_BEFORE_SAPLING;
|
||||
}
|
||||
|
||||
// If Sapling is not active, do not allow sending to a Sapling address.
|
||||
if (!NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) {
|
||||
auto res = DecodePaymentAddress(destaddress);
|
||||
if (IsValidPaymentAddress(res)) {
|
||||
bool toSapling = boost::get<libzcash::SaplingPaymentAddress>(&res) != nullptr;
|
||||
if (toSapling) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, Sapling has not activated");
|
||||
}
|
||||
} else {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, unknown address format: ") + destaddress );
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare to get coinbase utxos
|
||||
std::vector<ShieldCoinbaseUTXO> inputs;
|
||||
CAmount shieldedValue = 0;
|
||||
CAmount remainingValue = 0;
|
||||
//TODO: update these estimates
|
||||
size_t estimatedTxSize = 2000; // 1802 joinsplit description + tx overhead + wiggle room
|
||||
|
||||
#ifdef __LP64__
|
||||
@@ -5087,9 +5047,7 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp, const CPubKey& myp
|
||||
}
|
||||
|
||||
#define MERGE_TO_ADDRESS_DEFAULT_TRANSPARENT_LIMIT 50
|
||||
#define MERGE_TO_ADDRESS_DEFAULT_SPROUT_LIMIT 10
|
||||
#define MERGE_TO_ADDRESS_DEFAULT_SAPLING_LIMIT 90
|
||||
|
||||
#define MERGE_TO_ADDRESS_DEFAULT_SAPLING_LIMIT 90
|
||||
#define OUTPUTDESCRIPTION_SIZE GetSerializeSize(OutputDescription(), SER_NETWORK, PROTOCOL_VERSION)
|
||||
#define SPENDDESCRIPTION_SIZE GetSerializeSize(SpendDescription(), SER_NETWORK, PROTOCOL_VERSION)
|
||||
|
||||
@@ -5099,11 +5057,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp
|
||||
return NullUniValue;
|
||||
|
||||
string enableArg = "zmergetoaddress";
|
||||
//auto fEnableMergeToAddress = fExperimentalMode && GetBoolArg("-" + enableArg, true);
|
||||
//std::string strDisabledMsg = "";
|
||||
//if (!fEnableMergeToAddress) {
|
||||
// strDisabledMsg = experimentalDisabledHelpMsg("z_mergetoaddress", enableArg);
|
||||
//}
|
||||
|
||||
if (fHelp || params.size() < 2 || params.size() > 7)
|
||||
throw runtime_error(
|
||||
@@ -5115,8 +5068,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp
|
||||
"\n\nThe number of UTXOs and notes selected for merging can be limited by the caller. If the transparent limit"
|
||||
"\nparameter is set to zero, and Overwinter is not yet active, the -mempooltxinputlimit option will determine the"
|
||||
"\nnumber of UTXOs. Any limit is constrained by the consensus rule defining a maximum transaction size of"
|
||||
+ strprintf("\n%d bytes before Sapling, and %d bytes once Sapling activates.", MAX_TX_SIZE_BEFORE_SAPLING, MAX_TX_SIZE_AFTER_SAPLING)
|
||||
+ HelpRequiringPassphrase() + "\n"
|
||||
"\nArguments:\n"
|
||||
"1. fromaddresses (string, required) A JSON array with addresses.\n"
|
||||
" The following special strings are accepted inside the array:\n"
|
||||
@@ -5157,9 +5108,10 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp
|
||||
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
|
||||
// Hilarious that Komodo commented this out, opening themselves up to metadata attackz, lulz
|
||||
THROW_IF_SYNCING(HUSH_INSYNC);
|
||||
|
||||
bool useAnyUTXO = false;
|
||||
bool useAnyUTXO = false;
|
||||
bool useAnySapling = false;
|
||||
std::set<CTxDestination> taddrs = {};
|
||||
std::set<libzcash::PaymentAddress> zaddrs = {};
|
||||
@@ -5168,7 +5120,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp
|
||||
if (addresses.size()==0)
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, fromaddresses array is empty.");
|
||||
|
||||
// Keep track of addresses to spot duplicates
|
||||
// Keep track of addresses
|
||||
std::set<std::string> setAddress;
|
||||
|
||||
// Sources
|
||||
@@ -5208,9 +5160,8 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot specify specific z-addrs when using \"ANY_SAPLING\"");
|
||||
}
|
||||
|
||||
const int nextBlockHeight = chainActive.Height() + 1;
|
||||
const int nextBlockHeight = chainActive.Height() + 1;
|
||||
const bool overwinterActive = NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER);
|
||||
const bool saplingActive = NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING);
|
||||
|
||||
// Validate the destination address
|
||||
auto destaddress = params[1].get_str();
|
||||
@@ -5221,10 +5172,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp
|
||||
if (IsValidPaymentAddress(decodeAddr)) {
|
||||
if (boost::get<libzcash::SaplingPaymentAddress>(&decodeAddr) != nullptr) {
|
||||
isToSaplingZaddr = true;
|
||||
// If Sapling is not active, do not allow sending to a sapling addresses.
|
||||
if (!saplingActive) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, Sapling has not activated");
|
||||
}
|
||||
} else {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Only Sapling zaddrs allowed!");
|
||||
}
|
||||
@@ -5233,7 +5180,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp
|
||||
}
|
||||
}
|
||||
|
||||
// Convert fee from currency format to zatoshis
|
||||
// Convert fee from currency format to puposhis
|
||||
CAmount nFee = SHIELD_COINBASE_DEFAULT_MINERS_FEE;
|
||||
if (params.size() > 2) {
|
||||
if (params[2].get_real() == 0.0) {
|
||||
@@ -5276,10 +5223,11 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp
|
||||
if (!isToSaplingZaddr) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Memo can not be used with a taddr. It can only be used with a zaddr.");
|
||||
} else if (!IsHex(memo)) {
|
||||
//TODO: this sux, would be nice to accept in utf8
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected memo data in hexadecimal format.");
|
||||
}
|
||||
if (memo.length() > ZC_MEMO_SIZE*2) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid parameter, size of memo is larger than maximum allowed %d", ZC_MEMO_SIZE ));
|
||||
if (memo.length() > HUSH_MEMO_SIZE*2) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid parameter, size of memo is larger than maximum allowed %d", HUSH_MEMO_SIZE ));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5288,17 +5236,16 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp
|
||||
// Prepare to get UTXOs and notes
|
||||
std::vector<MergeToAddressInputUTXO> utxoInputs;
|
||||
std::vector<MergeToAddressInputSaplingNote> saplingNoteInputs;
|
||||
CAmount mergedUTXOValue = 0;
|
||||
CAmount mergedNoteValue = 0;
|
||||
CAmount mergedUTXOValue = 0;
|
||||
CAmount mergedNoteValue = 0;
|
||||
CAmount remainingUTXOValue = 0;
|
||||
CAmount remainingNoteValue = 0;
|
||||
size_t utxoCounter = 0;
|
||||
size_t noteCounter = 0;
|
||||
bool maxedOutUTXOsFlag = false;
|
||||
bool maxedOutNotesFlag = false;
|
||||
size_t mempoolLimit = (nUTXOLimit != 0) ? nUTXOLimit : (overwinterActive ? 0 : (size_t)GetArg("-mempooltxinputlimit", 0));
|
||||
|
||||
unsigned int max_tx_size = saplingActive ? MAX_TX_SIZE_AFTER_SAPLING : MAX_TX_SIZE_BEFORE_SAPLING;
|
||||
size_t utxoCounter = 0;
|
||||
size_t noteCounter = 0;
|
||||
bool maxedOutUTXOsFlag = false;
|
||||
bool maxedOutNotesFlag = false;
|
||||
size_t mempoolLimit = (nUTXOLimit != 0) ? nUTXOLimit : (overwinterActive ? 0 : (size_t)GetArg("-mempooltxinputlimit", 0));
|
||||
unsigned int max_tx_size = MAX_TX_SIZE_AFTER_SAPLING;
|
||||
size_t estimatedTxSize = 200; // tx overhead + wiggle room
|
||||
|
||||
if (isToSaplingZaddr) {
|
||||
@@ -5329,8 +5276,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp
|
||||
|
||||
CAmount nValue = out.tx->vout[out.i].nValue;
|
||||
|
||||
if (maximum_utxo_size != 0)
|
||||
{
|
||||
if (maximum_utxo_size != 0) {
|
||||
//fprintf(stderr, "utxo txid.%s vout.%i nValue.%li scriptpubkeylength.%i\n",out.tx->GetHash().ToString().c_str(),out.i,nValue,out.tx->vout[out.i].scriptPubKey.size());
|
||||
if (nValue > maximum_utxo_size)
|
||||
continue;
|
||||
@@ -5426,9 +5372,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp
|
||||
contextInfo.push_back(Pair("fee", ValueFromAmount(nFee)));
|
||||
|
||||
// Contextual transaction we will build on
|
||||
CMutableTransaction contextualTx = CreateNewContextualCMutableTransaction(
|
||||
Params().GetConsensus(),
|
||||
nextBlockHeight);
|
||||
CMutableTransaction contextualTx; //= CreateNewContextualCMutableTransaction( Params().GetConsensus(), nextBlockHeight);
|
||||
|
||||
// Builder (used if Sapling addresses are involved)
|
||||
boost::optional<TransactionBuilder> builder;
|
||||
@@ -5511,7 +5455,7 @@ UniValue z_listoperationids(const UniValue& params, bool fHelp, const CPubKey& m
|
||||
int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex);
|
||||
extern std::string NOTARY_PUBKEY;
|
||||
|
||||
int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33, void *pTr)
|
||||
int32_t hush_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33, void *pTr)
|
||||
{
|
||||
set<CBitcoinAddress> setAddress; uint8_t *script,utxosig[128]; uint256 utxotxid; uint64_t utxovalue; int32_t i,siglen=0,nMinDepth = 0,nMaxDepth = 9999999; vector<COutput> vecOutputs; uint32_t utxovout,eligible,earliest = 0; CScript best_scriptPubKey; bool fNegative,fOverflow;
|
||||
bool signSuccess; SignatureData sigdata; uint64_t txfee; uint8_t *ptr;
|
||||
@@ -5612,8 +5556,7 @@ int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33, void *
|
||||
#include "../cc/CCPayments.h"
|
||||
#include "../cc/CCPegs.h"
|
||||
|
||||
int32_t ensure_CCrequirements(uint8_t evalcode)
|
||||
{
|
||||
int32_t ensure_CCrequirements(uint8_t evalcode) {
|
||||
CCerror = "";
|
||||
if ( ASSETCHAINS_CCDISABLES[evalcode] != 0 || (evalcode == EVAL_MARMARA && ASSETCHAINS_MARMARA == 0) )
|
||||
{
|
||||
@@ -5725,54 +5668,46 @@ UniValue setpubkey(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
" \"R-address\" : \"R address\", (string) The pubkey\n"
|
||||
" }\n"
|
||||
"\nExamples:\n"
|
||||
+ HelpExampleCli("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e")
|
||||
+ HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e")
|
||||
+ HelpExampleCli("setpubkey", "0420597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea1987")
|
||||
+ HelpExampleRpc("setpubkey", "0420597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea1987")
|
||||
);
|
||||
|
||||
LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL);
|
||||
|
||||
char Raddress[64];
|
||||
uint8_t pubkey33[33];
|
||||
if ( NOTARY_PUBKEY33[0] == 0 )
|
||||
{
|
||||
if (strlen(params[0].get_str().c_str()) == 66)
|
||||
{
|
||||
if ( NOTARY_PUBKEY33[0] == 0 ) {
|
||||
if (strlen(params[0].get_str().c_str()) == 66) {
|
||||
decode_hex(pubkey33,33,(char *)params[0].get_str().c_str());
|
||||
pubkey2addr((char *)Raddress,(uint8_t *)pubkey33);
|
||||
CBitcoinAddress address(Raddress);
|
||||
bool isValid = address.IsValid();
|
||||
if (isValid)
|
||||
{
|
||||
if (isValid) {
|
||||
CTxDestination dest = address.Get();
|
||||
isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO;
|
||||
if ( mine == ISMINE_NO )
|
||||
if ( mine == ISMINE_NO ) {
|
||||
result.push_back(Pair("WARNING", "privkey for this pubkey is not imported to wallet!"));
|
||||
else
|
||||
{
|
||||
} else {
|
||||
result.push_back(Pair("ismine", "true"));
|
||||
}
|
||||
NOTARY_PUBKEY = params[0].get_str();
|
||||
decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str());
|
||||
USE_EXTERNAL_PUBKEY = 1;
|
||||
NOTARY_ADDRESS = address.ToString();
|
||||
}
|
||||
else
|
||||
} else {
|
||||
result.push_back(Pair("error", "pubkey entered is invalid."));
|
||||
}
|
||||
else
|
||||
}
|
||||
} else {
|
||||
result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string."));
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( NOTARY_ADDRESS.empty() )
|
||||
{
|
||||
}
|
||||
} else {
|
||||
if ( NOTARY_ADDRESS.empty() ) {
|
||||
pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33);
|
||||
NOTARY_ADDRESS.assign(Raddress);
|
||||
}
|
||||
result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon."));
|
||||
}
|
||||
if ( NOTARY_PUBKEY33[0] != 0 && !NOTARY_ADDRESS.empty() )
|
||||
{
|
||||
if ( NOTARY_PUBKEY33[0] != 0 && !NOTARY_ADDRESS.empty() ) {
|
||||
result.push_back(Pair("address", NOTARY_ADDRESS));
|
||||
result.push_back(Pair("pubkey", NOTARY_PUBKEY));
|
||||
}
|
||||
@@ -7443,9 +7378,9 @@ UniValue tokencreate(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
|
||||
if (params.size() == 4) {
|
||||
nonfungibleData = ParseHex(params[3].get_str());
|
||||
if (nonfungibleData.size() > IGUANA_MAXSCRIPTSIZE) // opret limit
|
||||
if (nonfungibleData.size() > DRAGON_MAXSCRIPTSIZE) // opret limit
|
||||
{
|
||||
ERR_RESULT("Non-fungible data size must be <= " + std::to_string(IGUANA_MAXSCRIPTSIZE));
|
||||
ERR_RESULT("Non-fungible data size must be <= " + std::to_string(DRAGON_MAXSCRIPTSIZE));
|
||||
return(result);
|
||||
}
|
||||
if( nonfungibleData.empty() ) {
|
||||
|
||||
@@ -347,7 +347,7 @@ struct SaplingNoteEntry
|
||||
SaplingOutPoint op;
|
||||
libzcash::SaplingPaymentAddress address;
|
||||
libzcash::SaplingNote note;
|
||||
std::array<unsigned char, ZC_MEMO_SIZE> memo;
|
||||
std::array<unsigned char, HUSH_MEMO_SIZE> memo;
|
||||
int confirmations;
|
||||
};
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ boost::optional<uint256> SaplingNote::nullifier(const SaplingFullViewingKey& vk,
|
||||
// Construct and populate SaplingNotePlaintext for a given note and memo.
|
||||
SaplingNotePlaintext::SaplingNotePlaintext(
|
||||
const SaplingNote& note,
|
||||
std::array<unsigned char, ZC_MEMO_SIZE> memo) : BaseNotePlaintext(note, memo)
|
||||
std::array<unsigned char, HUSH_MEMO_SIZE> memo) : BaseNotePlaintext(note, memo)
|
||||
{
|
||||
d = note.d;
|
||||
rcm = note.r;
|
||||
|
||||
@@ -48,15 +48,15 @@ public:
|
||||
class BaseNotePlaintext {
|
||||
protected:
|
||||
uint64_t value_ = 0;
|
||||
std::array<unsigned char, ZC_MEMO_SIZE> memo_;
|
||||
std::array<unsigned char, HUSH_MEMO_SIZE> memo_;
|
||||
public:
|
||||
BaseNotePlaintext() {}
|
||||
BaseNotePlaintext(const BaseNote& note, std::array<unsigned char, ZC_MEMO_SIZE> memo)
|
||||
BaseNotePlaintext(const BaseNote& note, std::array<unsigned char, HUSH_MEMO_SIZE> memo)
|
||||
: value_(note.value()), memo_(memo) {}
|
||||
virtual ~BaseNotePlaintext() {}
|
||||
|
||||
inline uint64_t value() const { return value_; }
|
||||
inline const std::array<unsigned char, ZC_MEMO_SIZE> & memo() const { return memo_; }
|
||||
inline const std::array<unsigned char, HUSH_MEMO_SIZE> & memo() const { return memo_; }
|
||||
};
|
||||
|
||||
typedef std::pair<SaplingEncCiphertext, SaplingNoteEncryption> SaplingNotePlaintextEncryptionResult;
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
|
||||
SaplingNotePlaintext() {}
|
||||
|
||||
SaplingNotePlaintext(const SaplingNote& note, std::array<unsigned char, ZC_MEMO_SIZE> memo);
|
||||
SaplingNotePlaintext(const SaplingNote& note, std::array<unsigned char, HUSH_MEMO_SIZE> memo);
|
||||
|
||||
static boost::optional<SaplingNotePlaintext> decrypt(
|
||||
const SaplingEncCiphertext &ciphertext,
|
||||
|
||||
@@ -17,14 +17,14 @@
|
||||
#define ZC_V_SIZE 8
|
||||
#define ZC_RHO_SIZE 32
|
||||
#define ZC_R_SIZE 32
|
||||
#define ZC_MEMO_SIZE 512
|
||||
#define HUSH_MEMO_SIZE 512
|
||||
#define ZC_DIVERSIFIER_SIZE 11
|
||||
#define ZC_JUBJUB_POINT_SIZE 32
|
||||
#define ZC_JUBJUB_SCALAR_SIZE 32
|
||||
|
||||
#define ZC_NOTEPLAINTEXT_SIZE (ZC_NOTEPLAINTEXT_LEADING + ZC_V_SIZE + ZC_RHO_SIZE + ZC_R_SIZE + ZC_MEMO_SIZE)
|
||||
#define ZC_NOTEPLAINTEXT_SIZE (ZC_NOTEPLAINTEXT_LEADING + ZC_V_SIZE + ZC_RHO_SIZE + ZC_R_SIZE + HUSH_MEMO_SIZE)
|
||||
|
||||
#define ZC_SAPLING_ENCPLAINTEXT_SIZE (ZC_NOTEPLAINTEXT_LEADING + ZC_DIVERSIFIER_SIZE + ZC_V_SIZE + ZC_R_SIZE + ZC_MEMO_SIZE)
|
||||
#define ZC_SAPLING_ENCPLAINTEXT_SIZE (ZC_NOTEPLAINTEXT_LEADING + ZC_DIVERSIFIER_SIZE + ZC_V_SIZE + ZC_R_SIZE + HUSH_MEMO_SIZE)
|
||||
#define ZC_SAPLING_OUTPLAINTEXT_SIZE (ZC_JUBJUB_POINT_SIZE + ZC_JUBJUB_SCALAR_SIZE)
|
||||
|
||||
#define ZC_SAPLING_ENCCIPHERTEXT_SIZE (ZC_SAPLING_ENCPLAINTEXT_SIZE + NOTEENCRYPTION_AUTH_BYTES)
|
||||
|
||||
@@ -304,7 +304,7 @@ double benchmark_create_sapling_output()
|
||||
auto sk = libzcash::SaplingSpendingKey::random();
|
||||
auto address = sk.default_address();
|
||||
|
||||
std::array<unsigned char, ZC_MEMO_SIZE> memo;
|
||||
std::array<unsigned char, HUSH_MEMO_SIZE> memo;
|
||||
SaplingNote note(address, GetRand(MAX_MONEY));
|
||||
|
||||
libzcash::SaplingNotePlaintext notePlaintext(note, memo);
|
||||
|
||||
Reference in New Issue
Block a user