add util_raddr, util_accid

This commit is contained in:
tequ
2025-09-29 13:55:23 +09:00
parent 4ff8d688e2
commit cf59180660
3 changed files with 35 additions and 13 deletions

View File

@@ -305,8 +305,24 @@ using namespace hook_float;
// rollback
/// util APIs
// util_raddr
// util_accid
Expected<std::string, HookReturnCode>
HookAPI::util_raddr(Bytes const& accountID) const
{
if (accountID.size() != 20)
return Unexpected(INVALID_ARGUMENT);
return encodeBase58Token(
TokenType::AccountID, accountID.data(), accountID.size());
}
Expected<Bytes, HookReturnCode>
HookAPI::util_accid(std::string raddress) const
{
auto const result = decodeBase58Token(raddress, TokenType::AccountID);
if (result.empty())
return Unexpected(INVALID_ARGUMENT);
return Bytes(result.data(), result.data() + result.size());
}
Expected<bool, HookReturnCode>
HookAPI::util_verify(Slice const& data, Slice const& sig, Slice const& key)