Change name to Stake Guard
This commit is contained in:
@@ -291,8 +291,8 @@ libbitcoin_server_a_SOURCES = \
|
|||||||
cc/CCcustom.cpp \
|
cc/CCcustom.cpp \
|
||||||
cc/CCtx.cpp \
|
cc/CCtx.cpp \
|
||||||
cc/CCutils.cpp \
|
cc/CCutils.cpp \
|
||||||
cc/CoinbaseGuard.cpp \
|
cc/StakeGuard.cpp \
|
||||||
cc/CoinbaseGuard.h \
|
cc/StakeGuard.h \
|
||||||
cc/assets.cpp \
|
cc/assets.cpp \
|
||||||
cc/faucet.cpp \
|
cc/faucet.cpp \
|
||||||
cc/rewards.cpp \
|
cc/rewards.cpp \
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
#include "CCTriggers.h"
|
#include "CCTriggers.h"
|
||||||
#include "CCPayments.h"
|
#include "CCPayments.h"
|
||||||
#include "CCGateways.h"
|
#include "CCGateways.h"
|
||||||
#include "CoinbaseGuard.h"
|
#include "StakeGuard.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
CCcustom has most of the functions that need to be extended to create a new CC contract.
|
CCcustom has most of the functions that need to be extended to create a new CC contract.
|
||||||
@@ -227,12 +227,12 @@ struct CCcontract_info *CCinit(struct CCcontract_info *cp, uint8_t evalcode)
|
|||||||
cp->evalcode = evalcode;
|
cp->evalcode = evalcode;
|
||||||
switch ( evalcode )
|
switch ( evalcode )
|
||||||
{
|
{
|
||||||
case EVAL_COINBASEGUARD:
|
case EVAL_STAKEGUARD:
|
||||||
strcpy(cp->unspendableCCaddr,AssetsCCaddr);
|
strcpy(cp->unspendableCCaddr,AssetsCCaddr);
|
||||||
strcpy(cp->normaladdr,AssetsNormaladdr);
|
strcpy(cp->normaladdr,AssetsNormaladdr);
|
||||||
strcpy(cp->CChexstr,AssetsCChexstr);
|
strcpy(cp->CChexstr,AssetsCChexstr);
|
||||||
memcpy(cp->CCpriv,AssetsCCpriv,32);
|
memcpy(cp->CCpriv,AssetsCCpriv,32);
|
||||||
cp->validate = CoinbaseGuardValidate;
|
cp->validate = StakeGuardValidate;
|
||||||
cp->ismyvin = IsAssetsInput;
|
cp->ismyvin = IsAssetsInput;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "CoinbaseGuard.h"
|
#include "StakeGuard.h"
|
||||||
#include "script/script.h"
|
#include "script/script.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
@@ -184,13 +184,13 @@ bool ValidateStakeTransaction(const CTransaction &stakeTx, CStakeParams &stakePa
|
|||||||
bool MakeGuardedOutput(CAmount value, CPubKey &dest, CTransaction &stakeTx, CTxOut &vout)
|
bool MakeGuardedOutput(CAmount value, CPubKey &dest, CTransaction &stakeTx, CTxOut &vout)
|
||||||
{
|
{
|
||||||
CCcontract_info *cp, C;
|
CCcontract_info *cp, C;
|
||||||
cp = CCinit(&C,EVAL_COINBASEGUARD);
|
cp = CCinit(&C,EVAL_STAKEGUARD);
|
||||||
|
|
||||||
CPubKey ccAddress = CPubKey(ParseHex(cp->CChexstr));
|
CPubKey ccAddress = CPubKey(ParseHex(cp->CChexstr));
|
||||||
|
|
||||||
// return an output that is bound to the stake transaction and can be spent by presenting either a signed condition by the original
|
// return an output that is bound to the stake transaction and can be spent by presenting either a signed condition by the original
|
||||||
// destination address or a properly signed stake transaction of the same utxo on a fork
|
// destination address or a properly signed stake transaction of the same utxo on a fork
|
||||||
vout = MakeCC1of2vout(EVAL_COINBASEGUARD, value, dest, ccAddress);
|
vout = MakeCC1of2vout(EVAL_STAKEGUARD, value, dest, ccAddress);
|
||||||
|
|
||||||
std::vector<CPubKey> vPubKeys = std::vector<CPubKey>();
|
std::vector<CPubKey> vPubKeys = std::vector<CPubKey>();
|
||||||
vPubKeys.push_back(dest);
|
vPubKeys.push_back(dest);
|
||||||
@@ -218,7 +218,7 @@ bool MakeGuardedOutput(CAmount value, CPubKey &dest, CTransaction &stakeTx, CTxO
|
|||||||
}
|
}
|
||||||
vData.push_back(height);
|
vData.push_back(height);
|
||||||
|
|
||||||
COptCCParams ccp = COptCCParams(COptCCParams::VERSION, EVAL_COINBASEGUARD, 1, 2, vPubKeys, vData);
|
COptCCParams ccp = COptCCParams(COptCCParams::VERSION, EVAL_STAKEGUARD, 1, 2, vPubKeys, vData);
|
||||||
|
|
||||||
vout.scriptPubKey << ccp.AsVector() << OP_DROP;
|
vout.scriptPubKey << ccp.AsVector() << OP_DROP;
|
||||||
return true;
|
return true;
|
||||||
@@ -352,12 +352,12 @@ int IsCCFulfilled(CC *cc, ccFulfillmentCheck *ctx)
|
|||||||
return ctx->vCount[0];
|
return ctx->vCount[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CoinbaseGuardValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction &tx, uint32_t nIn)
|
bool StakeGuardValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction &tx, uint32_t nIn)
|
||||||
{
|
{
|
||||||
// This also supports a variable blockstomaturity option for backward feature compatibility
|
// WARNING: this has not been tested combined with time locks
|
||||||
// validate this spend of a transaction with it being past any applicable time lock and one of the following statements being true:
|
// validate this spend of a transaction with it being past any applicable time lock and one of the following statements being true:
|
||||||
// 1. the spend is signed by the original output destination's private key and normal payment requirements, spends as normal
|
// 1. the spend is signed by the original output destination's private key and normal payment requirements, spends as normal
|
||||||
// 2. the spend is signed by the private key of the CoinbaseGuard contract and pushes a signed stake transaction
|
// 2. the spend is signed by the private key of the StakeGuard contract and pushes a signed stake transaction
|
||||||
// with the same exact utxo source, a target block height of later than or equal to this tx, and a different prevBlock hash
|
// with the same exact utxo source, a target block height of later than or equal to this tx, and a different prevBlock hash
|
||||||
|
|
||||||
// first, check to see if the spending contract is signed by the default destination address
|
// first, check to see if the spending contract is signed by the default destination address
|
||||||
@@ -424,7 +424,7 @@ bool CoinbaseGuardValidate(struct CCcontract_info *cp, Eval* eval, const CTransa
|
|||||||
else return true;
|
else return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue CoinbaseGuardInfo()
|
UniValue StakeGuardInfo()
|
||||||
{
|
{
|
||||||
UniValue result(UniValue::VOBJ); char numstr[64];
|
UniValue result(UniValue::VOBJ); char numstr[64];
|
||||||
CMutableTransaction mtx;
|
CMutableTransaction mtx;
|
||||||
@@ -432,10 +432,10 @@ UniValue CoinbaseGuardInfo()
|
|||||||
|
|
||||||
CCcontract_info *cp,C;
|
CCcontract_info *cp,C;
|
||||||
|
|
||||||
cp = CCinit(&C,EVAL_COINBASEGUARD);
|
cp = CCinit(&C,EVAL_STAKEGUARD);
|
||||||
|
|
||||||
result.push_back(Pair("result","success"));
|
result.push_back(Pair("result","success"));
|
||||||
result.push_back(Pair("name","CoinbaseGuard"));
|
result.push_back(Pair("name","StakeGuard"));
|
||||||
|
|
||||||
// all UTXOs to the contract address that are to any of the wallet addresses are to us
|
// all UTXOs to the contract address that are to any of the wallet addresses are to us
|
||||||
// each is spendable as a normal transaction, but the spend may fail if it gets spent out
|
// each is spendable as a normal transaction, but the spend may fail if it gets spent out
|
||||||
@@ -9,8 +9,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CC_COINBASEGUARD_H
|
#ifndef CC_STAKEGUARD_H
|
||||||
#define CC_COINBASEGUARD_H
|
#define CC_STAKEGUARD_H
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -32,8 +32,8 @@ bool MakeGuardedOutput(CAmount value, CPubKey &dest, CTransaction &stakeTx, CTxO
|
|||||||
|
|
||||||
bool MakeCheatEvidence(CMutableTransaction &mtx, const CTransaction &ccTx, uint32_t voutNum, const CTransaction &cheatTx);
|
bool MakeCheatEvidence(CMutableTransaction &mtx, const CTransaction &ccTx, uint32_t voutNum, const CTransaction &cheatTx);
|
||||||
|
|
||||||
bool CoinbaseGuardValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn);
|
bool StakeGuardValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn);
|
||||||
|
|
||||||
UniValue CoinbaseGuardInfo();
|
UniValue StakeGuardInfo();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -83,7 +83,7 @@ bool Eval::Dispatch(const CC *cond, const CTransaction &txTo, unsigned int nIn)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
// only support coinbase guard for now
|
// only support coinbase guard for now
|
||||||
if (ecode == EVAL_COINBASEGUARD)
|
if (ecode == EVAL_STAKEGUARD)
|
||||||
return(ProcessCC(cp,this, vparams, txTo, nIn));
|
return(ProcessCC(cp,this, vparams, txTo, nIn));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
* after the code is interpreted as a bitcoin script.
|
* after the code is interpreted as a bitcoin script.
|
||||||
*/
|
*/
|
||||||
#define FOREACH_EVAL(EVAL) \
|
#define FOREACH_EVAL(EVAL) \
|
||||||
EVAL(EVAL_COINBASEGUARD, 0x1) \
|
EVAL(EVAL_STAKEGUARD, 0x1) \
|
||||||
EVAL(EVAL_IMPORTPAYOUT, 0xe1) \
|
EVAL(EVAL_IMPORTPAYOUT, 0xe1) \
|
||||||
EVAL(EVAL_IMPORTCOIN, 0xe2) \
|
EVAL(EVAL_IMPORTCOIN, 0xe2) \
|
||||||
EVAL(EVAL_ASSETS, 0xe3) \
|
EVAL(EVAL_ASSETS, 0xe3) \
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#include "amount.h"
|
#include "amount.h"
|
||||||
#include "chainparams.h"
|
#include "chainparams.h"
|
||||||
#include "cc/CoinbaseGuard.h"
|
#include "cc/StakeGuard.h"
|
||||||
#include "importcoin.h"
|
#include "importcoin.h"
|
||||||
#include "consensus/consensus.h"
|
#include "consensus/consensus.h"
|
||||||
#include "consensus/upgrades.h"
|
#include "consensus/upgrades.h"
|
||||||
@@ -488,7 +488,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount,
|
|||||||
txNew.vout[0].scriptPubKey = scriptPubKeyIn;
|
txNew.vout[0].scriptPubKey = scriptPubKeyIn;
|
||||||
txNew.vout[0].nValue = GetBlockSubsidy(nHeight,chainparams.GetConsensus()) + nFees;
|
txNew.vout[0].nValue = GetBlockSubsidy(nHeight,chainparams.GetConsensus()) + nFees;
|
||||||
|
|
||||||
// once we get to Sapling, enable CC CoinbaseGuard for stake transactions
|
// once we get to Sapling, enable CC StakeGuard for stake transactions
|
||||||
if (isStake && extendedStake)
|
if (isStake && extendedStake)
|
||||||
{
|
{
|
||||||
// if there is a specific destination, use it
|
// if there is a specific destination, use it
|
||||||
|
|||||||
@@ -49,13 +49,13 @@ void CBlockHeader::SetVerusHash()
|
|||||||
// if it returns false, value is set to 0, but it can still be calculated from the full block
|
// if it returns false, value is set to 0, but it can still be calculated from the full block
|
||||||
// in that case. the only difference between this and the POS hash for the contest is that it is not divided by the value out
|
// in that case. the only difference between this and the POS hash for the contest is that it is not divided by the value out
|
||||||
// this is used as a source of entropy
|
// this is used as a source of entropy
|
||||||
bool CBlockHeader::GetRawVerusPOSHash(uint256 &value, int32_t nHeight) const
|
bool CBlockHeader::GetRawVerusPOSHash(uint256 &ret, int32_t nHeight) const
|
||||||
{
|
{
|
||||||
// if below the required height or no storage space in the solution, we can't get
|
// if below the required height or no storage space in the solution, we can't get
|
||||||
// a cached txid value to calculate the POSHash from the header
|
// a cached txid value to calculate the POSHash from the header
|
||||||
if (!(CPOSNonce::NewNonceActive(nHeight) && IsVerusPOSBlock()))
|
if (!(CPOSNonce::NewNonceActive(nHeight) && IsVerusPOSBlock()))
|
||||||
{
|
{
|
||||||
value = uint256();
|
ret = uint256();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,10 +74,21 @@ bool CBlockHeader::GetRawVerusPOSHash(uint256 &value, int32_t nHeight) const
|
|||||||
hashWriter << ASSETCHAINS_MAGIC;
|
hashWriter << ASSETCHAINS_MAGIC;
|
||||||
hashWriter << nNonce;
|
hashWriter << nNonce;
|
||||||
hashWriter << nHeight;
|
hashWriter << nHeight;
|
||||||
value = hashWriter.GetHash();
|
ret = hashWriter.GetHash();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CBlockHeader::GetVerusPOSHash(arith_uint256 &ret, int32_t nHeight, CAmount value) const
|
||||||
|
{
|
||||||
|
uint256 raw;
|
||||||
|
if (GetRawVerusPOSHash(raw, nHeight))
|
||||||
|
{
|
||||||
|
ret = UintToArith256(raw) / value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// depending on the height of the block and its type, this returns the POS hash or the POW hash
|
// depending on the height of the block and its type, this returns the POS hash or the POW hash
|
||||||
uint256 CBlockHeader::GetVerusEntropyHash(int32_t height) const
|
uint256 CBlockHeader::GetVerusEntropyHash(int32_t height) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -84,8 +84,8 @@ public:
|
|||||||
uint256 GetVerusHash() const;
|
uint256 GetVerusHash() const;
|
||||||
static void SetVerusHash();
|
static void SetVerusHash();
|
||||||
|
|
||||||
bool GetRawVerusPOSHash(uint256 &value, int32_t nHeight) const;
|
bool GetRawVerusPOSHash(uint256 &ret, int32_t nHeight) const;
|
||||||
|
bool GetVerusPOSHash(arith_uint256 &ret, int32_t nHeight, CAmount value) const; // value is amount of stake tx
|
||||||
uint256 GetVerusEntropyHash(int32_t nHeight) const;
|
uint256 GetVerusEntropyHash(int32_t nHeight) const;
|
||||||
|
|
||||||
uint256 GetVerusV2Hash() const;
|
uint256 GetVerusV2Hash() const;
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ std::vector<CCcontract_info> &GetCryptoConditions()
|
|||||||
|
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
{
|
{
|
||||||
C.evalcode = EVAL_COINBASEGUARD;
|
C.evalcode = EVAL_STAKEGUARD;
|
||||||
uint8_t privKey[32] = { 0x9b, 0x17, 0x66, 0xe5, 0x82, 0x66, 0xac, 0xb6, 0xba, 0x43, 0x83, 0x74, 0xf7, 0x63, 0x11, 0x3b, 0xf0, 0xf3, 0x50, 0x6f, 0xd9, 0x6b, 0x67, 0x85, 0xf9, 0x7a, 0xf0, 0x54, 0x4d, 0xb1, 0x30, 0x77 };
|
uint8_t privKey[32] = { 0x9b, 0x17, 0x66, 0xe5, 0x82, 0x66, 0xac, 0xb6, 0xba, 0x43, 0x83, 0x74, 0xf7, 0x63, 0x11, 0x3b, 0xf0, 0xf3, 0x50, 0x6f, 0xd9, 0x6b, 0x67, 0x85, 0xf9, 0x7a, 0xf0, 0x54, 0x4d, 0xb1, 0x30, 0x77 };
|
||||||
strcpy(C.unspendableCCaddr,"RGKRjeTBw4LYFotSDLT6RWzMHbhXri6BG6");
|
strcpy(C.unspendableCCaddr,"RGKRjeTBw4LYFotSDLT6RWzMHbhXri6BG6");
|
||||||
strcpy(C.normaladdr,"RFYE2yL3KknWdHK6uNhvWacYsCUtwzjY3u");
|
strcpy(C.normaladdr,"RFYE2yL3KknWdHK6uNhvWacYsCUtwzjY3u");
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
#include "crypter.h"
|
#include "crypter.h"
|
||||||
#include "coins.h"
|
#include "coins.h"
|
||||||
#include "zcash/zip32.h"
|
#include "zcash/zip32.h"
|
||||||
#include "cc/CoinbaseGuard.h"
|
#include "cc/StakeGuard.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user