diff --git a/README.md b/README.md index 794d8d5..eb5cdfc 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Jabit [![Build Status](https://travis-ci.org/Dissem/Jabit.svg?branch=master)](https://travis-ci.org/Dissem/Jabit) ===== -A Java implementation for the Bitmessage protocol. To build, use command `gradle build`. Note that for some tests to run, a standard Bitmessage client needs to run on the same system, using port 8444 (the default port). +A Java implementation for the Bitmessage protocol. To build, use command `gradle build` or `./gradlew build`. Please note that development is still heavily in progress, and I will break the database a lot until it's ready for prime time. @@ -12,6 +12,7 @@ There are most probably some security issues, me programming this thing all by m Project Status -------------- + Basically, everything needed for a working Bitmessage client is there: * Creating new identities (private addresses) * Adding contracts and subscriptions @@ -22,3 +23,59 @@ Basically, everything needed for a working Bitmessage client is there: * Initialise and manage a registry of Bitmessage network nodes * An easy to use API * A command line demo application built using the API + +Setup +----- + +Add Jabit as Gradle dependency: +```Gradle +compile 'ch.dissem.jabit:jabit-domain:0.2.0' +``` +Unless you want to implement your own, also add the following: +```Gradle +compile 'ch.dissem.jabit:jabit-networking:0.2.0' +compile 'ch.dissem.jabit:jabit-repositories:0.2.0' +``` +And if you want to import from or export to the Wallet Import Format (used by PyBitmessage) you might also want to add: +```Gradle +compile 'ch.dissem.jabit:jabit-wif:0.2.0' +``` + +Usage +----- + +First, you'll need to create a `BitmessageContext`: +```Java +JdbcConfig jdbcConfig = new JdbcConfig(); +BitmessageContext ctx = new BitmessageContext.Builder() + .addressRepo(new JdbcAddressRepository(jdbcConfig)) + .inventory(new JdbcInventory(jdbcConfig)) + .messageRepo(new JdbcMessageRepository(jdbcConfig)) + .nodeRegistry(new MemoryNodeRegistry()) + .networkHandler(new NetworkNode()) + .build(); +``` +This creates a simple context using a H2 database that will be created in the user's home directory. Next you'll need to +start the context and decide what happens if a message arrives: +```Java +ctx.startup(new BitmessageContext.Listener() { + @Override + public void receive(Plaintext plaintext) { + // TODO: Notify the user + } +}); +``` +Then you might want to create an identity +```Java +BitmessageAddress identity = ctx.createIdentity(false, Pubkey.Feature.DOES_ACK); +``` +or add some contacts +```Java +BitmessageAddress contact = new BitmessageAddress("BM-2cTarrmjMdRicKZ4qQ8A13JhoR3Uq6Zh5j"); +address.setAlias("Chris"); +ctx.addContact(contact); +``` +to which you can send some messages +```Java +ctx.send(identity, contact, "Test", "Hello Chris, this is a message."); +``` diff --git a/build.gradle b/build.gradle index e344836..7bf5c3f 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,9 @@ subprojects { sourceCompatibility = 1.7 group = 'ch.dissem.jabit' - version = '0.1.3-SNAPSHOT' + version = '0.2.0' + + ext.isReleaseVersion = !version.endsWith("SNAPSHOT") repositories { mavenCentral() @@ -25,50 +27,51 @@ subprojects { archives javadocJar, sourcesJar } - // Note: to build the project, you'll either need to - if (hasProperty('signing.keyId')) { - signing { - sign configurations.archives - } + signing { + required { isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives") } + sign configurations.archives } - if (hasProperty('ossrhUsername')) { - uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } + uploadArchives { + repositories { + mavenDeployer { + beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { - authentication(userName: ossrhUsername, password: ossrhPassword) + if (!hasProperty('ossrhUsername')) { + ext.ossrhUsername = 'dummy' + ext.ossrhPassword = 'dummy' + } + + repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { + authentication(userName: ossrhUsername, password: ossrhPassword) + } + + snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { + authentication(userName: ossrhUsername, password: ossrhPassword) + } + + pom.project { + name 'Jabit' + packaging 'jar' + url 'https://github.com/Dissem/Jabit' + + scm { + connection 'scm:git:https://github.com/Dissem/Jabit.git' + developerConnection 'scm:git:git@github.com:Dissem/Jabit.git' + url 'https://github.com/Dissem/Jabit.git' } - snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { - authentication(userName: ossrhUsername, password: ossrhPassword) + licenses { + license { + name 'The Apache License, Version 2.0' + url 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } } - pom.project { - name 'Jabit' - packaging 'jar' - url 'https://github.com/Dissem/Jabit' - - scm { - connection 'scm:git:https://github.com/Dissem/Jabit.git' - developerConnection 'scm:git:git@github.com:Dissem/Jabit.git' - url 'https://github.com/Dissem/Jabit.git' - } - - licenses { - license { - name 'The Apache License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } - } - - developers { - developer { - name 'Christian Basler' - email 'chrigu.meyer@gmail.com' - } + developers { + developer { + name 'Christian Basler' + email 'chrigu.meyer@gmail.com' } } }