1
// Copyright © 2017-2020 Trust Wallet.
2
//
3
// This file is part of Trust. The full Trust copyright notice, including
4
// terms governing use, modification, and redistribution, is contained in the
5
// file LICENSE at the root of the source code distribution tree.
6

7
#pragma once
8

9
#include "../Data.h"
10
#include "ISerializable.h"
11
#include "Serializable.h"
12

13
namespace TW::NEO {
14

15 1
class Witness : public Serializable {
16
  public:
17
    Data invocationScript;
18
    Data verificationScript;
19

20 1
    virtual ~Witness() {}
21

22 0
    int64_t size() const override {
23 0
        return invocationScript.size() + verificationScript.size();
24
    }
25

26 1
    void deserialize(const Data& data, int initial_pos = 0) override {
27
        uint32_t size;
28 1
        invocationScript = readVarBytes(data, initial_pos, &size);
29 1
        verificationScript = readVarBytes(data, initial_pos + size);
30
    }
31

32 1
    Data serialize() const override {
33 1
        return concat(writeVarBytes(invocationScript), writeVarBytes(verificationScript));
34
    }
35

36 1
    bool operator==(const Witness &other) const {
37 1
        return this->invocationScript.size() == other.invocationScript.size()
38 1
            && this->verificationScript.size() == other.verificationScript.size()
39 1
            && this->invocationScript == other.invocationScript
40 1
            && this->verificationScript == other.verificationScript;
41
    }
42
};
43

44
}

Read our documentation on viewing source code .

Loading