I have an implementation of the BitCoin protocol written in Java that is fairly easy to use. The code I wrote to take these coins looked like:
ECKey halsKey = new ECKey(Base58.decodeToBigInteger("2qy6pGXd5yCo9qy3vxnN7rALgsXXcdboReZ9NZx5aExy"));
wallet.addKey(halsKey);
NetworkConnection conn = new NetworkConnection(params);
BlockChain chain = new BlockChain(params, wallet);
Peer peer = new Peer(params, conn, chain);
peer.start();
peer.startBlockChainDownload().await();
Address dest = new Address(params, "my address");
Transaction tx = wallet.createSend(dest, wallet.getBalance(), dest);
peer.broadcastTransaction(tx);
wallet.confirmSend(tx);
....
public ECKey(BigInteger privKey) {
priv = privKey;
pub = ecParams.getG().multiply(priv).getEncoded();
}
I know I'm not the only one with an independent implementation of the system by this point. Like I said, I'm hoping to be able to open source it, but still need some approvals.
On use cases: I wonder if it would be easier to make the client support having multiple independent wallets. Import/export of private keys isn't enough for those use cases, you have to be able to delete the key from your own wallet too.
I'm still not 100% convinced, but OK, I will defer to the wisdom of the crowd on this one. It can't hurt. I wouldn't normally post bounties as you have to be pretty precise when specifying them, but here we go. If somebody can see a better design or more precise spec let me know.
Bounty for the 50 coinsThe first person to get a patch merged by Gavin into the core software that allows import/export of wallet files, via the GUI on all 3 supported platforms, defined in the following manner wins the coins.
Export should write out the private keys and simultaneously delete those keys from the wallet. You are required to do the export, then the import, then only do the delete if the import passes. This is to guard against trivial failures like out of disk space. The bounty already requires import to be written so this is not much more work.
The format should be a text file with unix line endings and a default extension of .bitkeys that looks like this:
# Comment
v=1
base58 encoded privkey,block number # comment
base58 encoded privkey,block number
base58 encoded privkey,block number
# Comment
where the block number is the earliest block in which that address received coins, to make scanning for transactions faster by avoiding the need to check the entire block chain. Characters after a hash symbol should be ignored, the first non-comment line should be v=1. If the first line is not v=1 then the file should be rejected and the user told to upgrade their software.
I'll also throw in 50 of my own coins for a web page that, in JavaScript, accepts such a file (copy/paste into a text area), formats a file like the above into binary and then generates a QRcode using the html5 canvas library available here:
http://www.cipherbrain.be/qrcode/In other words, I should be able to take a .bitkeys file, copy/paste it into a web page and without any network traffic be then able to print my keys out onto paper. Don't cheat and use your own server side code or Google chartserver - I want to be able to trust that the keys never left my computer. HTML5 app because that way it'll work on everyones systems.
[edits: complicate the text format a bit to allow for future upgrades, require key deletion]