| 1 | <?php |
||
| 12 | class ScriptWitnessSerializer |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var \BitWasp\Buffertools\Types\VarString |
||
| 16 | */ |
||
| 17 | private $varstring; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var \BitWasp\Buffertools\Types\VarInt |
||
| 21 | */ |
||
| 22 | private $varint; |
||
| 23 | |||
| 24 | 2530 | public function __construct() |
|
| 29 | |||
| 30 | /** |
||
| 31 | * @param Parser $parser |
||
| 32 | * @return ScriptWitnessInterface |
||
| 33 | */ |
||
| 34 | 22 | public function fromParser(Parser $parser) |
|
| 35 | { |
||
| 36 | 22 | $size = $this->varint->read($parser); |
|
| 37 | 22 | $entries = []; |
|
| 38 | 22 | for ($j = 0; $j < $size; $j++) { |
|
| 39 | 22 | $entries[] = $this->varstring->read($parser); |
|
| 40 | } |
||
| 41 | |||
| 42 | 22 | return new ScriptWitness($entries); |
|
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @param ScriptWitnessInterface $witness |
||
| 47 | * @return BufferInterface |
||
| 48 | */ |
||
| 49 | 44 | public function serialize(ScriptWitnessInterface $witness) |
|
| 58 | } |
||
| 59 |