1 | <?php |
||
16 | class AddressFactory |
||
17 | { |
||
18 | /** |
||
19 | * Returns a pay-to-pubkey-hash address for the given public key |
||
20 | * |
||
21 | * @param KeyInterface $key |
||
22 | * @return PayToPubKeyHashAddress |
||
23 | */ |
||
24 | public static function p2pkh(KeyInterface $key): PayToPubKeyHashAddress |
||
28 | |||
29 | 11 | /** |
|
30 | * Takes the $p2shScript and generates the scriptHash address. |
||
31 | 11 | * |
|
32 | * @param ScriptInterface $p2shScript |
||
33 | * @return ScriptHashAddress |
||
34 | */ |
||
35 | public static function p2sh(ScriptInterface $p2shScript): ScriptHashAddress |
||
39 | |||
40 | 10 | /** |
|
41 | * @param WitnessProgram $wp |
||
42 | 10 | * @return SegwitAddress |
|
43 | */ |
||
44 | public static function fromWitnessProgram(WitnessProgram $wp): SegwitAddress |
||
48 | |||
49 | 6 | /** |
|
50 | * @param ScriptInterface $outputScript |
||
51 | 6 | * @return Address |
|
52 | */ |
||
53 | public static function fromOutputScript(ScriptInterface $outputScript): Address |
||
58 | 26 | ||
59 | /** |
||
60 | 26 | * @param string $address |
|
61 | * @param NetworkInterface|null $network |
||
62 | * @return Address |
||
63 | * @throws \BitWasp\Bitcoin\Exceptions\UnrecognizedAddressException |
||
64 | 26 | */ |
|
65 | 26 | public static function fromString(string $address, NetworkInterface $network = null): Address |
|
71 | 20 | ||
72 | 20 | /** |
|
73 | * @param string $address |
||
74 | 10 | * @param NetworkInterface $network |
|
75 | 11 | * @return bool |
|
76 | */ |
||
77 | 9 | public static function isValidAddress(string $address, NetworkInterface $network = null): bool |
|
88 | |||
89 | 36 | /** |
|
90 | * Following a loose definition of 'associated', returns |
||
91 | 36 | * the current script types, and a PayToPubKeyHash address for P2PK. |
|
92 | * |
||
93 | * @param ScriptInterface $script |
||
94 | 36 | * @return AddressInterface |
|
95 | 30 | * @throws \RuntimeException |
|
96 | */ |
||
97 | 30 | public static function getAssociatedAddress(ScriptInterface $script): AddressInterface |
|
108 | } |
||
109 |