Christian Basler
bc68a5d3ec
- most notably removed some unnecessary synchronize blocks in the DefaultNetworkHandler |
||
---|---|---|
core | ||
cryptography-bc | ||
cryptography-sc | ||
demo | ||
extensions | ||
gradle/wrapper | ||
networking | ||
repositories | ||
wif | ||
.gitignore | ||
.travis.yml | ||
Bitmessage.uml | ||
build.gradle | ||
CONTRIBUTING.md | ||
gradle.properties | ||
gradlew | ||
gradlew.bat | ||
LICENSE | ||
README.md | ||
settings.gradle |
Jabit
A Java implementation for the Bitmessage protocol. To build, use command gradle build
or ./gradlew build
.
Please note that it still has its limitations, but the API should now be stable. Jabit uses Semantic Versioning, meaning as long as the major version doesn't change, nothing should break if you update.
Master
Develop
Security
There are most probably some security issues, me programming this thing all by myself. Jabit doesn't do anything against timing attacks yet, for example. Please feel free to use the library, report bugs and maybe even help out. I hope the code is easy to understand and work with.
Project Status
Basically, everything needed for a working Bitmessage client is there:
- Creating new identities (private addresses)
- Adding contacts and subscriptions
- Receiving broadcasts
- Receiving messages
- Sending messages and broadcasts
- Managing outgoing and incoming connections
- 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:
compile 'ch.dissem.jabit:jabit-core:1.0.0'
Unless you want to implement your own, also add the following:
compile 'ch.dissem.jabit:jabit-networking:1.0.0'
compile 'ch.dissem.jabit:jabit-repositories:1.0.0'
compile 'ch.dissem.jabit:jabit-cryptography-bouncy:1.0.0'
And if you want to import from or export to the Wallet Import Format (used by PyBitmessage) you might also want to add:
compile 'ch.dissem.jabit:jabit-wif:1.0.0'
For Android clients use jabit-cryptography-spongy
instead of jabit-cryptography-bouncy
.
Usage
First, you'll need to create a BitmessageContext
:
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())
.cryptography(new BouncyCryptography())
.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:
ctx.startup(new BitmessageContext.Listener() {
@Override
public void receive(Plaintext plaintext) {
// TODO: Notify the user
}
});
Then you might want to create an identity
BitmessageAddress identity = ctx.createIdentity(false, Pubkey.Feature.DOES_ACK);
or add some contacts
BitmessageAddress contact = new BitmessageAddress("BM-2cTarrmjMdRicKZ4qQ8A13JhoR3Uq6Zh5j");
address.setAlias("Chris");
ctx.addContact(contact);
to which you can send some messages
ctx.send(identity, contact, "Test", "Hello Chris, this is a message.");