Skip to content

Commit b9cf796

Browse files
committed
full method names are better
1 parent f05b338 commit b9cf796

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/ScriptPubKey.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function isReturn(): bool
2727
/**
2828
* @return bool
2929
*/
30-
public function isP2PK(): bool
30+
public function isPayToPubKey(): bool
3131
{
3232
$operations = $this->parse();
3333

@@ -39,7 +39,7 @@ public function isP2PK(): bool
3939
/**
4040
* @return bool
4141
*/
42-
public function isP2PKH(): bool
42+
public function isPayToPubKeyHash(): bool
4343
{
4444
$operations = $this->parse();
4545

@@ -54,7 +54,7 @@ public function isP2PKH(): bool
5454
/**
5555
* @return bool
5656
*/
57-
public function isP2SH(): bool
57+
public function isPayToScriptHash(): bool
5858
{
5959
$operations = $this->parse();
6060

@@ -80,7 +80,7 @@ public function isMultisig(): bool
8080
/**
8181
* @return bool
8282
*/
83-
public function isP2WPKH(): bool
83+
public function isPayToWitnessPubKeyHash(): bool
8484
{
8585
$operations = $this->parse();
8686

@@ -92,7 +92,7 @@ public function isP2WPKH(): bool
9292
/**
9393
* @return bool
9494
*/
95-
public function isP2WSH(): bool
95+
public function isPayToWitnessScriptHash(): bool
9696
{
9797
$operations = $this->parse();
9898

@@ -115,23 +115,23 @@ public function getOutputAddress(Bitcoin $network = null): string
115115

116116
$operations = $this->parse();
117117

118-
if ($this->isP2PK()) {
118+
if ($this->isPayToPubKey()) {
119119
return Utils::pubKeyToAddress($operations[0]->data, $network::P2PKH_PREFIX);
120120
}
121121

122-
if ($this->isP2PKH()) {
122+
if ($this->isPayToPubKeyHash()) {
123123
return Utils::hash160ToAddress($operations[2]->data, $network::P2PKH_PREFIX);
124124
}
125125

126-
if ($this->isP2SH()) {
126+
if ($this->isPayToScriptHash()) {
127127
return Utils::hash160ToAddress($operations[1]->data, $network::P2SH_PREFIX);
128128
}
129129

130-
if ($this->isP2WPKH()) {
130+
if ($this->isPayToWitnessPubKeyHash()) {
131131
return encodeSegwit($network::BECH32_HRP, $operations[0]->data, $operations[1]->data);
132132
}
133133

134-
if ($this->isP2WSH()) {
134+
if ($this->isPayToWitnessScriptHash()) {
135135
return encodeSegwit($network::BECH32_HRP, $operations[0]->data, $operations[1]->data);
136136
}
137137

tests/ScriptPubKeyTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function testParseP2PK()
2828

2929
$script = new ScriptPubKey(hex2bin($hex));
3030

31-
$this->assertTrue($script->isP2PK());
31+
$this->assertTrue($script->isPayToPubKey());
3232
$this->assertEquals($script->getOutputAddress(), '1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm');
3333
}
3434

@@ -41,7 +41,7 @@ public function testParseP2PKCompressed()
4141

4242
$script = new ScriptPubKey(hex2bin($hex));
4343

44-
$this->assertTrue($script->isP2PK());
44+
$this->assertTrue($script->isPayToPubKey());
4545
$this->assertEquals($script->getOutputAddress(), '1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH');
4646
}
4747

@@ -57,7 +57,7 @@ public function testParseP2PKH()
5757

5858
$script = new ScriptPubKey(hex2bin($hex));
5959

60-
$this->assertTrue($script->isP2PKH());
60+
$this->assertTrue($script->isPayToPubKeyHash());
6161
$this->assertEquals($script->getOutputAddress(), '1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm');
6262
}
6363

@@ -71,7 +71,7 @@ public function testParseP2SH()
7171

7272
$script = new ScriptPubKey(hex2bin($hex));
7373

74-
$this->assertTrue($script->isP2SH());
74+
$this->assertTrue($script->isPayToScriptHash());
7575
$this->assertEquals($script->getOutputAddress(), '3EyPVdtVrtMJ1XwPT9oiBrQysGpRY8LE9K');
7676
}
7777

@@ -102,7 +102,7 @@ public function testParseP2WPKH()
102102

103103
$script = new ScriptPubKey(hex2bin($hex));
104104

105-
$this->assertTrue($script->isP2WPKH());
105+
$this->assertTrue($script->isPayToWitnessPubKeyHash());
106106
$this->assertEquals($script->getOutputAddress(), 'bc1q2djj8vu2ypensaq8jlxs8se396q5pr2n3sa2wn');
107107
}
108108

@@ -115,7 +115,7 @@ public function testParseP2WSH()
115115

116116
$script = new ScriptPubKey(hex2bin($hex));
117117

118-
$this->assertTrue($script->isP2WSH());
118+
$this->assertTrue($script->isPayToWitnessScriptHash());
119119
$this->assertEquals($script->getOutputAddress(), 'bc1qwqdg6squsna38e46795at95yu9atm8azzmyvckulcc7kytlcckxswvvzej');
120120
}
121121
}

0 commit comments

Comments
 (0)