Chans should now work.

Other deterministic addresses should be easy to implement, but aren't done yet
This commit is contained in:
2016-04-07 17:24:56 +02:00
parent ead5341b2e
commit 32ea3517fe
8 changed files with 70 additions and 16 deletions

View File

@ -54,14 +54,11 @@ public class Application {
.networkHandler(new DefaultNetworkHandler())
.cryptography(new BouncyCryptography())
.port(48444)
.listener(new BitmessageContext.Listener() {
@Override
public void receive(Plaintext plaintext) {
try {
System.out.println(new String(plaintext.getMessage(), "UTF-8"));
} catch (UnsupportedEncodingException e) {
LOG.error(e.getMessage(), e);
}
.listener(plaintext -> {
try {
System.out.println(new String(plaintext.getMessage(), "UTF-8"));
} catch (UnsupportedEncodingException e) {
LOG.error(e.getMessage(), e);
}
})
.build();
@ -136,6 +133,7 @@ public class Application {
System.out.println();
commandLine.listAddresses(identities, "identities");
System.out.println("a) create identity");
System.out.println("c) join chan");
System.out.println(COMMAND_BACK);
command = commandLine.nextCommand();
@ -144,6 +142,10 @@ public class Application {
addIdentity();
identities = ctx.addresses().getIdentities();
break;
case "c":
joinChan();
identities = ctx.addresses().getIdentities();
break;
case "b":
return;
default:
@ -168,6 +170,15 @@ public class Application {
ctx.addresses().save(identity);
}
private void joinChan() {
System.out.println();
System.out.print("Passphrase: ");
String passphrase = commandLine.nextLine();
System.out.print("Address: ");
String address = commandLine.nextLineTrimmed();
ctx.joinChan(passphrase, address);
}
private void contacts() {
String command;
List<BitmessageAddress> contacts = ctx.addresses().getContacts();
@ -258,6 +269,12 @@ public class Application {
} else {
System.out.println("Public key available");
}
} else {
if (address.isChan()) {
System.out.println("Chan");
} else {
System.out.println("Identity");
}
}
}