BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
address.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cryptonomex, Inc., and contributors.
3  *
4  * The MIT License
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 #pragma once
25 
27 
28 #include <fc/crypto/elliptic.hpp>
29 #include <fc/crypto/ripemd160.hpp>
30 
31 namespace graphene { namespace protocol {
32  struct pts_address;
33 
44  class address
45  {
46  public:
47  address(){}
48  explicit address( const std::string& base58str );
49  explicit address( const fc::ecc::public_key& pub );
50  explicit address( const fc::ecc::public_key_data& pub );
51  explicit address( const pts_address& pub );
52  explicit address( const public_key_type& pubkey );
53 
54  static bool is_valid( const std::string& base58str, const std::string& prefix = GRAPHENE_ADDRESS_PREFIX );
55 
56  explicit operator std::string()const;
57 
59  };
60  inline bool operator == ( const address& a, const address& b ) { return a.addr == b.addr; }
61  inline bool operator != ( const address& a, const address& b ) { return a.addr != b.addr; }
62  inline bool operator < ( const address& a, const address& b ) { return a.addr < b.addr; }
63 
64  inline bool operator == ( const pts_address& a, const address& b ) { return address(a) == b; }
65  inline bool operator == ( const address& a, const pts_address& b ) { return a == address(b); }
66 
67  inline bool operator == ( const public_key_type& a, const address& b ) { return address(a) == b; }
68  inline bool operator == ( const address& a, const public_key_type& b ) { return a == address(b); }
69 
70 } } // namespace graphene::protocol
71 
72 namespace fc
73 {
74  void to_variant( const graphene::protocol::address& var, fc::variant& vo, uint32_t max_depth = 1 );
75  void from_variant( const fc::variant& var, graphene::protocol::address& vo, uint32_t max_depth = 1 );
76 }
77 
79 
graphene::protocol::operator<
bool operator<(const price &a, const price &b)
Definition: asset.cpp:45
fc
Definition: api.hpp:15
graphene::protocol::pts_address
Definition: pts_address.hpp:41
fc::zero_initialized_array< unsigned char, 33 >
fc::ecc::public_key
contains only the public point of an elliptic curve key.
Definition: elliptic.hpp:35
fc::from_variant
void from_variant(const variant &var, flat_set< T, A... > &vo, uint32_t _max_depth)
Definition: flat.hpp:116
graphene::protocol::public_key_type
Definition: types.hpp:312
types.hpp
fc::ripemd160
Definition: ripemd160.hpp:11
graphene::protocol::operator==
bool operator==(const price &a, const price &b)
Definition: asset.cpp:34
GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION
#define GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION(type)
Definition: types.hpp:85
fc::to_variant
void to_variant(const flat_set< T, A... > &var, variant &vo, uint32_t _max_depth)
Definition: flat.hpp:105
graphene::protocol::address::address
address(const std::string &base58str)
converts to binary, validates checksum
Definition: address.cpp:33
ripemd160.hpp
graphene::protocol::address::addr
fc::ripemd160 addr
Definition: address.hpp:58
fc::variant
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
Definition: variant.hpp:198
GRAPHENE_ADDRESS_PREFIX
#define GRAPHENE_ADDRESS_PREFIX
Definition: config.hpp:27
elliptic.hpp
FC_REFLECT
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
Definition: reflect.hpp:388
graphene::protocol::address::is_valid
static bool is_valid(const std::string &base58str, const std::string &prefix=GRAPHENE_ADDRESS_PREFIX)
Definition: address.cpp:42
graphene
Definition: api.cpp:48
graphene::protocol::address
a 160 bit hash of a public key
Definition: address.hpp:44
graphene::protocol::operator!=
bool operator!=(const address &a, const address &b)
Definition: address.hpp:61