From 8597e7d9c783f722b629abadc9b2aa7f7164a73a Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Mon, 23 Oct 2023 14:41:30 +0800 Subject: [PATCH] rpc: addressmap: Add ERC55 address validity check (#2607) * rpc: addressmap: Better error messages * rpc: addressmap: add erc55 validity check --------- Co-authored-by: Peter John Bushnell --- src/wallet/rpcwallet.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 2895b1ddde..1c99251e69 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4322,7 +4322,12 @@ UniValue addressmap(const JSONRPCRequest &request) { if (key.IsCompressed()) { key.Decompress(); } - format.pushKV("erc55", EncodeDestination(WitnessV16EthHash(key))); + auto erc55 = EncodeDestination(WitnessV16EthHash(key)); + // Check if it's in the wallet. + // Note: Can be removed if the full wallet is migrated. + // Ref: https://github.com/DeFiCh/ain/issues/2604 + AddrToPubKey(pwallet, erc55); + format.pushKV("erc55", erc55); break; } case AddressConversionType::EVMToDVMAddress: {