Bitcoin-Crypto
view release on metacpan or search on metacpan
lib/Bitcoin/Crypto/Key/Public.pm view on Meta::CPAN
Character encoding note: C<$message> should be encoded in the proper encoding
before passing it to this method. Passing Unicode string will cause the
function to fail. You can encode like this (for UTF-8):
use Encode qw(encode);
$message = encode('UTF-8', $message);
=head3 get_legacy_address
$address_string = $object->get_legacy_address()
Returns string containing Base58Check encoded public key hash (C<p2pkh> address).
If the public key was obtained through BIP44 derivation scheme, this method
will check whether the purpose was C<44> and raise an exception otherwise. If
you wish to generate this address anyway, call C<clear_purpose>.
=head3 get_compat_address
$address_string = $object->get_compat_address()
Returns string containing Base58Check encoded script hash containing a witness
program for compatibility purposes (C<p2sh(p2wpkh)> address)
If the public key was obtained through BIP44 derivation scheme, this method
will check whether the purpose was C<49> and raise an exception otherwise. If
you wish to generate this address anyway, call C<clear_purpose>.
=head3 get_segwit_address
$address_string = $object->get_segwit_address()
Returns a string containing Bech32 encoded witness version 0 program (C<p2wpkh>
address)
If the public key was obtained through BIP44 derivation scheme, this method
will check whether the purpose was C<84> and raise an exception otherwise. If
you wish to generate this address anyway, call C<clear_purpose>.
=head3 get_taproot_address
$address_string = $object->get_taproot_address($script_tree = undef)
Returns a string containing Bech32m encoded witness version 1 program (C<p2tr>
address)
Optional C<$script_tree> can be passed as L<Bitcoin::Crypto::Script::Tree>
object. Passing this argument will generate an address that can be spent using
script path spend as well as key path spend. If this argument is not passed, an
unspendable script path will be used according to BIP341.
If the public key was obtained through BIP44 derivation scheme, this method
will check whether the purpose was C<86> and raise an exception otherwise. If
you wish to generate this address anyway, call C<clear_purpose>.
=head3 get_address
$address_string = $object->get_address()
Returns a string containing the address. Tries to guess which address type is
most fitting:
=over
=item * If the key has a BIP44 purpose set, generates type of address which
matches the purpose
=item * If the key doesn't have a purpose but the network supports segwit,
returns a taproot address (same as C<get_taproot_address>, but does not accept
a script tree)
=item * If the network doesn't support segwit, returns legacy address
=back
B<NOTE>: The rules this function uses to choose the address type B<will>
change when more up-to-date address types are implemented. Use
other address functions if this is not what you want.
=head1 SEE ALSO
L<Bitcoin::Crypto::Key::Private>
L<Bitcoin::Crypto::Key::NUMS>
L<Bitcoin::Crypto::Base58>
L<Bitcoin::Crypto::Bech32>
( run in 1.358 second using v1.01-cache-2.11-cpan-39bf76dae61 )