Using P2PKH

How to use P2PKH in OP_NET

OP_NET provides two ways to access P2PKH addresses. Use the p2pkh property on a wallet object to retrieve the P2PKH address directly. Alternatively, call the p2pkh() method on an Address object, which allows specifying the target network as a parameter.

The following example shows how to use both ways:
typescript
// Mainnet Legacy
const p2pkhMainnet = wallet.p2pkh;
console.log('P2PKH Mainnet:', p2pkhMainnet);
// Output: 1...

// Validate  key
const isLegacyValid = AddressVerificator.isP2PKHOrP2SH(p2pkh, networks.bitcoin);
console.log('Legacy valid:', isLegacyValid);  // true

// Testnet Legacy
const p2pkhTestnet = wallet.address.p2pkh(networks.testnet);
console.log('P2PKH Testnet:', p2pkhTestnet);
// Output: m... or n...