Skip to content
Merged
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
6 changes: 4 additions & 2 deletions src/rpc/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
Expand Down
13 changes: 11 additions & 2 deletions test/functional/feature_fedpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down Expand Up @@ -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"]
Expand Down