Crypto/Transaction/ControlBlock.pm

filter: Statementstmt 100% 35 / 35 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 2 / 2 totaltotal 100% 47 / 47 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Crypto/Tapscript.pm ↑ Summary Crypto/Transaction/Signer/CompatP2WSH.pm »
1 package Bitcoin::Crypto::Transaction::ControlBlock;
2 41 $Bitcoin::Crypto::Transaction::ControlBlock::VERSION = '4.006';
3 41 ▶use v5.14;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 41 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 41 ▶use Mooish::Base -standard;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 41 ▶use Types::Common -sigs;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 41 ▶use Bitcoin::Crypto qw(btc_pub);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 41 ▶use Bitcoin::Crypto::Types -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 41 ▶use Bitcoin::Crypto::Util::Internal qw(lift_x);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 41 has param 'control_byte' => (
14 isa => IntMaxBits [8],
15 );
16  
17 41 has param 'public_key' => (
18 isa => InstanceOf ['Bitcoin::Crypto::Key::Public'],
19 );
20  
21 41 has param 'script_blocks' => (
22 coerce => (ArrayRef [ByteStrLen [32]])
23 ->where(q{ @$_ <= 128 }),
24 );
25  
26 41 signature_for from_serialized => (
27 method => !!1,
28 positional => [ByteStr],
29 );
30  
31 sub from_serialized
32 41 ▶{
Subroutine from_serialized: called CC=1 SCAR=0.0
33 41 my ($class, $control_block) = @_;
34  
35 41 my ($control_byte, $xonly_pub, @script_blocks) = grep { length } unpack 'Ca32(a32)*', $control_block;
36  
37 41 return $class->new(
38 control_byte => $control_byte,
39 public_key => btc_pub->from_serialized(lift_x $xonly_pub),
40 script_blocks => \@script_blocks,
41 );
42 }
43  
44 sub to_serialized
45 39 ▶{
Subroutine to_serialized: called CC=1 SCAR=0.0
Pod documented
46 39 my ($self) = @_;
47  
48 return pack('C', $self->control_byte)
49 . $self->public_key->get_xonly_key
50 39 . join '', @{$self->script_blocks};
51 }
52  
53 sub get_leaf_version
54 12 ▶{
Subroutine get_leaf_version: called CC=1 SCAR=0.0
Pod documented
55 12 my ($self) = @_;
56  
57 12 return $self->control_byte & 0xfe;
58 }
59  
60 41 1;
61  
62 __END__
« Crypto/Tapscript.pm ↑ Summary Crypto/Transaction/Signer/CompatP2WSH.pm »