From 2a2553821462c8e8e08c303ec0154b661e0cfb84 Mon Sep 17 00:00:00 2001 From: tate Date: Mon, 22 Jan 2024 10:34:55 +1100 Subject: [PATCH] sol coding string length --- src/coin/sol.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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");