| 3076 | // ELEMENTS: |
| 3077 | |
| 3078 | static RPCHelpMan getsidechaininfo() |
| 3079 | { |
| 3080 | return RPCHelpMan{"getsidechaininfo", |
| 3081 | "Returns an object containing various state info regarding sidechain functionality.\n", |
| 3082 | {}, |
| 3083 | RPCResult{ |
| 3084 | RPCResult::Type::OBJ, "", "", |
| 3085 | { |
| 3086 | {RPCResult::Type::STR_HEX, "fedpegscript", "The fedpegscript from genesis block"}, |
| 3087 | {RPCResult::Type::ARR, "current_fedpegscripts", "The currently-enforced fedpegscripts in hex. Peg-ins for any entries on this list are honored by consensus and policy. Newest first. Two total entries are possible", |
| 3088 | {{RPCResult::Type::STR_HEX, "", "active fedpegscript"}}}, |
| 3089 | {RPCResult::Type::ARR, "current_fedpeg_programs", "The currently-enforced fedpegscript scriptPubKeys in hex. Prior to a transition this may be P2SH scriptpubkey, otherwise it will be a native segwit script. Results are paired in-order with current_fedpegscripts", |
| 3090 | {{RPCResult::Type::STR_HEX, "", "active fedpegscript scriptPubKeys"}}}, |
| 3091 | {RPCResult::Type::STR_HEX, "pegged_asset", "Pegged asset type"}, |
| 3092 | {RPCResult::Type::STR, "min_peg_diff", "The minimum difficulty parent chain header target. Peg-in headers that have less work will be rejected as an anti-Dos measure"}, |
| 3093 | {RPCResult::Type::STR_HEX, "parent_blockhash", "The parent genesis blockhash as source of pegged-in funds"}, |
| 3094 | {RPCResult::Type::BOOL, "parent_chain_has_pow", "Whether parent chain has pow or signed blocks"}, |
| 3095 | {RPCResult::Type::STR, "parent_chain_signblockscript_asm", "If the parent chain has signed blocks, its signblockscript in ASM"}, |
| 3096 | {RPCResult::Type::STR_HEX, "parent_chain_signblockscript_hex", "If the parent chain has signed blocks, its signblockscript in hex"}, |
| 3097 | {RPCResult::Type::STR_HEX, "parent_pegged_asset", "If the parent chain has Confidential Assets, the asset id of the pegged asset in that chain"}, |
| 3098 | {RPCResult::Type::NUM, "pegin_confirmation_depth", "The number of mainchain confirmations required for a peg-in transaction to become valid"}, |
| 3099 | {RPCResult::Type::BOOL, "enforce_pak", "If peg-out authorization is being enforced"}, |
| 3100 | }}, |
| 3101 | RPCExamples{ |
| 3102 | HelpExampleCli("getsidechaininfo", "") |
| 3103 | + HelpExampleRpc("getsidechaininfo", "") |
| 3104 | }, |
| 3105 | [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue |
| 3106 | { |
| 3107 | LOCK(cs_main); |
| 3108 | |
| 3109 | NodeContext& node = EnsureAnyNodeContext(request.context); |
| 3110 | ChainstateManager& chainman = EnsureChainman(node); |
| 3111 | const Consensus::Params& consensus = Params().GetConsensus(); |
| 3112 | const uint256& parent_blockhash = Params().ParentGenesisBlockHash(); |
| 3113 | |
| 3114 | UniValue obj(UniValue::VOBJ); |
| 3115 | obj.pushKV("fedpegscript", HexStr(consensus.fedpegScript)); |
| 3116 | // We use mempool_validation as true to show what is enforced for *next* block |
| 3117 | std::vector<std::pair<CScript, CScript>> fedpegscripts = GetValidFedpegScripts(chainman.ActiveChain().Tip(), consensus, true /* nextblock_validation */); |
| 3118 | UniValue fedpeg_prog_entries(UniValue::VARR); |
| 3119 | UniValue fedpeg_entries(UniValue::VARR); |
| 3120 | for (const auto& scripts : fedpegscripts) { |
| 3121 | fedpeg_prog_entries.push_back(HexStr(scripts.first)); |
| 3122 | fedpeg_entries.push_back(HexStr(scripts.second)); |
| 3123 | } |
| 3124 | obj.pushKV("current_fedpeg_programs", fedpeg_prog_entries); |
| 3125 | obj.pushKV("current_fedpegscripts", fedpeg_entries); |
| 3126 | obj.pushKV("pegged_asset", consensus.pegged_asset.GetHex()); |
| 3127 | obj.pushKV("min_peg_diff", consensus.parentChainPowLimit.GetHex()); |
| 3128 | obj.pushKV("parent_blockhash", parent_blockhash.GetHex()); |
| 3129 | obj.pushKV("parent_chain_has_pow", consensus.ParentChainHasPow()); |
| 3130 | obj.pushKV("enforce_pak", Params().GetEnforcePak()); |
| 3131 | obj.pushKV("pegin_confirmation_depth", (uint64_t)consensus.pegin_min_depth); |
| 3132 | if (!consensus.ParentChainHasPow()) { |
| 3133 | obj.pushKV("parent_chain_signblockscript_asm", ScriptToAsmStr(consensus.parent_chain_signblockscript)); |
| 3134 | obj.pushKV("parent_chain_signblockscript_hex", HexStr(consensus.parent_chain_signblockscript)); |
| 3135 | obj.pushKV("parent_pegged_asset", consensus.parent_pegged_asset.GetHex()); |
nothing calls this directly
no test coverage detected