Skip to content

Commit

Permalink
Add documentation for Bitcoin::Crypto::Types
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrtj committed Jul 26, 2024
1 parent 38913a8 commit d879551
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Revision history for Perl extension Bitcoin::Crypto.
2.006 NOT RELEASED
[Improvements]
- test suite now uses Test2
- Bitcoin::Crypto::Types is now documented

2.005 Wed Jul 24 2024
[Added interface]
Expand Down
87 changes: 85 additions & 2 deletions lib/Bitcoin/Crypto/Types.pm
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,89 @@ __PACKAGE__->make_immutable;

1;

# This module is mostly used internally, but it can be used from outside for
# bitcoin-specific types like BIP44Purpose.
__END__
=head1 NAME
Bitcoin::Crypto::Types - Bitcoin-specific data types
=head1 SYNOPSIS
use Bitcoin::Crypto::Types qw(
BIP44Purpose
FormatStr
FormatDesc
ByteStr
ScriptType
ScriptDesc
BitcoinScript
PSBTMapType
PSBTFieldType
IntMaxBits
SatoshiAmount
);
=head1 DESCRIPTION
This module is a L<Type::Tiny> library for types which are either specific for
Bitcoin or are used by Bitcoin::Crypto to implement its routines.
=head1 AVAILABLE TYPES
=head2 BIP44Purpose
An integer with one of the available purpose numbers for BIP44, like C<44>.
=head2 FormatStr
A string with one of the available format names, like C<hex>.
=head2 FormatDesc
An array reference with exactly two elements, where the first one is
L</FormatStr> and the second one is a string with the data encoded in that
format.
=head2 ByteStr
A string where each character is 8 bit. Can be coerced from L</FormatDesc>.
=head2 ScriptType
A string with one of the available script type names, like C<P2WPKH>.
=head2 ScriptDesc
An array reference with exactly two elements, where the first one is
L</ScriptType> or a string C<address>, and the second one is defined data
specific for that script type.
=head2 BitcoinScript
An instance of L<Bitcoin::Crypto::Script>. Can be coerced from L</ScriptDesc>
or L</ByteStr> (or any of its coercion types).
=head2 PSBTMapType
A string with one of the available PSBT map type names, like C<global>.
=head2 PSBTFieldType
An instance of L<Bitcoin::Crypto::PSBT::FieldType>. Can be coerced from a
string name of the PSBT field, or from an array reference of two values, where
the first one is L</PSBTMapType> and the second one is a positive integer with
field code.
=head2 IntMaxBits
A non-negative integer which must be small enough to be representable with the
specified number of bits (parametrizable).
=head2 SatoshiAmount
A non-negative integer, represented as L<Math::BigInt> object. Can be coerced
from an integer or from a string.
=head1 SEE ALSO
L<Type::Library>

0 comments on commit d879551

Please sign in to comment.