VerusStakeTransaction
This commit is contained in:
@@ -5125,9 +5125,9 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
|
||||
return(siglen);
|
||||
}
|
||||
|
||||
int32_t verus_staked(CBlock *pBlock, CMutableTransaction &txNew, uint32_t &nBits, arith_uint256 &hashResult, uint8_t *utxosig)
|
||||
int32_t verus_staked(CBlock *pBlock, CMutableTransaction &txNew, uint32_t &nBits, arith_uint256 &hashResult, uint8_t *utxosig, CPubKey &pk)
|
||||
{
|
||||
return pwalletMain->VerusStakeTransaction(pBlock, txNew, nBits, hashResult, utxosig);
|
||||
return pwalletMain->VerusStakeTransaction(pBlock, txNew, nBits, hashResult, utxosig, pk);
|
||||
}
|
||||
|
||||
int32_t ensure_CCrequirements()
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "crypter.h"
|
||||
#include "coins.h"
|
||||
#include "zcash/zip32.h"
|
||||
#include "cc/CoinbaseGuard.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
@@ -44,6 +45,8 @@ bool fSendFreeTransactions = false;
|
||||
bool fPayAtLeastCustomFee = true;
|
||||
#include "komodo_defs.h"
|
||||
|
||||
extern int32_t USE_EXTERNAL_PUBKEY;
|
||||
extern std::string NOTARY_PUBKEY;
|
||||
extern int32_t KOMODO_EXCHANGEWALLET;
|
||||
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
||||
extern int32_t VERUS_MIN_STAKEAGE;
|
||||
@@ -1245,7 +1248,7 @@ bool CWallet::VerusSelectStakeOutput(CBlock *pBlock, arith_uint256 &hashResult,
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t CWallet::VerusStakeTransaction(CBlock *pBlock, CMutableTransaction &txNew, uint32_t &bnTarget, arith_uint256 &hashResult, uint8_t *utxosig) const
|
||||
int32_t CWallet::VerusStakeTransaction(CBlock *pBlock, CMutableTransaction &txNew, uint32_t &bnTarget, arith_uint256 &hashResult, uint8_t *utxosig, CPubKey pk) const
|
||||
{
|
||||
CTransaction stakeSource;
|
||||
int32_t voutNum, siglen = 0;
|
||||
@@ -1257,6 +1260,9 @@ int32_t CWallet::VerusStakeTransaction(CBlock *pBlock, CMutableTransaction &txNe
|
||||
tipindex = chainActive.LastTip();
|
||||
bool extendedStake = tipindex->GetHeight() >= Params().GetConsensus().vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight;
|
||||
|
||||
if (!extendedStake)
|
||||
pk = CPubKey();
|
||||
|
||||
bnTarget = lwmaGetNextPOSRequired(tipindex, Params().GetConsensus());
|
||||
|
||||
if (!VerusSelectStakeOutput(pBlock, hashResult, stakeSource, voutNum, tipindex->GetHeight() + 1, bnTarget) ||
|
||||
@@ -1278,17 +1284,16 @@ int32_t CWallet::VerusStakeTransaction(CBlock *pBlock, CMutableTransaction &txNe
|
||||
txNew.vin[0].prevout.hash = stakeSource.GetHash();
|
||||
txNew.vin[0].prevout.n = voutNum;
|
||||
|
||||
CPubKey pk = CPubKey();
|
||||
|
||||
if (whichType == TX_PUBKEY)
|
||||
{
|
||||
txNew.vout[0].scriptPubKey << ToByteVector(vSolutions[0]) << OP_CHECKSIG;
|
||||
pk = CPubKey(vSolutions[0]);
|
||||
if (!pk.IsValid())
|
||||
pk = CPubKey(vSolutions[0]);
|
||||
}
|
||||
else if (whichType == TX_PUBKEYHASH)
|
||||
{
|
||||
txNew.vout[0].scriptPubKey << OP_DUP << OP_HASH160 << ToByteVector(vSolutions[0]) << OP_EQUALVERIFY << OP_CHECKSIG;
|
||||
if (extendedStake)
|
||||
if (extendedStake && !pk.IsValid())
|
||||
{
|
||||
// we need a pubkey, so try to get one from the key ID, if not there, fail
|
||||
if (!keystore.GetPubKey(CKeyID(uint160(vSolutions[0])), pk))
|
||||
@@ -1299,7 +1304,7 @@ int32_t CWallet::VerusStakeTransaction(CBlock *pBlock, CMutableTransaction &txNe
|
||||
return 0;
|
||||
|
||||
// if we are staking with the extended format, add the opreturn data required
|
||||
//if (extendedStake)
|
||||
if (extendedStake)
|
||||
{
|
||||
uint256 srcBlock = uint256();
|
||||
CBlockIndex *pSrcIndex;
|
||||
@@ -1314,14 +1319,7 @@ int32_t CWallet::VerusStakeTransaction(CBlock *pBlock, CMutableTransaction &txNe
|
||||
return 0;
|
||||
|
||||
txOut1.scriptPubKey << OP_RETURN
|
||||
<< (int8_t)OPRETTYPE_STAKEPARAMS
|
||||
<< pSrcIndex->GetHeight() << tipindex->GetHeight()
|
||||
<< std::vector<unsigned char>(pBlock->hashPrevBlock.begin(), pBlock->hashPrevBlock.end())
|
||||
<< std::vector<unsigned char>(pk.begin(), pk.end());
|
||||
|
||||
// need to decide how to decide, but then we can add a delegated source here for the coinbase output
|
||||
//if (USE_EXTERNAL_PUBKEY)
|
||||
// txOut1.scriptPubKey << ParseHex(NOTARY_PUBKEY);
|
||||
<< CStakeParams(pSrcIndex->GetHeight(), tipindex->GetHeight(), pBlock->hashPrevBlock, pk).AsVector();
|
||||
}
|
||||
|
||||
nValue = txNew.vout[0].nValue = stakeSource.vout[voutNum].nValue - txfee;
|
||||
|
||||
@@ -1278,7 +1278,7 @@ public:
|
||||
|
||||
// staking functions
|
||||
bool VerusSelectStakeOutput(CBlock *pBlock, arith_uint256 &hashResult, CTransaction &stakeSource, int32_t &voutNum, int32_t nHeight, uint32_t &bnTarget) const;
|
||||
int32_t VerusStakeTransaction(CBlock *pBlock, CMutableTransaction &txNew, uint32_t &bnTarget, arith_uint256 &hashResult, uint8_t *utxosig) const;
|
||||
int32_t VerusStakeTransaction(CBlock *pBlock, CMutableTransaction &txNew, uint32_t &bnTarget, arith_uint256 &hashResult, uint8_t *utxosig, CPubKey pk) const;
|
||||
|
||||
/* Find unspent notes filtered by payment address, min depth and max depth */
|
||||
void GetUnspentFilteredNotes(std::vector<CUnspentSproutNotePlaintextEntry>& sproutEntries,
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "keystore.h"
|
||||
#include "script/script.h"
|
||||
#include "script/standard.h"
|
||||
#include "cc/eval.h"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
@@ -83,6 +84,30 @@ isminetype IsMine(const CKeyStore &keystore, const CScript& _scriptPubKey)
|
||||
break;
|
||||
}
|
||||
|
||||
case TX_CRYPTOCONDITION:
|
||||
{
|
||||
// some crypto conditions we consider "mine" if our address is the first specified
|
||||
// extra address
|
||||
CScript subScript;
|
||||
vector<valtype> vParams;
|
||||
COptCCParams p;
|
||||
if (scriptPubKey.IsPayToCryptoCondition(&subScript, vParams))
|
||||
{
|
||||
if (vParams.size() > 1)
|
||||
{
|
||||
p = COptCCParams(vParams[0]);
|
||||
// if we are the primary output on a coinbase guard, it is ours
|
||||
if (p.IsValid() && p.evalCode == EVAL_COINBASEGUARD && vParams[1].size() == 20)
|
||||
{
|
||||
CKeyID adr = CKeyID(uint160(vParams[1]));
|
||||
if (keystore.HaveKey(keyID))
|
||||
return ISMINE_SPENDABLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case TX_MULTISIG:
|
||||
{
|
||||
// Only consider transactions "mine" if we own ALL the
|
||||
|
||||
Reference in New Issue
Block a user