Learning-Bitcoin-from-the-C.../15_1_i2p_service.md
Prayank 30e945b6a3 Add ports link and fix note
+ Information about ports required for i2p (inbound and outbound)
+ i2prouter (java) works with Bitcoin Core, so previous note is incorrect. Changed it with relevant information.
2021-08-12 15:49:32 +05:30

3.9 KiB
Raw Blame History

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 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
    
  4. Restart bitcoind

    $ bitcoind
    
  5. Check debug.logif 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)
    
  6. 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
    
  7. bitcoin-cli -netinfo or bitcoin-cli getnetworkinforeturns 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.

NOTE: For the official i2prouter implementation in Java, visit download page and follow the instructions for your Operating System. Once installed, open a terminal window and type i2prouter start. Then visit 127.0.0.1:7657 in your browser to enable SAM. To do so, select: "Configure Homepage", then "Clients", and finally select the "Play Button" next to SAM application Bridge. On the left side of the page, there should be a green light next to "Shared Clients".

Move on to "Programming with RPC" with Chapter Sixteen: Talking to Bitcoind with C.

Or, if you're not a programmer, you can skip to Chapter Nineteen: Understanding Your Lightning Seutp to continue your command-line education with the Lightning Network.