The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Bitcoin::Crypto::Segwit - DEPRECATED

SYNOPSIS

        use Bitcoin::Crypto::Segwit qw(validate_program);

        my $program_version = validate_program($segwit_program);

DESCRIPTION

This module is now deprecated and will be removed. Use validate_segwit from Bitcoin::Crypto::Util instead

This module provides tools required to validate a Segregated Witness program of a given version. It can be used to see if a bytestring looks like a witness program.

Currently, special validators are defined for version 0, SegWit addresses. Version 1, Taproot does not define a special validator unless an output is spent.

If you look for a way to encode a new type of address, see "encode_segwit" in Bitcoin::Crypto::Bech32.

FUNCTIONS

validate_program

        $segwit_version = validate_program($program)

Performs a segwit program validation on $program, which is expected to be a byte string in which the first byte is a segwit version. Based on this version a validator is invoked, present in %Bitcoin::Crypto::Segwit::validators module hash variable.

The function returns the detected segwit program version. Note that it does not perform any more checks than ensuring the byte string is in correct format.

The current implementation is in line with validations for segwit versions 0 and 1. Future segwit version addresses will work just fine, but no special validation will be performed until implemented.

EXCEPTIONS

This module throws an instance of Bitcoin::Crypto::Exception if it encounters an error. It can produce the following error types from the Bitcoin::Crypto::Exception namespace:

  • SegwitProgram - a validation of a segwit program has failed

SEE ALSO

Bitcoin::Crypto::Bech32