Skip to content

Commit a304a36

Browse files
committed
Revert "Store p2sh scripts in AddAndGetDestinationForScript"
This reverts commit 4a7e43e.
1 parent eb7d8a5 commit a304a36

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/outputtype.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,30 +82,22 @@ CTxDestination AddAndGetDestinationForScript(FillableSigningProvider& keystore,
8282
{
8383
// Add script to keystore
8484
keystore.AddCScript(script);
85-
ScriptHash sh(script);
8685
// Note that scripts over 520 bytes are not yet supported.
8786
switch (type) {
8887
case OutputType::LEGACY:
89-
keystore.AddCScript(GetScriptForDestination(sh));
90-
return sh;
88+
return ScriptHash(script);
9189
case OutputType::P2SH_SEGWIT:
9290
case OutputType::BECH32: {
9391
CTxDestination witdest = WitnessV0ScriptHash(script);
9492
CScript witprog = GetScriptForDestination(witdest);
9593
// Check if the resulting program is solvable (i.e. doesn't use an uncompressed key)
96-
if (!IsSolvable(keystore, witprog)) {
97-
// Since the wsh is invalid, add and return the sh instead.
98-
keystore.AddCScript(GetScriptForDestination(sh));
99-
return sh;
100-
}
94+
if (!IsSolvable(keystore, witprog)) return ScriptHash(script);
10195
// Add the redeemscript, so that P2WSH and P2SH-P2WSH outputs are recognized as ours.
10296
keystore.AddCScript(witprog);
10397
if (type == OutputType::BECH32) {
10498
return witdest;
10599
} else {
106-
ScriptHash sh_w = ScriptHash(witprog);
107-
keystore.AddCScript(GetScriptForDestination(sh_w));
108-
return sh_w;
100+
return ScriptHash(witprog);
109101
}
110102
}
111103
default: assert(false);

0 commit comments

Comments
 (0)