Reading the Bitcoin destination bytes in an ENS multicoin record
An ENS integration returns bytes for a Bitcoin recipient and a payment form tries to display them as a UTF-8 address. For Bitcoin the record contains the output script, so the payment form needs a chain-specific conversion.
Identify the script template
Read addr(node, coinType) for the intended coin; the Bitcoin mainnet coin type is zero. The fixture constructs a 22-byte P2WPKH scriptPubKey. Its first byte selects witness version zero and its second pushes a 20-byte program. Feeding the entire script into a Bech32 encoder as if it were the witness program would yield the wrong result.
const script = Buffer.from("0014" + "ab".repeat(20), "hex");
console.log(script.length, script[0], script[1]);
Round-trip the proposed address
Use a Bitcoin address library configured for the required network and witness version. Decode the proposed display address back into an output script and compare it byte for byte with the record before preparing a payment. Other script templates need their own decoding path. If the requested record is empty or unsupported, show the missing destination instead of borrowing the name’s Ethereum address.