3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-31 15:22:16 +00:00

Deprecate Script.isSentToP2SH() as it did the same thing as isPayToScriptHash.

This commit is contained in:
Mike Hearn 2014-04-15 17:28:55 +02:00
parent 0942bb57b5
commit 5c8cf6bc38
2 changed files with 6 additions and 10 deletions

View File

@ -238,15 +238,11 @@ public class Script {
} }
/** /**
* Returns true if this script is of the form OP_HASH160 <scriptHash> OP_EQUAL, ie, payment to an * An alias for isPayToScriptHash.
* address like 35b9vsyH1KoFT5a5KtrKusaCcPLkiSo1tU. This form was codified as part of BIP13 and BIP16,
* for pay to script hash type addresses.
*/ */
@Deprecated
public boolean isSentToP2SH() { public boolean isSentToP2SH() {
return chunks.size() == 3 && return isPayToScriptHash();
chunks.get(0).equalsOpCode(OP_HASH160) &&
chunks.get(1).data.length == Address.LENGTH &&
chunks.get(2).equalsOpCode(OP_EQUAL);
} }
/** /**
@ -258,7 +254,7 @@ public class Script {
public byte[] getPubKeyHash() throws ScriptException { public byte[] getPubKeyHash() throws ScriptException {
if (isSentToAddress()) if (isSentToAddress())
return chunks.get(2).data; return chunks.get(2).data;
else if (isSentToP2SH()) else if (isPayToScriptHash())
return chunks.get(1).data; return chunks.get(1).data;
else else
throw new ScriptException("Script not in the standard scriptPubKey form"); throw new ScriptException("Script not in the standard scriptPubKey form");
@ -303,7 +299,7 @@ public class Script {
public Address getToAddress(NetworkParameters params) throws ScriptException { public Address getToAddress(NetworkParameters params) throws ScriptException {
if (isSentToAddress()) if (isSentToAddress())
return new Address(params, getPubKeyHash()); return new Address(params, getPubKeyHash());
else if (isSentToP2SH()) else if (isPayToScriptHash())
return Address.fromP2SHScript(params, this); return Address.fromP2SHScript(params, this);
else else
throw new ScriptException("Cannot cast this script to a pay-to-address type"); throw new ScriptException("Cannot cast this script to a pay-to-address type");

View File

@ -99,7 +99,7 @@ public class ScriptTest {
@Test @Test
public void testP2SHOutputScript() throws Exception { public void testP2SHOutputScript() throws Exception {
Address p2shAddress = new Address(MainNetParams.get(), "35b9vsyH1KoFT5a5KtrKusaCcPLkiSo1tU"); Address p2shAddress = new Address(MainNetParams.get(), "35b9vsyH1KoFT5a5KtrKusaCcPLkiSo1tU");
assertTrue(ScriptBuilder.createOutputScript(p2shAddress).isSentToP2SH()); assertTrue(ScriptBuilder.createOutputScript(p2shAddress).isPayToScriptHash());
} }
@Test @Test