| 1 | package Bitcoin::Crypto::Script::Common; | ||||||||||||||||||||
| 2 | 64 | $Bitcoin::Crypto::Script::Common::VERSION = '4.005'; | |||||||||||||||||||
| 3 | 64 | ▶ | use v5.14; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 64 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 64 | ▶ | use namespace::autoclean; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 64 | ▶ | use Bitcoin::Crypto qw(btc_script btc_tapscript); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 64 | ▶ | use Bitcoin::Crypto::Types -types; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 64 | ▶ | use Bitcoin::Crypto::Exception; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | sub _make_PKH | ||||||||||||||||||||
| 13 | 75 | ▶ | { | ||||||||||||||||||
|
Subroutine
_make_PKH: called CC=2 SCAR=7.0
| |||||||||||||||||||||
| 14 | 75 | my ($class, $script, $hash) = @_; | |||||||||||||||||||
| 15 | 75 | ▶ | $script //= btc_script->new; | ||||||||||||||||||
|
Condition66%2/3
$script //= btc_script()->new
MC/DC0%0/2
$script //= btc_script()->new
$script
btc_script()->new
Truth table66%2/3
A //= B
A= $scriptB= btc_script()->new
| |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 75 | return $script | |||||||||||||||||||
| 18 | ->add('OP_DUP') | ||||||||||||||||||||
| 19 | ->add('OP_HASH160') | ||||||||||||||||||||
| 20 | ->push($hash) | ||||||||||||||||||||
| 21 | ->add('OP_EQUALVERIFY') | ||||||||||||||||||||
| 22 | ->add('OP_CHECKSIG'); | ||||||||||||||||||||
| 23 | } | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | sub _make_SH | ||||||||||||||||||||
| 26 | 20 | ▶ | { | ||||||||||||||||||
|
Subroutine
_make_SH: called CC=2 SCAR=7.6
| |||||||||||||||||||||
| 27 | 20 | my ($class, $script, $hash) = @_; | |||||||||||||||||||
| 28 | 20 | ▶ | $script //= btc_script->new; | ||||||||||||||||||
|
Condition33%1/3
$script //= btc_script()->new
MC/DC0%0/2
$script //= btc_script()->new
$script
btc_script()->new
Truth table33%1/3
A //= B
A= $scriptB= btc_script()->new
| |||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 20 | return $script | |||||||||||||||||||
| 31 | ->add('OP_HASH160') | ||||||||||||||||||||
| 32 | ->push($hash) | ||||||||||||||||||||
| 33 | ->add('OP_EQUAL'); | ||||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | sub _make_WSH | ||||||||||||||||||||
| 37 | 21 | ▶ | { | ||||||||||||||||||
|
Subroutine
_make_WSH: called CC=2 SCAR=7.6
| |||||||||||||||||||||
| 38 | 21 | my ($class, $script, $hash) = @_; | |||||||||||||||||||
| 39 | 21 | ▶ | $script //= btc_script->new; | ||||||||||||||||||
|
Condition33%1/3
$script //= btc_script()->new
MC/DC0%0/2
$script //= btc_script()->new
$script
btc_script()->new
Truth table33%1/3
A //= B
A= $scriptB= btc_script()->new
| |||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 21 | return $script | |||||||||||||||||||
| 42 | ->add('OP_SHA256') | ||||||||||||||||||||
| 43 | ->push($hash) | ||||||||||||||||||||
| 44 | ->add('OP_EQUAL'); | ||||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | sub _make_TR | ||||||||||||||||||||
| 48 | 30 | ▶ | { | ||||||||||||||||||
|
Subroutine
_make_TR: called CC=2 SCAR=7.6
| |||||||||||||||||||||
| 49 | 30 | my ($class, $script, $pubkey) = @_; | |||||||||||||||||||
| 50 | 30 | ▶ | $script //= btc_tapscript->new; | ||||||||||||||||||
|
Condition33%1/3
$script //= btc_tapscript()->new
MC/DC0%0/2
$script //= btc_tapscript()->new
$script
btc_tapscript()->new
Truth table33%1/3
A //= B
A= $scriptB= btc_tapscript()->new
| |||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 30 | return $script | |||||||||||||||||||
| 53 | ->push($pubkey) | ||||||||||||||||||||
| 54 | ->add('OP_CHECKSIG'); | ||||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | sub new | ||||||||||||||||||||
| 58 | 100 | ▶ | { | ||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 59 | 100 | my ($class, $type, $data) = @_; | |||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 100 | return $class->fill($type, undef, $data); | |||||||||||||||||||
| 62 | } | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | sub fill | ||||||||||||||||||||
| 65 | 146 | ▶ | { | ||||||||||||||||||
|
Subroutine
fill: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||||||||||||
| 66 | 146 | my ($class, $type, $script, $data) = @_; | |||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | 146 | state $methods = { | |||||||||||||||||||
| 69 | PKH => '_make_PKH', | ||||||||||||||||||||
| 70 | SH => '_make_SH', | ||||||||||||||||||||
| 71 | WSH => '_make_WSH', | ||||||||||||||||||||
| 72 | TR => '_make_TR', | ||||||||||||||||||||
| 73 | }; | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | 146 | ▶ | my $method = $methods->{$type} // Bitcoin::Crypto::Exception::ScriptType->raise( | ||||||||||||||||||
|
Condition33%1/3
$methods->{$type} // "Bitcoin::Crypto::Exception::ScriptType"->raise("cannot create common script of type $type")
MC/DC0%0/2
$methods->{$type} // "Bitcoin::Crypto::Exception::ScriptType"->raise("cannot create common script of type $type")
$methods->{$type}
"Bitcoin::Crypto::Exception::ScriptType"->raise("cannot create common script of type $type")
Truth table33%1/3
A // B
A= $methods->{$type}B= "Bitcoin::Crypto::Exception::ScriptType"->raise("cannot create common script of type $type")
| |||||||||||||||||||||
| 76 | "cannot create common script of type $type" | ||||||||||||||||||||
| 77 | ); | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 146 | return $class->$method($script, $data); | |||||||||||||||||||
| 80 | } | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | 64 | 1; | |||||||||||||||||||
| 83 | |||||||||||||||||||||