From b628d91894abb4a693ee76790e005a4aa2673ffb Mon Sep 17 00:00:00 2001 From: Gregory Sanders Date: Wed, 28 Mar 2018 11:40:20 -0400 Subject: [PATCH] make peginconfirmationdepth a chain param --- src/chainparams.cpp | 1 + src/consensus/params.h | 1 + src/validation.cpp | 2 +- src/wallet/rpcwallet.cpp | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 7985073af0..1faa19e2e1 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -129,6 +129,7 @@ protected: consensus.nMinimumChainWork = uint256S(GetArg("-con_nminimumchainwork", "0x00")); // By default assume that the signatures in ancestors of this block are valid. consensus.defaultAssumeValid = uint256S(GetArg("-con_defaultassumevalid", "0x00")); + consensus.pegin_min_depth = GetArg("-peginconfirmationdepth", DEFAULT_PEGIN_CONFIRMATION_DEPTH); // bitcoin regtest is the parent chain by default parentGenesisBlockHash = uint256S(GetArg("-parentgenesisblockhash", "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206")); diff --git a/src/consensus/params.h b/src/consensus/params.h index 0763ff5d2f..cf9ab42ec3 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -69,6 +69,7 @@ struct Params { CScript fedpegScript; CAsset pegged_asset; uint256 defaultAssumeValid; + uint32_t pegin_min_depth; }; } // namespace Consensus diff --git a/src/validation.cpp b/src/validation.cpp index acd85346f6..bc999ed11d 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2474,7 +2474,7 @@ bool IsValidPeginWitness(const CScriptWitness& pegin_witness, const COutPoint& p // Finally, validate peg-in via rpc call if (check_depth && GetBoolArg("-validatepegin", DEFAULT_VALIDATE_PEGIN)) { - return IsConfirmedBitcoinBlock(merkle_block.header.GetHash(), GetArg("-peginconfirmationdepth", DEFAULT_PEGIN_CONFIRMATION_DEPTH)); + return IsConfirmedBitcoinBlock(merkle_block.header.GetHash(), Params().GetConsensus().pegin_min_depth); } return true; } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 81f942f967..a3ad9b0144 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3687,7 +3687,7 @@ UniValue createrawpegin(const JSONRPCRequest& request) // Additional block lee-way to avoid bitcoin block races if (GetBoolArg("-validatepegin", DEFAULT_VALIDATE_PEGIN)) { - ret.push_back(Pair("mature", IsConfirmedBitcoinBlock(merkleBlock.header.GetHash(), GetArg("-peginconfirmationdepth", DEFAULT_PEGIN_CONFIRMATION_DEPTH)+2))); + ret.push_back(Pair("mature", IsConfirmedBitcoinBlock(merkleBlock.header.GetHash(), Params().GetConsensus().pegin_min_depth+2))); } return ret;