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);