Crypto/Transaction/Signer/CompatSegwit.pm

filter: Statementstmt 100% 31 / 31 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod n/a totaltotal 97.6% 41 / 42 CC 2 SCAR 1.8
CC
2
Cov
97%
_finalize
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« Crypto/Base58.pm ↑ Summary Crypto/Secret.pm »
1 package Bitcoin::Crypto::Transaction::Signer::CompatSegwit;
2 5 $Bitcoin::Crypto::Transaction::Signer::CompatSegwit::VERSION = '4.006';
3 5 ▶use v5.14;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 ▶use Mooish::Base -standard;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 5 ▶use Bitcoin::Crypto qw(btc_script);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use Bitcoin::Crypto::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use Bitcoin::Crypto::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use Bitcoin::Crypto::Types -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 5 extends 'Bitcoin::Crypto::Transaction::Signer::Segwit';
14  
15 5 has field 'witness_program' => (
16 isa => BitcoinScript,
17 trigger => 1,
18 writer => 1,
19 );
20  
21 sub _trigger_witness_program
22 10 ▶{
Subroutine _trigger_witness_program: called CC=1 SCAR=0.0
23 10 my ($self) = @_;
24  
25 10 $self->_runner->transaction->inputs->[$self->signing_index]->set_signature_script(
26 btc_script->new->push_bytes($self->witness_program->to_serialized)
27 );
28 }
29  
30 sub _finalize
31 7 ▶{
Subroutine _finalize: called CC=2 SCAR=7.0
32 7 my ($self) = @_;
33  
34 7 my $witness_program = $self->witness_program;
35  
36 7 ▶ Bitcoin::Crypto::Exception::Sign->raise(
Branch: 1 branch
BranchTrueFalseTotal
unless $witness_program 0 7 7
37 'signature is missing a witness program'
38 ) unless $witness_program;
39  
40 7 $self->transaction->inputs->[$self->signing_index]->set_signature_script(
41 btc_script->new->push_bytes($witness_program->to_serialized)
42 );
43  
44 7 $self->SUPER::_finalize;
45 }
46  
47 5 1;
48  
« Crypto/Base58.pm ↑ Summary Crypto/Secret.pm »