Crypto/Role/PSBT/Signer.pm

filter: Statementstmt 98.9% 179 / 181 Branchbran 70.6% 65 / 92 Conditioncond 73.3% 11 / 15 MC/DCmcdc 30.0% 3 / 10 Subroutinesub 100% 28 / 28 Podpod n/a totaltotal 87.7% 286 / 326 CC 54 SCAR 17.6
CC
54
Cov
89%
_do_sign_P2SH
10.7
_do_sign_P2WSH
9.8
_do_sign_P2TR_scriptpath
8.1
CRAP 5.8
« Crypto/Tapscript/Opcode.pm ↑ Summary Crypto/Transaction/AutoSigner.pm »
1 package Bitcoin::Crypto::Role::PSBT::Signer;
2 11 $Bitcoin::Crypto::Role::PSBT::Signer::VERSION = '4.006';
3 12 ▶use v5.14;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 12 ▶use Mooish::Base -standard, -role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 12 ▶use Types::Common -sigs;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 12 ▶use List::Util qw(any first);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 12 ▶use Bitcoin::Crypto qw(btc_script_tree);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 12 ▶use Bitcoin::Crypto::Constants qw(:sighash :script);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 12 ▶use Bitcoin::Crypto::Transaction::Flags;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 sub _input_has_witness_utxo
15 3 ▶{
Subroutine _input_has_witness_utxo: called CC=1 SCAR=0.0
16 3 my ($self, $input_index) = @_;
17  
18 3 my $witness_utxo = $self->get_all_fields('PSBT_IN_WITNESS_UTXO', $input_index);
19 3 return !!$witness_utxo;
20 }
21  
22 sub _update_modifiable_flags
23 18 ▶{
Subroutine _update_modifiable_flags: called CC=7 SCAR=19.5
24 18 my ($self, $sighash) = @_;
25  
26 18 ▶ return unless $self->version == 2;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->version == 2 0 18 18
27  
28 # NOTE: SIGHASH_DEFAULT may not be correct for pre-taproot, but it's only
29 # used to set modifiable flags, which will be the same for SIGHASH_ALL
30 18 ▶ $sighash = $sighash ? $sighash->value : SIGHASH_ALL;
Branch: 1 branch
BranchTrueFalseTotal
$sighash ? : 6 12 18
31  
32 18 my $modifiable = $self->get_all_fields('PSBT_GLOBAL_TX_MODIFIABLE');
33 18 ▶ $modifiable //= $self
Condition66%2/3
$modifiable //=
l!l&&r!l&&!r
5130
MC/DC0%0/2
$modifiable //=
$modifiable
Truth table66%2/3
A //= B
A= $modifiableB=
ABresult
1X1
011
000
34 ->add_field(
35 type => 'PSBT_GLOBAL_TX_MODIFIABLE',
36 value => {
37 inputs_modifiable => !!1,
38 outputs_modifiable => !!1,
39 },
40 )
41 ->get_field('PSBT_GLOBAL_TX_MODIFIABLE');
42  
43 18 my $value = $modifiable->value;
44  
45 18 ▶ if (!($sighash & SIGHASH_ANYONECANPAY)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($sighash & 128) 16 2 18
46 16 $value->{inputs_modifiable} = !!0;
47 }
48  
49 18 my $sighash_type = $sighash & 31;
50  
51 18 ▶ if ($sighash_type != SIGHASH_NONE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sighash_type != 2) 15 3 18
52 15 $value->{outputs_modifiable} = !!0;
53 }
54  
55 18 ▶ if ($sighash_type == SIGHASH_SINGLE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sighash_type == 3) 2 16 18
56 2 $value->{has_sighash_single} = !!1;
57 }
58  
59 # update the value back in the PSBT
60 18 $modifiable->set_value($value);
61 }
62  
63 sub _add_partial_signature_legacy
64 12 ▶{
Subroutine _add_partial_signature_legacy: called CC=1 SCAR=0.0
65 12 my ($self, $input_index, $key, $signature, $sighash) = @_;
66  
67 12 $self->add_field(
68 type => 'PSBT_IN_PARTIAL_SIG',
69 index => $input_index,
70 key => $key->get_public_key,
71 value => $signature,
72 );
73  
74 12 $self->_update_modifiable_flags($sighash);
75 }
76  
77 sub _has_partial_signature_legacy
78 16 ▶{
Subroutine _has_partial_signature_legacy: called CC=1 SCAR=0.0
79 16 my ($self, $input_index, $key) = @_;
80  
81 16 my $public_hash = $key->get_public_key->get_hash;
82 16 my @sigs = $self->get_all_fields('PSBT_IN_PARTIAL_SIG', $input_index);
83  
84 16 ▶ return any { $_->key->get_hash eq $public_hash } @sigs;
Subroutine __ANON__: called CC=1 SCAR=0.0
85 }
86  
87 sub _add_partial_signature_taproot
88 6 ▶{
Subroutine _add_partial_signature_taproot: called CC=2 SCAR=6.9
89 6 my ($self, $input_index, $key, $signature, $sighash, $leaf_hash) = @_;
90  
91 6 ▶ if (defined $leaf_hash) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $leaf_hash) { } 3 3 6
92 3 $self->add_field(
93 type => 'PSBT_IN_TAP_SCRIPT_SIG',
94 index => $input_index,
95 key => [$key->get_public_key, $leaf_hash],
96 value => $signature,
97 );
98 }
99 else {
100 3 $self->add_field(
101 type => 'PSBT_IN_TAP_KEY_SIG',
102 index => $input_index,
103 value => $signature,
104 );
105 }
106  
107 6 $self->_update_modifiable_flags($sighash);
108 }
109  
110 sub _has_partial_signature_taproot
111 8 ▶{
Subroutine _has_partial_signature_taproot: called CC=2 SCAR=6.9
112 8 my ($self, $input_index, $key) = @_;
113  
114 8 my $key_sig = $self->get_all_fields('PSBT_IN_TAP_KEY_SIG', $input_index);
115 8 ▶ return !!1 if $key_sig;
Branch: 1 branch
BranchTrueFalseTotal
if $key_sig 1 7 8
116  
117 7 my $public = $key->get_taproot_output_key->get_public_key->get_xonly_key;
118 7 my @sigs = $self->get_all_fields('PSBT_IN_TAP_SCRIPT_SIG', $input_index);
119  
120 7 ▶ return any { $_->key->[0]->get_xonly_key eq $public } @sigs;
Subroutine __ANON__: called CC=1 SCAR=0.0
121 }
122  
123 sub _do_sign_P2PKH
124 1 ▶{
Subroutine _do_sign_P2PKH: called CC=5 SCAR=16.7
125 1 my ($self, $key, $tx, $input, $input_index) = @_;
126  
127 1 ▶ return 0 if $self->_has_partial_signature_legacy($input_index, $key);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_has_partial_signature_legacy($input_index, $key) 0 1 1
128 1 ▶ return 0 if $self->_input_has_witness_utxo($input_index);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_input_has_witness_utxo($input_index) 0 1 1
129  
130 1 ▶ return 0 unless $key->get_public_key->get_hash eq $input->utxo->output->locking_script->get_raw_address;
Branch: 1 branch
BranchTrueFalseTotal
unless $key->get_public_key->get_hash eq $input->utxo->output->locking_script->get_raw_address 0 1 1
131 1 my $signer = $tx->sign(signing_index => $input_index, flags => Bitcoin::Crypto::Transaction::Flags->new_full);
132 1 my $sighash = $self->get_all_fields('PSBT_IN_SIGHASH_TYPE', $input_index);
133  
134 # use transaction signer's ability to give us the signature
135 1 ▶ my $signature = $signer->add_signature($key, sighash => $sighash ? $sighash->value : undef)
Branch: 1 branch
BranchTrueFalseTotal
$sighash ? : 0 1 1
136 ->signature->[-1];
137  
138 1 $self->_add_partial_signature_legacy($input_index, $key, $signature, $sighash);
139 1 return 1;
140 }
141  
142 sub _do_sign_P2SH
143 5 ▶{
Subroutine _do_sign_P2SH: called CC=10 SCAR=23.7
144 5 my ($self, $key, $tx, $input, $input_index) = @_;
145  
146 5 ▶ return 0 if $self->_has_partial_signature_legacy($input_index, $key);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_has_partial_signature_legacy($input_index, $key) 0 5 5
147  
148 # is there a matching redeem script?
149 5 my $redeem = $self->get_all_fields('PSBT_IN_REDEEM_SCRIPT', $input_index);
150 5 ▶ return 0 unless $redeem;
Branch: 1 branch
BranchTrueFalseTotal
unless $redeem 0 5 5
151  
152 5 my $script = $redeem->value;
153 5 ▶ return 0 unless $script->get_hash eq $input->utxo->output->locking_script->get_raw_address;
Branch: 1 branch
BranchTrueFalseTotal
unless $script->get_hash eq $input->utxo->output->locking_script->get_raw_address 0 5 5
154  
155 5 my $type = $script->type;
156 5 ▶ if ($type eq 'P2WPKH' || $type eq 'P2WSH') {
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'P2WPKH' or $type eq 'P2WSH') { } 3 2 5
elsif ($type eq 'P2MS') { } 2 0 2
Condition100%3/3
$type eq "P2WPKH" or $type eq "P2WSH"
l!l&&r!l&&!r
122
MC/DC100%2/2
$type eq "P2WPKH" or $type eq "P2WSH"
$type eq "P2WPKH" $type eq "P2WSH"
Truth table100%3/3
A or B
A= $type eq "P2WPKH"B= $type eq "P2WSH"
ABresult
1X1
011
000
157 3 my $method = "_do_sign_$type";
158 3 return $self->$method($key, $tx, $input, $input_index, $script);
159 }
160 elsif ($type eq 'P2MS') {
161 2 ▶ return 0 if $self->_input_has_witness_utxo($input_index);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_input_has_witness_utxo($input_index) 0 2 2
162  
163 2 my $pubkeys = $script->get_raw_address;
164 2 my $this_pubkey = $key->get_public_key->to_serialized;
165  
166 2 ▶ my $index = first { $_ eq $this_pubkey } @{$pubkeys};
Subroutine __ANON__: called CC=1 SCAR=0.0
167 2 ▶ return 0 unless defined $index;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $index 0 2 2
168  
169 2 my $signer = $tx->sign(
170 signing_index => $input_index,
171 script => $script,
172 flags => Bitcoin::Crypto::Transaction::Flags->new_full,
173 );
174 2 my $sighash = $self->get_all_fields('PSBT_IN_SIGHASH_TYPE', $input_index);
175  
176 # use transaction signer's ability to give us the signature
177 2 ▶ my $signature = $signer->add_signature($key, sighash => $sighash ? $sighash->value : undef)
Branch: 1 branch
BranchTrueFalseTotal
$sighash ? : 0 2 2
178 ->signature->[-1];
179  
180 2 $self->_add_partial_signature_legacy($input_index, $key, $signature, $sighash);
181 2 return 1;
182 }
183  
184 0 return 0;
185 }
186  
187 sub _do_sign_P2WPKH
188 6 ▶{
Subroutine _do_sign_P2WPKH: called CC=6 SCAR=17.9
189 6 my ($self, $key, $tx, $input, $input_index, $compat_script) = @_;
190  
191 6 ▶ return 0 if $self->_has_partial_signature_legacy($input_index, $key);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_has_partial_signature_legacy($input_index, $key) 1 5 6
192  
193 5 ▶ my $to_compare = $compat_script
Branch: 1 branch
BranchTrueFalseTotal
$compat_script ? : 1 4 5
194 ? $compat_script->get_raw_address
195 : $input->utxo->output->locking_script->get_raw_address
196 ;
197  
198 5 ▶ return 0 unless $key->get_public_key->get_hash eq $to_compare;
Branch: 1 branch
BranchTrueFalseTotal
unless $key->get_public_key->get_hash eq $to_compare 0 5 5
199  
200 5 ▶ my $signer = $tx->sign(
Branch: 1 branch
BranchTrueFalseTotal
$compat_script ? : 1 4 5
201 signing_index => $input_index,
202 flags => Bitcoin::Crypto::Transaction::Flags->new_full,
203 ($compat_script ? (compat => !!1) : ()),
204 );
205 5 my $sighash = $self->get_all_fields('PSBT_IN_SIGHASH_TYPE', $input_index);
206  
207 # use transaction signer's ability to give us the signature
208 5 ▶ my $signature = $signer->add_signature($key, sighash => $sighash ? $sighash->value : undef)
Branch: 1 branch
BranchTrueFalseTotal
$sighash ? : 2 3 5
209 ->signature->[-1];
210  
211 5 $self->_add_partial_signature_legacy($input_index, $key, $signature, $sighash);
212 5 return 1;
213 }
214  
215 sub _do_sign_P2WSH
216 4 ▶{
Subroutine _do_sign_P2WSH: called CC=9 SCAR=22.8
217 4 my ($self, $key, $tx, $input, $input_index, $compat_script) = @_;
218  
219 4 ▶ return 0 if $self->_has_partial_signature_legacy($input_index, $key);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_has_partial_signature_legacy($input_index, $key) 0 4 4
220  
221 # is there a matching witness redeem script?
222 4 my $redeem = $self->get_all_fields('PSBT_IN_WITNESS_SCRIPT', $input_index);
223 4 ▶ return 0 unless $redeem;
Branch: 1 branch
BranchTrueFalseTotal
unless $redeem 0 4 4
224  
225 4 my $script = $redeem->value;
226 4 ▶ my $compare_script = $compat_script // $input->utxo->output->locking_script;
Condition66%2/3
$compat_script // $input->utxo->output->locking_script
l!l&&r!l&&!r
220
MC/DC0%0/2
$compat_script // $input->utxo->output->locking_script
$compat_script $input->utxo->output->locking_script
Truth table66%2/3
A // B
A= $compat_scriptB= $input->utxo->output->locking_script
ABresult
1X1
011
000
227 4 ▶ return 0 unless $script->get_witness_hash eq $compare_script->get_raw_address;
Branch: 1 branch
BranchTrueFalseTotal
unless $script->get_witness_hash eq $compare_script->get_raw_address 0 4 4
228  
229 4 my $type = $script->type;
230 4 ▶ if ($type eq 'P2MS') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "P2MS") 4 0 4
231 4 my $pubkeys = $script->get_raw_address;
232 4 my $this_pubkey = $key->get_public_key->to_serialized;
233  
234 4 ▶ my $index = first { $_ eq $this_pubkey } @{$pubkeys};
Subroutine __ANON__: called CC=1 SCAR=0.0
235 4 ▶ return 0 unless defined $index;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $index 0 4 4
236  
237 4 ▶ my $signer = $tx->sign(
Branch: 1 branch
BranchTrueFalseTotal
$compat_script ? : 2 2 4
238 signing_index => $input_index,
239 script => $script,
240 flags => Bitcoin::Crypto::Transaction::Flags->new_full,
241 ($compat_script ? (compat => !!1) : ()),
242 );
243 4 my $sighash = $self->get_all_fields('PSBT_IN_SIGHASH_TYPE', $input_index);
244  
245 # use transaction signer's ability to give us the signature
246 4 ▶ my $signature = $signer->add_signature($key, sighash => $sighash ? $sighash->value : undef)
Branch: 1 branch
BranchTrueFalseTotal
$sighash ? : 4 0 4
247 ->signature->[-1];
248  
249 4 $self->_add_partial_signature_legacy($input_index, $key, $signature, $sighash);
250 4 return 1;
251 }
252  
253 0 return 0;
254 }
255  
256 sub _do_sign_P2TR_keypath
257 3 ▶{
Subroutine _do_sign_P2TR_keypath: called CC=6 SCAR=18.0
258 3 my ($self, $key, $tx, $input, $input_index) = @_;
259  
260 3 my $tree_root = $self->get_all_fields('PSBT_IN_TAP_MERKLE_ROOT', $input_index);
261 3 ▶ my $tree = $tree_root ? btc_script_tree->new(tree => [{hash => $tree_root->value}]) : undef;
Branch: 1 branch
BranchTrueFalseTotal
$tree_root ? : 1 2 3
262  
263 3 ▶ my $output_key = $key->get_public_key->get_taproot_output_key($tree ? $tree->get_merkle_root : ());
Branch: 1 branch
BranchTrueFalseTotal
$tree ? : 1 2 3
264 3 ▶ return 0 unless $output_key->get_xonly_key eq $input->utxo->output->locking_script->get_raw_address;
Branch: 1 branch
BranchTrueFalseTotal
unless $output_key->get_xonly_key eq $input->utxo->output->locking_script->get_raw_address 0 3 3
265  
266 3 ▶ my $signer = $tx->sign(
Branch: 1 branch
BranchTrueFalseTotal
$tree ? : 1 2 3
267 signing_index => $input_index,
268 ($tree ? (script_tree => $tree) : ()),
269 );
270 3 my $sighash = $self->get_all_fields('PSBT_IN_SIGHASH_TYPE', $input_index);
271  
272 # use transaction signer's ability to give us the signature
273 3 ▶ my $signature = $signer->add_signature($key, sighash => $sighash ? $sighash->value : undef)
Branch: 1 branch
BranchTrueFalseTotal
$sighash ? : 0 3 3
274 ->signature->[-1];
275  
276 3 $self->_add_partial_signature_taproot($input_index, $key, $signature, $sighash);
277  
278 3 return 1;
279 }
280  
281 sub _do_sign_P2TR_scriptpath
282 6 ▶{
Subroutine _do_sign_P2TR_scriptpath: called CC=8 SCAR=20.9
283 6 my ($self, $key, $tx, $input, $input_index) = @_;
284 6 my $signer_key = $key->get_taproot_output_key;
285  
286 6 my @leaves = $self->get_all_fields('PSBT_IN_TAP_LEAF_SCRIPT', $input_index);
287 6 ▶ return 0 unless @leaves;
Branch: 1 branch
BranchTrueFalseTotal
unless @leaves 3 3 6
288  
289 3 my $sighash = $self->get_all_fields('PSBT_IN_SIGHASH_TYPE', $input_index);
290 3 my $signed = 0;
291 3 foreach my $leaf (@leaves) {
292 3 my $leaf_obj = $leaf->value;
293 3 my $script = $leaf_obj->script;
294 3 ▶ next if $script->type ne 'TAPSCRIPT_MULTISIG';
Branch: 1 branch
BranchTrueFalseTotal
if $script->type ne "TAPSCRIPT_MULTISIG" 0 3 3
295 3 ▶ next if $leaf_obj->leaf_version != TAPSCRIPT_LEAF_VERSION;
Branch: 1 branch
BranchTrueFalseTotal
if $leaf_obj->leaf_version != 192 0 3 3
296  
297 3 my $pubkeys = $script->get_raw_address;
298 3 my $this_pubkey = $signer_key->get_public_key->get_xonly_key;
299 3 ▶ my $index = first { $pubkeys->[$_] eq $this_pubkey } keys @{$pubkeys};
Subroutine __ANON__: called CC=1 SCAR=0.0
300 3 ▶ next unless defined $index;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $index 0 3 3
301  
302 3 my $control_block = $leaf->key;
303 3 my $tree = btc_script_tree->from_path($leaf_obj, $control_block->script_blocks);
304 3 my $signer = $tx->sign(
305 signing_index => $input_index,
306 script_tree => $tree,
307 leaf_id => $leaf_obj->id,
308 public_key => $control_block->public_key,
309 );
310  
311 3 ▶ while ($index-- > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($index-- > 0) 1 3 4
312 1 $signer->add_signature('');
313 }
314  
315 3 ▶ my $signature = $signer->add_signature($signer_key, sighash => $sighash ? $sighash->value : undef)
Branch: 1 branch
BranchTrueFalseTotal
$sighash ? : 0 3 3
316 ->signature->[-1];
317  
318 3 $self->_add_partial_signature_taproot($input_index, $signer_key, $signature, $sighash, $leaf_obj->hash);
319 3 $signed = 1;
320 }
321  
322 # NOTE: we count inputs signed, so it's either 1 or 0
323 3 return $signed;
324 }
325  
326 sub _do_sign_P2TR
327 8 ▶{
Subroutine _do_sign_P2TR: called CC=3 SCAR=11.0
328 8 my ($self, $key, $tx, $input, $input_index) = @_;
329  
330 8 ▶ return 0 if $self->_has_partial_signature_taproot($input_index, $key);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_has_partial_signature_taproot($input_index, $key) 2 6 8
331  
332 6 ▶ return $self->_do_sign_P2TR_scriptpath($key, $tx, $input, $input_index)
Condition66%2/3
$self->_do_sign_P2TR_scriptpath($key, $tx, $input, $input_index) || $self->_do_sign_P2TR_keypath($key, $tx, $input, $input_index)
l!l&&r!l&&!r
330
MC/DC0%0/2
$self->_do_sign_P2TR_scriptpath($key, $tx, $input, $input_index) || $self->_do_sign_P2TR_keypath($key, $tx, $input, $input_index)
$self->_do_sign_P2TR_scriptpath($key, $tx, $input, $input_index) $self->_do_sign_P2TR_keypath($key, $tx, $input, $input_index)
Truth table66%2/3
A || B
A= $self->_do_sign_P2TR_scriptpath($key, $tx, $input, $input_index)B= $self->_do_sign_P2TR_keypath($key, $tx, $input, $input_index)
ABresult
1X1
011
000
333 || $self->_do_sign_P2TR_keypath($key, $tx, $input, $input_index);
334 }
335  
336 sub _do_sign
337 22 ▶{
Subroutine _do_sign: called CC=5 SCAR=16.3
338 22 my ($self, $key, $tx, $input, $input_index) = @_;
339  
340 # is this input finalized already?
341 22 my $signature_field = $self->get_all_fields('PSBT_IN_FINAL_SCRIPTSIG', $input_index);
342 22 my $witness_field = $self->get_all_fields('PSBT_IN_FINAL_SCRIPTWITNESS', $input_index);
343 22 ▶ return 0 if $signature_field || $witness_field;
Branch: 1 branch
BranchTrueFalseTotal
if $signature_field or $witness_field 1 21 22
Condition66%2/3
$signature_field or $witness_field
l!l&&r!l&&!r
0121
MC/DC50%1/2
$signature_field or $witness_field
$signature_field $witness_field
Truth table66%2/3
A or B
A= $signature_fieldB= $witness_field
ABresult
1X1
011
000
344  
345 # custom script - unsupported
346 21 my $type = $input->utxo->output->locking_script->type;
347 21 ▶ return 0 unless defined $type;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type 0 21 21
348  
349 # some types are defined but unsupported (P2PK, nulldata)
350 21 my $method = $self->can("_do_sign_$type");
351 21 ▶ return 0 unless $method;
Branch: 1 branch
BranchTrueFalseTotal
unless $method 0 21 21
352  
353 21 return $self->$method($key, $tx, $input, $input_index);
354 }
355  
356 11 signature_for sign => (
357 method => !!1,
358 positional => [
359 InstanceOf ['Bitcoin::Crypto::Key::Private']
360 ],
361 );
362  
363 sub sign
364 21 ▶{
Subroutine sign: called CC=2 SCAR=6.9
365 21 my ($self, $key) = @_;
366 21 my $tx = $self->get_transaction;
367 21 my $inputs = $tx->inputs;
368  
369 21 my $signed = 0;
370 21 foreach my $input_index (0 .. $#{$inputs}) {
371 22 $signed += $self->_do_sign($key, $tx, $inputs->[$input_index], $input_index);
372 }
373  
374 21 return $signed;
375 }
376  
377 11 1;
378  
« Crypto/Tapscript/Opcode.pm ↑ Summary Crypto/Transaction/AutoSigner.pm »