From 8b2dcf0d5615cea14f88c80f8974f11783c7d363 Mon Sep 17 00:00:00 2001 From: M1 Date: Wed, 18 Mar 2026 23:22:37 +0400 Subject: [PATCH] =?UTF-8?q?fix:=20convert=20zpub=20to=20xpub=20version=20b?= =?UTF-8?q?ytes=20=E2=80=94=20bitcore-lib-ltc=20only=20understands=20stand?= =?UTF-8?q?ard=20xpub?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/pay/src/address.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/pay/src/address.ts b/apps/pay/src/address.ts index bfbb20d..86d86a4 100644 --- a/apps/pay/src/address.ts +++ b/apps/pay/src/address.ts @@ -85,11 +85,11 @@ export function deriveAddressSafe(coin: string, index: number): string { if (coin === "ltc") { // zpub uses BIP84 version bytes — convert to Ltub so bitcore-lib-ltc can parse it let key = xpub; - if (xpub.startsWith("zpub") || xpub.startsWith("Zpub")) { - // Decode base58check, swap version bytes to Ltub (0x019da462), re-encode - const decoded = bs58check.decode(xpub); - // Replace first 4 bytes with Ltub version: 0x019da462 - decoded[0] = 0x01; decoded[1] = 0x9d; decoded[2] = 0xa4; decoded[3] = 0x62; + if (xpub.startsWith("zpub") || xpub.startsWith("Zpub") || xpub.startsWith("Ltub") || xpub.startsWith("Mtub")) { + // bitcore-lib-ltc only understands standard xpub version bytes (0x0488b21e). + // Convert zpub/Ltub/Mtub → xpub by swapping the 4-byte version prefix. + const decoded = Buffer.from(bs58check.decode(xpub)); + decoded[0] = 0x04; decoded[1] = 0x88; decoded[2] = 0xb2; decoded[3] = 0x1e; key = bs58check.encode(decoded); } const hd = new bitcoreLtc.HDPublicKey(key);