-
Notifications
You must be signed in to change notification settings - Fork 112
/
btc.java
52 lines (41 loc) · 1.54 KB
/
btc.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package btc.btc2;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.Scanner;
import org.bitcoinj.core.Address;
import org.bitcoinj.core.DumpedPrivateKey;
import org.bitcoinj.core.ECKey;
import org.bitcoinj.core.NetworkParameters;
public class btc {
@SuppressWarnings("deprecation")
public static void main(String[] args) throws Exception {
Scanner reader = new Scanner(System.in);
System.out.println("Enter Bitcoin Address: ");
String GivenAddress = reader.nextLine();
PrintWriter writer = new PrintWriter(new FileWriter("foundaddress.txt"));
for(;;) {
String net = "prod";
if (args.length >= 1 && (args[0].equals("test") || args[0].equals("prod"))) {
net = args[0];
System.out.println("Using " + net + " network.");
}
ECKey key = new ECKey();
final NetworkParameters netParams;
if (net.equals("prod")) {
netParams = NetworkParameters.prodNet();
} else {
netParams = NetworkParameters.testNet();
}
Address addressFromKey = key.toAddress(netParams);
String privatekey = key.getPrivateKeyAsHex();
DumpedPrivateKey privatekey2 = key.getPrivateKeyEncoded(netParams);
if(GivenAddress.equals(addressFromKey)) {
writer.print(addressFromKey + " " + privatekey2);
writer.flush();
System.out.println("Using " + net + " network, Generated address:\n" + addressFromKey + " da private keyz: " + privatekey + " " + privatekey2);
break;
}
}
reader.close(); writer.flush(); writer.close();
}
}