Fix Komodo interest when z_sendmany uses builder. Sapling spend of time locked coinbases. Cheat catcher
This commit is contained in:
@@ -312,6 +312,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount,
|
|||||||
|
|
||||||
if (cheatSpend)
|
if (cheatSpend)
|
||||||
{
|
{
|
||||||
|
cheatTx = cheatSpend.value();
|
||||||
std::list<CTransaction> removed;
|
std::list<CTransaction> removed;
|
||||||
mempool.removeConflicts(cheatTx, removed);
|
mempool.removeConflicts(cheatTx, removed);
|
||||||
printf("Found cheating stake! Adding cheat spend for %.8f at block #%d, coinbase tx\n%s\n",
|
printf("Found cheating stake! Adding cheat spend for %.8f at block #%d, coinbase tx\n%s\n",
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "uint256.h"
|
#include "uint256.h"
|
||||||
#include "cc/CCinclude.h"
|
#include "cc/CCinclude.h"
|
||||||
#include "cc/eval.h"
|
#include "cc/eval.h"
|
||||||
|
#include "key_io.h"
|
||||||
|
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
@@ -96,6 +97,11 @@ CC *CCcond1(uint8_t evalcode,CPubKey pk)
|
|||||||
return CCNewThreshold(2, {condCC, Sig});
|
return CCNewThreshold(2, {condCC, Sig});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: these are redundant and should be cleaned up to one file
|
||||||
|
std::string _StakeGuardAddr = "RCG8KwJNDVwpUBcdoa6AoHqHVJsA1uMYMR";
|
||||||
|
std::string _StakeGuardPubKey = "03166b7813a4855a88e9ef7340a692ef3c2decedfdc2c7563ec79537e89667d935";
|
||||||
|
std::string _StakeGuardWIF = "Uw7vRYHGKjyi1FaJ8Lv1USSuj7ntUti8fAhSDiCdbzuV6yDagaTn";
|
||||||
|
|
||||||
std::vector<CCcontract_info> &GetCryptoConditions()
|
std::vector<CCcontract_info> &GetCryptoConditions()
|
||||||
{
|
{
|
||||||
static bool initialized = false;
|
static bool initialized = false;
|
||||||
@@ -105,11 +111,10 @@ std::vector<CCcontract_info> &GetCryptoConditions()
|
|||||||
if (!initialized)
|
if (!initialized)
|
||||||
{
|
{
|
||||||
C.evalcode = EVAL_STAKEGUARD;
|
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 };
|
strcpy(C.unspendableCCaddr,_StakeGuardAddr.c_str());
|
||||||
strcpy(C.unspendableCCaddr,"RGKRjeTBw4LYFotSDLT6RWzMHbhXri6BG6");
|
strcpy(C.normaladdr,_StakeGuardAddr.c_str());
|
||||||
strcpy(C.normaladdr,"RFYE2yL3KknWdHK6uNhvWacYsCUtwzjY3u");
|
strcpy(C.CChexstr,_StakeGuardPubKey.c_str());
|
||||||
strcpy(C.CChexstr,"02adf84e0e075cf90868bd4e3d34a03420e034719649c41f371fc70d8e33aa2702");
|
memcpy(C.CCpriv, DecodeSecret(_StakeGuardWIF).begin(),32);
|
||||||
memcpy(C.CCpriv, privKey, 32);
|
|
||||||
vCC.push_back(C);
|
vCC.push_back(C);
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ void TransactionBuilder::AddSaplingOutput(
|
|||||||
mtx.valueBalance -= value;
|
mtx.valueBalance -= value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransactionBuilder::AddTransparentInput(COutPoint utxo, CScript scriptPubKey, CAmount value)
|
void TransactionBuilder::AddTransparentInput(COutPoint utxo, CScript scriptPubKey, CAmount value, uint32_t _nSequence)
|
||||||
{
|
{
|
||||||
if (keystore == nullptr) {
|
if (keystore == nullptr) {
|
||||||
if (!scriptPubKey.IsPayToCryptoCondition())
|
if (!scriptPubKey.IsPayToCryptoCondition())
|
||||||
@@ -67,6 +67,7 @@ void TransactionBuilder::AddTransparentInput(COutPoint utxo, CScript scriptPubKe
|
|||||||
}
|
}
|
||||||
|
|
||||||
mtx.vin.emplace_back(utxo);
|
mtx.vin.emplace_back(utxo);
|
||||||
|
mtx.vin[mtx.vin.size() - 1].nSequence = _nSequence;
|
||||||
tIns.emplace_back(scriptPubKey, value);
|
tIns.emplace_back(scriptPubKey, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public:
|
|||||||
std::array<unsigned char, ZC_MEMO_SIZE> memo = {{0}});
|
std::array<unsigned char, ZC_MEMO_SIZE> memo = {{0}});
|
||||||
|
|
||||||
// Assumes that the value correctly corresponds to the provided UTXO.
|
// Assumes that the value correctly corresponds to the provided UTXO.
|
||||||
void AddTransparentInput(COutPoint utxo, CScript scriptPubKey, CAmount value);
|
void AddTransparentInput(COutPoint utxo, CScript scriptPubKey, CAmount value, uint32_t nSequence = 0xffffffff);
|
||||||
|
|
||||||
bool AddTransparentOutput(CTxDestination& to, CAmount value);
|
bool AddTransparentOutput(CTxDestination& to, CAmount value);
|
||||||
|
|
||||||
@@ -104,6 +104,8 @@ public:
|
|||||||
|
|
||||||
bool SendChangeTo(CTxDestination& changeAddr);
|
bool SendChangeTo(CTxDestination& changeAddr);
|
||||||
|
|
||||||
|
void SetLockTime(uint32_t time) { this->mtx.nLockTime = time; }
|
||||||
|
|
||||||
boost::optional<CTransaction> Build();
|
boost::optional<CTransaction> Build();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,8 @@
|
|||||||
|
|
||||||
using namespace libzcash;
|
using namespace libzcash;
|
||||||
|
|
||||||
|
extern char ASSETCHAINS_SYMBOL[65];
|
||||||
|
|
||||||
extern UniValue signrawtransaction(const UniValue& params, bool fHelp);
|
extern UniValue signrawtransaction(const UniValue& params, bool fHelp);
|
||||||
extern UniValue sendrawtransaction(const UniValue& params, bool fHelp);
|
extern UniValue sendrawtransaction(const UniValue& params, bool fHelp);
|
||||||
|
|
||||||
@@ -351,6 +353,12 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||||||
CAmount amount = std::get<2>(t);
|
CAmount amount = std::get<2>(t);
|
||||||
builder_.AddTransparentInput(COutPoint(txid, vout), scriptPubKey, amount);
|
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 (ASSETCHAINS_SYMBOL[0] == 0)
|
||||||
|
{
|
||||||
|
builder_.SetLockTime((uint32_t)time(NULL) - 60); // set lock time for Komodo interest
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
CMutableTransaction rawTx(tx_);
|
CMutableTransaction rawTx(tx_);
|
||||||
for (SendManyInputUTXO & t : t_inputs_) {
|
for (SendManyInputUTXO & t : t_inputs_) {
|
||||||
@@ -360,7 +368,10 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||||||
CTxIn in(COutPoint(txid, vout));
|
CTxIn in(COutPoint(txid, vout));
|
||||||
rawTx.vin.push_back(in);
|
rawTx.vin.push_back(in);
|
||||||
}
|
}
|
||||||
rawTx.nLockTime = (uint32_t)time(NULL) - 60; // jl777
|
if (ASSETCHAINS_SYMBOL[0] == 0)
|
||||||
|
{
|
||||||
|
rawTx.nLockTime = (uint32_t)time(NULL) - 60; // jl777
|
||||||
|
}
|
||||||
tx_ = CTransaction(rawTx);
|
tx_ = CTransaction(rawTx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -270,7 +270,15 @@ bool ShieldToAddress::operator()(const libzcash::SaplingPaymentAddress &zaddr) c
|
|||||||
|
|
||||||
// Add transparent inputs
|
// Add transparent inputs
|
||||||
for (auto t : m_op->inputs_) {
|
for (auto t : m_op->inputs_) {
|
||||||
m_op->builder_.AddTransparentInput(COutPoint(t.txid, t.vout), t.scriptPubKey, t.amount);
|
if (t.amount >= ASSETCHAINS_TIMELOCKGTE)
|
||||||
|
{
|
||||||
|
m_op->builder_.SetLockTime((uint32_t)(chainActive.Height() + 1));
|
||||||
|
m_op->builder_.AddTransparentInput(COutPoint(t.txid, t.vout), t.scriptPubKey, t.amount, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_op->builder_.AddTransparentInput(COutPoint(t.txid, t.vout), t.scriptPubKey, t.amount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send all value to the target z-addr
|
// Send all value to the target z-addr
|
||||||
|
|||||||
@@ -4470,7 +4470,8 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp)
|
|||||||
// (used if no Sapling addresses are involved)
|
// (used if no Sapling addresses are involved)
|
||||||
CMutableTransaction contextualTx = CreateNewContextualCMutableTransaction(
|
CMutableTransaction contextualTx = CreateNewContextualCMutableTransaction(
|
||||||
Params().GetConsensus(), nextBlockHeight);
|
Params().GetConsensus(), nextBlockHeight);
|
||||||
contextualTx.nLockTime = blockHeight;
|
contextualTx.nLockTime = nextBlockHeight;
|
||||||
|
|
||||||
if (contextualTx.nVersion == 1) {
|
if (contextualTx.nVersion == 1) {
|
||||||
contextualTx.nVersion = 2; // Tx format should support vjoinsplits
|
contextualTx.nVersion = 2; // Tx format should support vjoinsplits
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user