bitcoin/src
Wladimir J. van der Laan b9f41df1ea
Merge #20685: Add I2P support using I2P SAM
a701fcf01f net: Do not skip the I2P network from GetNetworkNames() (Vasil Dimov)
0181e24439 net: recognize I2P from ParseNetwork() so that -onlynet=i2p works (Vasil Dimov)
b905363fa8 net: accept incoming I2P connections from CConnman (Vasil Dimov)
0635233a1e net: make outgoing I2P connections from CConnman (Vasil Dimov)
9559bd1404 net: add I2P to the reachability map (Vasil Dimov)
76c35c60f3 init: introduce I2P connectivity options (Vasil Dimov)
c22daa2ecf net: implement the necessary parts of the I2P SAM protocol (Vasil Dimov)
5bac7e45e1 net: extend Sock with a method to check whether connected (Vasil Dimov)
42c779f503 net: extend Sock with methods for robust send & read until terminator (Vasil Dimov)
ea1845315a net: extend Sock::Wait() to report a timeout (Vasil Dimov)
78fdfbea66 net: dedup MSG_NOSIGNAL and MSG_DONTWAIT definitions (Vasil Dimov)
34bcfab562 net: move the constant maxWait out of InterruptibleRecv() (Vasil Dimov)
cff65c4a27 net: extend CNetAddr::SetSpecial() to support I2P (Vasil Dimov)
f6c267db3b net: avoid unnecessary GetBindAddress() call (Vasil Dimov)
7c224fdac4 net: isolate the protocol-agnostic part of CConnman::AcceptConnection() (Vasil Dimov)
1f75a653dd net: get the bind address earlier in CConnman::AcceptConnection() (Vasil Dimov)
25605895af net: check for invalid socket earlier in CConnman::AcceptConnection() (Vasil Dimov)
545bc5f81d util: fix WriteBinaryFile() claiming success even if error occurred (Vasil Dimov)
8b6e4b3b23 util: fix ReadBinaryFile() returning partial contents (Vasil Dimov)
4cba2fdafa util: extract {Read,Write}BinaryFile() to its own files (Vasil Dimov)

