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