forked from trustwallet/wallet-core
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAddress.h
More file actions
63 lines (46 loc) · 1.65 KB
/
Copy pathAddress.h
File metadata and controls
63 lines (46 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright © 2017-2020 Trust Wallet.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.
#pragma once
#include "../Base58Address.h"
#include "../PrivateKey.h"
#include "../PublicKey.h"
#include <string>
namespace TW::NULS {
class Address : public Base58Address<24> {
public:
/// NULS Main Net Chain ID = 1
static const std::array<byte, 2> mainnetId;
/// NULS address prefix
static const std::string prefix;
/// NULS address type
static const byte addressType = 0x01;
/// Determines whether a string makes a valid address.
static bool isValid(const std::string& string);
/// Initializes an address from a string representation.
explicit Address(const std::string& string);
/// Initializes an address from a public key.
explicit Address(const PublicKey& publicKey);
/// Initializes an address with a collection of bytes.
explicit Address(const Data& data) : TW::Base58Address<24>(data) {}
/// Determines is a valid address.
bool isValid() const;
/// Mainnet chain id
uint16_t chainID() const;
/// TX type
uint8_t type() const;
/// Returns a string representation of the address.
std::string string() const;
/// calculate checksum
uint8_t checksum(std::array<byte, size>& byteArray) const;
};
static inline bool operator==(const Address& lhs, const Address& rhs) {
return lhs.bytes == rhs.bytes;
}
} // namespace TW::NULS
/// Wrapper for C interface.
struct TWNULSAddress {
TW::NULS::Address impl;
};