From 5d64e8945d508faf017885f5f1b1275c092b5c19 Mon Sep 17 00:00:00 2001 From: Byron Hambly Date: Tue, 13 Jan 2026 10:21:23 +0200 Subject: [PATCH] rpc!: change tweakfedpegscript to output P2WSH address Changes tweakfedpegscript to return both p2wsh and p2shwsh version of the tweaked address. "address" has been removed from the result and replaced with "p2wsh" and "p2shwsh". --- src/rpc/misc.cpp | 6 ++++-- test/functional/feature_fedpeg.py | 13 +++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index f0f57798313..b1a941e9aab 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -878,11 +878,13 @@ static RPCHelpMan tweakfedpegscript() CScript tweaked_script = calculate_contract(fedpegscript, claim_script); CScript redeem_script = GetScriptForDestination(WitnessV0ScriptHash(tweaked_script)); - CTxDestination parent_addr{ScriptHash(redeem_script)}; + CTxDestination p2wsh{WitnessV0ScriptHash(tweaked_script)}; + CTxDestination p2shwsh{ScriptHash(GetScriptForDestination(p2wsh))}; UniValue ret(UniValue::VOBJ); ret.pushKV("script", HexStr(tweaked_script)); - ret.pushKV("address", EncodeParentDestination(parent_addr)); + ret.pushKV("p2wsh", EncodeParentDestination(p2wsh)); + ret.pushKV("p2shwsh", EncodeParentDestination(p2shwsh)); return ret; }, diff --git a/test/functional/feature_fedpeg.py b/test/functional/feature_fedpeg.py index 78788a5968e..ee57b8b5d10 100755 --- a/test/functional/feature_fedpeg.py +++ b/test/functional/feature_fedpeg.py @@ -196,7 +196,10 @@ def run_test(self): # getting rid of old fedpegscript by making at least another epoch pass by WSH_OP_TRUE = self.nodes[0].decodescript("51")["segwit"]["hex"] # We just randomize the keys a bit to get another valid fedpegscript - new_fedpegscript = sidechain.tweakfedpegscript("f00dbabe")["script"] + tweaked = sidechain.tweakfedpegscript("f00dbabe") + assert sidechain.getaddressinfo(tweaked['p2wsh'])['iswitness'] + assert not sidechain.getaddressinfo(tweaked['p2shwsh'])['iswitness'] + new_fedpegscript = tweaked["script"] if self.options.post_transition: print("Running test post-transition") for _ in range(30): @@ -218,6 +221,12 @@ def run_test(self): addrs = sidechain.getpeginaddress() addr = addrs["mainchain_address"] assert_equal(sidechain.decodescript(addrs["claim_script"])["type"], "witness_v0_keyhash") + current_fedpegscript = sidechain.getsidechaininfo()["current_fedpegscripts"][0] + tweaked = sidechain.tweakfedpegscript(addrs["claim_script"], current_fedpegscript) + if sidechain.getaddressinfo(addr)['iswitness']: + assert_equal(tweaked['p2wsh'], addr) + else: + assert_equal(tweaked['p2shwsh'], addr) txid1 = parent.sendtoaddress(addr, 24) vout = find_vout_for_address(parent, txid1, addr) # 10+2 confirms required to get into mempool and confirm @@ -378,7 +387,7 @@ def run_test(self): # Look at pegin fields decoded = sidechain.decoderawtransaction(tx1["hex"]) - assert decoded["vin"][0]["is_pegin"] == True + assert decoded["vin"][0]["is_pegin"] assert len(decoded["vin"][0]["pegin_witness"]) > 0 # Check that there's sufficient fee for the peg-in vsize = decoded["vsize"]