Sorry for so many questions, but is a pretty useful library.
What is the thread safety model for this library?
The intention is that multiple threads can access block chain and wallet instances concurrently. However currently there's only ever one peer thread, so the thread safety hasn't been well tested and there are surely bugs.
If you connect to 2 peers, can you set them to the same block chain? That way if a block arrives from either peer, it will be incorporated into the chain.
It's intended that will be possible. It may even work today. I haven't tried it yet.
How does the getBlock() method in Peer work. Does it send a request to the peer and the Future resolves when it gets an answer? If the peer dies, then it would never complete?
Correct. There are no timeouts on the future.
A getTransaction() method would be great for the Peer class. That would require a new message though
.
I think you can use getdata on a transaction if it's in memory. Otherwise yes, you're right. But what would it be used for?
Transaction.verifyInput() has a "warning: not finished" message. How much functionality has it? Can it verify the 2 standard scripts?
Lightweight/SPV clients don't verify transactions. They take inclusion in the chain as proof of validity. See here:
http://code.google.com/p/bitcoinj/wiki/SecurityModelThe verifyInput code dates from a time before I decided to implement this model and I'll delete it at some point. Verifying transactions means (at minimum) storing them all, which it does not do.
The Block object doesn't have a way to get at the transactions in the block. It could have an isHeader() method to indicate that it doesn't have all the information.
Right, that would be useful. Patches welcome.
A Block.attemptMine(int attempts) would be nice too, but that is probably outside the scope of the project. That would need to be combined with a way to add transactions to a block.
There is already a solve() method which does mining, but it doesn't update the extraNonce so it's only useful for unit-test difficulties.
It isn't possible to create transactions directly. The constructor isn't public. It could be done by sending a fake payload.
We can make the bytestream constructor public.
Script could also do with a default constructor and some script processing methods. The script could be broken into pieces of some super class. The OP_PUSHDATA1 opcode could be combined with the actual data.
Yes, the Script class needs a lot of work. It'll probably get done in the context of supporting contracts.