| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Bitcoin::Crypto::Script::Common; |
|
2
|
|
|
|
|
|
|
$Bitcoin::Crypto::Script::Common::VERSION = '2.000_01'; # TRIAL |
|
3
|
|
|
|
|
|
|
$Bitcoin::Crypto::Script::Common::VERSION = '2.00001'; |
|
4
|
29
|
|
|
29
|
|
379
|
use v5.10; |
|
|
29
|
|
|
|
|
114
|
|
|
5
|
29
|
|
|
29
|
|
392
|
use strict; |
|
|
29
|
|
|
|
|
157
|
|
|
|
29
|
|
|
|
|
623
|
|
|
6
|
29
|
|
|
29
|
|
146
|
use warnings; |
|
|
29
|
|
|
|
|
83
|
|
|
|
29
|
|
|
|
|
949
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
29
|
|
|
29
|
|
163
|
use Type::Params -sigs; |
|
|
29
|
|
|
|
|
82
|
|
|
|
29
|
|
|
|
|
212
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
29
|
|
|
29
|
|
12959
|
use Bitcoin::Crypto qw(btc_script); |
|
|
29
|
|
|
|
|
105
|
|
|
|
29
|
|
|
|
|
1340
|
|
|
11
|
29
|
|
|
29
|
|
208
|
use Bitcoin::Crypto::Types qw(Str ByteStr InstanceOf); |
|
|
29
|
|
|
|
|
69
|
|
|
|
29
|
|
|
|
|
191
|
|
|
12
|
29
|
|
|
29
|
|
100810
|
use Bitcoin::Crypto::Exception; |
|
|
29
|
|
|
|
|
67
|
|
|
|
29
|
|
|
|
|
9621
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub _make_PKH |
|
15
|
|
|
|
|
|
|
{ |
|
16
|
41
|
|
|
41
|
|
118
|
my ($class, $script, $hash) = @_; |
|
17
|
|
|
|
|
|
|
|
|
18
|
41
|
|
|
|
|
166
|
return $script |
|
19
|
|
|
|
|
|
|
->add('OP_DUP') |
|
20
|
|
|
|
|
|
|
->add('OP_HASH160') |
|
21
|
|
|
|
|
|
|
->push($hash) |
|
22
|
|
|
|
|
|
|
->add('OP_EQUALVERIFY') |
|
23
|
|
|
|
|
|
|
->add('OP_CHECKSIG'); |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _make_SH |
|
27
|
|
|
|
|
|
|
{ |
|
28
|
14
|
|
|
14
|
|
61
|
my ($class, $script, $hash) = @_; |
|
29
|
|
|
|
|
|
|
|
|
30
|
14
|
|
|
|
|
61
|
return $script |
|
31
|
|
|
|
|
|
|
->add('OP_HASH160') |
|
32
|
|
|
|
|
|
|
->push($hash) |
|
33
|
|
|
|
|
|
|
->add('OP_EQUAL'); |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _make_WSH |
|
37
|
|
|
|
|
|
|
{ |
|
38
|
9
|
|
|
9
|
|
40
|
my ($class, $script, $hash) = @_; |
|
39
|
|
|
|
|
|
|
|
|
40
|
9
|
|
|
|
|
37
|
return $script |
|
41
|
|
|
|
|
|
|
->add('OP_SHA256') |
|
42
|
|
|
|
|
|
|
->push($hash) |
|
43
|
|
|
|
|
|
|
->add('OP_EQUAL'); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _get_method |
|
47
|
|
|
|
|
|
|
{ |
|
48
|
64
|
|
|
64
|
|
184
|
my ($class, $type) = @_; |
|
49
|
|
|
|
|
|
|
|
|
50
|
64
|
|
|
|
|
171
|
my $method = '_make_' . $type; |
|
51
|
64
|
50
|
|
|
|
493
|
Bitcoin::Crypto::Exception::ScriptType->raise( |
|
52
|
|
|
|
|
|
|
"cannot create common script of type $type" |
|
53
|
|
|
|
|
|
|
) unless $class->can($method); |
|
54
|
|
|
|
|
|
|
|
|
55
|
64
|
|
|
|
|
170
|
return $method; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
signature_for new => ( |
|
59
|
|
|
|
|
|
|
method => Str, |
|
60
|
|
|
|
|
|
|
positional => [Str, ByteStr], |
|
61
|
|
|
|
|
|
|
); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub new |
|
64
|
|
|
|
|
|
|
{ |
|
65
|
|
|
|
|
|
|
my ($class, $type, $data) = @_; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
return $class->fill($type, btc_script->new, $data); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
signature_for fill => ( |
|
71
|
|
|
|
|
|
|
method => Str, |
|
72
|
|
|
|
|
|
|
positional => [Str, InstanceOf ['Bitcoin::Crypto::Script'], ByteStr], |
|
73
|
|
|
|
|
|
|
); |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub fill |
|
76
|
|
|
|
|
|
|
{ |
|
77
|
|
|
|
|
|
|
my ($class, $type, $script, $data) = @_; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
my $method = $class->_get_method($type); |
|
80
|
|
|
|
|
|
|
return $class->$method($script, $data); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
|
84
|
|
|
|
|
|
|
|