Skip to content

Commit ade539c

Browse files
committed
Don't assume mainchain is Bitcoin
1 parent cf77a23 commit ade539c

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

src/init.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -529,12 +529,12 @@ void SetupServerArgs()
529529
std::vector<std::string> 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"};
530530

531531
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);
532-
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);
533-
gArgs.AddArg("-mainchainrpchost=<host>", "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);
534-
gArgs.AddArg("-mainchainrpcport=<n>", 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);
535-
gArgs.AddArg("-mainchainrpcuser=<user>", "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);
536-
gArgs.AddArg("-mainchainrpcpassword=<pwd>", "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);
537-
gArgs.AddArg("-mainchainrpccookiefile=<file>", "The bitcoind cookie auth path which the daemon will use to connect to the trusted bitcoind to validate peg-ins. (default: `<datadir>/regtest/.cookie`)", false, OptionsCategory::ELEMENTS);
532+
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);
533+
gArgs.AddArg("-mainchainrpchost=<host>", "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);
534+
gArgs.AddArg("-mainchainrpcport=<n>", 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);
535+
gArgs.AddArg("-mainchainrpcuser=<user>", "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);
536+
gArgs.AddArg("-mainchainrpcpassword=<pwd>", "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);
537+
gArgs.AddArg("-mainchainrpccookiefile=<file>", "The bitcoind cookie auth path which the daemon will use to connect to the trusted mainchain daemon to validate peg-ins. (default: `<datadir>/regtest/.cookie`)", false, OptionsCategory::ELEMENTS);
538538
gArgs.AddArg("-mainchainrpctimeout=<n>", strprintf("Timeout in seconds during mainchain RPC requests, or 0 for no timeout. (default: %d)", DEFAULT_HTTP_CLIENT_TIMEOUT), false, OptionsCategory::ELEMENTS);
539539
gArgs.AddArg("-peginconfirmationdepth=<n>", strprintf("Pegin claims must be this deep to be considered valid. (default: %d)", DEFAULT_PEGIN_CONFIRMATION_DEPTH), false, OptionsCategory::ELEMENTS);
540540
gArgs.AddArg("-recheckpeginblockinterval=<n>", 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()
18661866
SetRPCWarmupFinished();
18671867

18681868
// ELEMENTS:
1869-
CScheduler::Function f2 = boost::bind(&BitcoindRPCCheck, false);
1869+
CScheduler::Function f2 = boost::bind(&MainchainRPCCheck, false);
18701870
unsigned int check_rpc_every = gArgs.GetArg("-recheckpeginblockinterval", 120);
18711871
if (check_rpc_every) {
18721872
scheduler.scheduleEvery(f2, check_rpc_every);
18731873
}
1874-
uiInterface.InitMessage(_("Awaiting bitcoind RPC warmup"));
1875-
if (!BitcoindRPCCheck(true)) { //Initial check, fail immediately
1876-
return InitError(_("ERROR: elementsd is set to verify pegins but cannot get valid response from bitcoind. Please check debug.log for more information."));
1874+
uiInterface.InitMessage(_("Awaiting mainchain RPC warmup"));
1875+
if (!MainchainRPCCheck(true)) { //Initial check, fail immediately
1876+
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."));
18771877
}
18781878

18791879
uiInterface.InitMessage(_("Done loading"));

src/mainchainrpc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,10 @@ bool IsConfirmedBitcoinBlock(const uint256& hash, const int nMinConfirmationDept
177177
}
178178
}
179179
} catch (CConnectionFailed& e) {
180-
LogPrintf("ERROR: Lost connection to bitcoind RPC, you will want to restart after fixing this!\n");
180+
LogPrintf("ERROR: Lost connection to mainchain daemon RPC, you will want to restart after fixing this!\n");
181181
return false;
182182
} catch (...) {
183-
LogPrintf("ERROR: Failure connecting to bitcoind RPC, you will want to restart after fixing this!\n");
183+
LogPrintf("ERROR: Failure connecting to mainchain daemon RPC, you will want to restart after fixing this!\n");
184184
return false;
185185
}
186186
return true;

src/validation.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5107,7 +5107,7 @@ class CMainCleanup
51075107
* from the perspective of peg-in witness validation. Blocks are
51085108
* added to this queue in ConnectTip based on the error code returned.
51095109
*/
5110-
bool BitcoindRPCCheck(const bool init)
5110+
bool MainchainRPCCheck(const bool init)
51115111
{
51125112
// First, we can clear out any blocks thatsomehow are now deemed valid
51135113
// eg reconsiderblock rpc call manually
@@ -5144,7 +5144,7 @@ bool BitcoindRPCCheck(const bool init)
51445144
continue;
51455145
}
51465146
else {
5147-
LogPrintf("ERROR: Bitcoind RPC check returned 'error' response.\n");
5147+
LogPrintf("ERROR: Mainchain daemon RPC check returned 'error' response.\n");
51485148
return false;
51495149
}
51505150
}
@@ -5160,7 +5160,7 @@ bool BitcoindRPCCheck(const bool init)
51605160
reply = CallMainChainRPC("getblockhash", params);
51615161
error = reply["error"];
51625162
if (!error.isNull()) {
5163-
LogPrintf("ERROR: Bitcoind RPC check returned 'error' response.\n");
5163+
LogPrintf("ERROR: Mainchain daemon RPC check returned 'error' response.\n");
51645164
return false;
51655165
}
51665166
result = reply["result"];
@@ -5169,7 +5169,7 @@ bool BitcoindRPCCheck(const bool init)
51695169
return false;
51705170
}
51715171
} catch (const std::runtime_error& re) {
5172-
LogPrintf("ERROR: Failure connecting to bitcoind RPC: %s\n", std::string(re.what()));
5172+
LogPrintf("ERROR: Failure connecting to mainchain daemon RPC: %s\n", std::string(re.what()));
51735173
return false;
51745174
}
51755175
// Success

src/validation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,6 @@ inline bool IsBlockPruned(const CBlockIndex* pblockindex)
506506

507507
// ELEMENTS:
508508
/** Check if bitcoind connection via RPC is correctly working*/
509-
bool BitcoindRPCCheck(bool init);
509+
bool MainchainRPCCheck(bool init);
510510

511511
#endif // BITCOIN_VALIDATION_H

src/wallet/rpcwallet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5065,7 +5065,7 @@ static UniValue createrawpegin(const JSONRPCRequest& request, T_tx_ref& txBTCRef
50655065
"If a transaction is not relayed it may require manual addition to a functionary mempool in order for it to be mined.\n"
50665066
"\nArguments:\n"
50675067
"1. \"bitcoinTx\" (string, required) The raw bitcoin transaction (in hex) depositing bitcoin to the mainchain_address generated by getpeginaddress\n"
5068-
"2. \"txoutproof\" (string, required) A rawtxoutproof (in hex) generated by bitcoind's `gettxoutproof` containing a proof of only bitcoinTx\n"
5068+
"2. \"txoutproof\" (string, required) A rawtxoutproof (in hex) generated by the mainchain daemon's `gettxoutproof` containing a proof of only bitcoinTx\n"
50695069
"3. \"claim_script\" (string, optional) The witness program generated by getpeginaddress. Only needed if not in wallet.\n"
50705070
"\nResult:\n"
50715071
"{\n"
@@ -5280,7 +5280,7 @@ UniValue claimpegin(const JSONRPCRequest& request)
52805280
"If a transaction is not relayed it may require manual addition to a functionary mempool in order for it to be mined.\n"
52815281
"\nArguments:\n"
52825282
"1. \"bitcoinTx\" (string, required) The raw bitcoin transaction (in hex) depositing bitcoin to the mainchain_address generated by getpeginaddress\n"
5283-
"2. \"txoutproof\" (string, required) A rawtxoutproof (in hex) generated by bitcoind's `gettxoutproof` containing a proof of only bitcoinTx\n"
5283+
"2. \"txoutproof\" (string, required) A rawtxoutproof (in hex) generated by the mainchain daemon's `gettxoutproof` containing a proof of only bitcoinTx\n"
52845284
"3. \"claim_script\" (string, optional) The witness program generated by getpeginaddress. Only needed if not in wallet.\n"
52855285
"\nResult:\n"
52865286
"\"txid\" (string) Txid of the resulting sidechain transaction\n"

0 commit comments

Comments
 (0)