Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
php-version:
- 8.0
- 8.1
- 8.2
- 8.4

steps:
- name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}
},
"require": {
"php-64bit": ">=7.0",
"php-64bit": ">=7.1",
"pleonasm/merkle-tree": "~1.0.0",
"composer/semver": "^1.4.0|^3.2.0",
"lastguest/murmurhash": "^v2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Address/AddressCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function fromOutputScript(ScriptInterface $outputScript): Address
* @return Address
* @throws UnrecognizedAddressException
*/
public function fromString(string $strAddress, NetworkInterface $network = null): Address
public function fromString(string $strAddress, ?NetworkInterface $network = null): Address
{
$network = $network ?: Bitcoin::getNetwork();

Expand Down
2 changes: 1 addition & 1 deletion src/Address/AddressInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface AddressInterface
* @param NetworkInterface $network
* @return string
*/
public function getAddress(NetworkInterface $network = null): string;
public function getAddress(?NetworkInterface $network = null): string;

/**
* @return BufferInterface
Expand Down
2 changes: 1 addition & 1 deletion src/Address/Base58Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ abstract class Base58Address extends Address implements Base58AddressInterface
* @param NetworkInterface|null $network
* @return string
*/
public function getAddress(NetworkInterface $network = null): string
public function getAddress(?NetworkInterface $network = null): string
{
$network = $network ?: Bitcoin::getNetwork();
$payload = new Buffer($this->getPrefixByte($network) . $this->getHash()->getBinary());
Expand Down
2 changes: 1 addition & 1 deletion src/Address/Base58AddressInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ interface Base58AddressInterface extends AddressInterface
* @param NetworkInterface $network
* @return string
*/
public function getPrefixByte(NetworkInterface $network = null): string;
public function getPrefixByte(?NetworkInterface $network = null): string;
}
2 changes: 1 addition & 1 deletion src/Address/BaseAddressCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ abstract class BaseAddressCreator
* @param NetworkInterface|null $network
* @return Address
*/
abstract public function fromString(string $strAddress, NetworkInterface $network = null): Address;
abstract public function fromString(string $strAddress, ?NetworkInterface $network = null): Address;

/**
* @param ScriptInterface $script
Expand Down
2 changes: 1 addition & 1 deletion src/Address/Bech32AddressInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ interface Bech32AddressInterface extends AddressInterface
* @param NetworkInterface $network
* @return string
*/
public function getHRP(NetworkInterface $network = null): string;
public function getHRP(?NetworkInterface $network = null): string;
}
2 changes: 1 addition & 1 deletion src/Address/PayToPubKeyHashAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(BufferInterface $data)
* @param NetworkInterface $network
* @return string
*/
public function getPrefixByte(NetworkInterface $network = null): string
public function getPrefixByte(?NetworkInterface $network = null): string
{
$network = $network ?: Bitcoin::getNetwork();
return pack("H*", $network->getAddressByte());
Expand Down
2 changes: 1 addition & 1 deletion src/Address/ScriptHashAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(BufferInterface $data)
* @param NetworkInterface $network
* @return string
*/
public function getPrefixByte(NetworkInterface $network = null): string
public function getPrefixByte(?NetworkInterface $network = null): string
{
$network = $network ?: Bitcoin::getNetwork();
return pack("H*", $network->getP2shByte());
Expand Down
4 changes: 2 additions & 2 deletions src/Address/SegwitAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(WitnessProgram $witnessProgram)
* @param NetworkInterface|null $network
* @return string
*/
public function getHRP(NetworkInterface $network = null): string
public function getHRP(?NetworkInterface $network = null): string
{
$network = $network ?: Bitcoin::getNetwork();
return $network->getSegwitBech32Prefix();
Expand All @@ -57,7 +57,7 @@ public function getScriptPubKey(): ScriptInterface
* @param NetworkInterface|null $network
* @return string
*/
public function getAddress(NetworkInterface $network = null): string
public function getAddress(?NetworkInterface $network = null): string
{
$network = $network ?: Bitcoin::getNetwork();

Expand Down
4 changes: 2 additions & 2 deletions src/Bitcoin.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static function getGenerator()
* @param GeneratorPoint $generator
* @return EcAdapterInterface
*/
public static function getEcAdapter(Math $math = null, GeneratorPoint $generator = null)
public static function getEcAdapter(?Math $math = null, ?GeneratorPoint $generator = null)
{
if (null === self::$adapter) {
self::$adapter = EcAdapterFactory::getAdapter(
Expand Down Expand Up @@ -86,7 +86,7 @@ public static function getParams()
* @param Math|null $math
* @return ParamsInterface
*/
public static function getDefaultParams(Math $math = null)
public static function getDefaultParams(?Math $math = null)
{
return new Params($math ?: self::getMath());
}
Expand Down
4 changes: 2 additions & 2 deletions src/Block/BlockFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class BlockFactory
* @throws \BitWasp\Buffertools\Exceptions\ParserOutOfRange
* @throws \Exception
*/
public static function fromHex(string $string, Math $math = null): BlockInterface
public static function fromHex(string $string, ?Math $math = null): BlockInterface
{
return self::fromBuffer(Buffer::hex($string), $math);
}
Expand All @@ -37,7 +37,7 @@ public static function fromHex(string $string, Math $math = null): BlockInterfac
* @return BlockInterface
* @throws \BitWasp\Buffertools\Exceptions\ParserOutOfRange
*/
public static function fromBuffer(BufferInterface $buffer, Math $math = null): BlockInterface
public static function fromBuffer(BufferInterface $buffer, ?Math $math = null): BlockInterface
{
$opcodes = new Opcodes();
$serializer = new BlockSerializer(
Expand Down
2 changes: 1 addition & 1 deletion src/Block/MerkleRoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(Math $math, array $txCollection)
* @return BufferInterface
* @throws MerkleTreeEmpty
*/
public function calculateHash(callable $hashFunction = null): BufferInterface
public function calculateHash(?callable $hashFunction = null): BufferInterface
{
if ($this->lastHash instanceof BufferInterface) {
return $this->lastHash;
Expand Down
2 changes: 1 addition & 1 deletion src/Crypto/EcAdapter/EcAdapterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class EcAdapterFactory
* @param int|null $flags
* @return resource
*/
public static function getSecp256k1Context(int $flags = null)
public static function getSecp256k1Context(?int $flags = null)
{
if (!extension_loaded('secp256k1')) {
throw new \RuntimeException('Secp256k1 not installed');
Expand Down
2 changes: 1 addition & 1 deletion src/Crypto/EcAdapter/EcSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static function getAdapterImplPath(EcAdapterInterface $adapter): string
* @param EcAdapterInterface $adapter
* @return mixed
*/
public static function getSerializer(string $interface, $useCache = true, EcAdapterInterface $adapter = null)
public static function getSerializer(string $interface, $useCache = true, ?EcAdapterInterface $adapter = null)
{
if (null === $adapter) {
$adapter = Bitcoin::getEcAdapter();
Expand Down
6 changes: 3 additions & 3 deletions src/Crypto/EcAdapter/Impl/PhpEcc/Key/PrivateKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function getSecret(): \GMP
* @param RbgInterface|null $rbg
* @return Signature
*/
public function sign(BufferInterface $msg32, RbgInterface $rbg = null): SignatureInterface
public function sign(BufferInterface $msg32, ?RbgInterface $rbg = null): SignatureInterface
{
$rbg = $rbg ?: new Rfc6979($this->ecAdapter, $this, $msg32);
$randomK = gmp_init($rbg->bytes(32)->getHex(), 16);
Expand All @@ -101,7 +101,7 @@ public function sign(BufferInterface $msg32, RbgInterface $rbg = null): Signatur
* @return CompactSignatureInterface
* @throws \Exception
*/
public function signCompact(BufferInterface $msg32, RbgInterface $rbg = null): CompactSignatureInterface
public function signCompact(BufferInterface $msg32, ?RbgInterface $rbg = null): CompactSignatureInterface
{
$sign = $this->sign($msg32, $rbg);

Expand Down Expand Up @@ -165,7 +165,7 @@ public function getPublicKey(): PublicKeyInterface
* @param NetworkInterface $network
* @return string
*/
public function toWif(NetworkInterface $network = null): string
public function toWif(?NetworkInterface $network = null): string
{
$network = $network ?: Bitcoin::getNetwork();
$serializer = new WifPrivateKeySerializer(
Expand Down
2 changes: 1 addition & 1 deletion src/Crypto/EcAdapter/Impl/PhpEcc/Key/PublicKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct(
EcAdapter $ecAdapter,
PointInterface $point,
bool $compressed = false,
string $prefix = null
?string $prefix = null
) {
$this->ecAdapter = $ecAdapter;
$this->point = $point;
Expand Down
6 changes: 3 additions & 3 deletions src/Crypto/EcAdapter/Impl/Secp256k1/Key/PrivateKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function __construct(EcAdapter $adapter, \GMP $secret, bool $compressed =
* @param RbgInterface|null $rbgInterface
* @return Signature
*/
public function sign(BufferInterface $msg32, RbgInterface $rbgInterface = null): Signature
public function sign(BufferInterface $msg32, ?RbgInterface $rbgInterface = null): Signature
{
$context = $this->ecAdapter->getContext();

Expand All @@ -101,7 +101,7 @@ public function sign(BufferInterface $msg32, RbgInterface $rbgInterface = null):
* @param RbgInterface|null $rbfInterface
* @return CompactSignature
*/
public function signCompact(BufferInterface $msg32, RbgInterface $rbfInterface = null): CompactSignatureInterface
public function signCompact(BufferInterface $msg32, ?RbgInterface $rbfInterface = null): CompactSignatureInterface
{
$context = $this->ecAdapter->getContext();

Expand Down Expand Up @@ -224,7 +224,7 @@ public function tweakMul(\GMP $tweak): KeyInterface
* @param NetworkInterface $network
* @return string
*/
public function toWif(NetworkInterface $network = null): string
public function toWif(?NetworkInterface $network = null): string
{
$network = $network ?: Bitcoin::getNetwork();
$wifSerializer = new WifPrivateKeySerializer(new PrivateKeySerializer($this->ecAdapter));
Expand Down
2 changes: 1 addition & 1 deletion src/Crypto/EcAdapter/Key/Key.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function isPrivate(): bool
* @param PublicKeySerializerInterface|null $serializer
* @return \BitWasp\Buffertools\BufferInterface
*/
public function getPubKeyHash(PublicKeySerializerInterface $serializer = null): BufferInterface
public function getPubKeyHash(?PublicKeySerializerInterface $serializer = null): BufferInterface
{
if ($this instanceof PrivateKeyInterface) {
$publicKey = $this->getPublicKey();
Expand Down
2 changes: 1 addition & 1 deletion src/Crypto/EcAdapter/Key/KeyInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function isPrivate(): bool;
* @param PublicKeySerializerInterface|null $serializer
* @return BufferInterface
*/
public function getPubKeyHash(PublicKeySerializerInterface $serializer = null): BufferInterface;
public function getPubKeyHash(?PublicKeySerializerInterface $serializer = null): BufferInterface;

/**
* @param \GMP $offset
Expand Down
6 changes: 3 additions & 3 deletions src/Crypto/EcAdapter/Key/PrivateKeyInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ public function getSecret();
* @param RbgInterface $rbg
* @return SignatureInterface
*/
public function sign(BufferInterface $msg32, RbgInterface $rbg = null);
public function sign(BufferInterface $msg32, ?RbgInterface $rbg = null);

/**
* @param BufferInterface $msg32
* @param RbgInterface|null $rbgInterface
* @return CompactSignature
*/
public function signCompact(BufferInterface $msg32, RbgInterface $rbgInterface = null);
public function signCompact(BufferInterface $msg32, ?RbgInterface $rbgInterface = null);

/**
* Return the public key.
Expand All @@ -48,5 +48,5 @@ public function getPublicKey();
* @param NetworkInterface $network
* @return string
*/
public function toWif(NetworkInterface $network = null);
public function toWif(?NetworkInterface $network = null);
}
6 changes: 3 additions & 3 deletions src/Key/Deterministic/HierarchicalKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ public function derivePath(string $path): HierarchicalKey
* @param NetworkInterface $network
* @return string
*/
public function toExtendedKey(NetworkInterface $network = null): string
public function toExtendedKey(?NetworkInterface $network = null): string
{
$network = $network ?: Bitcoin::getNetwork();

Expand All @@ -361,7 +361,7 @@ public function toExtendedKey(NetworkInterface $network = null): string
* @param NetworkInterface $network
* @return string
*/
public function toExtendedPrivateKey(NetworkInterface $network = null): string
public function toExtendedPrivateKey(?NetworkInterface $network = null): string
{
if (!$this->isPrivate()) {
throw new \LogicException('Cannot create extended private key from public');
Expand All @@ -376,7 +376,7 @@ public function toExtendedPrivateKey(NetworkInterface $network = null): string
* @param NetworkInterface $network
* @return string
*/
public function toExtendedPublicKey(NetworkInterface $network = null): string
public function toExtendedPublicKey(?NetworkInterface $network = null): string
{
return $this->withoutPrivateKey()->toExtendedKey($network);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Key/Deterministic/Slip132/Slip132.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Slip132
*/
private $helper;

public function __construct(KeyToScriptHelper $helper = null)
public function __construct(?KeyToScriptHelper $helper = null)
{
$this->helper = $helper ?: new KeyToScriptHelper(Bitcoin::getEcAdapter());
}
Expand Down
4 changes: 2 additions & 2 deletions src/Key/Factory/ElectrumKeyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ElectrumKeyFactory
* ElectrumKeyFactory constructor.
* @param EcAdapterInterface|null $ecAdapter
*/
public function __construct(EcAdapterInterface $ecAdapter = null)
public function __construct(?EcAdapterInterface $ecAdapter = null)
{
$this->adapter = $ecAdapter ?: Bitcoin::getEcAdapter();
$this->privateFactory = new PrivateKeyFactory($ecAdapter);
Expand All @@ -41,7 +41,7 @@ public function __construct(EcAdapterInterface $ecAdapter = null)
* @return ElectrumKey
* @throws \Exception
*/
public function fromMnemonic(string $mnemonic, ElectrumWordListInterface $wordList = null): ElectrumKey
public function fromMnemonic(string $mnemonic, ?ElectrumWordListInterface $wordList = null): ElectrumKey
{
$mnemonicConverter = MnemonicFactory::electrum($wordList, $this->adapter);
$entropy = $mnemonicConverter->mnemonicToEntropy($mnemonic);
Expand Down
8 changes: 4 additions & 4 deletions src/Key/Factory/HierarchicalKeyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class HierarchicalKeyFactory
* @param Base58ExtendedKeySerializer|null $serializer
* @throws \Exception
*/
public function __construct(EcAdapterInterface $ecAdapter = null, Base58ExtendedKeySerializer $serializer = null)
public function __construct(?EcAdapterInterface $ecAdapter = null, ?Base58ExtendedKeySerializer $serializer = null)
{
$this->adapter = $ecAdapter ?: Bitcoin::getEcAdapter();
$this->privFactory = new PrivateKeyFactory($this->adapter);
Expand All @@ -59,7 +59,7 @@ public function __construct(EcAdapterInterface $ecAdapter = null, Base58Extended
* @throws \BitWasp\Bitcoin\Exceptions\RandomBytesFailure
* @throws \Exception
*/
public function generateMasterKey(Random $random, ScriptDataFactory $scriptDataFactory = null): HierarchicalKey
public function generateMasterKey(Random $random, ?ScriptDataFactory $scriptDataFactory = null): HierarchicalKey
{
return $this->fromEntropy(
$random->bytes(64),
Expand All @@ -73,7 +73,7 @@ public function generateMasterKey(Random $random, ScriptDataFactory $scriptDataF
* @return HierarchicalKey
* @throws \Exception
*/
public function fromEntropy(BufferInterface $entropy, ScriptDataFactory $scriptFactory = null): HierarchicalKey
public function fromEntropy(BufferInterface $entropy, ?ScriptDataFactory $scriptFactory = null): HierarchicalKey
{
$seed = Hash::hmac('sha512', $entropy, new Buffer('Bitcoin seed'));
$privSecret = $seed->slice(0, 32);
Expand All @@ -89,7 +89,7 @@ public function fromEntropy(BufferInterface $entropy, ScriptDataFactory $scriptF
* @throws \BitWasp\Bitcoin\Exceptions\Base58ChecksumFailure
* @throws \BitWasp\Buffertools\Exceptions\ParserOutOfRange
*/
public function fromExtended(string $extendedKey, NetworkInterface $network = null): HierarchicalKey
public function fromExtended(string $extendedKey, ?NetworkInterface $network = null): HierarchicalKey
{
return $this->serializer->parse($network ?: Bitcoin::getNetwork(), $extendedKey);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Key/Factory/PrivateKeyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class PrivateKeyFactory
* PrivateKeyFactory constructor.
* @param EcAdapterInterface $ecAdapter
*/
public function __construct(EcAdapterInterface $ecAdapter = null)
public function __construct(?EcAdapterInterface $ecAdapter = null)
{
$ecAdapter = $ecAdapter ?: Bitcoin::getEcAdapter();
$this->privSerializer = EcSerializer::getSerializer(PrivateKeySerializerInterface::class, true, $ecAdapter);
Expand Down Expand Up @@ -106,7 +106,7 @@ public function fromHexUncompressed(string $hex): PrivateKeyInterface
* @throws \BitWasp\Bitcoin\Exceptions\InvalidPrivateKey
* @throws \Exception
*/
public function fromWif(string $wif, NetworkInterface $network = null): PrivateKeyInterface
public function fromWif(string $wif, ?NetworkInterface $network = null): PrivateKeyInterface
{
return $this->wifSerializer->parse($wif, $network);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Key/Factory/PublicKeyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PublicKeyFactory
* PublicKeyFactory constructor.
* @param EcAdapterInterface $ecAdapter
*/
public function __construct(EcAdapterInterface $ecAdapter = null)
public function __construct(?EcAdapterInterface $ecAdapter = null)
{
$ecAdapter = $ecAdapter ?: Bitcoin::getEcAdapter();
$this->serializer = EcSerializer::getSerializer(PublicKeySerializerInterface::class, true, $ecAdapter);
Expand Down
2 changes: 1 addition & 1 deletion src/Key/KeyToScript/Factory/KeyToScriptDataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ abstract class KeyToScriptDataFactory extends ScriptDataFactory
* KeyToP2PKScriptFactory constructor.
* @param PublicKeySerializerInterface|null $pubKeySerializer
*/
public function __construct(PublicKeySerializerInterface $pubKeySerializer = null)
public function __construct(?PublicKeySerializerInterface $pubKeySerializer = null)
{
if (null === $pubKeySerializer) {
$pubKeySerializer = EcSerializer::getSerializer(PublicKeySerializerInterface::class, true);
Expand Down
Loading