Bitcoinj is the Java implementation of the Bitcoin full node. Unlike the C + + implementation, which is officially recommended by Bitcoin, there is no built-in RPC or command-line interaction at this time.
Its functional interaction is manifested by several example examples, tool, and Walletkit.
For learning or development zone block chain, reading bitcoin source code, understanding its operating principle, learning its development process is a very good way.
Installation Preparation Work
- Installing Gradle,gradle is a project building tool, similar to Maven,bitcoinj is built with Gradle.
- Install Javafx,javafx is a set of Java graphical Interface library, Bitcoinj in the wallet instance is the interface written in JavaFX.
- Installing Protobuf,google Protocol Buffer (abbreviated as PROTOBUF) is a mixed-language data standard within Google Inc. is a lightweight and efficient structured data storage format that can be used for structured data serialization, or serializing. It is ideal for data storage or RPC data interchange formats. It can be used in the communication protocol, data storage and other fields of the language-independent, platform-independent, extensible serialization structure data format. It will also be used in Bitcoinj. Download Bitcoinj
: Https://github.com/bitcoinj/bitcoinj
Download the zip package directly to unzip it.
In MyEclipse, select:
Import -> Gradle -> Existing Gradle Project
Select the Bitcoinj directory that you just unzipped in project root directory. The following items will appear after the import is successful:
> bitcoinj> core # 全节点功能实现> examples # 几个调用core的例子> tools # 小工具> walletettemplate # 一款图形化的wallet
Execute PROTOC to generate related Java files
Many articles on the internet did not mention this point, just import Bitcoinj, the project in many places will be error, because some Java files need to Protoc to generate.
Under command line, enter the following directory Bitcoinj
core -> src -> main -> proto
You can see the following files:
paymentchannel.protopaymentrequest.protopeerseeds.protostoredclientpaymentchannel.protostoredserverpaymentchannel.protowallet.proto
Execute the following command:
protoc --java_out=../java paymentchannel.proto
Each file executes once, in the Java directory in the corresponding package will generate the corresponding Java files, and then refresh the entire project, will no longer error.
MyEclipse running bitcoin full node Bitcoinj