Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <node/transaction.h>
#include <node/utxo_snapshot.h>
#include <node/warnings.h>
#include <policy/policy.h>
#include <primitives/transaction.h>
#include <rpc/server.h>
#include <rpc/server_util.h>
Expand Down Expand Up @@ -3682,6 +3683,7 @@ static RPCHelpMan getsidechaininfo()
{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",
{{RPCResult::Type::STR_HEX, "", "active fedpegscript"}}},
{RPCResult::Type::STR_HEX, "pegged_asset", "Pegged asset type"},
{RPCResult::Type::STR_HEX, "fee_asset", "The asset used for transaction fees and relay policy"},
{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"},
{RPCResult::Type::STR_HEX, "parent_blockhash", "The parent genesis blockhash as source of pegged-in funds"},
{RPCResult::Type::BOOL, "parent_chain_has_pow", "Whether parent chain has pow or signed blocks"},
Expand Down Expand Up @@ -3723,6 +3725,7 @@ static RPCHelpMan getsidechaininfo()
obj.pushKV("current_fedpeg_programs", fedpeg_prog_entries);
obj.pushKV("current_fedpegscripts", fedpeg_entries);
obj.pushKV("pegged_asset", consensus.pegged_asset.GetHex());
obj.pushKV("fee_asset", policyAsset.GetHex());
obj.pushKV("min_peg_diff", consensus.parentChainPowLimit.GetHex());
obj.pushKV("parent_blockhash", parent_blockhash.GetHex());
obj.pushKV("parent_chain_has_pow", consensus.ParentChainHasPow());
Expand Down
38 changes: 38 additions & 0 deletions test/functional/rpc_sidechaininfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python3
# Copyright (c) 2026 The Elements developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the getsidechaininfo fee-asset contract."""

from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import BITCOIN_ASSET, assert_equal, assert_is_hash_string


OVERRIDE_FEE_ASSET = "11" * 32


class SidechainInfoTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 2
self.setup_clean_chain = True
self.extra_args = [[], [f"-feeasset={OVERRIDE_FEE_ASSET}"]]

def setup_network(self):
self.setup_nodes()

def run_test(self):
default_info = self.nodes[0].getsidechaininfo()
override_info = self.nodes[1].getsidechaininfo()

for info in [default_info, override_info]:
assert_is_hash_string(info["pegged_asset"])
assert_is_hash_string(info["fee_asset"])
assert_equal(info["pegged_asset"], BITCOIN_ASSET)

assert_equal(default_info["fee_asset"], default_info["pegged_asset"])
assert_equal(override_info["fee_asset"], OVERRIDE_FEE_ASSET)
assert_equal(override_info["pegged_asset"], default_info["pegged_asset"])


if __name__ == "__main__":
SidechainInfoTest(__file__).main()
1 change: 1 addition & 0 deletions test/functional/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
'feature_blocksign.py --legacy-wallet',
'rpc_calcfastmerkleroot.py',
'feature_txwitness.py',
'rpc_sidechaininfo.py',
'rpc_tweakfedpeg.py --legacy-wallet',
'feature_issuance.py --legacy-wallet',
'feature_confidential_transactions.py --legacy-wallet',
Expand Down
Loading