It is the start of a longish road, but I have started on a command line interface for the MultiBit object model. This will, when it is complete, be able to manipulate all the 'things' in MultiBit using a command line.
At the moment all it can do is show help, create new wallets and exit the shell as follows:
host47:Java jim$ cat multiBitShell.sh
java -classpath multibit-shell-exe.jar org.multibit.viewsystem.commandline.MultiBitCommandLine
host47:Java jim$ ./multiBitShell.sh
22:31:33.477 [main] INFO o.m.v.c.MultiBitCommandLine - Starting MultiBitCommandLine
22:31:33.484 [main] INFO o.m.ApplicationDataDirectoryLocator - Application data directory.1 = '/Users/jim/Library/Application Support/MultiBit'
22:31:33.514 [main] DEBUG o.m.v.c.MultiBitCommandLine - useTestNet = false
22:31:33.545 [main] DEBUG o.m.v.c.MultiBitCommandLine - userLanguageCode = en
22:31:33.564 [main] DEBUG o.m.v.c.MultiBitCommandLine - Creating model
22:31:33.569 [main] DEBUG org.multibit.model.MultiBitModel - Initial view from properties file is '1'
22:31:33.569 [main] DEBUG o.m.v.c.MultiBitCommandLine - Creating views
MB > 22:31:33.576 [main] DEBUG o.m.v.c.MultiBitCommandLine - Registering with controller
22:31:33.577 [main] DEBUG o.m.v.c.MultiBitCommandLine - Creating Bitcoin service
22:31:33.678 [main] DEBUG org.multibit.network.MultiBitService - Reading block store '/Users/jim/Library/Application Support/MultiBit/multibit.blockchain' from disk
22:31:33.683 [main] INFO o.m.store.ReplayableBlockStore - Reading block store fromUsers/jim/Library/Application Support/MultiBit/multibit.blockchain
22:31:33.691 [main] INFO o.m.store.ReplayableBlockStore - Read chain head from disk: 0000000000000a22f6f29ba1f5ca3c95bcf13d5f2bafeb45028971a154d73026
22:31:33.693 [main] DEBUG org.multibit.network.MultiBitService - Connecting ...
22:31:33.720 [main] DEBUG o.m.v.c.MultiBitCommandLine - Locating wallets
22:31:33.721 [main] DEBUG o.m.v.c.MultiBitCommandLine - Loading wallet from '/Users/jim/real money/blockChain.wallet'
MB:Message : Opening wallet "/Users/jim/real money/blockChain.wallet"...
22:31:36.204 [main] DEBUG org.multibit.file.FileHandler - rememberFileSizesAndLastModified: Wallet filenameUsers/jim/real money/blockChain.wallet , walletFileSize 3728832 ,walletFileLastModified 1333804495000 ,walletInfoFileSize 4399 ,walletInfoFileLastModified 1333804493000
MB:Message : Opening wallet "/Users/jim/real money/blockChain.wallet"... done.
22:31:36.219 [main] DEBUG o.m.v.c.MultiBitCommandLine - Loading wallet from '/Users/jim/real money/pettyCash.wallet'
MB:Message : Opening wallet "/Users/jim/real money/pettyCash.wallet"...
22:31:36.547 [main] DEBUG org.multibit.file.FileHandler - rememberFileSizesAndLastModified: Wallet filenameUsers/jim/real money/pettyCash.wallet , walletFileSize 452062 ,walletFileLastModified 1333804496000 ,walletInfoFileSize 1246 ,walletInfoFileLastModified 1333804496000
MB:Message : Opening wallet "/Users/jim/real money/pettyCash.wallet"... done.
22:31:36.563 [main] DEBUG o.m.v.c.MultiBitCommandLine - Loading wallet from '/Users/jim/real money/multibitDonate/donations.wallet'
MB:Message : Opening wallet "/Users/jim/real money/multibitDonate/donations.wallet"...
22:31:37.072 [main] DEBUG org.multibit.file.FileHandler - rememberFileSizesAndLastModified: Wallet filenameUsers/jim/real money/multibitDonate/donations.wallet , walletFileSize 992392 ,walletFileLastModified 1333804841000 ,walletInfoFileSize 1189 ,walletInfoFileLastModified 1333804840000
MB:Message : Opening wallet "/Users/jim/real money/multibitDonate/donations.wallet"... done.
22:31:37.103 [main] DEBUG o.m.v.c.MultiBitCommandLine - Loading wallet from '/users/jim/test/test1.wallet'
MB:Message : Opening wallet "/users/jim/test/test1.wallet"...
22:31:37.109 [main] DEBUG org.multibit.file.FileHandler - rememberFileSizesAndLastModified: Wallet filenameusers/jim/test/test1.wallet , walletFileSize 3082 ,walletFileLastModified 1333833631000 ,walletInfoFileSize 278 ,walletInfoFileLastModified 1333833631000
MB:Message : Opening wallet "/users/jim/test/test1.wallet"... done.
22:31:37.110 [main] DEBUG o.m.v.c.MultiBitCommandLine - Loading wallet from '/users/jim/test/test2.wallet'
MB:Message : Opening wallet "/users/jim/test/test2.wallet"...
22:31:37.115 [main] DEBUG org.multibit.file.FileHandler - rememberFileSizesAndLastModified: Wallet filenameusers/jim/test/test2.wallet , walletFileSize 3082 ,walletFileLastModified 1333833671000 ,walletInfoFileSize 395 ,walletInfoFileLastModified 1333833671000
MB:Message : Opening wallet "/users/jim/test/test2.wallet"... done.
22:31:37.116 [main] DEBUG o.m.v.c.MultiBitCommandLine - Loading wallet from '/users/jim/test/test3.wallet'
MB:Message : Opening wallet "/users/jim/test/test3.wallet"...
22:31:37.121 [main] DEBUG org.multibit.file.FileHandler - rememberFileSizesAndLastModified: Wallet filenameusers/jim/test/test3.wallet , walletFileSize 3082 ,walletFileLastModified 1333833719000 ,walletInfoFileSize 87 ,walletInfoFileLastModified 1333833719000
MB:Message : Opening wallet "/users/jim/test/test3.wallet"... done.
22:31:37.127 [main] DEBUG o.m.v.c.MultiBitCommandLine - Downloading blockchain
MB:Error : No view to display with id 1
MultiBitTool#processLine args = --action=HELP
22:31:37.128 [SwingWorker-pool-1-thread-7] DEBUG org.multibit.network.MultiBitService - Downloading blockchain
MultiBitShell: print and manipulate the MultiBit object model
Usage (Implemented):
HELP Show this help text.
EXIT Exit this MultiBitShell session.
CREATE --wallet --filename=<> Makes a new wallet in the file specified.
(Not Implemented Yet):
CREATE --sendingAddress --address=<> --label=<> Makes a new sending address with the given address and label.
--receivingAddress --label=<> Makes a new receiving address with the given label.
EDIT --preferences Edit the MultiBit preferences.
--sendingAddress --address=<> --label=<> Edit the sending address matching the given address or label.
--receivingAddress --address=<> --label=<> Edit the receiving address matching the given address or label.
LIST --wallets Lists all open wallets in a format suitable for picking.
--sendingAddresses Lists all sending addresses in a format suitable for picking.
--receivingAddresses Lists all receiving addresses in a format suitable for picking.
--transactions Lists all transactions for the active wallet for picking.
PICK --number=<> or --value=<> Pick from the last list either by list number or match by value.
DELETE --wallet --filename=<> Delete the wallet with the file specified.
--sendingAddress --address=<> --label=<> Delete the sending address with the given address or label.
--receivingAddress --address --label=<> Delete the receiving address with the given address or label.
SEND --address=<> --amount=<> Send the specified amount of BTC to the address specified.
RESET --date=<> Remove all transactions on or after the date, or all if no date specified.
REPLAY --date=<> Replay the blockchain from the date specified.
IMPORT_KEYS --filename=<> --password=<> Import private keys from the filename specified, using the password.
EXPORT_KEYS --filename=<> --password=<> Export private keys from the filename specified, using the password.
WAIT_FOR --online or --replayComplete Wait for MultiBit to come online or for the blockchain replay to complete.
SHOW --activeWallet Show which wallet is the active wallet.
--online Show whether MultiBit is onine or not.
--helpAbout Show the help about MultiBit details.
--ticker Show the most recent ticker details.
--messages=<number> Show the most recent <number> of messages.
--transaction Show the details of the last picked transaction.
MB:Message : Synchronised with network.
MB:Message : Synchronised with network.. 100.0% complete.
MB:Message : Synchronised with network.
MB:Message : Synchronised with network.. 100.0% complete.
MB:Message : MultiBit is now online
MB > CREATE --wallet --filename=/users/jim/test/test4.wallet
MultiBitTool#processLine args = --action=CREATE --wallet --filename=/users/jim/test/test4.wallet
22:32:07.727 [Thread-2] DEBUG org.multibit.model.WalletInfo - Could not load walletinfo file '/users/jim/test/test4.info'
22:32:07.728 [Thread-2] DEBUG org.multibit.model.WalletInfo - Cause :users/jim/test/test4.info (No such file or directory)
22:32:07.733 [Thread-2] DEBUG org.multibit.file.FileHandler - Result of check of whether files have changed for wallet filenameusers/jim/test/test4.wallet was true.
22:32:07.741 [Thread-2] DEBUG org.multibit.file.FileHandler - rememberFileSizesAndLastModified: Wallet filenameusers/jim/test/test4.wallet , walletFileSize 3082 ,walletFileLastModified 1333834327000 ,walletInfoFileSize 87 ,walletInfoFileLastModified 1333834327000
22:32:07.745 [Thread-2] DEBUG org.multibit.file.FileHandler - rememberFileSizesAndLastModified: Wallet filenameusers/jim/test/test4.wallet , walletFileSize 3082 ,walletFileLastModified 1333834327000 ,walletInfoFileSize 87 ,walletInfoFileLastModified 1333834327000
22:32:07.746 [Thread-2] DEBUG org.multibit.file.FileHandler - When writing wallets, there were 7
22:32:07.749 [Thread-2] DEBUG o.m.v.s.action.CreateNewWalletAction - User preferences with new wallet written successfully
MB > EXIT
MultiBitTool#processLine args = --action=EXIT
MultiBitTool#processLine - exit called.
host47:Java jim$
It will be a 'background task' whilst I work through other stuff.
Note: Primarily for security considerations none of the code for the MultiBit command line will be put in the regular MultiBit installers. There is a separate jar file (multibit-shell-exe.jar) that people will have to download if they want to use this. It is for advanced users so it is better not to have it in the regular installers.
P.S. The parser (the clever bit of the code that interprets all the commands and options) is a blatant copy of Mike Hearn's wallet-tool which does a similar task for the bitcoinj code. Thanks Mike !