Fix RPC, add CLI wallet commands for sidechain addresses
This commit is contained in:
parent
243a269f36
commit
c79b215aa0
13 changed files with 313 additions and 45 deletions
|
|
@ -153,10 +153,11 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
|
|||
uint64_t get_son_count()const;
|
||||
|
||||
// Sidechain addresses
|
||||
vector<optional<sidechain_address_object>> get_all_sidechain_addresses()const;
|
||||
vector<optional<sidechain_address_object>> get_sidechain_addresses(const vector<sidechain_address_id_type>& sidechain_address_ids)const;
|
||||
vector<optional<sidechain_address_object>> get_sidechain_addresses_by_account(account_id_type account)const;
|
||||
vector<optional<sidechain_address_object>> get_sidechain_addresses_by_sidechain(peerplays_sidechain::sidechain_type sidechain)const;
|
||||
fc::optional<sidechain_address_object> get_sidechain_addresses_by_account_and_sidechain(account_id_type account, peerplays_sidechain::sidechain_type sidechain)const;
|
||||
fc::optional<sidechain_address_object> get_sidechain_address_by_account_and_sidechain(account_id_type account, peerplays_sidechain::sidechain_type sidechain)const;
|
||||
uint64_t get_sidechain_addresses_count()const;
|
||||
|
||||
// Votes
|
||||
|
|
@ -1776,6 +1777,22 @@ uint64_t database_api_impl::get_son_count()const
|
|||
// //
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
vector<optional<sidechain_address_object>> database_api::get_all_sidechain_addresses()const
|
||||
{
|
||||
return my->get_all_sidechain_addresses();
|
||||
}
|
||||
|
||||
vector<optional<sidechain_address_object>> database_api_impl::get_all_sidechain_addresses()const
|
||||
{
|
||||
vector<optional<sidechain_address_object>> result;
|
||||
const auto& idx = _db.get_index_type<sidechain_address_index>().indices().get<by_id>();
|
||||
std::for_each(idx.begin(), idx.end(),
|
||||
[&result] (const sidechain_address_object& sao) {
|
||||
result.push_back(sao);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
vector<optional<sidechain_address_object>> database_api::get_sidechain_addresses(const vector<sidechain_address_id_type>& sidechain_address_ids)const
|
||||
{
|
||||
return my->get_sidechain_addresses( sidechain_address_ids );
|
||||
|
|
@ -1800,9 +1817,12 @@ vector<optional<sidechain_address_object>> database_api::get_sidechain_addresses
|
|||
|
||||
vector<optional<sidechain_address_object>> database_api_impl::get_sidechain_addresses_by_account(account_id_type account)const
|
||||
{
|
||||
//const auto& idx = _db.get_index_type<sidechain_address_index>().indices().get<by_account>();
|
||||
|
||||
vector<optional<sidechain_address_object>> result;
|
||||
const auto& sidechain_addresses_range = _db.get_index_type<sidechain_address_index>().indices().get<by_account>().equal_range(account);
|
||||
std::for_each(sidechain_addresses_range.first, sidechain_addresses_range.second,
|
||||
[&result] (const sidechain_address_object& sao) {
|
||||
result.push_back(sao);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -1813,18 +1833,21 @@ vector<optional<sidechain_address_object>> database_api::get_sidechain_addresses
|
|||
|
||||
vector<optional<sidechain_address_object>> database_api_impl::get_sidechain_addresses_by_sidechain(peerplays_sidechain::sidechain_type sidechain)const
|
||||
{
|
||||
//const auto& idx = _db.get_index_type<sidechain_address_index>().indices().get<by_sidechain>();
|
||||
|
||||
vector<optional<sidechain_address_object>> result;
|
||||
const auto& sidechain_addresses_range = _db.get_index_type<sidechain_address_index>().indices().get<by_sidechain>().equal_range(sidechain);
|
||||
std::for_each(sidechain_addresses_range.first, sidechain_addresses_range.second,
|
||||
[&result] (const sidechain_address_object& sao) {
|
||||
result.push_back(sao);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
fc::optional<sidechain_address_object> database_api::get_sidechain_addresses_by_account_and_sidechain(account_id_type account, peerplays_sidechain::sidechain_type sidechain)const
|
||||
fc::optional<sidechain_address_object> database_api::get_sidechain_address_by_account_and_sidechain(account_id_type account, peerplays_sidechain::sidechain_type sidechain)const
|
||||
{
|
||||
return my->get_sidechain_addresses_by_account_and_sidechain( account, sidechain );
|
||||
return my->get_sidechain_address_by_account_and_sidechain( account, sidechain );
|
||||
}
|
||||
|
||||
fc::optional<sidechain_address_object> database_api_impl::get_sidechain_addresses_by_account_and_sidechain(account_id_type account, peerplays_sidechain::sidechain_type sidechain)const
|
||||
fc::optional<sidechain_address_object> database_api_impl::get_sidechain_address_by_account_and_sidechain(account_id_type account, peerplays_sidechain::sidechain_type sidechain)const
|
||||
{
|
||||
const auto& idx = _db.get_index_type<sidechain_address_index>().indices().get<by_account_and_sidechain>();
|
||||
auto itr = idx.find( boost::make_tuple( account, sidechain ) );
|
||||
|
|
|
|||
|
|
@ -607,9 +607,17 @@ class database_api
|
|||
// Sidechain Addresses //
|
||||
/////////////////////////
|
||||
|
||||
/**
|
||||
* @brief Get a list of all sidechain addresses
|
||||
* @return The list of all sidechain accounts
|
||||
*
|
||||
* This function has semantics identical to @ref get_objects
|
||||
*/
|
||||
vector<optional<sidechain_address_object>> get_all_sidechain_addresses()const;
|
||||
|
||||
/**
|
||||
* @brief Get a list of sidechain addresses
|
||||
* @param sidechain_address_ids IDs of the sidechain accounts to retrieve
|
||||
* @param sidechain_address_ids IDs of the sidechain addresses to retrieve
|
||||
* @return The sidechain accounts corresponding to the provided IDs
|
||||
*
|
||||
* This function has semantics identical to @ref get_objects
|
||||
|
|
@ -636,7 +644,7 @@ class database_api
|
|||
* @param sidechain Sidechain for which address should be retrieved
|
||||
* @return The sidechain addresses objects, or null if the account does not have a sidechain addresses for a given sidechain
|
||||
*/
|
||||
fc::optional<sidechain_address_object> get_sidechain_addresses_by_account_and_sidechain(account_id_type account, peerplays_sidechain::sidechain_type sidechain)const;
|
||||
fc::optional<sidechain_address_object> get_sidechain_address_by_account_and_sidechain(account_id_type account, peerplays_sidechain::sidechain_type sidechain)const;
|
||||
|
||||
/**
|
||||
* @brief Get the total number of sidechain addresses registered with the blockchain
|
||||
|
|
@ -856,10 +864,11 @@ FC_API(graphene::app::database_api,
|
|||
(get_son_count)
|
||||
|
||||
// Sidechain addresses
|
||||
(get_all_sidechain_addresses)
|
||||
(get_sidechain_addresses)
|
||||
(get_sidechain_addresses_by_account)
|
||||
(get_sidechain_addresses_by_sidechain)
|
||||
(get_sidechain_addresses_by_account_and_sidechain)
|
||||
(get_sidechain_address_by_account_and_sidechain)
|
||||
(get_sidechain_addresses_count)
|
||||
|
||||
// workers
|
||||
|
|
|
|||
|
|
@ -35,16 +35,17 @@ namespace graphene { namespace chain {
|
|||
struct by_account;
|
||||
struct by_sidechain;
|
||||
struct by_account_and_sidechain;
|
||||
struct by_sidechain_and_address;
|
||||
using sidechain_address_multi_index_type = multi_index_container<
|
||||
sidechain_address_object,
|
||||
indexed_by<
|
||||
ordered_unique< tag<by_id>,
|
||||
member<object, object_id_type, &object::id>
|
||||
>,
|
||||
ordered_unique< tag<by_account>,
|
||||
ordered_non_unique< tag<by_account>,
|
||||
member<sidechain_address_object, account_id_type, &sidechain_address_object::sidechain_address_account>
|
||||
>,
|
||||
ordered_unique< tag<by_sidechain>,
|
||||
ordered_non_unique< tag<by_sidechain>,
|
||||
member<sidechain_address_object, peerplays_sidechain::sidechain_type, &sidechain_address_object::sidechain>
|
||||
>,
|
||||
ordered_unique< tag<by_account_and_sidechain>,
|
||||
|
|
@ -52,6 +53,12 @@ namespace graphene { namespace chain {
|
|||
member<sidechain_address_object, account_id_type, &sidechain_address_object::sidechain_address_account>,
|
||||
member<sidechain_address_object, peerplays_sidechain::sidechain_type, &sidechain_address_object::sidechain>
|
||||
>
|
||||
>,
|
||||
ordered_unique< tag<by_sidechain_and_address>,
|
||||
composite_key<sidechain_address_object,
|
||||
member<sidechain_address_object, peerplays_sidechain::sidechain_type, &sidechain_address_object::sidechain>,
|
||||
member<sidechain_address_object, std::string, &sidechain_address_object::address>
|
||||
>
|
||||
>
|
||||
>
|
||||
>;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <graphene/peerplays_sidechain/defs.hpp>
|
||||
#include <graphene/peerplays_sidechain/peerplays_sidechain_plugin.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
|
@ -10,12 +11,13 @@ namespace graphene { namespace peerplays_sidechain {
|
|||
|
||||
class sidechain_net_handler {
|
||||
public:
|
||||
sidechain_net_handler(const boost::program_options::variables_map& options);
|
||||
sidechain_net_handler(peerplays_sidechain_plugin &_plugin, const boost::program_options::variables_map& options);
|
||||
virtual ~sidechain_net_handler();
|
||||
|
||||
std::vector<std::string> get_user_sidechain_address_mapping();
|
||||
std::vector<std::string> get_sidechain_addresses();
|
||||
|
||||
protected:
|
||||
peerplays_sidechain_plugin &plugin;
|
||||
graphene::peerplays_sidechain::sidechain_type sidechain;
|
||||
|
||||
virtual std::string create_multisignature_wallet( const std::vector<std::string> public_keys ) = 0;
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ private:
|
|||
|
||||
class sidechain_net_handler_bitcoin : public sidechain_net_handler {
|
||||
public:
|
||||
sidechain_net_handler_bitcoin(const boost::program_options::variables_map& options);
|
||||
sidechain_net_handler_bitcoin(peerplays_sidechain_plugin &_plugin, const boost::program_options::variables_map& options);
|
||||
virtual ~sidechain_net_handler_bitcoin();
|
||||
|
||||
void update_tx_infos( const std::string& block_hash );
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <graphene/peerplays_sidechain/defs.hpp>
|
||||
#include <graphene/peerplays_sidechain/peerplays_sidechain_plugin.hpp>
|
||||
#include <graphene/peerplays_sidechain/sidechain_net_handler.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
|
@ -11,12 +12,12 @@ namespace graphene { namespace peerplays_sidechain {
|
|||
|
||||
class sidechain_net_manager {
|
||||
public:
|
||||
sidechain_net_manager();
|
||||
sidechain_net_manager(peerplays_sidechain_plugin &_plugin);
|
||||
virtual ~sidechain_net_manager();
|
||||
|
||||
bool create_handler(peerplays_sidechain::sidechain_type sidechain, const boost::program_options::variables_map& options);
|
||||
private:
|
||||
|
||||
peerplays_sidechain_plugin &plugin;
|
||||
std::vector<std::unique_ptr<sidechain_net_handler>> net_handlers;
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,8 +14,9 @@ namespace detail
|
|||
class peerplays_sidechain_plugin_impl
|
||||
{
|
||||
public:
|
||||
peerplays_sidechain_plugin_impl(peerplays_sidechain_plugin& _plugin)
|
||||
: _self( _plugin )
|
||||
peerplays_sidechain_plugin_impl(peerplays_sidechain_plugin& _plugin) :
|
||||
_self( _plugin ),
|
||||
_net_manager( _plugin )
|
||||
{ }
|
||||
virtual ~peerplays_sidechain_plugin_impl();
|
||||
|
||||
|
|
@ -77,9 +78,10 @@ void peerplays_sidechain_plugin::plugin_initialize(const boost::program_options:
|
|||
{
|
||||
ilog("peerplays sidechain plugin: plugin_initialize()");
|
||||
|
||||
if( options.count( "bitcoin-node-ip" ) && options.count( "bitcoin-node-zmq-port" ) && options.count( "bitcoin-node-rpc-port" )
|
||||
&& options.count( "bitcoin-node-rpc-user" ) && options.count( "bitcoin-node-rpc-password" )
|
||||
&& options.count( "bitcoin-address" ) && options.count( "bitcoin-public-key" ) && options.count( "bitcoin-private-key" ) )
|
||||
if ( options.count( "son-id" ) && options.count( "peerplays-private-key" )
|
||||
&& options.count( "bitcoin-node-ip" ) && options.count( "bitcoin-node-zmq-port" ) && options.count( "bitcoin-node-rpc-port" )
|
||||
&& options.count( "bitcoin-node-rpc-user" ) && options.count( "bitcoin-node-rpc-password" )
|
||||
&& options.count( "bitcoin-address" ) && options.count( "bitcoin-public-key" ) && options.count( "bitcoin-private-key" ) )
|
||||
{
|
||||
my->_net_manager.create_handler(sidechain_type::bitcoin, options);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,29 +1,31 @@
|
|||
#include <graphene/peerplays_sidechain/sidechain_net_handler.hpp>
|
||||
|
||||
#include <graphene/chain/sidechain_address_object.hpp>
|
||||
|
||||
#include <fc/log/logger.hpp>
|
||||
|
||||
namespace graphene { namespace peerplays_sidechain {
|
||||
|
||||
sidechain_net_handler::sidechain_net_handler(const boost::program_options::variables_map& options) {
|
||||
sidechain_net_handler::sidechain_net_handler(peerplays_sidechain_plugin &_plugin, const boost::program_options::variables_map& options) :
|
||||
plugin( _plugin ) {
|
||||
}
|
||||
|
||||
sidechain_net_handler::~sidechain_net_handler() {
|
||||
}
|
||||
|
||||
std::vector<std::string> sidechain_net_handler::get_user_sidechain_address_mapping() {
|
||||
std::vector<std::string> sidechain_net_handler::get_sidechain_addresses() {
|
||||
std::vector<std::string> result;
|
||||
|
||||
switch (sidechain) {
|
||||
case sidechain_type::bitcoin:
|
||||
result.push_back("2N5aFW5WFaYZLuJWx9RGziHBdEMj9Zf8s3J");
|
||||
result.push_back("2MxAnE469fhhdvUqUB7daU997VSearb2mn7");
|
||||
result.push_back("2NAYptFvTU8vJ1pC7CxvVA9R7D3NdBJHpwL");
|
||||
result.push_back("2N9zPaLDfaJazUmVfr3wgn8BK75tid2kkzR");
|
||||
result.push_back("2NDN7cDH3E57E1B8TwTYvBgF7CndL4FTBPL");
|
||||
//result.push_back("2MzEmSiwrRzozxE6gfZ14LAyDHZ4DYP1zVG");
|
||||
//result.push_back("2NDCdm1WVJVCMWJzRaSSy9NDvpNKiqkbrMg");
|
||||
//result.push_back("2Mu2iz3Jfqjyv3hBQGQZSGmZGZxhJp91TNX");
|
||||
//result.push_back("2N1sFbwcn4QVbvjp7yRsN4mg4mBFbvC8gKM");
|
||||
//result.push_back("2NDmxr6ufBE7Zgdgq9hShF2grx2YPEiTyNy");
|
||||
|
||||
{
|
||||
const auto& sidechain_addresses_range = plugin.database().get_index_type<sidechain_address_index>().indices().get<by_sidechain>().equal_range(sidechain);
|
||||
std::for_each(sidechain_addresses_range.first, sidechain_addresses_range.second,
|
||||
[&result] (const sidechain_address_object& sao) {
|
||||
result.push_back(sao.address);
|
||||
});
|
||||
break;
|
||||
}
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -178,17 +178,17 @@ void zmq_listener::handle_zmq() {
|
|||
while ( true ) {
|
||||
auto msg = receive_multipart();
|
||||
const auto header = std::string( static_cast<char*>( msg[0].data() ), msg[0].size() );
|
||||
const auto hash = boost::algorithm::hex( std::string( static_cast<char*>( msg[1].data() ), msg[1].size() ) );
|
||||
const auto block_hash = boost::algorithm::hex( std::string( static_cast<char*>( msg[1].data() ), msg[1].size() ) );
|
||||
|
||||
event_received( hash );
|
||||
event_received( block_hash );
|
||||
}
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
|
||||
sidechain_net_handler_bitcoin::sidechain_net_handler_bitcoin(const boost::program_options::variables_map& options) :
|
||||
sidechain_net_handler(options) {
|
||||
sidechain = sidechain_type::bitcoin;
|
||||
sidechain_net_handler_bitcoin::sidechain_net_handler_bitcoin(peerplays_sidechain_plugin &_plugin, const boost::program_options::variables_map& options) :
|
||||
sidechain_net_handler(plugin, options) {
|
||||
sidechain = sidechain_type::bitcoin;
|
||||
|
||||
ip = options.at("bitcoin-node-ip").as<std::string>();
|
||||
zmq_port = options.at("bitcoin-node-zmq-port").as<uint32_t>();
|
||||
|
|
@ -302,6 +302,9 @@ std::string sidechain_net_handler_bitcoin::send_transaction( const std::string&
|
|||
void sidechain_net_handler_bitcoin::handle_event( const std::string& event_data ) {
|
||||
ilog("peerplays sidechain plugin: sidechain_net_handler_bitcoin::handle_event");
|
||||
ilog(" event_data: ${event_data}", ("event_data", event_data));
|
||||
|
||||
update_tx_infos( event_data );
|
||||
|
||||
//update_tx_approvals();
|
||||
//update_estimated_fee();
|
||||
//update_tx_infos( block_hash );
|
||||
|
|
@ -315,7 +318,7 @@ std::vector<info_for_vin> sidechain_net_handler_bitcoin::extract_info_from_block
|
|||
|
||||
std::vector<info_for_vin> result;
|
||||
|
||||
const auto& addr_idx = get_user_sidechain_address_mapping();// db->get_index_type<bitcoin_address_index>().indices().get<by_address>();
|
||||
const auto& addr_idx = get_sidechain_addresses();// db->get_index_type<bitcoin_address_index>().indices().get<by_address>();
|
||||
|
||||
for (const auto& tx_child : block.get_child("tx")) {
|
||||
const auto& tx = tx_child.second;
|
||||
|
|
@ -327,14 +330,18 @@ std::vector<info_for_vin> sidechain_net_handler_bitcoin::extract_info_from_block
|
|||
|
||||
for (const auto& addr : script.get_child("addresses")) { // in which cases there can be more addresses?
|
||||
const auto address_base58 = addr.second.get_value<std::string>();
|
||||
ilog(" address_base58: ${address_base58}", ("address_base58", address_base58));
|
||||
|
||||
auto it = find(addr_idx.begin(), addr_idx.end(), address_base58);
|
||||
if (it == addr_idx.end()) continue;
|
||||
ilog(" address_base58 found: ${address_base58}", ("address_base58", address_base58));
|
||||
|
||||
info_for_vin vin;
|
||||
vin.out.hash_tx = tx.get_child("txid").get_value<std::string>();
|
||||
vin.out.amount = parse_amount( o.second.get_child( "value" ).get_value<std::string>() );
|
||||
ilog(" amount: ${amount}", ("amount", vin.out.amount));
|
||||
vin.out.n_vout = o.second.get_child( "n" ).get_value<uint32_t>();
|
||||
ilog(" n_vout: ${n_vout}", ("n_vout", vin.out.n_vout));
|
||||
vin.address = address_base58;
|
||||
result.push_back( vin );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@
|
|||
|
||||
namespace graphene { namespace peerplays_sidechain {
|
||||
|
||||
sidechain_net_manager::sidechain_net_manager() {
|
||||
sidechain_net_manager::sidechain_net_manager(peerplays_sidechain_plugin &_plugin) :
|
||||
plugin(_plugin)
|
||||
{
|
||||
ilog(__FUNCTION__);
|
||||
}
|
||||
|
||||
|
|
@ -20,7 +22,7 @@ bool sidechain_net_manager::create_handler(peerplays_sidechain::sidechain_type s
|
|||
|
||||
switch (sidechain) {
|
||||
case sidechain_type::bitcoin: {
|
||||
std::unique_ptr<sidechain_net_handler> h = std::unique_ptr<sidechain_net_handler>(new sidechain_net_handler_bitcoin(options));
|
||||
std::unique_ptr<sidechain_net_handler> h = std::unique_ptr<sidechain_net_handler>(new sidechain_net_handler_bitcoin(plugin, options));
|
||||
net_handlers.push_back(std::move(h));
|
||||
ret_val = true;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ else()
|
|||
endif()
|
||||
|
||||
add_library( graphene_wallet wallet.cpp ${CMAKE_CURRENT_BINARY_DIR}/api_documentation.cpp ${HEADERS} )
|
||||
target_link_libraries( graphene_wallet PRIVATE graphene_app graphene_net graphene_chain graphene_utilities fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
|
||||
target_link_libraries( graphene_wallet PRIVATE graphene_app graphene_net graphene_chain graphene_utilities fc peerplays_sidechain ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
|
||||
target_include_directories( graphene_db PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
|
||||
|
||||
if(MSVC)
|
||||
|
|
|
|||
|
|
@ -1368,6 +1368,89 @@ class wallet_api
|
|||
*/
|
||||
map<string, son_id_type> list_active_sons();
|
||||
|
||||
/** Adds sidechain address owned by the given account for a given sidechain.
|
||||
*
|
||||
* An account can have at most one sidechain address for one sidechain.
|
||||
*
|
||||
* @param account the name or id of the account who owns the address
|
||||
* @param sidechain a sidechain to whom address belongs
|
||||
* @param address sidechain address
|
||||
* @param private_key private key for sidechain address
|
||||
* @param public_key public key for sidechain address
|
||||
* @param broadcast true to broadcast the transaction on the network
|
||||
* @returns the signed transaction adding sidechain address
|
||||
*/
|
||||
signed_transaction add_sidechain_address(string account,
|
||||
peerplays_sidechain::sidechain_type sidechain,
|
||||
string address,
|
||||
string private_key,
|
||||
string public_key,
|
||||
bool broadcast = false);
|
||||
|
||||
/** Updates existing sidechain address owned by the given account for a given sidechain.
|
||||
*
|
||||
* Only address, private key and public key might be updated.
|
||||
*
|
||||
* @param account the name or id of the account who owns the address
|
||||
* @param sidechain a sidechain to whom address belongs
|
||||
* @param address sidechain address
|
||||
* @param private_key private key for sidechain address
|
||||
* @param public_key public key for sidechain address
|
||||
* @param broadcast true to broadcast the transaction on the network
|
||||
* @returns the signed transaction updating sidechain address
|
||||
*/
|
||||
signed_transaction update_sidechain_address(string account,
|
||||
peerplays_sidechain::sidechain_type sidechain,
|
||||
string address,
|
||||
string private_key,
|
||||
string public_key,
|
||||
bool broadcast = false);
|
||||
|
||||
/** Deletes existing sidechain address owned by the given account for a given sidechain.
|
||||
*
|
||||
* @param account the name or id of the account who owns the address
|
||||
* @param sidechain a sidechain to whom address belongs
|
||||
* @param broadcast true to broadcast the transaction on the network
|
||||
* @returns the signed transaction updating sidechain address
|
||||
*/
|
||||
signed_transaction delete_sidechain_address(string account,
|
||||
peerplays_sidechain::sidechain_type sidechain,
|
||||
bool broadcast = false);
|
||||
|
||||
/** Retrieves all sidechain addresses registered in the system.
|
||||
*
|
||||
* @returns the list of all sidechain addresses registered in the system
|
||||
*/
|
||||
vector<optional<sidechain_address_object>> get_all_sidechain_addresses ();
|
||||
|
||||
/** Retrieves all sidechain addresses owned by given account.
|
||||
*
|
||||
* @param account the name or id of the account who owns the address
|
||||
* @returns the list of all sidechain addresses owned by given account.
|
||||
*/
|
||||
vector<optional<sidechain_address_object>> get_sidechain_addresses_by_account(string account);
|
||||
|
||||
/** Retrieves all sidechain addresses registered for a given sidechain.
|
||||
*
|
||||
* @param sidechain the name of the sidechain
|
||||
* @returns the list of all sidechain addresses registered for a given sidechain.
|
||||
*/
|
||||
vector<optional<sidechain_address_object>> get_sidechain_addresses_by_sidechain(peerplays_sidechain::sidechain_type sidechain);
|
||||
|
||||
/** Retrieves sidechain address owned by given account for a given sidechain.
|
||||
*
|
||||
* @param account the name or id of the account who owns the address
|
||||
* @param sidechain the name of the sidechain
|
||||
* @returns the sidechain address owned by given account for a given sidechain.
|
||||
*/
|
||||
fc::optional<sidechain_address_object> get_sidechain_address_by_account_and_sidechain(string account, peerplays_sidechain::sidechain_type sidechain);
|
||||
|
||||
/** Retrieves the total number of sidechain addresses registered in the system.
|
||||
*
|
||||
* @returns the total number of sidechain addresses registered in the system.
|
||||
*/
|
||||
uint64_t get_sidechain_addresses_count();
|
||||
|
||||
/** Creates a witness object owned by the given account.
|
||||
*
|
||||
* An account can have at most one witness object.
|
||||
|
|
@ -2121,6 +2204,14 @@ FC_API( graphene::wallet::wallet_api,
|
|||
(update_son)
|
||||
(delete_son)
|
||||
(list_sons)
|
||||
(add_sidechain_address)
|
||||
(update_sidechain_address)
|
||||
(delete_sidechain_address)
|
||||
(get_all_sidechain_addresses)
|
||||
(get_sidechain_addresses_by_account)
|
||||
(get_sidechain_addresses_by_sidechain)
|
||||
(get_sidechain_address_by_account_and_sidechain)
|
||||
(get_sidechain_addresses_count)
|
||||
(create_witness)
|
||||
(update_witness)
|
||||
(create_worker)
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@
|
|||
#include <graphene/chain/rock_paper_scissors.hpp>
|
||||
|
||||
#include <graphene/bookie/bookie_api.hpp>
|
||||
#include <graphene/peerplays_sidechain/defs.hpp>
|
||||
|
||||
#include <graphene/chain/protocol/fee_schedule.hpp>
|
||||
#include <graphene/utilities/git_revision.hpp>
|
||||
|
|
@ -1954,6 +1955,73 @@ public:
|
|||
return result;
|
||||
} FC_CAPTURE_AND_RETHROW() }
|
||||
|
||||
signed_transaction add_sidechain_address(string account,
|
||||
peerplays_sidechain::sidechain_type sidechain,
|
||||
string address,
|
||||
string private_key,
|
||||
string public_key,
|
||||
bool broadcast /* = false */)
|
||||
{ try {
|
||||
account_id_type sidechain_address_account_id = get_account_id(account);
|
||||
|
||||
sidechain_address_add_operation op;
|
||||
op.sidechain_address_account = sidechain_address_account_id;
|
||||
op.sidechain = sidechain;
|
||||
op.address = address;
|
||||
op.private_key = private_key;
|
||||
op.public_key = public_key;
|
||||
|
||||
signed_transaction tx;
|
||||
tx.operations.push_back( op );
|
||||
set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees);
|
||||
tx.validate();
|
||||
|
||||
return sign_transaction( tx, broadcast );
|
||||
} FC_CAPTURE_AND_RETHROW() }
|
||||
|
||||
signed_transaction update_sidechain_address(string account,
|
||||
peerplays_sidechain::sidechain_type sidechain,
|
||||
string address,
|
||||
string private_key,
|
||||
string public_key,
|
||||
bool broadcast /* = false */)
|
||||
{ try {
|
||||
account_id_type sidechain_address_account_id = get_account_id(account);
|
||||
|
||||
sidechain_address_update_operation op;
|
||||
op.sidechain_address_account = sidechain_address_account_id;
|
||||
op.sidechain = sidechain;
|
||||
op.address = address;
|
||||
op.private_key = private_key;
|
||||
op.public_key = public_key;
|
||||
|
||||
signed_transaction tx;
|
||||
tx.operations.push_back( op );
|
||||
set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees);
|
||||
tx.validate();
|
||||
|
||||
return sign_transaction( tx, broadcast );
|
||||
} FC_CAPTURE_AND_RETHROW() }
|
||||
|
||||
signed_transaction delete_sidechain_address(string account,
|
||||
peerplays_sidechain::sidechain_type sidechain,
|
||||
bool broadcast /* = false */)
|
||||
{ try {
|
||||
account_id_type sidechain_address_account_id = get_account_id(account);
|
||||
|
||||
sidechain_address_delete_operation op;
|
||||
op.sidechain_address_account = sidechain_address_account_id;
|
||||
op.sidechain = sidechain;
|
||||
|
||||
signed_transaction tx;
|
||||
tx.operations.push_back( op );
|
||||
set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees);
|
||||
tx.validate();
|
||||
|
||||
return sign_transaction( tx, broadcast );
|
||||
|
||||
} FC_CAPTURE_AND_RETHROW() }
|
||||
|
||||
signed_transaction create_witness(string owner_account,
|
||||
string url,
|
||||
bool broadcast /* = false */)
|
||||
|
|
@ -4330,6 +4398,60 @@ map<string, son_id_type> wallet_api::list_active_sons()
|
|||
return my->list_active_sons();
|
||||
}
|
||||
|
||||
signed_transaction wallet_api::add_sidechain_address(string account,
|
||||
peerplays_sidechain::sidechain_type sidechain,
|
||||
string address,
|
||||
string private_key,
|
||||
string public_key,
|
||||
bool broadcast /* = false */)
|
||||
{
|
||||
return my->add_sidechain_address(account, sidechain, address, private_key, public_key, broadcast);
|
||||
}
|
||||
|
||||
signed_transaction wallet_api::update_sidechain_address(string account,
|
||||
peerplays_sidechain::sidechain_type sidechain,
|
||||
string address,
|
||||
string private_key,
|
||||
string public_key,
|
||||
bool broadcast /* = false */)
|
||||
{
|
||||
return my->update_sidechain_address(account, sidechain, address, private_key, public_key, broadcast);
|
||||
}
|
||||
|
||||
signed_transaction wallet_api::delete_sidechain_address(string account,
|
||||
peerplays_sidechain::sidechain_type sidechain,
|
||||
bool broadcast /* = false */)
|
||||
{
|
||||
return my->delete_sidechain_address(account, sidechain, broadcast);
|
||||
}
|
||||
|
||||
vector<optional<sidechain_address_object>> wallet_api::get_all_sidechain_addresses ()
|
||||
{
|
||||
return my->_remote_db->get_all_sidechain_addresses();
|
||||
}
|
||||
|
||||
vector<optional<sidechain_address_object>> wallet_api::get_sidechain_addresses_by_account(string account)
|
||||
{
|
||||
account_id_type account_id = get_account_id(account);
|
||||
return my->_remote_db->get_sidechain_addresses_by_account(account_id);
|
||||
}
|
||||
|
||||
vector<optional<sidechain_address_object>> wallet_api::get_sidechain_addresses_by_sidechain(peerplays_sidechain::sidechain_type sidechain)
|
||||
{
|
||||
return my->_remote_db->get_sidechain_addresses_by_sidechain(sidechain);
|
||||
}
|
||||
|
||||
fc::optional<sidechain_address_object> wallet_api::get_sidechain_address_by_account_and_sidechain(string account, peerplays_sidechain::sidechain_type sidechain)
|
||||
{
|
||||
account_id_type account_id = get_account_id(account);
|
||||
return my->_remote_db->get_sidechain_address_by_account_and_sidechain(account_id, sidechain);
|
||||
}
|
||||
|
||||
uint64_t wallet_api::get_sidechain_addresses_count()
|
||||
{
|
||||
return my->_remote_db->get_sidechain_addresses_count();
|
||||
}
|
||||
|
||||
signed_transaction wallet_api::create_witness(string owner_account,
|
||||
string url,
|
||||
bool broadcast /* = false */)
|
||||
|
|
|
|||
Loading…
Reference in a new issue