github.com/igggame/nebulas-go@v2.1.0+incompatible/nbre/common/address.h (about) 1 // Copyright (C) 2018 go-nebulas authors 2 // 3 // This file is part of the go-nebulas library. 4 // 5 // the go-nebulas library is free software: you can redistribute it and/or 6 // modify 7 // it under the terms of the GNU General Public License as published by 8 // the Free Software Foundation, either version 3 of the License, or 9 // (at your option) any later version. 10 // 11 // the go-nebulas library is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU General Public License for more details. 15 // 16 // You should have received a copy of the GNU General Public License 17 // along with the go-nebulas library. If not, see 18 // <http://www.gnu.org/licenses/>. 19 // 20 21 #pragma once 22 #include "common/byte.h" 23 #include "common/common.h" 24 25 namespace neb { 26 typedef std::string base58_address_t; 27 typedef neb::bytes address_t; 28 29 address_t base58_to_address(const base58_address_t &addr); 30 base58_address_t address_to_base58(const address_t &addr); 31 32 typedef std::string address_bytes_t; 33 typedef std::tuple<module_t, address_bytes_t, block_height_t, block_height_t> 34 auth_row_t; 35 typedef std::vector<auth_row_t> auth_table_t; 36 37 inline address_t to_address(const std::string &addr) { 38 return string_to_byte(addr); 39 } 40 inline std::string address_to_string(const address_t &addr) { 41 return byte_to_string(addr); 42 } 43 44 bool is_valid_address(const address_t &addr); 45 bool is_contract_address(const address_t &addr); 46 bool is_normal_address(const address_t &addr); 47 48 #define NAS_ADDRESS_LEN 26 49 #define NAS_ADDRESS_MAGIC_NUM 0x19 50 #define NAS_ADDRESS_ACCOUNT_MAGIC_NUM 0x57 51 #define NAS_ADDRESS_CONTRACT_MAGIC_NUM 0x58 52 } // namespace neb