mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
add getsidechaininfo RPC call
This commit is contained in:
parent
4b021d6f6c
commit
7e182a1840
2 changed files with 40 additions and 0 deletions
|
|
@ -208,6 +208,13 @@ try:
|
|||
|
||||
print("Success!")
|
||||
|
||||
# Testing sidechain info RPC
|
||||
sideinfo = sidechain.getsidechaininfo()
|
||||
assert sideinfo["fedpegscript"] == fedpeg_pubkey
|
||||
assert sideinfo["pegged_asset"] == sidechain.dumpassetlabels()["bitcoin"]
|
||||
assert sideinfo["min_peg_diff"] == "7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
|
||||
assert sideinfo["parent_blockhash"] == "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"
|
||||
|
||||
except JSONRPCException as e:
|
||||
print("Pegging testing failed, aborting:")
|
||||
print(e.error)
|
||||
|
|
|
|||
|
|
@ -1109,6 +1109,38 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
|
|||
return obj;
|
||||
}
|
||||
|
||||
UniValue getsidechaininfo(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.fHelp || request.params.size() != 0)
|
||||
throw runtime_error(
|
||||
"getsidechaininfo\n"
|
||||
"Returns an object containing various state info regarding sidechain functionality.\n"
|
||||
"\nResult:\n"
|
||||
"{\n"
|
||||
" \"fedpegscript\": \"xxxx\", (string) The fedpegscript in hex\n"
|
||||
" \"pegged_asset\" : \"xxxx\", (string) Pegged asset type in hex\n"
|
||||
" \"min_peg_diff\" : \"xxxx\", (string) The minimum difficulty parent chain header target. Peg-in headers that have less work will be rejected as an anti-Dos measure.\n"
|
||||
" \"parent_blockhash\" : \"xxxx\", (string) The parent genesis blockhash as source of pegged-in funds.\n"
|
||||
"}\n"
|
||||
"\nExamples:\n"
|
||||
+ HelpExampleCli("getsidechaininfo", "")
|
||||
+ HelpExampleRpc("getsidechaininfo", "")
|
||||
);
|
||||
|
||||
LOCK(cs_main);
|
||||
|
||||
const Consensus::Params& consensus = Params().GetConsensus();
|
||||
const uint256& parent_blockhash = Params().ParentGenesisBlockHash();
|
||||
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
obj.push_back(Pair("fedpegscript", HexStr(consensus.fedpegScript.begin(), consensus.fedpegScript.end())));
|
||||
obj.push_back(Pair("pegged_asset", consensus.pegged_asset.GetHex()));
|
||||
obj.push_back(Pair("min_peg_diff", consensus.parentChainPowLimit.GetHex()));
|
||||
obj.push_back(Pair("parent_blockhash", parent_blockhash.GetHex()));
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
/** Comparison function for sorting the getchaintips heads. */
|
||||
struct CompareBlocksByHeight
|
||||
{
|
||||
|
|
@ -1391,6 +1423,7 @@ static const CRPCCommand commands[] =
|
|||
{ "blockchain", "getmempoolentry", &getmempoolentry, true, {"txid"} },
|
||||
{ "blockchain", "getmempoolinfo", &getmempoolinfo, true, {} },
|
||||
{ "blockchain", "getrawmempool", &getrawmempool, true, {"verbose"} },
|
||||
{ "blockchain", "getsidechaininfo", &getsidechaininfo, true, {} },
|
||||
{ "blockchain", "gettxout", &gettxout, true, {"txid","n","include_mempool"} },
|
||||
{ "blockchain", "gettxoutsetinfo", &gettxoutsetinfo, true, {} },
|
||||
{ "blockchain", "pruneblockchain", &pruneblockchain, true, {"height"} },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue