BitShares-Core  4.0.0
BitShares blockchain implementation and command-line interface 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  address( const fc::ecc::public_key& pub );
50  explicit address( const fc::ecc::public_key_data& pub );
51  address( const pts_address& pub );
52  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 } } // namespace graphene::protocol
65 
66 namespace fc
67 {
68  void to_variant( const graphene::protocol::address& var, fc::variant& vo, uint32_t max_depth = 1 );
69  void from_variant( const fc::variant& var, graphene::protocol::address& vo, uint32_t max_depth = 1 );
70 }
71 
73 
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
Definition: reflect.hpp:386
Definition: api.cpp:56
#define GRAPHENE_ADDRESS_PREFIX
Definition: config.hpp:27
static bool is_valid(const std::string &base58str, const std::string &prefix=GRAPHENE_ADDRESS_PREFIX)
Definition: address.cpp:42
bool operator<(const price &a, const price &b)
Definition: asset.cpp:46
void to_variant(const flat_set< T, A... > &var, variant &vo, uint32_t _max_depth)
Definition: flat.hpp:105
#define GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION(type)
Definition: types.hpp:73
contains only the public point of an elliptic curve key.
Definition: elliptic.hpp:35
bool operator!=(const address &a, const address &b)
Definition: address.hpp:61
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object&#39;s.
Definition: variant.hpp:198
void from_variant(const variant &var, flat_set< T, A... > &vo, uint32_t _max_depth)
Definition: flat.hpp:116
Definition: api.hpp:15
a 160 bit hash of a public key
Definition: address.hpp:44
address()
constructs empty / null address
Definition: address.hpp:47
bool operator==(const price &a, const price &b)
Definition: asset.cpp:35