Merge branch 'dev' into sietch
Conflicts: src/coins.cpp
This commit is contained in:
@@ -50,7 +50,7 @@ int32_t komodo_blockheight(uint256 hash);
|
||||
|
||||
using namespace libzcash;
|
||||
|
||||
extern UniValue sendrawtransaction(const UniValue& params, bool fHelp);
|
||||
extern UniValue sendrawtransaction(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
|
||||
int mta_find_output(UniValue obj, int n)
|
||||
{
|
||||
@@ -403,7 +403,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
||||
if (!testmode) {
|
||||
UniValue params = UniValue(UniValue::VARR);
|
||||
params.push_back(signedtxn);
|
||||
UniValue sendResultValue = sendrawtransaction(params, false);
|
||||
UniValue sendResultValue = sendrawtransaction(params, false, CPubKey());
|
||||
if (sendResultValue.isNull()) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "sendrawtransaction did not return an error or a txid.");
|
||||
}
|
||||
@@ -780,7 +780,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
||||
}
|
||||
|
||||
|
||||
extern UniValue signrawtransaction(const UniValue& params, bool fHelp);
|
||||
extern UniValue signrawtransaction(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
|
||||
/**
|
||||
* Sign and send a raw transaction.
|
||||
@@ -797,7 +797,7 @@ void AsyncRPCOperation_mergetoaddress::sign_send_raw_transaction(UniValue obj)
|
||||
|
||||
UniValue params = UniValue(UniValue::VARR);
|
||||
params.push_back(rawtxn);
|
||||
UniValue signResultValue = signrawtransaction(params, false);
|
||||
UniValue signResultValue = signrawtransaction(params, false, CPubKey());
|
||||
UniValue signResultObject = signResultValue.get_obj();
|
||||
UniValue completeValue = find_value(signResultObject, "complete");
|
||||
bool complete = completeValue.get_bool();
|
||||
@@ -817,7 +817,7 @@ void AsyncRPCOperation_mergetoaddress::sign_send_raw_transaction(UniValue obj)
|
||||
params.clear();
|
||||
params.setArray();
|
||||
params.push_back(signedtxn);
|
||||
UniValue sendResultValue = sendrawtransaction(params, false);
|
||||
UniValue sendResultValue = sendrawtransaction(params, false, CPubKey());
|
||||
if (sendResultValue.isNull()) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Send raw transaction did not return an error or a txid.");
|
||||
}
|
||||
|
||||
@@ -57,8 +57,9 @@ extern char ASSETCHAINS_SYMBOL[65];
|
||||
int32_t komodo_dpowconfs(int32_t height,int32_t numconfs);
|
||||
int32_t komodo_blockheight(uint256 hash);
|
||||
int tx_height( const uint256 &hash );
|
||||
extern UniValue signrawtransaction(const UniValue& params, bool fHelp);
|
||||
extern UniValue sendrawtransaction(const UniValue& params, bool fHelp);
|
||||
bool hush_hardfork_active(uint32_t time);
|
||||
extern UniValue signrawtransaction(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue sendrawtransaction(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
|
||||
int find_output(UniValue obj, int n) {
|
||||
UniValue outputMapValue = find_value(obj, "outputmap");
|
||||
@@ -375,7 +376,11 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
||||
// locktime to spend time locked coinbases
|
||||
if (ASSETCHAINS_SYMBOL[0] == 0)
|
||||
{
|
||||
builder_.SetLockTime((uint32_t)time(NULL) - 60); // set lock time for Komodo interest
|
||||
//if ((uint32_t)chainActive.LastTip()->nTime < ASSETCHAINS_STAKED_HF_TIMESTAMP)
|
||||
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());
|
||||
}
|
||||
} else {
|
||||
CMutableTransaction rawTx(tx_);
|
||||
@@ -388,7 +393,11 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
||||
}
|
||||
if (ASSETCHAINS_SYMBOL[0] == 0)
|
||||
{
|
||||
rawTx.nLockTime = (uint32_t)time(NULL) - 60; // jl777
|
||||
//if ((uint32_t)chainActive.LastTip()->nTime < ASSETCHAINS_STAKED_HF_TIMESTAMP)
|
||||
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();
|
||||
}
|
||||
tx_ = CTransaction(rawTx);
|
||||
}
|
||||
@@ -521,7 +530,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
||||
if (!testmode) {
|
||||
UniValue params = UniValue(UniValue::VARR);
|
||||
params.push_back(signedtxn);
|
||||
UniValue sendResultValue = sendrawtransaction(params, false);
|
||||
UniValue sendResultValue = sendrawtransaction(params, false, CPubKey());
|
||||
if (sendResultValue.isNull()) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "sendrawtransaction did not return an error or a txid.");
|
||||
}
|
||||
@@ -590,7 +599,12 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
||||
CMutableTransaction mtx(tx_);
|
||||
crypto_sign_keypair(joinSplitPubKey_.begin(), joinSplitPrivKey_);
|
||||
mtx.joinSplitPubKey = joinSplitPubKey_;
|
||||
mtx.nLockTime = (uint32_t)time(NULL) - 60; // jl777
|
||||
//if ((uint32_t)chainActive.LastTip()->nTime < ASSETCHAINS_STAKED_HF_TIMESTAMP)
|
||||
if ( !hush_hardfork_active((uint32_t)chainActive.LastTip()->nTime) )
|
||||
mtx.nLockTime = (uint32_t)time(NULL) - 60; // jl777
|
||||
else
|
||||
mtx.nLockTime = (uint32_t)chainActive.Tip()->GetMedianTimePast();
|
||||
|
||||
tx_ = CTransaction(mtx);
|
||||
|
||||
// Copy zinputs and zoutputs to more flexible containers
|
||||
@@ -983,7 +997,7 @@ void AsyncRPCOperation_sendmany::sign_send_raw_transaction(UniValue obj)
|
||||
|
||||
UniValue params = UniValue(UniValue::VARR);
|
||||
params.push_back(rawtxn);
|
||||
UniValue signResultValue = signrawtransaction(params, false);
|
||||
UniValue signResultValue = signrawtransaction(params, false, CPubKey());
|
||||
UniValue signResultObject = signResultValue.get_obj();
|
||||
UniValue completeValue = find_value(signResultObject, "complete");
|
||||
bool complete = completeValue.get_bool();
|
||||
@@ -1003,7 +1017,7 @@ void AsyncRPCOperation_sendmany::sign_send_raw_transaction(UniValue obj)
|
||||
params.clear();
|
||||
params.setArray();
|
||||
params.push_back(signedtxn);
|
||||
UniValue sendResultValue = sendrawtransaction(params, false);
|
||||
UniValue sendResultValue = sendrawtransaction(params, false, CPubKey());
|
||||
if (sendResultValue.isNull()) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Send raw transaction did not return an error or a txid.");
|
||||
}
|
||||
@@ -1361,7 +1375,12 @@ void AsyncRPCOperation_sendmany::add_taddr_outputs_to_tx() {
|
||||
CTxOut out(nAmount, scriptPubKey);
|
||||
rawTx.vout.push_back(out);
|
||||
}
|
||||
rawTx.nLockTime = (uint32_t)time(NULL) - 60; // jl777
|
||||
//if ((uint32_t)chainActive.LastTip()->nTime < ASSETCHAINS_STAKED_HF_TIMESTAMP)
|
||||
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();
|
||||
|
||||
tx_ = CTransaction(rawTx);
|
||||
}
|
||||
|
||||
@@ -1387,7 +1406,11 @@ void AsyncRPCOperation_sendmany::add_taddr_change_output_to_tx(CBitcoinAddress *
|
||||
|
||||
CMutableTransaction rawTx(tx_);
|
||||
rawTx.vout.push_back(out);
|
||||
rawTx.nLockTime = (uint32_t)time(NULL) - 60; // jl777
|
||||
//if ((uint32_t)chainActive.LastTip()->nTime < ASSETCHAINS_STAKED_HF_TIMESTAMP)
|
||||
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();
|
||||
tx_ = CTransaction(rawTx);
|
||||
}
|
||||
|
||||
|
||||
@@ -265,8 +265,8 @@ bool ShieldToAddress::operator()(const libzcash::SproutPaymentAddress &zaddr) co
|
||||
}
|
||||
|
||||
|
||||
extern UniValue signrawtransaction(const UniValue& params, bool fHelp);
|
||||
extern UniValue sendrawtransaction(const UniValue& params, bool fHelp);
|
||||
extern UniValue signrawtransaction(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
extern UniValue sendrawtransaction(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||
|
||||
bool ShieldToAddress::operator()(const libzcash::SaplingPaymentAddress &zaddr) const {
|
||||
m_op->builder_.SetFee(m_op->fee_);
|
||||
@@ -312,7 +312,7 @@ bool ShieldToAddress::operator()(const libzcash::SaplingPaymentAddress &zaddr) c
|
||||
if (!m_op->testmode) {
|
||||
UniValue params = UniValue(UniValue::VARR);
|
||||
params.push_back(signedtxn);
|
||||
UniValue sendResultValue = sendrawtransaction(params, false);
|
||||
UniValue sendResultValue = sendrawtransaction(params, false, CPubKey());
|
||||
if (sendResultValue.isNull()) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "sendrawtransaction did not return an error or a txid.");
|
||||
}
|
||||
@@ -354,7 +354,7 @@ void AsyncRPCOperation_shieldcoinbase::sign_send_raw_transaction(UniValue obj)
|
||||
|
||||
UniValue params = UniValue(UniValue::VARR);
|
||||
params.push_back(rawtxn);
|
||||
UniValue signResultValue = signrawtransaction(params, false);
|
||||
UniValue signResultValue = signrawtransaction(params, false, CPubKey());
|
||||
UniValue signResultObject = signResultValue.get_obj();
|
||||
UniValue completeValue = find_value(signResultObject, "complete");
|
||||
bool complete = completeValue.get_bool();
|
||||
@@ -374,7 +374,7 @@ void AsyncRPCOperation_shieldcoinbase::sign_send_raw_transaction(UniValue obj)
|
||||
params.clear();
|
||||
params.setArray();
|
||||
params.push_back(signedtxn);
|
||||
UniValue sendResultValue = sendrawtransaction(params, false);
|
||||
UniValue sendResultValue = sendrawtransaction(params, false, CPubKey());
|
||||
if (sendResultValue.isNull()) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Send raw transaction did not return an error or a txid.");
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ bool EnsureWalletIsAvailable(bool avoidException);
|
||||
/**
|
||||
* RPC call to generate a payment disclosure
|
||||
*/
|
||||
UniValue z_getpaymentdisclosure(const UniValue& params, bool fHelp)
|
||||
UniValue z_getpaymentdisclosure(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
@@ -158,7 +158,7 @@ UniValue z_getpaymentdisclosure(const UniValue& params, bool fHelp)
|
||||
/**
|
||||
* RPC call to validate a payment disclosure data blob.
|
||||
*/
|
||||
UniValue z_validatepaymentdisclosure(const UniValue& params, bool fHelp)
|
||||
UniValue z_validatepaymentdisclosure(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2019-2020 The Hush developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -89,7 +90,7 @@ std::string DecodeDumpString(const std::string &str) {
|
||||
return ret.str();
|
||||
}
|
||||
|
||||
UniValue convertpassphrase(const UniValue& params, bool fHelp)
|
||||
UniValue convertpassphrase(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
if (fHelp || params.size() < 1 || params.size() > 1)
|
||||
throw runtime_error(
|
||||
@@ -148,17 +149,17 @@ UniValue convertpassphrase(const UniValue& params, bool fHelp)
|
||||
return ret;
|
||||
}
|
||||
|
||||
UniValue importprivkey(const UniValue& params, bool fHelp)
|
||||
UniValue importprivkey(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
if (fHelp || params.size() < 1 || params.size() > 5)
|
||||
throw runtime_error(
|
||||
"importprivkey \"komodoprivkey\" ( \"label\" rescan height secret_key)\n"
|
||||
"importprivkey \"hushprivkey\" ( \"label\" rescan height secret_key)\n"
|
||||
"\nAdds a private key (as returned by dumpprivkey) to your wallet.\n"
|
||||
"\nArguments:\n"
|
||||
"1. \"komodoprivkey\" (string, required) The private key (see dumpprivkey)\n"
|
||||
"1. \"hushprivkey\" (string, required) The private key (see dumpprivkey)\n"
|
||||
"2. \"label\" (string, optional, default=\"\") An optional label\n"
|
||||
"3. rescan (boolean, optional, default=true) Rescan the wallet for transactions\n"
|
||||
"4. height (integer, optional, default=0) start at block height?\n"
|
||||
@@ -244,7 +245,7 @@ UniValue importprivkey(const UniValue& params, bool fHelp)
|
||||
return EncodeDestination(vchAddress);
|
||||
}
|
||||
|
||||
UniValue importaddress(const UniValue& params, bool fHelp)
|
||||
UniValue importaddress(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
@@ -278,7 +279,7 @@ UniValue importaddress(const UniValue& params, bool fHelp)
|
||||
std::vector<unsigned char> data(ParseHex(params[0].get_str()));
|
||||
script = CScript(data.begin(), data.end());
|
||||
} else {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Komodo address or script");
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Hush address or script");
|
||||
}
|
||||
|
||||
string strLabel = "";
|
||||
@@ -317,47 +318,57 @@ UniValue importaddress(const UniValue& params, bool fHelp)
|
||||
return NullUniValue;
|
||||
}
|
||||
|
||||
UniValue z_importwallet(const UniValue& params, bool fHelp)
|
||||
UniValue z_importwallet(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
if (fHelp || params.size() != 1)
|
||||
if (fHelp || params.size() < 1 || params.size() > 2)
|
||||
throw runtime_error(
|
||||
"z_importwallet \"filename\"\n"
|
||||
"\nImports taddr and zaddr keys from a wallet export file (see z_exportwallet).\n"
|
||||
"\nArguments:\n"
|
||||
"1. \"filename\" (string, required) The wallet file\n"
|
||||
"2. rescan (boolean, optional, default=yes) Rescan the wallet for transactions\n"
|
||||
"\nExamples:\n"
|
||||
"\nDump the wallet\n"
|
||||
+ HelpExampleCli("z_exportwallet", "\"nameofbackup\"") +
|
||||
"\nImport the wallet\n"
|
||||
+ HelpExampleCli("z_importwallet", "\"path/to/exportdir/nameofbackup\"") +
|
||||
"\nImport using the json rpc call\n"
|
||||
+ HelpExampleRpc("z_importwallet", "\"path/to/exportdir/nameofbackup\"")
|
||||
+ HelpExampleRpc("z_importwallet", "\"path/to/exportdir/nameofbackup\"")+
|
||||
"\nImport the wallet without rescan\n"
|
||||
+ HelpExampleCli("z_importwallet", "\"path/to/exportdir/nameofbackup\" no ")+
|
||||
"\nImport without Rescan using the json rpc call\n"
|
||||
+ HelpExampleRpc("z_importwallet", "\"path/to/exportdir/nameofbackup\" no")
|
||||
);
|
||||
|
||||
return importwallet_impl(params, fHelp, true);
|
||||
}
|
||||
|
||||
UniValue importwallet(const UniValue& params, bool fHelp)
|
||||
UniValue importwallet(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
|
||||
if (fHelp || params.size() != 1)
|
||||
if (fHelp || params.size() < 1 || params.size() > 2)
|
||||
throw runtime_error(
|
||||
"importwallet \"filename\"\n"
|
||||
"\nImports taddr keys from a wallet dump file (see dumpwallet).\n"
|
||||
"\nArguments:\n"
|
||||
"1. \"filename\" (string, required) The wallet file\n"
|
||||
"2. rescan (boolean, optional, default=true) Rescan the wallet for transactions\n"
|
||||
"\nExamples:\n"
|
||||
"\nDump the wallet\n"
|
||||
+ HelpExampleCli("dumpwallet", "\"nameofbackup\"") +
|
||||
"\nImport the wallet\n"
|
||||
+ HelpExampleCli("importwallet", "\"path/to/exportdir/nameofbackup\"") +
|
||||
"\nImport using the json rpc call\n"
|
||||
+ HelpExampleRpc("importwallet", "\"path/to/exportdir/nameofbackup\"")
|
||||
+ HelpExampleRpc("importwallet", "\"path/to/exportdir/nameofbackup\"")+
|
||||
"\nImport the wallet without rescan\n"
|
||||
+ HelpExampleCli("importwallet", "\"path/to/exportdir/nameofbackup\" no ")+
|
||||
"\nImport without Rescan using the json rpc call\n"
|
||||
+ HelpExampleRpc("importwallet", "\"path/to/exportdir/nameofbackup\" no ")
|
||||
);
|
||||
|
||||
return importwallet_impl(params, fHelp, false);
|
||||
@@ -394,7 +405,7 @@ UniValue importwallet_impl(const UniValue& params, bool fHelp, bool fImportZKeys
|
||||
if (vstr.size() < 2)
|
||||
continue;
|
||||
|
||||
// Let's see if the address is a valid Zcash spending key
|
||||
// Let's see if the address is a valid Hush spending key
|
||||
if (fImportZKeys) {
|
||||
auto spendingkey = DecodeSpendingKey(vstr[0]);
|
||||
int64_t nTime = DecodeDumpTime(vstr[1]);
|
||||
@@ -413,7 +424,7 @@ UniValue importwallet_impl(const UniValue& params, bool fHelp, bool fImportZKeys
|
||||
continue;
|
||||
} else {
|
||||
LogPrint("zrpc", "Importing detected an error: invalid spending key. Trying as a transparent key...\n");
|
||||
// Not a valid spending key, so carry on and see if it's a Zcash style t-address.
|
||||
// Not a valid spending key, so carry on and see if it's a Hush transparent address
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,24 +466,48 @@ UniValue importwallet_impl(const UniValue& params, bool fHelp, bool fImportZKeys
|
||||
file.close();
|
||||
pwalletMain->ShowProgress("", 100); // hide progress dialog in GUI
|
||||
|
||||
CBlockIndex *pindex = chainActive.LastTip();
|
||||
while (pindex && pindex->pprev && pindex->GetBlockTime() > nTimeBegin - 7200)
|
||||
pindex = pindex->pprev;
|
||||
bool fRescan = true;
|
||||
if (params.size() > 1){
|
||||
auto rescan = params[1].get_str();
|
||||
if (rescan.compare("yes") == 0) {
|
||||
fRescan = true;
|
||||
} else if (rescan.compare("no") == 0) {
|
||||
fRescan = false;
|
||||
} else { // Handle older API
|
||||
UniValue jVal;
|
||||
if (!jVal.read(std::string("[")+rescan+std::string("]")) ||
|
||||
!jVal.isArray() || jVal.size()!=1 || !jVal[0].isBool()) {
|
||||
throw JSONRPCError(
|
||||
RPC_INVALID_PARAMETER,
|
||||
"rescan must be \"yes\", \"no\"");
|
||||
}
|
||||
fRescan = jVal[0].getBool();
|
||||
}
|
||||
}
|
||||
|
||||
if (!pwalletMain->nTimeFirstKey || nTimeBegin < pwalletMain->nTimeFirstKey)
|
||||
pwalletMain->nTimeFirstKey = nTimeBegin;
|
||||
if (fRescan) {
|
||||
CBlockIndex *pindex = chainActive.LastTip();
|
||||
while (pindex && pindex->pprev && pindex->GetBlockTime() > nTimeBegin - 7200)
|
||||
pindex = pindex->pprev;
|
||||
|
||||
LogPrintf("Rescanning last %i blocks\n", chainActive.Height() - pindex->GetHeight() + 1);
|
||||
pwalletMain->ScanForWalletTransactions(pindex);
|
||||
pwalletMain->MarkDirty();
|
||||
LogPrintf("Rescanning last %i blocks\n", chainActive.Height() - pindex->GetHeight() + 1);
|
||||
if (!pwalletMain->nTimeFirstKey || nTimeBegin < pwalletMain->nTimeFirstKey)
|
||||
pwalletMain->nTimeFirstKey = nTimeBegin;
|
||||
pwalletMain->ScanForWalletTransactions(pindex);
|
||||
pwalletMain->MarkDirty();
|
||||
|
||||
if (!fGood)
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding some keys to wallet");
|
||||
if (!fGood)
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding some keys to wallet");
|
||||
|
||||
return NullUniValue;
|
||||
return NullUniValue; }
|
||||
|
||||
else{
|
||||
LogPrintf("Importwallet without Rescan successfull\n");
|
||||
return NullUniValue;}
|
||||
}
|
||||
|
||||
UniValue dumpprivkey(const UniValue& params, bool fHelp)
|
||||
|
||||
UniValue dumpprivkey(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
@@ -514,7 +549,7 @@ UniValue dumpprivkey(const UniValue& params, bool fHelp)
|
||||
|
||||
|
||||
|
||||
UniValue z_exportwallet(const UniValue& params, bool fHelp)
|
||||
UniValue z_exportwallet(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
@@ -524,7 +559,7 @@ UniValue z_exportwallet(const UniValue& params, bool fHelp)
|
||||
"z_exportwallet \"filename\"\n"
|
||||
"\nExports all wallet keys, for taddr and zaddr, in a human-readable format. Overwriting an existing file is not permitted.\n"
|
||||
"\nArguments:\n"
|
||||
"1. \"filename\" (string, required) The filename, saved in folder set by komodod -exportdir option\n"
|
||||
"1. \"filename\" (string, required) The filename, saved in folder set by hushd -exportdir option\n"
|
||||
"\nResult:\n"
|
||||
"\"path\" (string) The full path of the destination file\n"
|
||||
"\nExamples:\n"
|
||||
@@ -535,7 +570,7 @@ UniValue z_exportwallet(const UniValue& params, bool fHelp)
|
||||
return dumpwallet_impl(params, fHelp, true);
|
||||
}
|
||||
|
||||
UniValue dumpwallet(const UniValue& params, bool fHelp)
|
||||
UniValue dumpwallet(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
@@ -545,7 +580,7 @@ UniValue dumpwallet(const UniValue& params, bool fHelp)
|
||||
"dumpwallet \"filename\"\n"
|
||||
"\nDumps taddr wallet keys in a human-readable format. Overwriting an existing file is not permitted.\n"
|
||||
"\nArguments:\n"
|
||||
"1. \"filename\" (string, required) The filename, saved in folder set by komodod -exportdir option\n"
|
||||
"1. \"filename\" (string, required) The filename, saved in folder set by hushd -exportdir option\n"
|
||||
"\nResult:\n"
|
||||
"\"path\" (string) The full path of the destination file\n"
|
||||
"\nExamples:\n"
|
||||
@@ -569,7 +604,7 @@ UniValue dumpwallet_impl(const UniValue& params, bool fHelp, bool fDumpZKeys)
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, e.what());
|
||||
}
|
||||
if (exportdir.empty()) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Cannot export wallet until the komodod -exportdir option has been set");
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Cannot export wallet until the hushd -exportdir option has been set");
|
||||
}
|
||||
std::string unclean = params[0].get_str();
|
||||
std::string clean = SanitizeFilename(unclean);
|
||||
@@ -601,7 +636,7 @@ UniValue dumpwallet_impl(const UniValue& params, bool fHelp, bool fDumpZKeys)
|
||||
std::sort(vKeyBirth.begin(), vKeyBirth.end());
|
||||
|
||||
// produce output
|
||||
file << strprintf("# Wallet dump created by Komodo %s (%s)\n", CLIENT_BUILD, CLIENT_DATE);
|
||||
file << strprintf("# Wallet dump created by Hush %s (%s)\n", CLIENT_BUILD, CLIENT_DATE);
|
||||
file << strprintf("# * Created on %s\n", EncodeDumpTime(GetTime()));
|
||||
file << strprintf("# * Best block at time of backup was %i (%s),\n", chainActive.Height(), chainActive.Tip()->GetBlockHash().ToString());
|
||||
file << strprintf("# mined on %s\n", EncodeDumpTime(chainActive.Tip()->GetBlockTime()));
|
||||
@@ -672,7 +707,7 @@ UniValue dumpwallet_impl(const UniValue& params, bool fHelp, bool fDumpZKeys)
|
||||
}
|
||||
|
||||
|
||||
UniValue z_importkey(const UniValue& params, bool fHelp)
|
||||
UniValue z_importkey(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
@@ -763,7 +798,7 @@ UniValue z_importkey(const UniValue& params, bool fHelp)
|
||||
return NullUniValue;
|
||||
}
|
||||
|
||||
UniValue z_importviewingkey(const UniValue& params, bool fHelp)
|
||||
UniValue z_importviewingkey(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
@@ -881,7 +916,7 @@ UniValue z_importviewingkey(const UniValue& params, bool fHelp)
|
||||
return NullUniValue;
|
||||
}
|
||||
|
||||
UniValue z_exportkey(const UniValue& params, bool fHelp)
|
||||
UniValue z_exportkey(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
@@ -920,7 +955,7 @@ UniValue z_exportkey(const UniValue& params, bool fHelp)
|
||||
return EncodeSpendingKey(sk.get());
|
||||
}
|
||||
|
||||
UniValue z_exportviewingkey(const UniValue& params, bool fHelp)
|
||||
UniValue z_exportviewingkey(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
return NullUniValue;
|
||||
@@ -992,10 +1027,12 @@ UniValue NSPV_spentinfo(uint256 txid,int32_t vout);
|
||||
UniValue NSPV_notarizations(int32_t height);
|
||||
UniValue NSPV_hdrsproof(int32_t prevheight,int32_t nextheight);
|
||||
UniValue NSPV_txproof(int32_t vout,uint256 txid,int32_t height);
|
||||
UniValue NSPV_ccmoduleutxos(char *coinaddr, int64_t amount, uint8_t evalcode, std::string funcids, uint256 filtertxid);
|
||||
|
||||
uint256 Parseuint256(const char *hexstr);
|
||||
extern std::string NSPV_address;
|
||||
|
||||
UniValue nspv_getinfo(const UniValue& params, bool fHelp)
|
||||
UniValue nspv_getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
int32_t reqht = 0;
|
||||
if ( fHelp || params.size() > 1 )
|
||||
@@ -1007,7 +1044,7 @@ UniValue nspv_getinfo(const UniValue& params, bool fHelp)
|
||||
return(NSPV_getinfo_req(reqht));
|
||||
}
|
||||
|
||||
UniValue nspv_logout(const UniValue& params, bool fHelp)
|
||||
UniValue nspv_logout(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
if ( fHelp || params.size() != 0 )
|
||||
throw runtime_error("nspv_logout\n");
|
||||
@@ -1016,7 +1053,7 @@ UniValue nspv_logout(const UniValue& params, bool fHelp)
|
||||
return(NSPV_logout());
|
||||
}
|
||||
|
||||
UniValue nspv_login(const UniValue& params, bool fHelp)
|
||||
UniValue nspv_login(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
if ( fHelp || params.size() != 1 )
|
||||
throw runtime_error("nspv_login wif\n");
|
||||
@@ -1025,7 +1062,7 @@ UniValue nspv_login(const UniValue& params, bool fHelp)
|
||||
return(NSPV_login((char *)params[0].get_str().c_str()));
|
||||
}
|
||||
|
||||
UniValue nspv_listunspent(const UniValue& params, bool fHelp)
|
||||
UniValue nspv_listunspent(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
int32_t skipcount = 0,CCflag = 0;
|
||||
if ( fHelp || params.size() > 3 )
|
||||
@@ -1049,7 +1086,7 @@ UniValue nspv_listunspent(const UniValue& params, bool fHelp)
|
||||
else throw runtime_error("nspv_listunspent [address [isCC [skipcount]]]\n");
|
||||
}
|
||||
|
||||
UniValue nspv_mempool(const UniValue& params, bool fHelp)
|
||||
UniValue nspv_mempool(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
int32_t vout = 0,CCflag = 0; uint256 txid; uint8_t funcid; char *coinaddr;
|
||||
memset(&txid,0,sizeof(txid));
|
||||
@@ -1070,7 +1107,7 @@ UniValue nspv_mempool(const UniValue& params, bool fHelp)
|
||||
return(NSPV_mempooltxids(coinaddr,CCflag,funcid,txid,vout));
|
||||
}
|
||||
|
||||
UniValue nspv_listtransactions(const UniValue& params, bool fHelp)
|
||||
UniValue nspv_listtransactions(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
int32_t skipcount = 0,CCflag = 0;
|
||||
if ( fHelp || params.size() > 3 )
|
||||
@@ -1095,7 +1132,7 @@ UniValue nspv_listtransactions(const UniValue& params, bool fHelp)
|
||||
else throw runtime_error("nspv_listtransactions [address [isCC [skipcount]]]\n");
|
||||
}
|
||||
|
||||
UniValue nspv_spentinfo(const UniValue& params, bool fHelp)
|
||||
UniValue nspv_spentinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
uint256 txid; int32_t vout;
|
||||
if ( fHelp || params.size() != 2 )
|
||||
@@ -1107,7 +1144,7 @@ UniValue nspv_spentinfo(const UniValue& params, bool fHelp)
|
||||
return(NSPV_spentinfo(txid,vout));
|
||||
}
|
||||
|
||||
UniValue nspv_notarizations(const UniValue& params, bool fHelp)
|
||||
UniValue nspv_notarizations(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
int32_t height;
|
||||
if ( fHelp || params.size() != 1 )
|
||||
@@ -1118,7 +1155,7 @@ UniValue nspv_notarizations(const UniValue& params, bool fHelp)
|
||||
return(NSPV_notarizations(height));
|
||||
}
|
||||
|
||||
UniValue nspv_hdrsproof(const UniValue& params, bool fHelp)
|
||||
UniValue nspv_hdrsproof(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
int32_t prevheight,nextheight;
|
||||
if ( fHelp || params.size() != 2 )
|
||||
@@ -1130,7 +1167,7 @@ UniValue nspv_hdrsproof(const UniValue& params, bool fHelp)
|
||||
return(NSPV_hdrsproof(prevheight,nextheight));
|
||||
}
|
||||
|
||||
UniValue nspv_txproof(const UniValue& params, bool fHelp)
|
||||
UniValue nspv_txproof(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
uint256 txid; int32_t height;
|
||||
if ( fHelp || params.size() != 2 )
|
||||
@@ -1142,7 +1179,7 @@ UniValue nspv_txproof(const UniValue& params, bool fHelp)
|
||||
return(NSPV_txproof(0,txid,height));
|
||||
}
|
||||
|
||||
UniValue nspv_spend(const UniValue& params, bool fHelp)
|
||||
UniValue nspv_spend(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
uint64_t satoshis;
|
||||
if ( fHelp || params.size() != 2 )
|
||||
@@ -1158,7 +1195,7 @@ UniValue nspv_spend(const UniValue& params, bool fHelp)
|
||||
return(NSPV_spend((char *)NSPV_address.c_str(),(char *)params[0].get_str().c_str(),satoshis));
|
||||
}
|
||||
|
||||
UniValue nspv_broadcast(const UniValue& params, bool fHelp)
|
||||
UniValue nspv_broadcast(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
if ( fHelp || params.size() != 1 )
|
||||
throw runtime_error("nspv_broadcast hex\n");
|
||||
@@ -1166,3 +1203,23 @@ UniValue nspv_broadcast(const UniValue& params, bool fHelp)
|
||||
throw runtime_error("-nSPV=1 must be set to use nspv\n");
|
||||
return(NSPV_broadcast((char *)params[0].get_str().c_str()));
|
||||
}
|
||||
|
||||
UniValue nspv_listccmoduleunspent(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||
{
|
||||
int32_t skipcount = 0, CCflag = 0;
|
||||
if (fHelp || params.size() != 5)
|
||||
throw runtime_error("nspv_listccmoduleunspent address amount evalcode funcids txid\n\n"
|
||||
"returns utxos from the address, filtered by evalcode funcids and txid in opret.\n"
|
||||
"if amount is 0 just returns no utxos and available total.\n"
|
||||
"funcids is a string of funcid symbols. The first symbol is considered as the creation funcid, so the txid param will be compared to the creation tx id.\n"
|
||||
"For the second+ funcids the txid param will be compared to txid in opreturn\n\n" );
|
||||
if (KOMODO_NSPV_FULLNODE)
|
||||
throw runtime_error("-nSPV=1 must be set to use nspv\n");
|
||||
|
||||
std::string address = params[0].get_str().c_str();
|
||||
int64_t amount = atof(params[1].get_str().c_str());
|
||||
uint8_t evalcode = atoi(params[2].get_str().c_str());
|
||||
std::string funcids = params[3].get_str().c_str();
|
||||
uint256 txid = Parseuint256( params[4].get_str().c_str() );
|
||||
return(NSPV_ccmoduleutxos((char*)address.c_str(), amount, evalcode, funcids, txid));
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2019 The Hush developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -959,14 +960,16 @@ void CWallet::AddToSpends(const uint256& wtxid)
|
||||
}
|
||||
}
|
||||
|
||||
int64_t CWallet::NullifierCount()
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
return mapTxSaplingNullifiers.size();
|
||||
}
|
||||
|
||||
void CWallet::ClearNoteWitnessCache()
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) {
|
||||
for (mapSproutNoteData_t::value_type& item : wtxItem.second.mapSproutNoteData) {
|
||||
item.second.witnesses.clear();
|
||||
item.second.witnessHeight = -1;
|
||||
}
|
||||
for (mapSaplingNoteData_t::value_type& item : wtxItem.second.mapSaplingNoteData) {
|
||||
item.second.witnesses.clear();
|
||||
item.second.witnessHeight = -1;
|
||||
@@ -1338,120 +1341,6 @@ CWallet::TxItems CWallet::OrderedTxItems(std::list<CAccountingEntry>& acentries,
|
||||
return txOrdered;
|
||||
}
|
||||
|
||||
// looks through all wallet UTXOs and checks to see if any qualify to stake the block at the current height. it always returns the qualified
|
||||
// UTXO with the smallest coin age if there is more than one, as larger coin age will win more often and is worth saving
|
||||
// each attempt consists of taking a VerusHash of the following values:
|
||||
// ASSETCHAINS_MAGIC, nHeight, txid, voutNum
|
||||
bool CWallet::VerusSelectStakeOutput(CBlock *pBlock, arith_uint256 &hashResult, CTransaction &stakeSource, int32_t &voutNum, int32_t nHeight, uint32_t &bnTarget) const
|
||||
{
|
||||
arith_uint256 target;
|
||||
arith_uint256 curHash;
|
||||
vector<COutput> vecOutputs;
|
||||
COutput *pwinner = NULL;
|
||||
CBlockIndex *pastBlockIndex;
|
||||
txnouttype whichType;
|
||||
std:vector<std::vector<unsigned char>> vSolutions;
|
||||
|
||||
pBlock->nNonce.SetPOSTarget(bnTarget);
|
||||
target.SetCompact(bnTarget);
|
||||
|
||||
pwalletMain->AvailableCoins(vecOutputs, true, NULL, false, false);
|
||||
|
||||
if (pastBlockIndex = komodo_chainactive(nHeight - 100))
|
||||
{
|
||||
CBlockHeader bh = pastBlockIndex->GetBlockHeader();
|
||||
uint256 pastHash = bh.GetVerusEntropyHash(nHeight - 100);
|
||||
CPOSNonce curNonce;
|
||||
|
||||
BOOST_FOREACH(COutput &txout, vecOutputs)
|
||||
{
|
||||
if (txout.fSpendable && (UintToArith256(txout.tx->GetVerusPOSHash(&(pBlock->nNonce), txout.i, nHeight, pastHash)) <= target) && (txout.nDepth >= VERUS_MIN_STAKEAGE))
|
||||
{
|
||||
if ((!pwinner || UintToArith256(curNonce) > UintToArith256(pBlock->nNonce)) &&
|
||||
(Solver(txout.tx->vout[txout.i].scriptPubKey, whichType, vSolutions) && (whichType == TX_PUBKEY || whichType == TX_PUBKEYHASH)))
|
||||
{
|
||||
//printf("Found PoS block\nnNonce: %s\n", pBlock->nNonce.GetHex().c_str());
|
||||
pwinner = &txout;
|
||||
curNonce = pBlock->nNonce;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pwinner)
|
||||
{
|
||||
stakeSource = *(pwinner->tx);
|
||||
voutNum = pwinner->i;
|
||||
pBlock->nNonce = curNonce;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
int64_t nValue;
|
||||
txnouttype whichType;
|
||||
std::vector<std::vector<unsigned char>> vSolutions;
|
||||
|
||||
CBlockIndex *tipindex = chainActive.LastTip();
|
||||
uint32_t stakeHeight = tipindex->GetHeight() + 1;
|
||||
|
||||
pk = CPubKey();
|
||||
|
||||
bnTarget = lwmaGetNextPOSRequired(tipindex, Params().GetConsensus());
|
||||
|
||||
if (!VerusSelectStakeOutput(pBlock, hashResult, stakeSource, voutNum, tipindex->GetHeight() + 1, bnTarget) ||
|
||||
!Solver(stakeSource.vout[voutNum].scriptPubKey, whichType, vSolutions))
|
||||
{
|
||||
LogPrintf("Searched for eligible staking transactions, no winners found\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool signSuccess;
|
||||
SignatureData sigdata;
|
||||
uint64_t txfee;
|
||||
auto consensusBranchId = CurrentEpochBranchId(stakeHeight, Params().GetConsensus());
|
||||
|
||||
const CKeyStore& keystore = *pwalletMain;
|
||||
txNew.vin.resize(1);
|
||||
txNew.vout.resize(1);
|
||||
txfee = 0;
|
||||
txNew.vin[0].prevout.hash = stakeSource.GetHash();
|
||||
txNew.vin[0].prevout.n = voutNum;
|
||||
|
||||
if (whichType == TX_PUBKEY)
|
||||
{
|
||||
txNew.vout[0].scriptPubKey << ToByteVector(vSolutions[0]) << OP_CHECKSIG;
|
||||
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;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
|
||||
nValue = txNew.vout[0].nValue = stakeSource.vout[voutNum].nValue - txfee;
|
||||
|
||||
txNew.nLockTime = 0;
|
||||
CTransaction txNewConst(txNew);
|
||||
signSuccess = ProduceSignature(TransactionSignatureCreator(&keystore, &txNewConst, 0, nValue, SIGHASH_ALL), stakeSource.vout[voutNum].scriptPubKey, sigdata, consensusBranchId);
|
||||
if (!signSuccess)
|
||||
fprintf(stderr,"failed to create signature\n");
|
||||
else
|
||||
{
|
||||
uint8_t *ptr;
|
||||
UpdateTransaction(txNew,0,sigdata);
|
||||
ptr = (uint8_t *)&sigdata.scriptSig[0];
|
||||
siglen = sigdata.scriptSig.size();
|
||||
for (int i=0; i<siglen; i++)
|
||||
utxosig[i] = ptr[i];//, fprintf(stderr,"%02x",ptr[i]);
|
||||
}
|
||||
return(siglen);
|
||||
}
|
||||
|
||||
void CWallet::MarkDirty()
|
||||
{
|
||||
@@ -1794,7 +1683,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
|
||||
for (size_t i = 0; i < tx.vin.size(); i++)
|
||||
{
|
||||
uint256 hash; CTransaction txin; CTxDestination address;
|
||||
if ( GetTransaction(tx.vin[i].prevout.hash,txin,hash,false) && ExtractDestination(txin.vout[tx.vin[i].prevout.n].scriptPubKey, address) )
|
||||
if ( myGetTransaction(tx.vin[i].prevout.hash,txin,hash) && ExtractDestination(txin.vout[tx.vin[i].prevout.n].scriptPubKey, address) )
|
||||
{
|
||||
if ( CBitcoinAddress(address).ToString() == NotaryAddress )
|
||||
numvinIsOurs++;
|
||||
@@ -2198,13 +2087,13 @@ bool CWallet::IsMine(const CTransaction& tx)
|
||||
return false;
|
||||
}
|
||||
|
||||
// special case handling for non-standard/Verus OP_RETURN script outputs, which need the transaction
|
||||
// special case handling for non-standard OP_RETURN script outputs, which need the transaction
|
||||
// to determine ownership
|
||||
isminetype CWallet::IsMine(const CTransaction& tx, uint32_t voutNum)
|
||||
{
|
||||
vector<valtype> vSolutions;
|
||||
txnouttype whichType;
|
||||
const CScriptExt scriptPubKey = CScriptExt(tx.vout[voutNum].scriptPubKey);
|
||||
const CScript scriptPubKey = CScript(tx.vout[voutNum].scriptPubKey);
|
||||
|
||||
if (!Solver(scriptPubKey, whichType, vSolutions)) {
|
||||
if (this->HaveWatchOnly(scriptPubKey))
|
||||
@@ -2214,7 +2103,7 @@ isminetype CWallet::IsMine(const CTransaction& tx, uint32_t voutNum)
|
||||
|
||||
CKeyID keyID;
|
||||
CScriptID scriptID;
|
||||
CScriptExt subscript;
|
||||
CScript subscript;
|
||||
int voutNext = voutNum + 1;
|
||||
|
||||
switch (whichType)
|
||||
@@ -2248,6 +2137,7 @@ isminetype CWallet::IsMine(const CTransaction& tx, uint32_t voutNum)
|
||||
|
||||
case TX_SCRIPTHASH:
|
||||
scriptID = CScriptID(uint160(vSolutions[0]));
|
||||
//TODO: remove CLTV stuff not relevant to Hush
|
||||
if (this->GetCScript(scriptID, subscript))
|
||||
{
|
||||
// if this is a CLTV, handle it differently
|
||||
@@ -3763,9 +3653,13 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
|
||||
wtxNew.fTimeReceivedIsTxTime = true;
|
||||
wtxNew.BindWallet(this);
|
||||
int nextBlockHeight = chainActive.Height() + 1;
|
||||
CMutableTransaction txNew = CreateNewContextualCMutableTransaction(
|
||||
Params().GetConsensus(), nextBlockHeight);
|
||||
CMutableTransaction txNew = CreateNewContextualCMutableTransaction(Params().GetConsensus(), nextBlockHeight);
|
||||
|
||||
//if ((uint32_t)chainActive.LastTip()->nTime < ASSETCHAINS_STAKED_HF_TIMESTAMP)
|
||||
if ( !hush_hardfork_active((uint32_t)chainActive.LastTip()->nTime) )
|
||||
txNew.nLockTime = (uint32_t)chainActive.LastTip()->nTime + 1; // set to a time close to now
|
||||
else
|
||||
txNew.nLockTime = (uint32_t)chainActive.Tip()->GetMedianTimePast();
|
||||
|
||||
// Activates after Overwinter network upgrade
|
||||
if (NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2019 The Hush developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -795,6 +796,8 @@ public:
|
||||
|
||||
void ClearNoteWitnessCache();
|
||||
|
||||
int64_t NullifierCount();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* pindex is the new tip being connected.
|
||||
@@ -1330,9 +1333,6 @@ public:
|
||||
bool requireSpendingKey=true,
|
||||
bool ignoreLocked=true);
|
||||
|
||||
// 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, CPubKey pk) const;
|
||||
};
|
||||
|
||||
/** A key allocated from the key pool. */
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2019 The Hush developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -488,13 +489,10 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
|
||||
auto verifier = libzcash::ProofVerifier::Strict();
|
||||
// ac_public chains set at height like KMD and ZEX, will force a rescan if we dont ignore this error: bad-txns-acpublic-chain
|
||||
// there cannot be any ztx in the wallet on ac_public chains that started from block 1, so this wont affect those.
|
||||
// PIRATE fails this check for notary nodes, need exception. Triggers full rescan without it.
|
||||
if ( !(CheckTransaction(0,wtx, state, verifier) && (wtx.GetHash() == hash) && state.IsValid()) && (state.GetRejectReason() != "bad-txns-acpublic-chain" && state.GetRejectReason() != "bad-txns-acprivacy-chain") )
|
||||
// ac_private chains fail this check for notary nodes, need exception. Triggers full rescan without it.
|
||||
if ( !(CheckTransaction(0,wtx, state, verifier, 0, 0) && (wtx.GetHash() == hash) && state.IsValid()) && (state.GetRejectReason() != "bad-txns-acpublic-chain" && state.GetRejectReason() != "bad-txns-acprivacy-chain" && state.GetRejectReason() != "bad-txns-stakingtx") )
|
||||
{
|
||||
//fprintf(stderr, "tx failed: %s rejectreason.%s\n", wtx.GetHash().GetHex().c_str(), state.GetRejectReason().c_str());
|
||||
// vin-empty on staking chains is error relating to a failed staking tx, that for some unknown reason did not fully erase. save them here to erase and re-add later on.
|
||||
if ( ASSETCHAINS_STAKED != 0 && state.GetRejectReason() == "bad-txns-vin-empty" )
|
||||
deadTxns.push_back(hash);
|
||||
return false;
|
||||
}
|
||||
// Undo serialize changes in 31600
|
||||
@@ -1115,7 +1113,7 @@ DBErrors CWalletDB::ZapWalletTx(CWallet* pwallet, vector<CWalletTx>& vWtx)
|
||||
void ThreadFlushWalletDB(const string& strFile)
|
||||
{
|
||||
// Make this thread recognisable as the wallet flushing thread
|
||||
RenameThread("zcash-wallet");
|
||||
RenameThread("hush-wallet");
|
||||
|
||||
static bool fOneThread;
|
||||
if (fOneThread)
|
||||
|
||||
Reference in New Issue
Block a user