diff --git a/src/evo/providertx.h b/src/evo/providertx.h index d7f8f259ffbab3..b4b24256da1e55 100644 --- a/src/evo/providertx.h +++ b/src/evo/providertx.h @@ -22,6 +22,7 @@ class CBlockIndex; class CCoinsViewCache; class TxValidationState; +// CProRegTx is defined here class CProRegTx { public: diff --git a/src/netaddress.cpp b/src/netaddress.cpp index ac6afed471a55a..4483fec3952b4e 100644 --- a/src/netaddress.cpp +++ b/src/netaddress.cpp @@ -36,6 +36,8 @@ CNetAddr::BIP155Network CNetAddr::GetBIP155Network() const return BIP155Network::I2P; case NET_CJDNS: return BIP155Network::CJDNS; + case NET_HOSTNAME: + return BIP155Network::HOSTNAME; case NET_INTERNAL: // should have been handled before calling this function case NET_UNROUTABLE: // m_net is never and should not be set to NET_UNROUTABLE case NET_MAX: // m_net is never and should not be set to NET_MAX @@ -88,6 +90,14 @@ bool CNetAddr::SetNetFromBIP155Network(uint8_t possible_bip155_net, size_t addre throw std::ios_base::failure( strprintf("BIP155 CJDNS address with length %u (should be %u)", address_size, ADDR_CJDNS_SIZE)); + case BIP155Network::HOSTNAME: + if (address_size == ADDR_HOSTNAME_SIZE) { + m_net = NET_HOSTNAME; + return true; + } + throw std::ios_base::failure( + strprintf("BIP155 HOSTNAME address with length %u (should be %u)", address_size, + ADDR_HOSTNAME_SIZE)); } // Don't throw on addresses with unknown network ids (maybe from the future). diff --git a/src/netaddress.h b/src/netaddress.h index b8001a4dd73272..8e1f1b92df0f10 100644 --- a/src/netaddress.h +++ b/src/netaddress.h @@ -60,6 +60,9 @@ enum Network { /// CJDNS NET_CJDNS, + /// Hostname + NET_HOSTNAME, + /// A set of addresses that represent the hash of a string or FQDN. We use /// them in CAddrMan to keep track of which DNS seeds were used. NET_INTERNAL, @@ -105,6 +108,10 @@ static constexpr size_t ADDR_I2P_SIZE = 32; /// Size of CJDNS address (in bytes). static constexpr size_t ADDR_CJDNS_SIZE = 16; +/// Size of Hostname (in bytes). This is the maximum length of all labels and +/// dots as per RFC 1035 Size limits (Section 2.3.4.) +static constexpr size_t ADDR_HOSTNAME_SIZE = 255; + /// Size of "internal" (NET_INTERNAL) address (in bytes). static constexpr size_t ADDR_INTERNAL_SIZE = 10; @@ -114,6 +121,7 @@ static constexpr uint16_t I2P_SAM31_PORT{0}; /** * Network address. */ +// CNetAddr is defined here for IPv6 or IPv4 class CNetAddr { protected: @@ -164,8 +172,12 @@ class CNetAddr * @returns Whether the operation was successful. * @see CNetAddr::IsTor(), CNetAddr::IsI2P() */ + // Hmmm... looks like hostnames (DNS) *can* fit after all? bool SetSpecial(const std::string& addr); + // What might this look like?? + bool SetHostname(const std::string& addr); + bool IsBindAny() const; // INADDR_ANY equivalent bool IsIPv4() const; // IPv4 mapped address (::FFFF:0:0/96, 0.0.0.0/0) bool IsIPv6() const; // IPv6 address (not mapped IPv4, not Tor) @@ -191,6 +203,7 @@ class CNetAddr bool IsRoutable() const; bool IsInternal() const; bool IsValid() const; + bool IsHostname() const; /** * Check if the current object can be serialized in pre-ADDRv2/BIP155 format. @@ -282,6 +295,8 @@ class CNetAddr TORV3 = 4, I2P = 5, CJDNS = 6, + // add Hostname support here (and rename the enum?) + HOSTNAME = 1993, }; /** @@ -339,6 +354,7 @@ class CNetAddr case NET_ONION: case NET_I2P: case NET_CJDNS: + case NET_HOSTNAME: break; case NET_UNROUTABLE: case NET_MAX: @@ -518,6 +534,7 @@ class CSubNet }; /** A combination of a network address (CNetAddr) and a (TCP) port */ +// CService is defined here class CService : public CNetAddr { protected: diff --git a/src/netbase.cpp b/src/netbase.cpp index fc940b0501dac0..ecb56ab93888a2 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -90,6 +90,7 @@ enum Network ParseNetwork(const std::string& net_in) { if (net == "ipv4") return NET_IPV4; if (net == "ipv6") return NET_IPV6; if (net == "onion") return NET_ONION; + if (net == "hostname") return NET_HOSTNAME; if (net == "tor") { LogPrintf("Warning: net name 'tor' is deprecated and will be removed in the future. You should use 'onion' instead.\n"); return NET_ONION; @@ -109,6 +110,7 @@ std::string GetNetworkName(enum Network net) case NET_ONION: return "onion"; case NET_I2P: return "i2p"; case NET_CJDNS: return "cjdns"; + case NET_HOSTNAME: return "hostname"; case NET_INTERNAL: return "internal"; case NET_MAX: assert(false); } // no default case, so the compiler can warn about missing cases @@ -121,7 +123,7 @@ std::vector GetNetworkNames(bool append_unroutable) std::vector names; for (int n = 0; n < NET_MAX; ++n) { const enum Network network{static_cast(n)}; - if (network == NET_UNROUTABLE || network == NET_CJDNS || network == NET_INTERNAL) continue; + if (network == NET_UNROUTABLE || network == NET_HOSTNAME || network == NET_CJDNS || network == NET_INTERNAL) continue; names.emplace_back(GetNetworkName(network)); } if (append_unroutable) { diff --git a/src/rpc/evo.cpp b/src/rpc/evo.cpp index 180b9f97741f73..7b85c9274ee49c 100644 --- a/src/rpc/evo.cpp +++ b/src/rpc/evo.cpp @@ -620,11 +620,12 @@ static UniValue protx_register_common_wrapper(const JSONRPCRequest& request, size_t paramIdx = 0; CMutableTransaction tx; - tx.nVersion = 3; + tx.nVersion = 3; // EVO SEND!! tx.nType = TRANSACTION_PROVIDER_REGISTER; const bool use_legacy = isV19active ? specific_legacy_bls_scheme : true; + // This is the type that packs the IP presently CProRegTx ptx; ptx.nType = mnType; @@ -655,6 +656,7 @@ static UniValue protx_register_common_wrapper(const JSONRPCRequest& request, wallet->LockCoin(ptx.collateralOutpoint); } + // paramIdx is now for hostnameAndPort if (request.params[paramIdx].get_str() != "") { if (!Lookup(request.params[paramIdx].get_str().c_str(), ptx.addr, Params().GetDefaultPort(), false)) { throw std::runtime_error(strprintf("invalid network address %s", request.params[paramIdx].get_str())); diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index eb9b0af4d237a8..069a10cd474f58 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -87,7 +87,7 @@ static UniValue getpeerinfo(const JSONRPCRequest& request) { { {RPCResult::Type::NUM, "id", "Peer index"}, - {RPCResult::Type::STR, "addr", "(host:port) The IP address and port of the peer"}, + {RPCResult::Type::STR, "addr", "(hostname:port) The Hostname (or IP address) and port of the peer"}, {RPCResult::Type::STR, "addrbind", "(ip:port) Bind address of the connection to the peer"}, {RPCResult::Type::STR, "addrlocal", "(ip:port) Local address as reported by the peer"}, {RPCResult::Type::STR, "network", "Network (" + Join(GetNetworkNames(/* append_unroutable */ true), ", ") + ")"},