-
-
13 May 2022 20:30:43 UTC
- Distribution: Bitcoin-Crypto
- Module version: 1.006
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Repository
- Issues
- Testers (82 / 0 / 1)
- Kwalitee
Bus factor: 1- % Coverage
- License: perl_5
- Perl: v5.10.0
- Activity
24 month- Tools
- Download (59.96KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
NAME
Bitcoin::Crypto::Segwit - Segregated Witness version definitions
SYNOPSIS
use Bitcoin::Crypto::Segwit qw(validate_program); my $program_version = validate_program($segwit_program);
DESCRIPTION
This module provides tools required to define and use a Segregated Witness version validator.
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. If the validator is not defined for a segwit version being validated, a warning is issued.
The function returns the detected segwit program version. Please note that it does not perform any more checks than ensuring the byte string is in correct format.
The current implementation defines a validator for segwit version 0. In the future (when another segwit program version is defined) it might be neccessary to define another one in the program until it's added to the library. This can be done like so:
use Bitcoin::Crypto::Segwit; use Bitcoin::Crypto::Exception; $Bitcoin::Crypto::Segwit::validators{1} = sub { my ($data) = @_; # perform validation Bitcoin::Crypto::Exception::SegwitProgram->raise( "validation of program version 1 failed" ) if ...; # if validation is successful just do nothing return; };
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
Module Install Instructions
To install Bitcoin::Crypto, copy and paste the appropriate command in to your terminal.
cpanm Bitcoin::Crypto
perl -MCPAN -e shell install Bitcoin::Crypto
For more information on module installation, please visit the detailed CPAN module installation guide.