From ade539cbb46b618f01a032d212d2bb6fb79a9040 Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Thu, 21 Mar 2019 12:39:57 +0000 Subject: [PATCH] Don't assume mainchain is Bitcoin --- src/init.cpp | 20 ++++++++++---------- src/mainchainrpc.cpp | 4 ++-- src/validation.cpp | 8 ++++---- src/validation.h | 2 +- src/wallet/rpcwallet.cpp | 4 ++-- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index b2dd803832..dc7a0d39d0 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -529,12 +529,12 @@ void SetupServerArgs() std::vector elements_hidden_args = {"-con_fpowallowmindifficultyblocks", "-con_fpownoretargeting", "-con_nsubsidyhalvinginterval", "-con_bip16exception", "-con_bip34height", "-con_bip65height", "-con_bip66height", "-con_npowtargettimespan", "-con_npowtargetspacing", "-con_nrulechangeactivationthreshold", "-con_nminerconfirmationwindow", "-con_powlimit", "-con_bip34hash", "-con_nminimumchainwork", "-con_defaultassumevalid", "-npruneafterheight", "-fdefaultconsistencychecks", "-fmineblocksondemand", "-fallback_fee_enabled", "-pchmessagestart"}; gArgs.AddArg("-initialfreecoins", strprintf("The amount of OP_TRUE coins created in the genesis block. Primarily for testing. (default: %d)", 0), true, OptionsCategory::DEBUG_TEST); - gArgs.AddArg("-validatepegin", "Validate peg-in claims. An RPC connection will be attempted to the trusted bitcoind using the `mainchain*` settings below. All functionaries must run this enabled. (default: true if chain has federated peg)", false, OptionsCategory::ELEMENTS); - gArgs.AddArg("-mainchainrpchost=", "The address which the daemon will try to connect to the trusted bitcoind to validate peg-ins, if enabled. (default: 127.0.0.1)", false, OptionsCategory::ELEMENTS); - gArgs.AddArg("-mainchainrpcport=", strprintf("The port which the daemon will try to connect to the trusted bitcoind to validate peg-ins, if enabled. (default: %u)", defaultBaseParams->MainchainRPCPort()), false, OptionsCategory::ELEMENTS); - gArgs.AddArg("-mainchainrpcuser=", "The rpc username that the daemon will use to connect to the trusted bitcoind to validate peg-ins, if enabled. (default: cookie auth)", false, OptionsCategory::ELEMENTS); - gArgs.AddArg("-mainchainrpcpassword=", "The rpc password which the daemon will use to connect to the trusted bitcoind to validate peg-ins, if enabled. (default: cookie auth)", false, OptionsCategory::ELEMENTS); - gArgs.AddArg("-mainchainrpccookiefile=", "The bitcoind cookie auth path which the daemon will use to connect to the trusted bitcoind to validate peg-ins. (default: `/regtest/.cookie`)", false, OptionsCategory::ELEMENTS); + gArgs.AddArg("-validatepegin", "Validate peg-in claims. An RPC connection will be attempted to the trusted mainchain daemon using the `mainchain*` settings below. All functionaries must run this enabled. (default: true if chain has federated peg)", false, OptionsCategory::ELEMENTS); + gArgs.AddArg("-mainchainrpchost=", "The address which the daemon will try to connect to the trusted mainchain daemon to validate peg-ins, if enabled. (default: 127.0.0.1)", false, OptionsCategory::ELEMENTS); + gArgs.AddArg("-mainchainrpcport=", strprintf("The port which the daemon will try to connect to the trusted mainchain daemon to validate peg-ins, if enabled. (default: %u)", defaultBaseParams->MainchainRPCPort()), false, OptionsCategory::ELEMENTS); + gArgs.AddArg("-mainchainrpcuser=", "The rpc username that the daemon will use to connect to the trusted mainchain daemon to validate peg-ins, if enabled. (default: cookie auth)", false, OptionsCategory::ELEMENTS); + gArgs.AddArg("-mainchainrpcpassword=", "The rpc password which the daemon will use to connect to the trusted mainchain daemon to validate peg-ins, if enabled. (default: cookie auth)", false, OptionsCategory::ELEMENTS); + gArgs.AddArg("-mainchainrpccookiefile=", "The bitcoind cookie auth path which the daemon will use to connect to the trusted mainchain daemon to validate peg-ins. (default: `/regtest/.cookie`)", false, OptionsCategory::ELEMENTS); gArgs.AddArg("-mainchainrpctimeout=", strprintf("Timeout in seconds during mainchain RPC requests, or 0 for no timeout. (default: %d)", DEFAULT_HTTP_CLIENT_TIMEOUT), false, OptionsCategory::ELEMENTS); gArgs.AddArg("-peginconfirmationdepth=", strprintf("Pegin claims must be this deep to be considered valid. (default: %d)", DEFAULT_PEGIN_CONFIRMATION_DEPTH), false, OptionsCategory::ELEMENTS); gArgs.AddArg("-recheckpeginblockinterval=", strprintf("The interval in seconds at which a peg-in witness failing block is re-evaluated in case of intermittent peg-in witness failure. 0 means never. (default: %u)", 120), false, OptionsCategory::ELEMENTS); @@ -1866,14 +1866,14 @@ bool AppInitMain() SetRPCWarmupFinished(); // ELEMENTS: - CScheduler::Function f2 = boost::bind(&BitcoindRPCCheck, false); + CScheduler::Function f2 = boost::bind(&MainchainRPCCheck, false); unsigned int check_rpc_every = gArgs.GetArg("-recheckpeginblockinterval", 120); if (check_rpc_every) { scheduler.scheduleEvery(f2, check_rpc_every); } - uiInterface.InitMessage(_("Awaiting bitcoind RPC warmup")); - if (!BitcoindRPCCheck(true)) { //Initial check, fail immediately - return InitError(_("ERROR: elementsd is set to verify pegins but cannot get valid response from bitcoind. Please check debug.log for more information.")); + uiInterface.InitMessage(_("Awaiting mainchain RPC warmup")); + if (!MainchainRPCCheck(true)) { //Initial check, fail immediately + return InitError(_("ERROR: elementsd is set to verify pegins but cannot get valid response from the mainchain daemon. Please check debug.log for more information.")); } uiInterface.InitMessage(_("Done loading")); diff --git a/src/mainchainrpc.cpp b/src/mainchainrpc.cpp index cf4685497b..bb157ce383 100644 --- a/src/mainchainrpc.cpp +++ b/src/mainchainrpc.cpp @@ -177,10 +177,10 @@ bool IsConfirmedBitcoinBlock(const uint256& hash, const int nMinConfirmationDept } } } catch (CConnectionFailed& e) { - LogPrintf("ERROR: Lost connection to bitcoind RPC, you will want to restart after fixing this!\n"); + LogPrintf("ERROR: Lost connection to mainchain daemon RPC, you will want to restart after fixing this!\n"); return false; } catch (...) { - LogPrintf("ERROR: Failure connecting to bitcoind RPC, you will want to restart after fixing this!\n"); + LogPrintf("ERROR: Failure connecting to mainchain daemon RPC, you will want to restart after fixing this!\n"); return false; } return true; diff --git a/src/validation.cpp b/src/validation.cpp index 05ee3d65c4..4412bdfc18 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -5107,7 +5107,7 @@ public: * from the perspective of peg-in witness validation. Blocks are * added to this queue in ConnectTip based on the error code returned. */ -bool BitcoindRPCCheck(const bool init) +bool MainchainRPCCheck(const bool init) { // First, we can clear out any blocks thatsomehow are now deemed valid // eg reconsiderblock rpc call manually @@ -5144,7 +5144,7 @@ bool BitcoindRPCCheck(const bool init) continue; } else { - LogPrintf("ERROR: Bitcoind RPC check returned 'error' response.\n"); + LogPrintf("ERROR: Mainchain daemon RPC check returned 'error' response.\n"); return false; } } @@ -5160,7 +5160,7 @@ bool BitcoindRPCCheck(const bool init) reply = CallMainChainRPC("getblockhash", params); error = reply["error"]; if (!error.isNull()) { - LogPrintf("ERROR: Bitcoind RPC check returned 'error' response.\n"); + LogPrintf("ERROR: Mainchain daemon RPC check returned 'error' response.\n"); return false; } result = reply["result"]; @@ -5169,7 +5169,7 @@ bool BitcoindRPCCheck(const bool init) return false; } } catch (const std::runtime_error& re) { - LogPrintf("ERROR: Failure connecting to bitcoind RPC: %s\n", std::string(re.what())); + LogPrintf("ERROR: Failure connecting to mainchain daemon RPC: %s\n", std::string(re.what())); return false; } // Success diff --git a/src/validation.h b/src/validation.h index f1a0ac6296..044c21537c 100644 --- a/src/validation.h +++ b/src/validation.h @@ -506,6 +506,6 @@ inline bool IsBlockPruned(const CBlockIndex* pblockindex) // ELEMENTS: /** Check if bitcoind connection via RPC is correctly working*/ -bool BitcoindRPCCheck(bool init); +bool MainchainRPCCheck(bool init); #endif // BITCOIN_VALIDATION_H diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 989a967dd9..4f3473138f 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5065,7 +5065,7 @@ static UniValue createrawpegin(const JSONRPCRequest& request, T_tx_ref& txBTCRef "If a transaction is not relayed it may require manual addition to a functionary mempool in order for it to be mined.\n" "\nArguments:\n" "1. \"bitcoinTx\" (string, required) The raw bitcoin transaction (in hex) depositing bitcoin to the mainchain_address generated by getpeginaddress\n" - "2. \"txoutproof\" (string, required) A rawtxoutproof (in hex) generated by bitcoind's `gettxoutproof` containing a proof of only bitcoinTx\n" + "2. \"txoutproof\" (string, required) A rawtxoutproof (in hex) generated by the mainchain daemon's `gettxoutproof` containing a proof of only bitcoinTx\n" "3. \"claim_script\" (string, optional) The witness program generated by getpeginaddress. Only needed if not in wallet.\n" "\nResult:\n" "{\n" @@ -5280,7 +5280,7 @@ UniValue claimpegin(const JSONRPCRequest& request) "If a transaction is not relayed it may require manual addition to a functionary mempool in order for it to be mined.\n" "\nArguments:\n" "1. \"bitcoinTx\" (string, required) The raw bitcoin transaction (in hex) depositing bitcoin to the mainchain_address generated by getpeginaddress\n" - "2. \"txoutproof\" (string, required) A rawtxoutproof (in hex) generated by bitcoind's `gettxoutproof` containing a proof of only bitcoinTx\n" + "2. \"txoutproof\" (string, required) A rawtxoutproof (in hex) generated by the mainchain daemon's `gettxoutproof` containing a proof of only bitcoinTx\n" "3. \"claim_script\" (string, optional) The witness program generated by getpeginaddress. Only needed if not in wallet.\n" "\nResult:\n" "\"txid\" (string) Txid of the resulting sidechain transaction\n"