mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-15 12:13:24 +00:00
Fix pubkey parsing to be read as bytes
from_string was trying to parse it as base32z.snode Also leave FIXMEs behind for the badly named methods (both in RouterID itself and in ancestor classes).
This commit is contained in:
parent
329acaf56c
commit
ff3a495f0e
@ -32,9 +32,11 @@ namespace llarp
|
||||
std::string
|
||||
ToString() const;
|
||||
|
||||
// FIXME: this is deceptively named: it should be "from_hex" since that's what it does.
|
||||
bool
|
||||
FromString(const std::string& str);
|
||||
|
||||
// FIXME: this is deceptively named: it should be "from_hex" since that's what it does.
|
||||
static PubKey
|
||||
from_string(const std::string& s);
|
||||
|
||||
|
@ -61,7 +61,11 @@ namespace llarp
|
||||
"Invalid RC netid: expected {}, got {}; this is an RC for a different network!"_format(
|
||||
ACTIVE_NETID, netid)};
|
||||
|
||||
_router_id.from_string(data.require<std::string_view>("p"));
|
||||
auto pubkey = data.require<std::string_view>("p");
|
||||
if (pubkey.size() != 32)
|
||||
throw std::runtime_error{
|
||||
"Invalid RC pubkey: expected 32 bytes, got {}"_format(pubkey.size())};
|
||||
std::memcpy(_router_id.data(), pubkey.data(), 32);
|
||||
|
||||
// auto pk = data.require<std::string_view>("p");
|
||||
|
||||
|
@ -33,6 +33,9 @@ namespace llarp
|
||||
std::string
|
||||
ShortString() const;
|
||||
|
||||
// FIXME: this is deceptively named: it parses something base32z formatted with .snode on the
|
||||
// end, so should probably be called "from_snode_address" or "from_base32z" or something that
|
||||
// doesn't sound exactly like the other (different) from_strings of its base classes.
|
||||
bool
|
||||
from_string(std::string_view str);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user