From 5c8cf6bc388be0c06b6fe6b385a5bc6f7c5cb840 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Tue, 15 Apr 2014 17:28:55 +0200 Subject: [PATCH] Deprecate Script.isSentToP2SH() as it did the same thing as isPayToScriptHash. --- .../java/com/google/bitcoin/script/Script.java | 14 +++++--------- .../java/com/google/bitcoin/script/ScriptTest.java | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/com/google/bitcoin/script/Script.java b/core/src/main/java/com/google/bitcoin/script/Script.java index 2425fcd2..5b8894d1 100644 --- a/core/src/main/java/com/google/bitcoin/script/Script.java +++ b/core/src/main/java/com/google/bitcoin/script/Script.java @@ -238,15 +238,11 @@ public class Script { } /** - * Returns true if this script is of the form OP_HASH160 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"); diff --git a/core/src/test/java/com/google/bitcoin/script/ScriptTest.java b/core/src/test/java/com/google/bitcoin/script/ScriptTest.java index 2eb3205b..6735cadd 100644 --- a/core/src/test/java/com/google/bitcoin/script/ScriptTest.java +++ b/core/src/test/java/com/google/bitcoin/script/ScriptTest.java @@ -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