Skip to content
Bitcoin Solutions Ltd edited this page Jan 30, 2014 · 4 revisions

What is MBHD Hardware?

MBHD Hardware is a support library, written in Java, that simplifies the code required to talk to a Bitcoin hardware wallet and links it into the main MultiBit HD application. One example provided is for the popular Bitcoin Trezor device.

Why should I use it?

It will allow you to integrate your hardware wallet into the MultiBit HD wallet thus relieving you of the requirement to develop your own and focus on making hardware sales. In addition, much of the standard code to access a hardware wallet over USB HID and sockets is already written so you can leverage that in your project.

MultiBit Hardware will run standalone so you are under no obligation to integrate with MultiBit HD, but you can still use the library in your own projects to reduce the time to market.

How do I use it?

MBHD Hardware is built with Maven so you can just include the core as a dependency. Then you can choose which devices you want to support. At the moment the Trezor "Shield" board on a Raspberry Pi is available over USB HID and sockets, and shortly the main Trezor device will be implemented.

More hardware wallets will come in time.

<!-- MultiBit Hardware Core -->
<dependency>
  <groupId>org.multibit.hd.hardware</groupId>
  <artifactId>core</artifactId>
  <version>0.0.1-SNAPSHOT</version>
</dependency>

A quick overview of the API

In general you will work with the following top-level objects:

  • HardwareWalletFactory - to provide you with a variety of different connection types (USB, Socket etc)
  • HardwareWallet - the interface for the device allowing you to add a listener and send a message
  • HardwareWalletEvent - received as a result of something occurring on the hardware (new message, USB signalling etc)
  • HardwareWalletMessage - top-level class containing the protocol buffer message payload

That's pretty much it. Obviously you'll want to dig in deeper to HardwareWalletMessage but you won't need to learn much more than what is present in the examples module to get something up and running.

Some example code

Here's a typical example of the API in action:

// Create a socket Trezor
HardwareWallet trezor = HardwareWalletFactory.INSTANCE.newSocketTrezor(host, port);


// Set up an executor service to monitor Trezor events
createTrezorEventExecutorService();

// Connect
trezor.connect();

// Send a message
trezor.sendMessage(TrezorMessage.Ping.getDefaultInstance());

The above is a snippet from the Rasberry Pi Shield Example.

Where next?

If you have a Raspberry Pi and a Shield device, you'll want to read Trezor on Raspberry Pi from scratch.

Take a look at the Pages and explore from there.