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 | * @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 | * @return ScriptHashAddress |
||
35 | */ |
||
36 | 12 | public static function fromScript(ScriptInterface $p2shScript) |
|
40 | |||
41 | /** |
||
42 | * @param WitnessProgram $wp |
||
43 | * @return SegwitAddress |
||
44 | */ |
||
45 | 12 | public static function fromWitnessProgram(WitnessProgram $wp) |
|
49 | |||
50 | /** |
||
51 | * @param ScriptInterface $outputScript |
||
52 | * @return AddressInterface |
||
53 | */ |
||
54 | 8 | public static function fromOutputScript(ScriptInterface $outputScript) |
|
74 | |||
75 | /** |
||
76 | * @param string $address |
||
77 | * @param NetworkInterface $network |
||
78 | * @return AddressInterface |
||
79 | * @throws \BitWasp\Bitcoin\Exceptions\Base58ChecksumFailure |
||
80 | */ |
||
81 | 54 | public static function fromString($address, NetworkInterface $network = null) |
|
106 | |||
107 | /** |
||
108 | * @param string $address |
||
109 | * @param NetworkInterface $network |
||
110 | * @return bool |
||
111 | * @throws \BitWasp\Bitcoin\Exceptions\Base58ChecksumFailure |
||
112 | */ |
||
113 | 38 | 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 | 4 | public static function getAssociatedAddress(ScriptInterface $script) |
|
143 | } |
||
144 |