1 | <?php |
||
19 | class AddressFactory |
||
20 | { |
||
21 | /** |
||
22 | * Returns a pay-to-pubkey-hash address for the given public key |
||
23 | * |
||
24 | * @param KeyInterface $key |
||
25 | * @return PayToPubKeyHashAddress |
||
26 | */ |
||
27 | 44 | public static function fromKey(KeyInterface $key) |
|
31 | |||
32 | /** |
||
33 | * Takes the $p2shScript and generates the scriptHash address. |
||
34 | * |
||
35 | * @param ScriptInterface $p2shScript |
||
36 | * @return ScriptHashAddress |
||
37 | */ |
||
38 | 12 | public static function fromScript(ScriptInterface $p2shScript) |
|
42 | |||
43 | /** |
||
44 | * @param WitnessProgram $wp |
||
45 | * @return SegwitAddress |
||
46 | */ |
||
47 | 12 | public static function fromWitnessProgram(WitnessProgram $wp) |
|
51 | |||
52 | /** |
||
53 | * @param ScriptInterface $outputScript |
||
54 | * @return AddressInterface |
||
55 | */ |
||
56 | 44 | public static function fromOutputScript(ScriptInterface $outputScript) |
|
80 | |||
81 | /** |
||
82 | * @param string $address |
||
83 | * @param NetworkInterface $network |
||
84 | * @return AddressInterface |
||
85 | * @throws \BitWasp\Bitcoin\Exceptions\Base58ChecksumFailure |
||
86 | */ |
||
87 | 60 | public static function fromString($address, NetworkInterface $network = null) |
|
112 | |||
113 | /** |
||
114 | * @param string $address |
||
115 | * @param NetworkInterface $network |
||
116 | * @return bool |
||
117 | * @throws \BitWasp\Bitcoin\Exceptions\Base58ChecksumFailure |
||
118 | */ |
||
119 | 38 | public static function isValidAddress($address, NetworkInterface $network = null) |
|
130 | |||
131 | /** |
||
132 | * Following a loose definition of 'associated', returns |
||
133 | * the current script types, and a PayToPubKeyHash address for P2PK. |
||
134 | * |
||
135 | * @param ScriptInterface $script |
||
136 | * @return AddressInterface |
||
137 | * @throws \RuntimeException |
||
138 | */ |
||
139 | 4 | public static function getAssociatedAddress(ScriptInterface $script) |
|
149 | } |
||
150 |