Sunday, December 22, 2024

segregated witness – Bitcoin segwit addresses from HEX

For previous and new deal with format (P2SH, P2WPKH, P2WSH) you should utilize Common Bitcoin Tackle Generator library:
https://github.com/toggio/BitcoinAddressGenerator/

You’ll be able to generate and convert each kind of personal/public key and deal with format:

<?php

require_once('BitcoinAddressGenerator.php');

$BTC = new BitcoinAddressGenerator();

echo "Non-public key: ".$BTC->getPrivateKey()."n";
echo "Public key: ".$BTC->getPublicKey()."n";
echo "Compressed Public Key: ".$BTC->getCompPublicKey()."n";
echo "WIF: ".$BTC->getWIF()."n";
echo "Compressed WIF: ".$BTC->getCompWIF()."n";
echo "P2PKH Tackle: ".$BTC->getP2PKH()."n";
echo "Compressed P2PKH Tackle: ".$BTC->getCompP2PKH()."n";
echo "P2SH Tackle: ".$BTC->getP2SH()."n";
echo "P2WPKH Tackle: ".$BTC->getP2WPKH()."n";
echo "P2WSH Tackle: ".$BTC->getP2WSH()."n";
?>

The output shall be one thing like this:

Non-public key: 90bae5e94c422b7d8ba8cda13b6f8974e63fa409e909afda2ffb400dd1bc448d
Public key: 04f94c255da6ffb59d1859fa08c2d4b4942b4cf533a6d7ec9eb242047a60f4801ef47fad20a3b143194bca890ab9edb7de80635e3441f95eaaa917f59ae96e63af
Compressed Public Key: 03f94c255da6ffb59d1859fa08c2d4b4942b4cf533a6d7ec9eb242047a60f4801e
WIF: 5Jv2WwACnLoqbuqmY7uix2YW2xWGoXSBS736yTW1vNZSh1J15vt
Compressed WIF: L253h83d18RjX6EFaMVi9sp39dzCkML93oeHNBy54aACPMHyMBS4
P2PKH Tackle: 1JkQH9oQ8EiCzCAW3D2auwXz7LfKiC1m8o
Compressed P2PKH Tackle: 1BdyvjvUgdmu1AtmhV3CTGJ9H79SfD4b4P
P2SH Tackle: 3QAsNPQJBgFs98YjPoDquuE3Bju6T6Jgr2
P2WPKH Tackle: bc1qwjhupxjkrs2sctfqwm2a4rlhhxna93kk29x7he
P2WSH Tackle: bc1u7znk6gn992vuzn9u5044rdurwa8yw5a5f5kaacgs555mnnrarvswkuv8v

Or if you have already got your personal personal key, you may provide it after which acquire all different keys and addresses:

$BTC->newKeys("b428729db6df4dd1b14e20887d3f9cd71486f1c39ed994c065b17b5eb2f7e4a7");

echo "Non-public key: ".$BTC->getPrivateKey()."n";
echo "Public key: ".$BTC->getPublicKey()."n";
echo "Compressed Public Key: ".$BTC->getCompPublicKey()."n";
echo "WIF: ".$BTC->getWIF()."n";
echo "Compressed WIF: ".$BTC->getCompWIF()."n";
echo "P2PKH Tackle: ".$BTC->getP2PKH()."n";
echo "Compressed P2PKH Tackle: ".$BTC->getCompP2PKH()."n";
echo "P2SH Tackle: ".$BTC->getP2SH()."n";
echo "P2WPKH Tackle: ".$BTC->getP2WPKH()."n";
echo "P2WSH Tackle: ".$BTC->getP2WSH()."n";

This may output:

Non-public key: b428729db6df4dd1b14e20887d3f9cd71486f1c39ed994c065b17b5eb2f7e4a7
Public key: 043acb033826e2c3018fb88bc0e8a192f926cf3b2a73df2a00c7d45b5b522a47cd9953c59826bb217464d95cd9c0fbe4f1306b09ef526dabd55a8452c64a9d04cf
Compressed Public Key: 033acb033826e2c3018fb88bc0e8a192f926cf3b2a73df2a00c7d45b5b522a47cd
WIF: 5KBdUYphQaPwmcsvssq3JBqFGnVCAM563qDFNfpGqyz8JeKPBSC
Compressed WIF: L3FuzbTXM4QGjwMnoZM38rowzfmSGFb3HVo4SeKewCX9Ei5VhEFM
P2PKH Tackle: 1P2iFYGFB6GwguBfLEaqo2hSz6V9N5261J
Compressed P2PKH Tackle: 1E1P4noxSdNpErNwRHFzMSPucgmeDsHi4p
P2SH Tackle: 3DxLbTj5ARZ33VQ6yvccaEqWVVkEsdj3cz
P2WPKH Tackle: bc1q36kqmmduxne6fzse362e2ms7xxcmycw8uh4gft
P2WSH Tackle: bc1qx8hepy0nqq5r76jm5grqf6ash2hlydhe5upuw4gzsc5tpnxxxsq522h3u

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles