BitCoinJ as a full network client - what's needed?

138 views
Skip to first unread message

Petr Praus

unread,
Aug 22, 2012, 7:28:59 PM8/22/12
to bitc...@googlegroups.com
Hi,
I'm doing Bitcoin-related research towards my Master's and I need to create my own block chain and network (I'll skip the description of the research topic). The most straightforward approach would probably be to use the Satoshi client and build my network with Satoshi-based clients. However, BitCoinJ caught my eye with it's relative simplicity and readability and I would love to use BitCoinJ instead.

Going through the code, I can see that's not really possible right now if only because BitCoinJ does not even listen for incoming connections (which is understandable given it's mobile roots). The question is, what would be needed to implement in BitCoinJ to build a custom, functioning network consisting only from BitCoinJ-based clients? Note that this alternative network would be really only intended for playing around with some of the research ideas we have so it does not have to be particularly resilient against various attacks, for example. I'd also guess that a non-negligible amount of code from such an effort could be contributed back to BitCoinJ to help it on it's road to full network node.

I hope I'm not asking a recently discussed question but I haven't been able to find any recent thread about this. I did find this post from Mike Hearn describing some things that need to be done to achieve the full client status but that has been a year ago and some things have probably changed.

Thanks,
Petr Praus

Mike Hearn

unread,
Aug 23, 2012, 5:01:53 AM8/23/12
to bitc...@googlegroups.com
There's still a fair amount of work needed, unfortunately. Thanks for linking to my previous post, that saves me a bit of time to fish it out :-)

Matt Corallo has done a lot of work on making bitcoinj fully verifying. Getting that work merged in is obviously the most important next step. You can find it here and you may prefer to work based off his branch instead of bitcoinj master, at least for now:


Matts work is of very high quality and I usually find it can be merged with few or no changes, so I don't anticipate a ton of merge conflicts if you do base your work on his. On the other hand making bitcoinj fully verifying is a huge change and needs to be reviewed very carefully due the potential for seriously messing up the network. And I have many demands on my time, so it'll take a while. Certainly, if your understanding of the Bitcoin protocol is solid, doing reviews of his work will help me out too.

Beyond that, we'd still need to do a proper fee solver/coin selector, listening for incoming connections, a proper addr broadcast manager, and so on.

I think most of the work is just generally refactoring/abstracting the code better. I definitely want bitcoinj to evolve away from being purely mobile-oriented and become more of a general kit for building Bitcoin applications and Bitcoin-style networks. Right now bitcoinj is under-abstracted and suffers a lot from missing/rough APIs, tight coupling between components, etc.

Without knowing more about your research I can't really say whether it'd be easier to use bitcoinj or Satoshis code. I'm interested in all Bitcoin related research - if you describe it more I could give you further advice. A lot depends on how close to the existing Bitcoin network you need to be.

Joseph Gleason

unread,
Aug 23, 2012, 10:06:18 AM8/23/12
to bitc...@googlegroups.com
It is pretty easy to make a new blockchain on the Satoshi client. I
did it a year ago here:
https://github.com/fireduck64/duckcoin

It is over a year out of date but I recall the changes not being too
bad. I recall having to write some code to find a nonce that made the
first block work. I also discovered that if you have a single node
and no download blocks it will never generate any, it assumes
(reasonably) that it is disconnected from the network. You have to
have two nodes with no blocks in contact with each other before they
accept they there is no block chain yet.

Then you can start pointing any bitcoin miner software you like at
them and quickly make some blocks.

Petr Praus

unread,
Aug 23, 2012, 8:43:01 PM8/23/12
to bitc...@googlegroups.com
Thanks for the link to Matt's work, I'll look into it and talk with my advisor what he thinks and whether the bitcoinj contribution could be part of my project.

