Crypto/Transaction/Digest/Result.pm

filter: Statementstmt 100% 34 / 34 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 98.0% 49 / 50 CC 4 SCAR 5.1
CC
4
Cov
98%
_build_hash
3.0
as_string
2.0
BEGIN
1.0
CRAP 1.7
« Crypto/Transaction/Flags.pm ↑ Summary Crypto/Script/Common.pm »
1 package Bitcoin::Crypto::Transaction::Digest::Result;
2 36 $Bitcoin::Crypto::Transaction::Digest::Result::VERSION = '4.004';
3 36 ▶use v5.14;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 36 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 36 ▶use Mooish::Base -standard;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 36 ▶use Bitcoin::Crypto::Types -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 36 ▶use Bitcoin::Crypto::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 36 ▶use Bitcoin::Crypto::Util::Internal qw(hash256 tagged_hash);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 use overload
13 36 q{""} => "as_string",
14 36 ▶ fallback => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 36 has param 'taproot' => (
17 coerce => Bool,
18 default => !!0,
19 );
20  
21 36 has option 'preimage' => (
22 coerce => ByteStr,
23 );
24  
25 36 has param 'hash' => (
26 coerce => ByteStr,
27 lazy => 1,
28 );
29  
30 sub _build_hash
31 {
32 205 ▶ my $self = shift;
Subroutine _build_hash: called CC=3 SCAR=11.0
33 205 my $preimage = $self->preimage;
34  
35 205 ▶ Bitcoin::Crypto::Exception->raise(
Branch: 1 branch
BranchTrueFalseTotal
unless defined $preimage 0 205 205
36 "can't hash without preimage"
37 ) unless defined $preimage;
38  
39 205 ▶ if ($self->taproot) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->taproot) { } 56 149 205
40 56 return tagged_hash('TapSighash', $preimage);
41 }
42 else {
43 149 return hash256($preimage);
44 }
45 }
46  
47 sub as_string
48 {
49 50 ▶ my ($self) = @_;
Subroutine as_string: called CC=2 SCAR=6.9
Pod documented
50  
51 # backcompat - returns preimage
52  
53 50 ▶ Bitcoin::Crypto::Exception->raise(
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_preimage 1 49 50
54 'no preimage generated by digesting'
55 ) unless $self->has_preimage;
56  
57 49 return $self->preimage;
58 }
59  
60 36 1;
61  
62 __END__
« Crypto/Transaction/Flags.pm ↑ Summary Crypto/Script/Common.pm »