Merge branch 'prayank23-i2p'

This commit is contained in:
Shannon Appelcline 2021-06-30 14:20:06 -10:00
commit 2d1aab54e8
No known key found for this signature in database
GPG Key ID: 7EC6B928606F27AD
32 changed files with 165 additions and 46 deletions

31
15_0_Using_i2p.md Normal file
View File

@ -0,0 +1,31 @@
# Chapter 15: Using i2p
The Invisible Internet Project (I2P) is a fully encrypted private network layer. It uses a distributed [network database](https://geti2p.net/en/docs/how/network-database) and encrypted unidirectional tunnels between your and your peers.
Basic differences between Tor and i2p:
| | Tor | i2p |
| :--- | :---: | ---: |
| Routing | [Onion](https://www.onion-router.net/) | [Garlic](https://geti2p.net/en/docs/how/garlic-routing) |
| Network Database | Trusted [Directory Servers](https://blog.torproject.org/possible-upcoming-attempts-disable-tor-network) | [Distributed network database](https://geti2p.net/en/docs/how/network-database) |
| Relay | **Two-way** encrypted connections between each Relay | **One-way** connections between every server in its tunnels |
| Hidden services | Slow | Fast |
Read more: https://geti2p.net/en/comparison/tor
It is not installed by [Bitcoin Standup](https://github.com/BlockchainCommons/Bitcoin-Standup-Scripts) right now as i2p support was recently added in Bitcoin core. However, you can try it manually by following the steps mentioned in [Section One](15_1_i2p_service.md).
## Objectives for This Chapter
After working through this chapter, a developer will be able to:
* Run Bitcoin Core as an I2P (Invisible Internet Project) service
Supporting objectives include the ability to:
* Understand the i2p Network
* Learn difference between Tor and i2p
## Table of Contents
* [Section One: Bitcoin Core as an I2P (Invisible Internet Project) service](15_1_i2p_service.md)

85
15_1_i2p_service.md Normal file
View File

@ -0,0 +1,85 @@
# 15.1: Bitcoin Core as an I2P (Invisible Internet Project) service
Users should consider different trade-offs involved in using i2p with other networks in Bitcoin Core for better privacy:
- Sybil Attacks and Network Partitioning is possible with `onlynet=i2p`
- Running Onion service with i2p service is experimental for now.
- For maximum privacy, it is preferable to disable accepting incoming connections.
Read more: https://bitcoin.stackexchange.com/questions/107060/tor-and-i2p-tradeoffs-in-bitcoin-core
Follow the below steps to run Bitcoin Core i2p service:
1. You can install `i2pd` on Ubuntu with below commands:
```
sudo add-apt-repository ppa:purplei2p/i2pd
sudo apt-get update
sudo apt-get install i2pd
```
For installing on other OS: https://i2pd.readthedocs.io/en/latest/user-guide/install/
2. Then [run](https://i2pd.readthedocs.io/en/latest/user-guide/run/) it and check if its running:
```
$ sudo systemctl start i2pd.service
```
You should see it running on port 7656:
```
$ ss -nlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 4096 127.0.0.1:7656 0.0.0.0:*
```
3. Add the following lines in `bitcoin.conf`. Config logging option `debug=i2p` is used to have additional information in the debug log about your I2P configuration and connections (Default location on Linux: ~/.bitcoin/bitcoin.conf):
```
i2psam=127.0.0.1:7656
debug=i2p
```
5. Restart `bitcoind`
```
$ bitcoind
```
6. Check `debug.log`if i2p was setup correctly or any errors printed in logs. I2P address is mentioned in the logs and ends with _b32.i2p_:
```
2021-06-15T20:36:16Z i2paccept thread start
2021-06-15T20:36:16Z I2P: Creating SAM session with 127.0.0.1:7656
2021-06-15T20:36:56Z I2P: SAM session created: session id=3e0f35228b, my address=bmwyyuzyqdc5dcx27s4baltbu6zw7rbqfl2nmclt45i7ng3ul4pa.b32.i2p:18333
2021-06-15T20:36:56Z AddLocal(bmwyyuzyqdc5dcx27s4baltbu6zw7rbqfl2nmclt45i7ng3ul4pa.b32.i2p:18333,4)
```
7. Confirm `i2p_private_key` was created in Bitcoin Core data directory. The first time Bitcoin Core connects to the I2P router, its I2P address (and corresponding private key) will be automatically generated and saved in a file named *i2p_private_key*:
```
~/.bitcoin/testnet3$ ls
anchors.dat chainstate i2p_private_key settings.json
banlist.dat debug.log mempool.dat wallets
blocks fee_estimates.dat peers.dat
```
8. `bitcoin-cli -netinfo` or `bitcoin-cli getnetworkinfo`returns i2p address:
```
Local addresses
bmwyyuzyqdc5dcx27s4baltbu6zw7rbqfl2nmclt45i7ng3ul4pa.b32.i2p port 18333 score 4
```
## Summary: Bitcoin Core as an I2P (Invisible Internet Project) service
It is always good to have alternatives for privacy and not depend only on Tor to run Bitcoin Core as hidden service. Since i2p was recently added in Bitcoin Core, less people use it, experiment with it and report bugs if you find any issues.
> :information_source: **NOTE:** _i2pd_ (C++) is different from _i2prouter_ (Java), you will need `i2pd` for Bitcoin Core.
Move on to "Programming with RPC" with [Chapter Sixteen: Talking to Bitcoind with C](16_0_Talking_to_Bitcoind.md).
Or, if you're not a programmer, you can skip to [Chapter Nineteen: Understanding Your Lightning Seutp](https://github.com/BlockchainCommons/Learning-Bitcoin-from-the-Command-Line/blob/master/19_0_Understanding_Your_Lightning_Setup.md) to continue your command-line education with the Lightning Network.

View File

@ -2,11 +2,11 @@
> :information_source: **NOTE:** This section has been recently added to the course and is an early draft that may still be awaiting review. Caveat reader.
This section explains how to interact with `bitcoind` using the Java programming language and the [JavaBitcoindRpcClient](https://github.com/Polve/JavaBitcoindRpcClient).
This section explains how to interact with `bitcoind` using the Java programming language and the [JavaBitcoindRpcClient](https://github.com/Polve/JavaBitcoindRpcClient).
## Set Up Java
You can install Java on your server, using the `apt-get` command. You will also install [Apache Maven](http://maven.apache.org/) to manage the dependencies.
You can install Java on your server, using the `apt-get` command. You will also install [Apache Maven](http://maven.apache.org/) to manage the dependencies.
```
$ sudo apt-get install openjdk-11-jre-headless maven
```
@ -57,15 +57,15 @@ In order to include `JavaBitcoindRpcClient`, you must add its dependency to `<de
<version>1.2.1</version>
</dependency>
```
You also need to add compiler properties to indicate what JDK version will compile the source code.
You also need to add compiler properties to indicate what JDK version will compile the source code.
```
<properties>
<properties>
<!-- https://maven.apache.org/general.html#encoding-warning -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
</properties>
```
Whenever you add source code to your classes, you'll be able to test it with:
@ -110,7 +110,7 @@ rpcClient.stop();
### Make an RPC Call
You'll find that the `BitcoindRpcClient` provides most of the functionality that can be accessed through `bitcoin-cli` or other RPC methods, using the same method names, but in camelCase.
You'll find that the `BitcoindRpcClient` provides most of the functionality that can be accessed through `bitcoin-cli` or other RPC methods, using the same method names, but in camelCase.
For example, to execute the `getmininginfo` command to get the block information and the difficulty on the network, you should use the `getMiningInfo()` method:
```java
@ -137,7 +137,7 @@ You can look up addresses on your wallet by passing the address as an argument t
```java
String addr1 = "mvLyH7Rs45c16FG2dfV7uuTKV6pL92kWxo";
AddressInfo addr1Info = rpcClient.getAddressInfo(addr1);
System.out.println("Address: " + addr1Info.address());
System.out.println("MasterFingerPrint: " + addr1Info.hdMasterFingerprint());
@ -154,7 +154,7 @@ PubKey: 0368d0fffa651783524f8b934d24d03b32bf8ff2c0808943a556b3d74b2e5c7d65
### Run Your Code
The code for these examples can be found in [the src directory](src/17_2_App-getinfo.java) and should be installed into the standard directory structure created here as `~/java-project/src/main/java/com/blockchaincommons/lbtc/App.java`. It can then be compiled and run.
The code for these examples can be found in [the src directory](src/17_2_App-getinfo.java) and should be installed into the standard directory structure created here as `~/java-project/src/main/java/com/blockchaincommons/lbtc/App.java`. It can then be compiled and run.
```
$ mvn compile
@ -200,7 +200,7 @@ The JavaBitcoindRpcClient library has some good tools that make it easy to creat
### Create a Transaction
You can create a raw transaction using the `createRawTransaction` method, passing as arguments two ArrayList objects containing inputs and outputs to be used.
You can create a raw transaction using the `createRawTransaction` method, passing as arguments two ArrayList objects containing inputs and outputs to be used.
First you set up your new addresses, here an existing address on your system and a new address on your system.
```
@ -243,7 +243,7 @@ Second, you fill the ouputs each with an amount and an address:
BigDecimal estimatedFee = BigDecimal.valueOf(0.00000200);
BigDecimal txToAddr2Amount = utxos.get(0).amount().subtract(estimatedFee);
txb.out(addr2, txToAddr2Amount);
System.out.println("unsignedRawTx in amount: " + utxos.get(0).amount());
System.out.println("unsignedRawTx out amount: " + txToAddr2Amount);
```
@ -261,7 +261,7 @@ You now can sign transaction with the method `signRawTransactionWithKey`. This m
```java
SignedRawTransaction srTx = rpcClient.signRawTransactionWithKey(
unsignedRawTxHex,
Arrays.asList(rpcClient.dumpPrivKey(addr1)), //
Arrays.asList(rpcClient.dumpPrivKey(addr1)), //
Arrays.asList(in),
null);
System.out.println("signedRawTx hex: " + srTx.hex());

View File

@ -60,10 +60,10 @@ If you'd like to make your own translation, please see [Contributing](https://gi
* [7.1: Creating a Partially Signed Bitcoin Transaction](07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md)
* [7.2: Using a Partially Signed Bitcoin Transaction](07_2_Using_a_Partially_Signed_Bitcoin_Transaction.md)
* [7.3: Integrating with Hardware Wallets](07_3_Integrating_with_Hardware_Wallets.md)
* [8.0: Expanding Bitcoin Transactions in Other Ways](08_0_Expanding_Bitcoin_Transactions_Other.md)
* [8.0: Expanding Bitcoin Transactions in Other Ways](08_0_Expanding_Bitcoin_Transactions_Other.md)
* [8.1: Sending a Transaction with a Locktime](08_1_Sending_a_Transaction_with_a_Locktime.md)
* [8.2: Sending a Transaction with Data](08_2_Sending_a_Transaction_with_Data.md)
### PART THREE: BITCOIN SCRIPTING
**Status:** Finished. Updated for 0.20 and btcdeb.
@ -93,7 +93,7 @@ If you'd like to make your own translation, please see [Contributing](https://gi
* [13.2: Writing Complex Multisig Scripts](13_2_Writing_Complex_Multisig_Scripts.md)
* [13.3: Empowering Bitcoin with Scripts](13_3_Empowering_Bitcoin_with_Scripts.md)
### PART FOUR: USING TOR
### PART FOUR: PRIVACY
**Status:** Finished.
@ -102,45 +102,48 @@ If you'd like to make your own translation, please see [Contributing](https://gi
* [14.2: Changing Your Bitcoin Hidden Services](14_2_Changing_Your_Bitcoin_Hidden_Services.md)
* [14.3: Adding SSH Hidden Services](14_3_Adding_SSH_Hidden_Services.md)
* [15.0: Using i2p](15_0_Using_i2p.md)
* [15.1: Bitcoin Core as an I2P (Invisible Internet Project) service](15_1_i2p_service.md)
### PART FIVE: PROGRAMMING WITH RPC
**Status:** Finished.
* [15.0: Talking to Bitcoind with C](15_0_Talking_to_Bitcoind.md)
* [15.1: Accessing Bitcoind in C with RPC Libraries](15_1_Accessing_Bitcoind_with_C.md)
* [15.2: Programming Bitcoind in C with RPC Libraries](15_2_Programming_Bitcoind_with_C.md)
* [15.3: Receiving Notifications in C with ZMQ Libraries](15_3_Receiving_Bitcoind_Notifications_with_C.md)
* [16.0: Programming Bitcoin with Libwally](16_0_Programming_with_Libwally.md)
* [16.1: Setting Up Libwally](16_1_Setting_Up_Libwally.md)
* [16.2: Using BIP39 in Libwally](16_2_Using_BIP39_in_Libwally.md)
* [16.3: Using BIP32 in Libwally](16_3_Using_BIP32_in_Libwally.md)
* [16.4: Using PSBTs in Libwally](16_4_Using_PSBTs_in_Libwally.md)
* [16.5: Using Scripts in Libwally](16_5_Using_Scripts_in_Libwally.md)
* [16.6: Using Other Functions in Libwally](16_6_Using_Other_Functions_in_Libwally.md)
* [16.7: Integrating Libwally and Bitcoin-CLI](16_7_Integrating_Libwally_and_Bitcoin-CLI.md)
* [17.0: Talking to Bitcoind with Other Languages](17_0_Talking_to_Bitcoind_Other.md)
* [17.1: Accessing Bitcoind with Go](17_1_Accessing_Bitcoind_with_Go.md)
* [17.2: Accessing Bitcoind with Java](17_2_Accessing_Bitcoind_with_Java.md)
* [17.3: Accessing Bitcoind with Node JS](17_3_Accessing_Bitcoind_with_NodeJS.md)
* [17.4: Accessing Bitcoind with Python](17_4_Accessing_Bitcoind_with_Python.md)
* [17.5: Accessing Bitcoind with Rust](17_5_Accessing_Bitcoind_with_Rust.md)
* [17.6: Accessing Bitcoind with Swift](17_6_Accessing_Bitcoind_with_Swift.md)
* [16.0: Talking to Bitcoind with C](15_0_Talking_to_Bitcoind.md)
* [16.1: Accessing Bitcoind in C with RPC Libraries](15_1_Accessing_Bitcoind_with_C.md)
* [16.2: Programming Bitcoind in C with RPC Libraries](15_2_Programming_Bitcoind_with_C.md)
* [16.3: Receiving Notifications in C with ZMQ Libraries](16_3_Receiving_Bitcoind_Notifications_with_C.md)
* [17.0: Programming Bitcoin with Libwally](17_0_Programming_with_Libwally.md)
* [17.1: Setting Up Libwally](17_1_Setting_Up_Libwally.md)
* [17.2: Using BIP39 in Libwally](17_2_Using_BIP39_in_Libwally.md)
* [17.3: Using BIP32 in Libwally](17_3_Using_BIP32_in_Libwally.md)
* [17.4: Using PSBTs in Libwally](17_4_Using_PSBTs_in_Libwally.md)
* [17.5: Using Scripts in Libwally](17_5_Using_Scripts_in_Libwally.md)
* [17.6: Using Other Functions in Libwally](17_6_Using_Other_Functions_in_Libwally.md)
* [17.7: Integrating Libwally and Bitcoin-CLI](17_7_Integrating_Libwally_and_Bitcoin-CLI.md)
* [18.0: Talking to Bitcoind with Other Languages](18_0_Talking_to_Bitcoind_Other.md)
* [18.1: Accessing Bitcoind with Go](18_1_Accessing_Bitcoind_with_Go.md)
* [18.2: Accessing Bitcoind with Java](18_2_Accessing_Bitcoind_with_Java.md)
* [18.3: Accessing Bitcoind with Node JS](18_3_Accessing_Bitcoind_with_NodeJS.md)
* [18.4: Accessing Bitcoind with Python](18_4_Accessing_Bitcoind_with_Python.md)
* [18.5: Accessing Bitcoind with Rust](18_5_Accessing_Bitcoind_with_Rust.md)
* [18.6: Accessing Bitcoind with Swift](18_6_Accessing_Bitcoind_with_Swift.md)
### PART SIX: USING LIGHTNING-CLI
**Status:** Finished.
* [18.0: Understanding Your Lightning Setup](18_0_Understanding_Your_Lightning_Setup.md)
* [18.1: Verifying Your c-lightning Setup](18_1_Verifying_Your_Lightning_Setup.md)
* [18.2: Knowing Your c-lightning Setup](18_2_Knowing_Your_lightning_Setup.md)
* [Interlude: Accessing a Second Lightning Node](18_2__Interlude_Accessing_a_Second_Lightning_Node.md)
* [18.3: Creating a Lightning Channel](18_3_Setting_Up_a_Channel.md)
* [19.0: Using Lightning](19_0_Using_Lightning.md)
* [19.1: Generating a Payment Request](19_1_Generate_a_Payment_Request.md)
* [19.2: Paying an Invoice](19_2_Paying_a_Invoice.md)
* [19.3: Closing a Lighnting Channel]((19_3_Closing_a_Channel.md))
* [19.4: Expanding the Lightning Network](19_4_Lightning_Network_Review.md)
* [19.0: Understanding Your Lightning Setup](19_0_Understanding_Your_Lightning_Setup.md)
* [19.1: Verifying Your c-lightning Setup](19_1_Verifying_Your_Lightning_Setup.md)
* [19.2: Knowing Your c-lightning Setup](19_2_Knowing_Your_lightning_Setup.md)
* [Interlude: Accessing a Second Lightning Node](19_2__Interlude_Accessing_a_Second_Lightning_Node.md)
* [19.3: Creating a Lightning Channel](19_3_Setting_Up_a_Channel.md)
* [20.0: Using Lightning](20_0_Using_Lightning.md)
* [20.1: Generating a Payment Request](20_1_Generate_a_Payment_Request.md)
* [20.2: Paying an Invoice](20_2_Paying_a_Invoice.md)
* [20.3: Closing a Lighnting Channel]((20_3_Closing_a_Channel.md))
* [20.4: Expanding the Lightning Network](20_4_Lightning_Network_Review.md)
### APPENDICES
**Status:** Finished.
@ -149,7 +152,7 @@ If you'd like to make your own translation, please see [Contributing](https://gi
* [Appendix I: Understanding Bitcoin Standup](A1_0_Understanding_Bitcoin_Standup.md)
* [Appendix II: Compiling Bitcoin from Source](A2_0_Compiling_Bitcoin_from_Source.md)
* [Appendix III: Using Bitcoin Regtest](A3_0_Using_Bitcoin_Regtest.md)
## Status - Beta
v2.0.1 of **Learning Bitcoin from the Command Line** is feature complete. It may still be undergoing third-party review or editing, but it can be used for learning.
@ -192,7 +195,7 @@ The following people directly contributed to this repository. You can add your n
| Name | Role | Github | Email | GPG Fingerprint |
| ----------------- | ------------------- | ------------------------------------------------- | ------------------------------------- | -------------------------------------------------- |
| Christopher Allen | Lead Author | [@ChristopherA](https://github.com/ChristopherA) | \<ChristopherA@LifeWithAlacrity.com\> | FDFE 14A5 4ECB 30FC 5D22 74EF F8D3 6C91 3574 05ED |
| Shannon Appelcline | Lead Author | [@shannona](https://github.com/shannona) | \<shannon.appelcline@gmail.com\> | 7EC6 B928 606F 27AD |
| Shannon Appelcline | Lead Author | [@shannona](https://github.com/shannona) | \<shannon.appelcline@gmail.com\> | 7EC6 B928 606F 27AD |
Additional contributions are listed below: