This article uses Docker containers to quickly install and configure the Bitcoin test network (bitcoin-testnet) of a private node as a development test environment on the commonly used Ubuntu 14.04 operating system. It also uses Node.js as an example to illustrate how to call the RPC interface service provided by the Bitcoin wallet node to implement some specific Bitcoin-related account and transaction operations. RPC (Remote Procedure Call) is a protocol that requests services from a remote computer program over the network without having to understand the underlying network technology. Regarding how to install the Ubuntu 14.04 operating system and Node.js, if necessary, you can refer to the instructions in the previous article "Bitcoin Blockchain Development from Beginner to Advanced Guide 1" for installation (http://www.8btc.com/blockchain_develope_lesson_1). 1. Install the Docker operating environment 1. Use the apt-get command to install the Docker container support software: $sudo apt-get install docker.io 2. Create a soft link 3. Check the Docker version For more information about how to install and run Docker, you can search online for more information or visit this page: "Docker First Try" (http://my.oschina.net/lamciuloeng/blog/226107) 2. Install and run the Bitcoin test network (bitcoin-testnet) 1. Download the Docker image of the Bitcoin test network (bitcoin-testnet) 2. Run the Docker image Note: The ports 19001 and 19011 in the above command are configured to provide RPC services to the two nodes. 3. After entering the Docker runtime environment, enter the following command to start the Bitcoin test network: Enter the following command to view the test network node status information: The displayed prompt information is as follows, and the Chinese version is an explanation of some key information: make generate make generate BLOCKS=200 make getinfo make sendfrom1 ADDRESS=mkiytxYA6kxUC8iTnzLPgMfCphnz91zRfZ AMOUNT=10 make generate BLOCKS=10 make getinfo 3. Install the RPC support library for Node.js\ Open a new terminal command line interface on the Ubuntu desktop and enter the following command to install: For more information about the Kapitalize open source project, please refer to: https://github.com/shamoons/Kapitalize
Copy and save the following sample code to the test environment (save the file name as RpcTestnet.js), and enter the following command in the command line to run and see the running results: Note: Each time you run the test code, you need to enter "make generate BLOCKS=10" in the command line of the Docker runtime environment to simulate the generation of new block records so that the transaction records generated by the test code can be effectively confirmed. The source code of the sample program RpcTestnet.js is as follows (the source code file can be downloaded here): /********************* Starting point of sample code*************************/ /********************* End of sample code**********************/ |
<<: Brexit causes depreciation of RMB, does this mean more opportunities for Bitcoin?
Marriage line shows the relationship between men ...
In fact, it can be found in life that some women ...
Marriage is very important to everyone, and every...
Women are always pursuing perfection, even though...
On December 19, 2019, the second session of Spide...
According to BlockBeats, it is well known that De...
The career line, also known as the jade pillar li...
People have different moods and temperaments, so ...
Nasdaq-100 stocks and Bitcoin are distinct but co...
People all like to appreciate beautiful things, a...
Rebound without volume, short-term watch more les...
In mole physiognomy, different moles represent di...
Deep nasolabial folds If a person has deep and cl...
It is said that appearance reflects the heart. In...
In life, there are people who are very optimistic...