Pull request description:

  Add I2P support by using the [I2P SAM](https://geti2p.net/en/docs/api/samv3) protocol. Unlike Tor, for incoming connections we get the I2P address of the peer (and they also receive ours when we are the connection initiator).

  Two new options are added:

  ```
    -i2psam=<ip:port>
         I2P SAM proxy to reach I2P peers and accept I2P connections (default:
         none)

    -i2pacceptincoming
         If set and -i2psam is also set then incoming I2P connections are
         accepted via the SAM proxy. If this is not set but -i2psam is set
         then only outgoing connections will be made to the I2P network.
         Ignored if -i2psam is not set. Notice that listening for incoming
         I2P connections is done through the SAM proxy, not by binding to
         a local address and port (default: true)
  ```

  # Overview of the changes

  ## Make `ReadBinary()` and `WriteBinary()` reusable

  We would need to dump the I2P private key to a file and read it back later. Move those two functions out of `torcontrol.cpp`.

  ```
  util: extract {Read,Write}BinaryFile() to its own files
  util: fix ReadBinaryFile() returning partial contents
  util: fix WriteBinaryFile() claiming success even if error occurred
  ```

  ## Split `CConnman::AcceptConnection()`

  Most of `CConnman::AcceptConnection()` is agnostic of how the socket was accepted. The other part of it deals with the details of the `accept(2)` system call. Split those so that the protocol-agnostic part can be reused if we accept a socket by other means.

  ```
  net: check for invalid socket earlier in CConnman::AcceptConnection()
  net: get the bind address earlier in CConnman::AcceptConnection()
  net: isolate the protocol-agnostic part of CConnman::AcceptConnection()
  net: avoid unnecessary GetBindAddress() call
  ```

  ## Implement the I2P [SAM](https://geti2p.net/en/docs/api/samv3) protocol (not all of it)

  Just the parts that would enable us to make outgoing and accept incoming I2P connections.

  ```
  net: extend CNetAddr::SetSpecial() to support I2P
  net: move the constant maxWait out of InterruptibleRecv()
  net: dedup MSG_NOSIGNAL and MSG_DONTWAIT definitions
  net: extend Sock::Wait() to report a timeout
  net: extend Sock with methods for robust send & read until terminator
  net: extend Sock with a method to check whether connected
  net: implement the necessary parts of the I2P SAM protocol
  ```

  ## Use I2P SAM to connect to and accept connections from I2P peers

  Profit from all of the preceding commits.

  ```
  init: introduce I2P connectivity options
  net: add I2P to the reachability map
  net: make outgoing I2P connections from CConnman
  net: accept incoming I2P connections from CConnman
  net: recognize I2P from ParseNetwork() so that -onlynet=i2p works
  net: Do not skip the I2P network from GetNetworkNames()
  ```

ACKs for top commit:
  laanwj:
    re-ACK a701fcf01f
  jonatack:
    re-ACK a701fcf01f reviewed diff per `git range-diff ad89812 2a7bb34 a701fcf`, debug built and launched bitcoind with i2pd v2.35 running a dual I2P+Torv3 service with the I2P config settings listed below (did not test `onlynet=i2p`); operation appears nominal (same as it has been these past weeks), and tested the bitcoind help outputs grepping for `-i i2p` and the rpc getpeerinfo and getnetworkinfo helps

Tree-SHA512: de42090c9c0bf23b43b5839f5b4fc4b3a2657bde1e45c796b5f3c7bf83cb8ec6ca4278f8a89e45108ece92f9b573cafea3b42a06bc09076b40a196c909b6610e
2021-03-02 11:50:13 +01:00
..
bench Merge #21170: bench: Add benchmark to write JSON into a string 2021-03-01 19:12:09 +01:00
compat assumptions: check C++17 assumption with MSVC 2021-02-23 12:51:50 +08:00
config
consensus scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
crc32c build: Update crc32c subtree 2020-12-08 19:26:30 +01:00
crypto refactor: Improve encapsulation between MuHash3072 and Num3072 2021-01-24 16:28:27 +01:00
index Avoid accessing nullpointer in BaseIndex::GetSummary() 2021-02-11 11:39:45 +01:00
interfaces net: Add -natpmp command line option 2021-01-07 18:07:09 +02:00
leveldb
logging
node scripted-diff: Invoke ::AcceptToMemoryPool with chainstate 2021-02-18 14:49:06 -05:00
policy refactor: Use C++17 std::array deduction for ALL_FEE_ESTIMATE_HORIZONS 2021-01-03 18:38:31 +01:00
primitives scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
qt Merge #21286: build: Bump minimum Qt version to 5.9.5 2021-02-28 13:14:04 +08:00
rpc init: introduce I2P connectivity options 2021-03-01 18:19:46 +01:00
script Merge #19136: wallet: add parent_desc to getaddressinfo 2021-02-18 21:51:16 +13:00
secp256k1 Update secp256k1 subtree to latest master 2020-10-27 23:08:48 -07:00
support Merge #20464: refactor: Treat CDataStream bytes as uint8_t 2021-02-01 15:17:28 +01:00
test net: extend CNetAddr::SetSpecial() to support I2P 2021-03-01 13:22:11 +01:00
univalue Update univalue subtree 2020-11-19 15:48:24 +01:00
util net: extend Sock with a method to check whether connected 2021-03-01 17:36:17 +01:00
wallet Merge #18466: rpc: fix invalid parameter error codes for {sign,verify}message RPCs 2021-03-01 11:45:42 +01:00
zmq rpc: Remove duplicate name and argNames from CRPCCommand 2021-01-28 08:19:52 +01:00
.clang-format [tools] Allow argument/parameter bin packing in clang-format 2021-02-18 10:07:37 +00:00
addrdb.cpp log: Clarify log message when file does not exist 2021-02-18 15:08:35 +01:00
addrdb.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
addrman.cpp refactor: remove boost::thread_group usage 2021-01-29 15:39:44 +08:00
addrman.h [addrman] Don't repeat "Bucketing method was updated" log multiple times 2021-01-29 12:39:55 +00:00
amount.h
arith_uint256.cpp
arith_uint256.h
attributes.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
banman.cpp log: Clarify log message when file does not exist 2021-02-18 15:08:35 +01:00
banman.h Clean up separated ban/discourage interface 2020-07-03 20:43:55 -07:00
base58.cpp refactor: replace sizeof(a)/sizeof(a[0]) by std::size (C++17) 2021-01-31 17:35:16 +01:00
base58.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
bech32.cpp
bech32.h
bitcoin-cli-res.rc Drop the leading 0 from the version number 2020-11-18 12:00:57 -05:00
bitcoin-cli.cpp cli: Treat high detail levels as the maximum in -netinfo 2021-02-15 20:01:52 +01:00
bitcoin-tx-res.rc Drop the leading 0 from the version number 2020-11-18 12:00:57 -05:00
bitcoin-tx.cpp Move TX_MAX_STANDARD_VERSION to policy 2020-12-10 11:12:08 +01:00
bitcoin-util-res.rc Add bitcoin-util command line utility 2021-01-12 18:34:25 +10:00
bitcoin-util.cpp Merge #20938: build: fix linking against -latomic when building for riscv 2021-01-18 18:33:24 +01:00
bitcoin-wallet-res.rc Drop the leading 0 from the version number 2020-11-18 12:00:57 -05:00
bitcoin-wallet.cpp util: Add ArgsManager::GetCommand() and use it in bitcoin-wallet 2021-01-21 19:31:28 +01:00
bitcoind-res.rc Drop the leading 0 from the version number 2020-11-18 12:00:57 -05:00
bitcoind.cpp init: Signal-safe instant shutdown 2020-12-15 17:21:06 +01:00
blockencodings.cpp scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
blockencodings.h
blockfilter.cpp scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
blockfilter.h
bloom.cpp scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
bloom.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
chain.cpp
chain.h simplify ChainstateManager::SnapshotBlockhash() return semantics 2021-02-12 07:53:29 -06:00
chainparams.cpp Merge #15946: Allow maintaining the blockfilterindex when using prune 2021-02-18 09:40:42 +01:00
chainparams.h chainparams: add allowed assumeutxo values 2021-02-12 07:53:22 -06:00
chainparamsbase.cpp scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
chainparamsbase.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
chainparamsseeds.h net: Hardcoded seeds update for 0.21 2020-10-25 14:25:00 +01:00
checkqueue.h refactor: Drop boost::thread stuff in CCheckQueue 2020-09-24 06:55:34 +03:00
clientversion.cpp scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
clientversion.h refactor: Move STRINGIZE macro to macros.h 2021-02-01 22:30:05 +02:00
coins.cpp simplify ChainstateManager::SnapshotBlockhash() return semantics 2021-02-12 07:53:29 -06:00
coins.h simplify ChainstateManager::SnapshotBlockhash() return semantics 2021-02-12 07:53:29 -06:00
compat.h net: extend Sock with methods for robust send & read until terminator 2021-03-01 17:36:16 +01:00
compressor.cpp
compressor.h
core_io.h doc: fix various typos 2021-01-04 12:31:31 +08:00
core_memusage.h
core_read.cpp doc: fix various typos 2021-01-04 12:31:31 +08:00
core_write.cpp scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
cuckoocache.h doc: Use https URLs where possible 2021-01-04 12:23:16 +08:00
dbwrapper.cpp
dbwrapper.h Merge #20464: refactor: Treat CDataStream bytes as uint8_t 2021-02-01 15:17:28 +01:00
dummywallet.cpp wallet: add -signer argument for external signer command 2021-02-23 14:34:30 +01:00
flatfile.cpp log: Move "Pre-allocating up to position 0x[...] in [...].dat" log message to debug category 2021-02-10 20:46:25 +00:00
flatfile.h
fs.cpp Replace fs::absolute calls with AbsPathJoin calls 2021-01-15 22:48:15 +01:00
fs.h Replace fs::absolute calls with AbsPathJoin calls 2021-01-15 22:48:15 +01:00
hash.cpp doc: Use https URLs where possible 2021-01-04 12:23:16 +08:00
hash.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
httprpc.cpp rpc: Validate -rpcauth arguments 2020-11-23 21:02:54 +00:00
httprpc.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
httpserver.cpp net: Drop unneeded headers when compat.h included 2020-10-22 21:45:20 +03:00
httpserver.h
i2p.cpp net: implement the necessary parts of the I2P SAM protocol 2021-03-01 18:19:37 +01:00
i2p.h net: implement the necessary parts of the I2P SAM protocol 2021-03-01 18:19:37 +01:00
indirectmap.h
init.cpp net: recognize I2P from ParseNetwork() so that -onlynet=i2p works 2021-03-01 18:19:47 +01:00
init.h Don't make "in" parameters look like "out"/"in-out" parameters: pass by ref to const instead of ref to non-const 2020-12-06 00:22:40 +00:00
key.cpp doc: Use https URLs where possible 2021-01-04 12:23:16 +08:00
key.h
key_io.cpp Better error messages for invalid addresses 2021-01-24 02:44:53 +01:00
key_io.h Better error messages for invalid addresses 2021-01-24 02:44:53 +01:00
logging.cpp net: implement the necessary parts of the I2P SAM protocol 2021-03-01 18:19:37 +01:00
logging.h net: implement the necessary parts of the I2P SAM protocol 2021-03-01 18:19:37 +01:00
Makefile.am net: implement the necessary parts of the I2P SAM protocol 2021-03-01 18:19:37 +01:00
Makefile.bench.include net: Add libnatpmp support 2021-01-07 18:07:09 +02:00
Makefile.crc32c.include build: Update crc32c subtree 2020-12-08 19:26:30 +01:00
Makefile.leveldb.include
Makefile.qt.include gui: Add Roboto Mono font 2021-02-21 21:01:02 +02:00
Makefile.qt_locale.include qt: Pre-splitoff translations update 2020-10-27 19:40:44 +01:00
Makefile.qttest.include net: Add libnatpmp support 2021-01-07 18:07:09 +02:00
Makefile.test.include Merge #20788: net: add RAII socket and use it instead of bare SOCKET 2021-02-11 14:07:33 +01:00
Makefile.test_fuzz.include fuzz: move-only FillNode implementation to cpp file 2021-01-23 20:01:12 +01:00
Makefile.test_util.include test: Move P2WSH_OP_TRUE to shared test library 2021-02-17 11:36:30 +01:00
mapport.cpp net: Add -natpmp command line option 2021-01-07 18:07:09 +02:00
mapport.h net: Add -natpmp command line option 2021-01-07 18:07:09 +02:00
memusage.h
merkleblock.cpp doc: fix various typos 2021-01-04 12:31:31 +08:00
merkleblock.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
miner.cpp validation: Pass in chainstate to TestBlockValidity 2021-01-28 14:15:26 -05:00
miner.h Don't declare de facto const member functions as non-const 2020-12-06 18:44:25 +00:00
net.cpp net: accept incoming I2P connections from CConnman 2021-03-01 18:19:47 +01:00
net.h net: accept incoming I2P connections from CConnman 2021-03-01 18:19:47 +01:00
net_permissions.cpp scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
net_permissions.h Reduce MAX_PEER_TX_ANNOUNCEMENTS for non-PF_RELAY peers 2020-10-12 12:14:53 -07:00
net_processing.cpp Merge #20845: net: Log to net debug in MaybeDiscourageAndDisconnect except for noban and manual peers 2021-02-22 09:43:57 +01:00
net_processing.h [net processing] Move ping data fields to net processing 2021-02-15 16:15:51 +00:00
net_types.h
netaddress.cpp net: add I2P to the reachability map 2021-03-01 18:19:46 +01:00
netaddress.h net: extend CNetAddr::SetSpecial() to support I2P 2021-03-01 13:22:11 +01:00
netbase.cpp net: Do not skip the I2P network from GetNetworkNames() 2021-03-01 18:19:47 +01:00
netbase.h Merge #20965: net, rpc: return NET_UNROUTABLE as not_publicly_routable, automate helps 2021-02-15 15:31:15 +01:00
netmessagemaker.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
noui.cpp scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
noui.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
optional.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
outputtype.cpp refactor: Use C++17 std::array deduction for OUTPUT_TYPES 2021-01-03 18:37:59 +01:00
outputtype.h refactor: Use C++17 std::array deduction for OUTPUT_TYPES 2021-01-03 18:37:59 +01:00
pow.cpp
pow.h
prevector.h
protocol.cpp refactor: init vectors via std::{begin,end} to avoid pointer arithmetic 2021-01-31 17:35:01 +01:00
protocol.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
psbt.cpp Merge #20464: refactor: Treat CDataStream bytes as uint8_t 2021-02-01 15:17:28 +01:00
psbt.h scripted-diff: Use [[nodiscard]] (C++17) instead of NODISCARD 2020-11-26 09:05:59 +00:00
pubkey.cpp scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
pubkey.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
random.cpp refactor: replace sizeof(a)/sizeof(a[0]) by std::size (C++17) 2021-01-31 17:35:16 +01:00
random.h
randomenv.cpp util: Allow use of C++14 chrono literals 2020-12-08 16:47:36 +01:00
randomenv.h
rest.cpp Merge #20429: refactor: replace (sizeof(a)/sizeof(a[0])) with C++17 std::size 2021-02-18 07:53:37 +01:00
reverse_iterator.h
scheduler.cpp Add include for std::bind. 2021-01-13 02:05:00 +01:00
scheduler.h refactor: remove boost::thread_group usage 2021-01-29 15:39:44 +08:00
serialize.h Support bypassing range check in ReadCompactSize 2020-10-09 10:32:19 +02:00
shutdown.cpp init: only use pipe2 if availabile, check in configure 2021-02-22 14:17:24 +01:00
shutdown.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
signet.cpp refactor: Remove SignetTxs::m_valid and use optional instead 2020-09-22 22:31:31 +02:00
signet.h refactor: Remove SignetTxs::m_valid and use optional instead 2020-09-22 22:31:31 +02:00
span.h Merge #19387: span: update constructors to match c++20 draft spec and add lifetimebound attribute 2020-11-25 15:18:33 +01:00
streams.h Merge #20464: refactor: Treat CDataStream bytes as uint8_t 2021-02-01 15:17:28 +01:00
sync.cpp refactor: remove straggling boost::mutex usage 2021-01-26 15:57:28 +08:00
sync.h Merge #20495: sync: Use decltype(auto) return type for WITH_LOCK 2021-01-12 15:56:19 +08:00
threadinterrupt.cpp
threadinterrupt.h
threadsafety.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
timedata.cpp Avoid the use of abs64 in timedata 2020-10-12 19:50:16 -07:00
timedata.h
tinyformat.h refactor: Improve use of explicit keyword 2020-12-01 18:36:39 +01:00
torcontrol.cpp util: extract {Read,Write}BinaryFile() to its own files 2021-03-01 12:56:56 +01:00
torcontrol.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
txdb.cpp txdb: don't reset during in-memory cache resize 2021-02-12 07:53:32 -06:00
txdb.h txdb: add CCoinsViewDB::ChangeCacheSize 2020-07-01 14:44:24 -04:00
txmempool.cpp Merge #18017: txmempool: split epoch logic into class 2021-02-24 09:57:21 +01:00
txmempool.h Merge #18017: txmempool: split epoch logic into class 2021-02-24 09:57:21 +01:00
txrequest.cpp refactor: Improve use of explicit keyword 2020-12-01 18:36:39 +01:00
txrequest.h Report and verify expirations 2020-10-12 12:14:53 -07:00
uint256.cpp scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
uint256.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
undo.h
validation.cpp Merge #21202: [validation] Two small clang lock annotation improvements 2021-02-22 09:47:15 +01:00
validation.h style-only: Make CheckSequenceLock signature readable 2021-02-18 14:49:10 -05:00
validationinterface.cpp Add 'sequence' zmq publisher to track all block (dis)connects, mempool deltas 2020-09-22 11:34:30 -04:00
validationinterface.h Add 'sequence' zmq publisher to track all block (dis)connects, mempool deltas 2020-09-22 11:34:30 -04:00
version.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
versionbits.cpp
versionbits.h
versionbitsinfo.cpp scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
versionbitsinfo.h
walletinitinterface.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
warnings.cpp scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
warnings.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00