FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
bitcoin-php/src/Script/P2shScript.php at main · ProtonMail/bitcoin-php · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
ProtonMail
/
bitcoin-php
Public
forked from
Bit-Wasp/bitcoin-php
Notifications
You must be signed in to change notification settings
Fork
23
Star
32
Code
Issues
3
Pull requests
1
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
bitcoin-php
/
src
/
Script
/
P2shScript.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
72 lines (60 loc) · 1.7 KB
Breadcrumbs
bitcoin-php
/
src
/
Script
/
P2shScript.php
Copy path
File metadata and controls
72 lines (60 loc) · 1.7 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
declare
(strict_types=
1
);
namespace
BitWasp
\
Bitcoin
\
Script
;
use
BitWasp
\
Bitcoin
\
Address
\
ScriptHashAddress
;
use
BitWasp
\
Bitcoin
\
Exceptions
\
P2shScriptException
;
use
BitWasp
\
Buffertools
\
BufferInterface
;
class
P2shScript
extends
Script
{
/**
* @var \BitWasp\Buffertools\BufferInterface
*/
protected
$
scriptHash
;
/**
* @var ScriptInterface
*/
private
$
outputScript
;
/**
* @var ScriptHashAddress
*/
private
$
address
;
/**
* P2shScript constructor.
* @param ScriptInterface $script
* @param Opcodes|null $opcodes
* @throws P2shScriptException
*/
public
function
__construct
(
ScriptInterface
$
script
, ?
Opcodes
$
opcodes
=
null
)
{
if
(
$
script
instanceof
WitnessScript) {
$
script
=
$
script
->
getOutputScript
();
}
else
if
(
$
script
instanceof
self) {
throw
new
P2shScriptException
(
"
Cannot nest P2SH scripts.
"
);
}
parent
::
__construct
(
$
script
->
getBuffer
(),
$
opcodes
);
$
this
->
scriptHash
=
$
script
->
getScriptHash
();
$
this
->
outputScript
= ScriptFactory::
scriptPubKey
()->
p2sh
(
$
this
->
scriptHash
);
$
this
->
address
=
new
ScriptHashAddress
(
$
this
->
scriptHash
);
}
/**
* @throws P2shScriptException
*/
public
function
getWitnessScriptHash
():
BufferInterface
{
throw
new
P2shScriptException
(
"
Cannot compute witness-script-hash for a P2shScript
"
);
}
/**
* @return ScriptInterface
*/
public
function
getOutputScript
():
ScriptInterface
{
return
$
this
->
outputScript
;
}
/**
* @return ScriptHashAddress
*/
public
function
getAddress
():
ScriptHashAddress
{
return
$
this
->
address
;
}
}
Back
|
FazBrowse Home
|
New Git URL