Skip to content

Ideas for when there are two instances of MultiBit running

jim618 edited this page Sep 20, 2011 · 7 revisions

It will be quite a common use case for people to have 2 instances of multibit running. This enables the user to drag and drop between two screens.

(We could diasable this if we want to with a switch in the izPack installer to only have one JVM instance)

There needs to be careful coordination of the file writing with regards to the creation of private keys, especially with a move to 'My Wallets' where transactions are going into muliple wallets.

I propose we add explicit locking files as follows:

Locking filename : name of wallet minus .wallet.manage

These files would contain:

  • id for the JVM instance that is managing the creation of private keys
  • date time of last key created
  • bitcoin address of last private key created. NOT the private key itself.

We should use Java 6 and the random access file for writing/ locking as its behaviour is better than Java 5 and plain streams.

These would be used as follows:

User wants to create a private key, clicks on 'Create new' on receiving bitcoin page.

1 Code looks to see if locking file exists.

2 Creates it if not, adds a constant indicating the JVM, saves file. Now has manage lock.

3 Creates a private key, (does all the usual stuff) and puts address and creation date in file

4 Saves file again with key details.

This file is deleted by ExitAction and by a shutdown hook when this copy of bitcoin closes

If the other version of bitcoin running sees the lock file, it will not allow private keys to be made. The user is told to make it in the other one, with a 'refresh' button to reload the data.

This will stop there being multiple new private keys in different versions of the same wallets and having to merge them.

Also, when sending addresses are stored, the process should be:

1 load up file again from storage to see if new sending addresses have been created

2 add current sending addresses

3 write

that way sending addresses created in one copy of MultiBit will propagate to the other and not get overwritten.

Because both versions of the same wallet are hooked up the incoming bitcoin datastream we dont have to worry too much about merging the transaction data as long as we keep track in the wallet of the last block seen.