1 | <?php |
||
12 | class TransactionSerializer implements TransactionSerializerInterface |
||
13 | { |
||
14 | const NO_WITNESS = 1; |
||
15 | |||
16 | /** |
||
17 | * @var \BitWasp\Buffertools\Types\Int32 |
||
18 | */ |
||
19 | private $int32le; |
||
20 | |||
21 | /** |
||
22 | * @var \BitWasp\Buffertools\Types\Uint32 |
||
23 | */ |
||
24 | private $uint32le; |
||
25 | |||
26 | /** |
||
27 | * @var \BitWasp\Buffertools\Types\VarInt |
||
28 | */ |
||
29 | private $varint; |
||
30 | |||
31 | /** |
||
32 | * @var TransactionInputSerializer |
||
33 | */ |
||
34 | private $inputSerializer; |
||
35 | |||
36 | /** |
||
37 | * @var TransactionOutputSerializer |
||
38 | */ |
||
39 | private $outputSerializer; |
||
40 | |||
41 | /** |
||
42 | * @var ScriptWitnessSerializer |
||
43 | */ |
||
44 | private $witnessSerializer; |
||
45 | |||
46 | 1332 | public function __construct(TransactionInputSerializer $inputSerializer = null, TransactionOutputSerializer $outputSerializer = null, ScriptWitnessSerializer $witnessSerializer = null) |
|
47 | { |
||
48 | 1332 | $this->int32le = Types::int32le(); |
|
49 | 1332 | $this->uint32le = Types::uint32le(); |
|
50 | 1332 | $this->varint = Types::varint(); |
|
51 | |||
52 | 1332 | $this->inputSerializer = $inputSerializer ?: new TransactionInputSerializer(new OutPointSerializer()); |
|
53 | 1332 | $this->outputSerializer = $outputSerializer ?: new TransactionOutputSerializer; |
|
54 | 1332 | $this->witnessSerializer = $witnessSerializer ?: new ScriptWitnessSerializer(); |
|
55 | 1332 | } |
|
56 | |||
57 | /** |
||
58 | * @param Parser $parser |
||
59 | * @return TransactionInterface |
||
60 | */ |
||
61 | 62 | public function fromParser(Parser $parser) |
|
62 | { |
||
63 | 62 | $version = $this->int32le->read($parser); |
|
64 | |||
65 | 62 | $vin = []; |
|
66 | 62 | $vinCount = $this->varint->read($parser); |
|
67 | 62 | for ($i = 0; $i < $vinCount; $i++) { |
|
68 | 62 | $vin[] = $this->inputSerializer->fromParser($parser); |
|
69 | } |
||
70 | |||
71 | 62 | $vout = []; |
|
72 | 62 | $flags = 0; |
|
73 | 62 | if (count($vin) === 0) { |
|
74 | $flags = (int) $this->varint->read($parser); |
||
75 | if ($flags !== 0) { |
||
76 | $vinCount = $this->varint->read($parser); |
||
77 | for ($i = 0; $i < $vinCount; $i++) { |
||
78 | $vin[] = $this->inputSerializer->fromParser($parser); |
||
79 | } |
||
80 | |||
81 | $voutCount = $this->varint->read($parser); |
||
82 | for ($i = 0; $i < $voutCount; $i++) { |
||
83 | $vout[] = $this->outputSerializer->fromParser($parser); |
||
84 | } |
||
85 | } |
||
86 | } else { |
||
87 | 62 | $voutCount = $this->varint->read($parser); |
|
88 | 62 | for ($i = 0; $i < $voutCount; $i++) { |
|
89 | 62 | $vout[] = $this->outputSerializer->fromParser($parser); |
|
90 | } |
||
91 | } |
||
92 | |||
93 | 62 | $vwit = []; |
|
94 | 62 | if (($flags & 1)) { |
|
95 | $flags ^= 1; |
||
96 | $witCount = count($vin); |
||
97 | for ($i = 0; $i < $witCount; $i++) { |
||
98 | $vectorCount = $this->varint->read($parser); |
||
99 | $vwit[] = $this->witnessSerializer->fromParser($parser, $vectorCount); |
||
100 | } |
||
101 | } |
||
102 | |||
103 | 62 | if ($flags) { |
|
104 | throw new \RuntimeException('Flags byte was 0'); |
||
105 | } |
||
106 | |||
107 | 62 | $lockTime = $this->uint32le->read($parser); |
|
108 | |||
109 | 62 | return new Transaction($version, $vin, $vout, $vwit, $lockTime); |
|
110 | } |
||
111 | |||
112 | /** |
||
113 | * @param string|BufferInterface $data |
||
114 | * @return TransactionInterface |
||
115 | */ |
||
116 | 40 | public function parse($data) |
|
120 | |||
121 | /** |
||
122 | * @param TransactionInterface $transaction |
||
123 | * @param int $opt |
||
124 | * @return BufferInterface |
||
125 | */ |
||
126 | 1306 | public function serialize(TransactionInterface $transaction, $opt = 0) |
|
161 | } |
||
162 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.