1 | <?php |
||
17 | class ExtendedKeySerializer |
||
18 | { |
||
19 | /** |
||
20 | * @var EcAdapterInterface |
||
21 | */ |
||
22 | private $ecAdapter; |
||
23 | |||
24 | /** |
||
25 | * @var \BitWasp\Buffertools\Types\ByteString |
||
26 | */ |
||
27 | private $bytestring4; |
||
28 | |||
29 | /** |
||
30 | * @var \BitWasp\Buffertools\Types\Uint8 |
||
31 | */ |
||
32 | private $uint8; |
||
33 | |||
34 | /** |
||
35 | * @var \BitWasp\Buffertools\Types\Uint32 |
||
36 | */ |
||
37 | private $uint32; |
||
38 | |||
39 | /** |
||
40 | * @var \BitWasp\Buffertools\Types\ByteString |
||
41 | */ |
||
42 | private $bytestring32; |
||
43 | |||
44 | /** |
||
45 | * @var \BitWasp\Buffertools\Types\ByteString |
||
46 | */ |
||
47 | private $bytestring33; |
||
48 | |||
49 | /** |
||
50 | * @param EcAdapterInterface $ecAdapter |
||
51 | * @throws \Exception |
||
52 | */ |
||
53 | 26 | public function __construct(EcAdapterInterface $ecAdapter) |
|
62 | |||
63 | /** |
||
64 | * @param NetworkInterface $network |
||
65 | * @throws \Exception |
||
66 | */ |
||
67 | 26 | private function checkNetwork(NetworkInterface $network) |
|
68 | { |
||
69 | try { |
||
70 | 26 | $network->getHDPrivByte(); |
|
71 | 26 | $network->getHDPubByte(); |
|
72 | } catch (\Exception $e) { |
||
73 | throw new \Exception('Network not configured for HD wallets'); |
||
74 | } |
||
75 | 26 | } |
|
76 | |||
77 | /** |
||
78 | * @param NetworkInterface $network |
||
79 | * @param HierarchicalKey $key |
||
80 | * @return Buffer |
||
81 | */ |
||
82 | 6 | public function serialize(NetworkInterface $network, HierarchicalKey $key) |
|
99 | |||
100 | /** |
||
101 | * @param NetworkInterface $network |
||
102 | * @param Parser $parser |
||
103 | * @return HierarchicalKey |
||
104 | * @throws ParserOutOfRange |
||
105 | */ |
||
106 | 22 | public function fromParser(NetworkInterface $network, Parser $parser) |
|
135 | |||
136 | /** |
||
137 | * @param NetworkInterface $network |
||
138 | * @param BufferInterface $buffer |
||
139 | * @return HierarchicalKey |
||
140 | */ |
||
141 | 22 | public function parse(NetworkInterface $network, BufferInterface $buffer) |
|
145 | } |
||
146 |