Bitcoin-Crypto

 view release on metacpan or  search on metacpan

lib/Bitcoin/Crypto/Script/Common.pm  view on Meta::CPAN

package Bitcoin::Crypto::Script::Common;
$Bitcoin::Crypto::Script::Common::VERSION = '4.005';
use v5.14;
use warnings;

use namespace::autoclean;

use Bitcoin::Crypto qw(btc_script btc_tapscript);
use Bitcoin::Crypto::Types -types;
use Bitcoin::Crypto::Exception;

sub _make_PKH
{
	my ($class, $script, $hash) = @_;
	$script //= btc_script->new;

	return $script
		->add('OP_DUP')
		->add('OP_HASH160')
		->push($hash)
		->add('OP_EQUALVERIFY')
		->add('OP_CHECKSIG');
}

sub _make_SH
{
	my ($class, $script, $hash) = @_;
	$script //= btc_script->new;

	return $script
		->add('OP_HASH160')
		->push($hash)
		->add('OP_EQUAL');
}

sub _make_WSH
{
	my ($class, $script, $hash) = @_;
	$script //= btc_script->new;

	return $script
		->add('OP_SHA256')
		->push($hash)
		->add('OP_EQUAL');
}

sub _make_TR
{
	my ($class, $script, $pubkey) = @_;
	$script //= btc_tapscript->new;

	return $script
		->push($pubkey)
		->add('OP_CHECKSIG');
}

sub new
{
	my ($class, $type, $data) = @_;

	return $class->fill($type, undef, $data);
}

sub fill
{
	my ($class, $type, $script, $data) = @_;



( run in 0.546 second using v1.01-cache-2.11-cpan-39bf76dae61 )