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:
parent
0942bb57b5
commit
5c8cf6bc38
@ -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
|
||||
* address like 35b9vsyH1KoFT5a5KtrKusaCcPLkiSo1tU. This form was codified as part of BIP13 and BIP16,
|
||||
* for pay to script hash type addresses.
|
||||
* An alias for isPayToScriptHash.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isSentToP2SH() {
|
||||
return chunks.size() == 3 &&
|
||||
chunks.get(0).equalsOpCode(OP_HASH160) &&
|
||||
chunks.get(1).data.length == Address.LENGTH &&
|
||||
chunks.get(2).equalsOpCode(OP_EQUAL);
|
||||
return isPayToScriptHash();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -258,7 +254,7 @@ public class Script {
|
||||
public byte[] getPubKeyHash() throws ScriptException {
|
||||
if (isSentToAddress())
|
||||
return chunks.get(2).data;
|
||||
else if (isSentToP2SH())
|
||||
else if (isPayToScriptHash())
|
||||
return chunks.get(1).data;
|
||||
else
|
||||
throw new ScriptException("Script not in the standard scriptPubKey form");
|
||||
@ -303,7 +299,7 @@ public class Script {
|
||||
public Address getToAddress(NetworkParameters params) throws ScriptException {
|
||||
if (isSentToAddress())
|
||||
return new Address(params, getPubKeyHash());
|
||||
else if (isSentToP2SH())
|
||||
else if (isPayToScriptHash())
|
||||
return Address.fromP2SHScript(params, this);
|
||||
else
|
||||
throw new ScriptException("Cannot cast this script to a pay-to-address type");
|
||||
|
@ -99,7 +99,7 @@ public class ScriptTest {
|
||||
@Test
|
||||
public void testP2SHOutputScript() throws Exception {
|
||||
Address p2shAddress = new Address(MainNetParams.get(), "35b9vsyH1KoFT5a5KtrKusaCcPLkiSo1tU");
|
||||
assertTrue(ScriptBuilder.createOutputScript(p2shAddress).isSentToP2SH());
|
||||
assertTrue(ScriptBuilder.createOutputScript(p2shAddress).isPayToScriptHash());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user