diff --git a/examples/example_END_3.conf b/examples/example_END_3.conf
new file mode 100644
index 0000000..20090dd
--- /dev/null
+++ b/examples/example_END_3.conf
@@ -0,0 +1,6 @@
+END
+#target: L2VuM2Mj8E1VwwBLbxj8zujzeKJPQ9UE2GwMjEvLiCMY3kJj6F8F
+#2nd line: WIF with missing end
+L2VuM2Mj8E1VwwBLbxj8zujzeKJPQ9UE2GwMjEvLiCMY3
+#3rd end: expected address, if you know one
+3H1qgYqxfzqxmMT9MKAjbxyrpVZ5YtA3wX
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 6989a8f..f124931 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.pawelgorny
wifSolver
- 0.5.8
+ 0.5.9
jar
diff --git a/src/main/java/com/pawelgorny/wifsolver/Configuration.java b/src/main/java/com/pawelgorny/wifsolver/Configuration.java
index b9212d0..b2c3682 100644
--- a/src/main/java/com/pawelgorny/wifsolver/Configuration.java
+++ b/src/main/java/com/pawelgorny/wifsolver/Configuration.java
@@ -17,7 +17,7 @@ public class Configuration {
private final static int STATUS_PERIOD = 60 * 1000; //1 minute
private final static int CHECKSUM_CHARS = 5;
-
+ private Boolean isP2SH;
private final String targetAddress;
private final String wif;
private final String wifStatus;
@@ -33,9 +33,15 @@ public class Configuration {
public Configuration(String targetAddress, String wif, String wifStatus, WORK work, Map guess) {
this.targetAddress = targetAddress;
+ isP2SH = false;
if (targetAddress != null) {
- this.address = LegacyAddress.fromBase58(NETWORK_PARAMETERS, getTargetAddress());
- this.addressHash = address.getHash();
+ if (targetAddress.startsWith("3")){
+ compressed = true;
+ isP2SH = true;
+ }else {
+ this.address = LegacyAddress.fromBase58(NETWORK_PARAMETERS, getTargetAddress());
+ this.addressHash = address.getHash();
+ }
}
this.wif = wif;
this.compressed = wif.length() == COMPRESSED_WIF_LENGTH || (WORK.END.equals(work) && (wif.startsWith("L") || wif.startsWith("K")));
@@ -104,6 +110,10 @@ public void setForceThreads(Integer forceThreads) {
this.forceThreads = forceThreads;
}
+ public Boolean getIsP2SH() {
+ return isP2SH;
+ }
+
class EmailConfiguration{
private final Session mailSession;
private final String emailTo;
diff --git a/src/main/java/com/pawelgorny/wifsolver/WorkerEnd.java b/src/main/java/com/pawelgorny/wifsolver/WorkerEnd.java
index 2d85c41..676f982 100644
--- a/src/main/java/com/pawelgorny/wifsolver/WorkerEnd.java
+++ b/src/main/java/com/pawelgorny/wifsolver/WorkerEnd.java
@@ -1,6 +1,9 @@
package com.pawelgorny.wifsolver;
import org.bitcoinj.core.*;
+import org.bitcoinj.script.Script;
+import org.bitcoinj.script.ScriptBuilder;
+import org.bitcoinj.script.ScriptPattern;
import java.util.Arrays;
import java.util.Date;
@@ -121,12 +124,24 @@ private String checksumCheck(int missing, String wif, int len, final Address tar
if (!configuration.isCompressed()) {
ecKey = ecKey.decompress();
}
- if (targetAddress != null) {
- if (Arrays.equals(ecKey.getPubKeyHash(), targetAddress.getHash())) {
- Address foundAddress = LegacyAddress.fromKey(Configuration.getNetworkParameters(), ecKey);
- found = true;
- super.addResult(encoded + " -> " + foundAddress);
- System.out.println(encoded + " -> " + foundAddress);
+ if (targetAddress != null || configuration.getIsP2SH()) {
+ if (configuration.getIsP2SH()){
+ Script redeemScript = ScriptBuilder.createP2WPKHOutputScript(ecKey);
+ Script script = ScriptBuilder.createP2SHOutputScript(redeemScript);
+ byte[] scriptHash = ScriptPattern.extractHashFromP2SH(script);
+ LegacyAddress foundAddress = LegacyAddress.fromScriptHash(configuration.getNetworkParameters(), scriptHash);
+ if (foundAddress.toString().equals(configuration.getTargetAddress())){
+ found = true;
+ super.addResult(encoded + " -> " + foundAddress);
+ System.out.println(encoded + " -> " + foundAddress);
+ }
+ }else {
+ if (Arrays.equals(ecKey.getPubKeyHash(), targetAddress.getHash())) {
+ Address foundAddress = LegacyAddress.fromKey(Configuration.getNetworkParameters(), ecKey);
+ found = true;
+ super.addResult(encoded + " -> " + foundAddress);
+ System.out.println(encoded + " -> " + foundAddress);
+ }
}
} else {
Address foundAddress = LegacyAddress.fromKey(Configuration.getNetworkParameters(), ecKey);