for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace BitWasp\Bitcoin\Block;
use BitWasp\Bitcoin\Bitcoin;
use BitWasp\Bitcoin\Math\Math;
use BitWasp\Bitcoin\Serializer\Block\BlockHeaderSerializer;
use BitWasp\Bitcoin\Serializer\Block\BlockSerializer;
use BitWasp\Bitcoin\Serializer\Transaction\TransactionSerializer;
use BitWasp\Buffertools\Buffer;
use BitWasp\Buffertools\BufferInterface;
class BlockFactory
{
/**
* @param string $string
* @param Math|null $math
* @return BlockInterface
* @throws \BitWasp\Buffertools\Exceptions\ParserOutOfRange
* @throws \Exception
*/
public static function fromHex(string $string, Math $math = null): BlockInterface
return self::fromBuffer(Buffer::hex($string), $math);
}
* @param BufferInterface $buffer
public static function fromBuffer(BufferInterface $buffer, Math $math = null): BlockInterface
$serializer = new BlockSerializer(
$math ?: Bitcoin::getMath(),
new BlockHeaderSerializer(),
new TransactionSerializer()
);
return $serializer->parse($buffer);