My research is about multicurrency. I want to make it (relatively) easy to create your own Bitcoin chain (your own currency) with your own rules. For example, you could be able to control the supply of new money into the chain - becoming a sort of central authority. This could be probably done by issuing tokens that "authorize" coinbase transactions. E.g. if you want to include a coinbase transaction in your new block, you have to have my permission for that transaction to be valid and accepted by others. This could be useful if you wanted to create a block chain backed by (or tied 1:1 to) some other currency. You would obviously want to control new coins because they represent your "real" money, but transaction processing could be outsourced. The incentive for miners remains questionnable, decentralized Bitcoin certainly sounds much more appealing :-) But who knows, incentive does not have to be monetary, I can imagine some humanitarian organization operating like this for the purpose of transparency and cheap international transactions.

The reasoning behind all this is that Bitcoin has some nice features like cheap (because there is no monopoly on transaction confirmation) and fast transactions that you currently can't use on it's own without being forced into decentralization. There is obviously a bunch of open questions like whether we could do peer to peer exchanges without trusting 3rd party (like MtGox) but if we knew what we are doing, it wouldn't be called research, right? :-)

I recently run into a page you wrote on the Bitcoin wiki about Contracts. Example 5 especially caught my eye as that basically desribes a very similar use case to the one I wrote above. Maybe Contracts could be used to facilitate the abovementioned peer-to-peer exchange? Perhaps along the lines of "the coins I gave you are valid if only if the coins you gave me are valid". But I just skimmed the Contracts page, so this might be nonsense.

Petr Praus

unread,
Aug 23, 2012, 8:49:07 PM8/23/12
to bitc...@googlegroups.com
Thanks for this Joseph, I'll have a look, it will certainly help! :)

Gary Rowe

unread,
Aug 24, 2012, 3:24:08 AM8/24/12
to bitc...@googlegroups.com
Petr, you may also be interested in looking at the OpenTransactions project (see https://github.com/FellowTraveler/Open-Transactions/wiki/) which aims to create a legal framework of contracts with Bitcoin providing the financial fulfilment mechanism. 

Mike Hearn

unread,
Aug 24, 2012, 5:56:36 AM8/24/12
to bitc...@googlegroups.com
My research is about multicurrency. I want to make it (relatively) easy to create your own Bitcoin chain (your own currency) with your own rules. For example, you could be able to control the supply of new money into the chain - becoming a sort of central authority. This could be probably done by issuing tokens that "authorize" coinbase transactions.

I think if you were going to do that, the easiest way is just to have a magic key. When you see a transaction that's signed by that magic key (the key can be recovered from the signature, btw) you'd just not verify the inputs on those transactions. Thus you can issue as much money as you want. It doesn't have to be related to the coinbase.

I've thought about all this before as part of issuing a EURcoin or USDcoin type system. You could use the contracts protocol by hashcoin to atomically trade Bitcoin for USDcoin and vice-versa. I lost interest in the idea eventually in favor of pure p2p currency exchanges.
 
E.g. if you want to include a coinbase transaction in your new block, you have to have my permission for that transaction to be valid and accepted by others. This could be useful if you wanted to create a block chain backed by (or tied 1:1 to) some other currency. You would obviously want to control new coins because they represent your "real" money, but transaction processing could be outsourced. The incentive for miners remains questionnable, decentralized Bitcoin certainly sounds much more appealing :-) But who knows, incentive does not have to be monetary, I can imagine some humanitarian organization operating like this for the purpose of transparency and cheap international transactions.

You could incentivize it by just providing fees so miners can compete to claim them (there'd still be coinbases, just that the value of them would be zero+fees).
 
The reasoning behind all this is that Bitcoin has some nice features like cheap (because there is no monopoly on transaction confirmation) and fast transactions that you currently can't use on it's own without being forced into decentralization. There is obviously a bunch of open questions like whether we could do peer to peer exchanges without trusting 3rd party (like MtGox) but if we knew what we are doing, it wouldn't be called research, right? :-)

It's possible to do a pure P2P exchange, yes. I wrote a wiki page on it, see here:

 
I think you'll find much of this research has already been done, actually. Just not in an academic context.

Reply all
Reply to author
Forward
0 new messages