From 38d407f617273d43b1395ccbc03ad769ba9cc544 Mon Sep 17 00:00:00 2001 From: Fabio B Date: Fri, 15 Dec 2023 13:10:32 +0100 Subject: [PATCH] Since base58 is a subset of base64, we need to check if it's base58 encoded first --- packages/explorerkit-server/src/server.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/explorerkit-server/src/server.ts b/packages/explorerkit-server/src/server.ts index 21f09ea..9dbbf00 100644 --- a/packages/explorerkit-server/src/server.ts +++ b/packages/explorerkit-server/src/server.ts @@ -105,10 +105,10 @@ app.post("/decode/transactions", async (req: Request, res: Response) => { let decodedAccounts: DecodedTransactions[] = []; for (var encodedTx of transactions) { let txBuffer = null; - if (isValidBase64(encodedTx)) { - txBuffer = Buffer.from(encodedTx, "base64"); - } else if (isValidBase58(encodedTx)) { + if (isValidBase58(encodedTx)) { txBuffer = Buffer.from(bs58.decode(encodedTx)); + } else if (isValidBase64(encodedTx)) { + txBuffer = Buffer.from(encodedTx, "base64"); } else { decodedAccounts.push({ error: "'transaction' is not a valid base64 string.", decodedInstructions: null }); continue;