Crypto/Transaction/Digest/Result.pm

filter: Statementstmt 100% 34 / 34 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 96.0% 48 / 50 CC 4 SCAR 5.2
CC
4
Cov
95%
_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.005';
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",
Subroutine BEGIN: called CC=1 SCAR=0.0
14 36 fallback => 1;
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 208 ▶{
Subroutine _build_hash: called CC=3 SCAR=11.0
32 208 my $self = shift;
33 208 my $preimage = $self->preimage;
34  
35 208 ▶ Bitcoin::Crypto::Exception->raise(
Branch: 1 branch
BranchTrueFalseTotal
unless defined $preimage 0 208 208
36 "can't hash without preimage"
37 ) unless defined $preimage;
38  
39 208 ▶ if ($self->taproot) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->taproot) { } 56 152 208
40 56 return tagged_hash('TapSighash', $preimage);
41 }
42 else {
43 152 return hash256($preimage);
44 }
45 }
46  
47 sub as_string
48 17 ▶{
Subroutine as_string: called CC=2 SCAR=7.1
Pod documented
49 17 my ($self) = @_;
50  
51 # backcompat - returns preimage
52  
53 17 ▶ Bitcoin::Crypto::Exception->raise(
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_preimage 0 17 17
54 'no preimage generated by digesting'
55 ) unless $self->has_preimage;
56  
57 17 return $self->preimage;
58 }
59  
60 36 1;
61  
62 __END__
« Crypto/Transaction/Flags.pm ↑ Summary Crypto/Script/Common.pm »