diff --git a/src/coin/sol.ts b/src/coin/sol.ts index 7eff5a1f..06ca7625 100644 --- a/src/coin/sol.ts +++ b/src/coin/sol.ts @@ -10,9 +10,16 @@ const coinType = 501; export const encodeSolAddress = (source: Uint8Array) => { if (source.length !== 32) throw new Error("Unrecognised address format"); - return base58UncheckedEncode(source); + const encoded = base58UncheckedEncode(source); + if (encoded.length < 32 || encoded.length > 44) + throw new Error("Unrecognised address format"); + + return encoded; }; export const decodeSolAddress = (source: string) => { + if (source.length < 32 || source.length > 44) + throw new Error("Unrecognised address format"); + const decoded = base58UncheckedDecode(source); if (decoded.length !== 32) throw new Error("Unrecognised address format");