UNPKG

opnet

Version:

The perfect library for building Bitcoin-based applications.

15 lines (14 loc) 444 B
import { address as btcAddress } from '@btc-vision/bitcoin'; const P2MR_WITNESS_VERSION = 2; const P2MR_DATA_LENGTH = 32; export function isP2MRAddress(addr, network) { try { const decoded = btcAddress.fromBech32(addr); return (decoded.prefix === network.bech32 && decoded.version === P2MR_WITNESS_VERSION && decoded.data.length === P2MR_DATA_LENGTH); } catch { return false; } }