mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-13 12:33:42 +02:00
Merge pull request #1522 from delta1/2026-01-tweakfedpegscript
rpc!: change tweakfedpegscript to output both p2wsh and p2shwsh addresses
This commit is contained in:
commit
6d29a59f61
2 changed files with 15 additions and 4 deletions
|
|
@ -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;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -196,7 +196,10 @@ class FedPegTest(BitcoinTestFramework):
|
|||
# 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 @@ class FedPegTest(BitcoinTestFramework):
|
|||
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 @@ class FedPegTest(BitcoinTestFramework):
|
|||
|
||||
# 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"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue