1 | <?php |
||
17 | class AddressFactory |
||
18 | { |
||
19 | /** |
||
20 | * Returns a pay-to-pubkey-hash address for the given public key |
||
21 | * |
||
22 | * @param KeyInterface $key |
||
23 | 44 | * @return PayToPubKeyHashAddress |
|
24 | */ |
||
25 | 44 | public static function fromKey(KeyInterface $key) |
|
29 | |||
30 | /** |
||
31 | * Takes the $p2shScript and generates the scriptHash address. |
||
32 | * |
||
33 | * @param ScriptInterface $p2shScript |
||
34 | 12 | * @return ScriptHashAddress |
|
35 | */ |
||
36 | 12 | public static function fromScript(ScriptInterface $p2shScript) |
|
40 | |||
41 | /** |
||
42 | * @param WitnessProgram $wp |
||
43 | 8 | * @return SegwitAddress |
|
44 | */ |
||
45 | 8 | public static function fromWitnessProgram(WitnessProgram $wp) |
|
49 | 4 | ||
50 | 6 | /** |
|
51 | * @param ScriptInterface $outputScript |
||
52 | 2 | * @return AddressInterface |
|
53 | */ |
||
54 | 4 | public static function fromOutputScript(ScriptInterface $outputScript) |
|
74 | |||
75 | 2 | /** |
|
76 | * @param string $address |
||
77 | * @param NetworkInterface $network |
||
78 | * @return AddressInterface |
||
79 | * @throws \BitWasp\Bitcoin\Exceptions\Base58ChecksumFailure |
||
80 | */ |
||
81 | public static function fromString($address, NetworkInterface $network = null) |
||
106 | |||
107 | 4 | /** |
|
108 | 4 | * @param string $address |
|
109 | 4 | * @param NetworkInterface $network |
|
110 | 2 | * @return bool |
|
111 | * @throws \BitWasp\Bitcoin\Exceptions\Base58ChecksumFailure |
||
112 | 4 | */ |
|
113 | public static function isValidAddress($address, NetworkInterface $network = null) |
||
124 | |||
125 | /** |
||
126 | * Following a loose definition of 'associated', returns |
||
127 | * the current script types, and a PayToPubKeyHash address for P2PK. |
||
128 | * |
||
129 | * @param ScriptInterface $script |
||
130 | * @return AddressInterface |
||
131 | * @throws \RuntimeException |
||
132 | */ |
||
133 | public static function getAssociatedAddress(ScriptInterface $script) |
||
143 | } |
||
144 |