| 1 | package Bitcoin::Crypto::Transaction::Signer::CompatSegwit; | ||||||||||
| 2 | 3 | $Bitcoin::Crypto::Transaction::Signer::CompatSegwit::VERSION = '4.005'; | |||||||||
| 3 | 3 | ▶ | use v5.14; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 3 | ▶ | use Mooish::Base -standard; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 3 | ▶ | use Bitcoin::Crypto qw(btc_script); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 3 | ▶ | use Bitcoin::Crypto::Exception; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 3 | ▶ | use Bitcoin::Crypto::Constants; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 3 | ▶ | use Bitcoin::Crypto::Types -types; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 3 | extends 'Bitcoin::Crypto::Transaction::Signer::Segwit'; | |||||||||
| 14 | |||||||||||
| 15 | 3 | has field 'witness_program' => ( | |||||||||
| 16 | isa => BitcoinScript, | ||||||||||
| 17 | trigger => 1, | ||||||||||
| 18 | writer => 1, | ||||||||||
| 19 | ); | ||||||||||
| 20 | |||||||||||
| 21 | sub _trigger_witness_program | ||||||||||
| 22 | 6 | ▶ | { | ||||||||
|
Subroutine
_trigger_witness_program: called CC=1 SCAR=0.0
| |||||||||||
| 23 | 6 | my ($self) = @_; | |||||||||
| 24 | |||||||||||
| 25 | 6 | $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 | 6 | ▶ | { | ||||||||
|
Subroutine
_finalize: called CC=2 SCAR=7.0
| |||||||||||
| 32 | 6 | my ($self) = @_; | |||||||||
| 33 | |||||||||||
| 34 | 6 | my $witness_program = $self->witness_program; | |||||||||
| 35 | |||||||||||
| 36 | 6 | ▶ | Bitcoin::Crypto::Exception::Sign->raise( | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | 'signature is missing a witness program' | ||||||||||
| 38 | ) unless $witness_program; | ||||||||||
| 39 | |||||||||||
| 40 | 6 | $self->transaction->inputs->[$self->signing_index]->set_signature_script( | |||||||||
| 41 | btc_script->new->push_bytes($witness_program->to_serialized) | ||||||||||
| 42 | ); | ||||||||||
| 43 | |||||||||||
| 44 | 6 | $self->SUPER::_finalize; | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 3 | 1; | |||||||||
| 48 | |||||||||||