Merge branch 'pulls/970' into 970_merge
This commit is contained in:
commit
ef334651ab
7 changed files with 1427 additions and 2378 deletions
|
@ -3484,7 +3484,7 @@ TEST (rpc, wallet_create_fail)
|
|||
{
|
||||
system.poll ();
|
||||
}
|
||||
ASSERT_EQ ("Failed to create wallet. Increase lmdb_max_dbs in node config.", response.json.get<std::string> ("error"));
|
||||
ASSERT_EQ ("Failed to create wallet. Increase lmdb_max_dbs in node config", response.json.get<std::string> ("error"));
|
||||
}
|
||||
|
||||
TEST (rpc, wallet_ledger)
|
||||
|
|
|
@ -10,22 +10,42 @@ std::string nano::error_common_messages::message (int ev) const
|
|||
return "Account already exists";
|
||||
case nano::error_common::account_not_found:
|
||||
return "Account not found";
|
||||
case nano::error_common::account_not_found_wallet:
|
||||
return "Account not found in wallet";
|
||||
case nano::error_common::bad_account_number:
|
||||
return "Bad account number";
|
||||
case nano::error_common::bad_private_key:
|
||||
return "Bad private key";
|
||||
case nano::error_common::bad_public_key:
|
||||
return "Bad public key";
|
||||
case nano::error_common::bad_seed:
|
||||
return "Bad seed";
|
||||
case nano::error_common::bad_threshold:
|
||||
return "Bad threshold number";
|
||||
case nano::error_common::bad_wallet_number:
|
||||
return "Bad wallet number";
|
||||
case nano::error_common::bad_work_format:
|
||||
return "Bad work";
|
||||
case nano::error_common::invalid_work:
|
||||
return "Invalid work";
|
||||
case nano::error_common::insufficient_balance:
|
||||
return "Insufficient balance";
|
||||
case nano::error_common::invalid_amount:
|
||||
return "Invalid amount number";
|
||||
case nano::error_common::invalid_amount_big:
|
||||
return "Amount too big";
|
||||
case nano::error_common::invalid_count:
|
||||
return "Invalid count";
|
||||
case nano::error_common::invalid_ip_address:
|
||||
return "Invalid IP address";
|
||||
case nano::error_common::invalid_port:
|
||||
return "Invalid port";
|
||||
case nano::error_common::invalid_index:
|
||||
return "Invalid index";
|
||||
case nano::error_common::invalid_work:
|
||||
return "Invalid work";
|
||||
case nano::error_common::numeric_conversion:
|
||||
return "Numeric conversion error";
|
||||
case nano::error_common::wallet_lmdb_max_dbs:
|
||||
return "Failed to create wallet. Increase lmdb_max_dbs in node config";
|
||||
case nano::error_common::wallet_locked:
|
||||
return "Wallet is locked";
|
||||
case nano::error_common::wallet_not_found:
|
||||
|
@ -43,10 +63,108 @@ std::string nano::error_blocks_messages::message (int ev) const
|
|||
return "Unknown error";
|
||||
case nano::error_blocks::bad_hash_number:
|
||||
return "Bad hash number";
|
||||
case nano::error_blocks::invalid_block:
|
||||
return "Block is invalid";
|
||||
case nano::error_blocks::invalid_block_hash:
|
||||
return "Invalid block hash";
|
||||
case nano::error_blocks::invalid_type:
|
||||
return "Invalid block type";
|
||||
case nano::error_blocks::not_found:
|
||||
return "Block not found";
|
||||
case nano::error_blocks::work_low:
|
||||
return "Block work is less than threshold";
|
||||
}
|
||||
|
||||
return "Invalid error code";
|
||||
}
|
||||
|
||||
std::string nano::error_rpc_messages::message (int ev) const
|
||||
{
|
||||
switch (static_cast<nano::error_rpc> (ev))
|
||||
{
|
||||
case nano::error_rpc::generic:
|
||||
return "Unknown error";
|
||||
case nano::error_rpc::bad_destination:
|
||||
return "Bad destination account";
|
||||
case nano::error_rpc::bad_key:
|
||||
return "Bad key";
|
||||
case nano::error_rpc::bad_link:
|
||||
return "Bad link number";
|
||||
case nano::error_rpc::bad_previous:
|
||||
return "Bad previous";
|
||||
case nano::error_rpc::bad_representative_number:
|
||||
return "Bad representative number";
|
||||
case nano::error_rpc::bad_source:
|
||||
return "Bad source";
|
||||
case nano::error_rpc::bad_timeout:
|
||||
return "Bad timeout number";
|
||||
case nano::error_rpc::block_create_balance_mismatch:
|
||||
return "Balance mismatch for previous block";
|
||||
case nano::error_rpc::block_create_key_required:
|
||||
return "Private key or local wallet and account required";
|
||||
case nano::error_rpc::block_create_public_key_mismatch:
|
||||
return "Incorrect key for given account";
|
||||
case nano::error_rpc::block_create_requirements_state:
|
||||
return "Previous, representative, final balance and link (source or destination) are required";
|
||||
case nano::error_rpc::block_create_requirements_open:
|
||||
return "Representative account and source hash required";
|
||||
case nano::error_rpc::block_create_requirements_receive:
|
||||
return "Previous hash and source hash required";
|
||||
case nano::error_rpc::block_create_requirements_change:
|
||||
return "Representative account and previous hash required";
|
||||
case nano::error_rpc::block_create_requirements_send:
|
||||
return "Destination account, previous hash, current balance and amount required";
|
||||
case nano::error_rpc::invalid_balance:
|
||||
return "Invalid balance number";
|
||||
case nano::error_rpc::invalid_destinations:
|
||||
return "Invalid destinations number";
|
||||
case nano::error_rpc::invalid_offset:
|
||||
return "Invalid offset";
|
||||
case nano::error_rpc::invalid_missing_type:
|
||||
return "Invalid or missing type argument";
|
||||
case nano::error_rpc::invalid_sources:
|
||||
return "Invalid sources number";
|
||||
case nano::error_rpc::payment_account_balance:
|
||||
return "Account has non-zero balance";
|
||||
case nano::error_rpc::payment_unable_create_account:
|
||||
return "Unable to create transaction account";
|
||||
case nano::error_rpc::rpc_control_disabled:
|
||||
return "RPC control is disabled";
|
||||
case nano::error_rpc::source_not_found:
|
||||
return "Source not found";
|
||||
}
|
||||
|
||||
return "Invalid error code";
|
||||
}
|
||||
|
||||
std::string nano::error_process_messages::message (int ev) const
|
||||
{
|
||||
switch (static_cast<nano::error_process> (ev))
|
||||
{
|
||||
case nano::error_process::generic:
|
||||
return "Unknown error";
|
||||
case nano::error_process::bad_signature:
|
||||
return "Bad signature";
|
||||
case nano::error_process::old:
|
||||
return "Old block";
|
||||
case nano::error_process::negative_spend:
|
||||
return "Negative spend";
|
||||
case nano::error_process::fork:
|
||||
return "Fork";
|
||||
case nano::error_process::unreceivable:
|
||||
return "Unreceivable";
|
||||
case nano::error_process::gap_previous:
|
||||
return "Gap previous block";
|
||||
case nano::error_process::gap_source:
|
||||
return "Gap source block";
|
||||
case nano::error_process::opened_burn_account:
|
||||
return "Burning account";
|
||||
case nano::error_process::balance_mismatch:
|
||||
return "Balance and amount delta do not match";
|
||||
case nano::error_process::block_position:
|
||||
return "This block cannot follow the previous block";
|
||||
case nano::error_process::other:
|
||||
"Error processing block";
|
||||
}
|
||||
|
||||
return "Invalid error code";
|
||||
|
|
|
@ -29,15 +29,25 @@ enum class error_common
|
|||
{
|
||||
generic = 1,
|
||||
account_not_found,
|
||||
account_not_found_wallet,
|
||||
account_exists,
|
||||
bad_account_number,
|
||||
bad_private_key,
|
||||
bad_public_key,
|
||||
bad_seed,
|
||||
bad_threshold,
|
||||
bad_wallet_number,
|
||||
bad_work_format,
|
||||
invalid_work,
|
||||
invalid_amount,
|
||||
invalid_amount_big,
|
||||
invalid_count,
|
||||
invalid_index,
|
||||
invalid_ip_address,
|
||||
invalid_port,
|
||||
invalid_work,
|
||||
insufficient_balance,
|
||||
numeric_conversion,
|
||||
wallet_lmdb_max_dbs,
|
||||
wallet_locked,
|
||||
wallet_not_found
|
||||
};
|
||||
|
@ -47,8 +57,58 @@ enum class error_blocks
|
|||
{
|
||||
generic = 1,
|
||||
bad_hash_number,
|
||||
invalid_block,
|
||||
invalid_block_hash,
|
||||
not_found
|
||||
invalid_type,
|
||||
not_found,
|
||||
work_low
|
||||
};
|
||||
|
||||
/** RPC related errors */
|
||||
enum class error_rpc
|
||||
{
|
||||
generic = 1,
|
||||
bad_destination,
|
||||
bad_key,
|
||||
bad_link,
|
||||
bad_previous,
|
||||
bad_representative_number,
|
||||
bad_source,
|
||||
bad_timeout,
|
||||
block_create_balance_mismatch,
|
||||
block_create_key_required,
|
||||
block_create_public_key_mismatch,
|
||||
block_create_requirements_state,
|
||||
block_create_requirements_open,
|
||||
block_create_requirements_receive,
|
||||
block_create_requirements_change,
|
||||
block_create_requirements_send,
|
||||
invalid_balance,
|
||||
invalid_destinations,
|
||||
invalid_offset,
|
||||
invalid_missing_type,
|
||||
invalid_sources,
|
||||
payment_account_balance,
|
||||
payment_unable_create_account,
|
||||
rpc_control_disabled,
|
||||
source_not_found
|
||||
};
|
||||
|
||||
/** process_result related errors */
|
||||
enum class error_process
|
||||
{
|
||||
generic = 1,
|
||||
bad_signature, // Signature was bad, forged or transmission error
|
||||
old, // Already seen and was valid
|
||||
negative_spend, // Malicious attempt to spend a negative amount
|
||||
fork, // Malicious fork based on previous
|
||||
unreceivable, // Source block doesn't exist or has already been received
|
||||
gap_previous, // Block marked as previous is unknown
|
||||
gap_source, // Block marked as source is unknown
|
||||
opened_burn_account, // The impossible happened, someone found the private key associated with the public key '0'.
|
||||
balance_mismatch, // Balance and amount delta don't match
|
||||
block_position, // This block cannot follow the previous block
|
||||
other
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -95,3 +155,5 @@ enum class error_blocks
|
|||
|
||||
REGISTER_ERROR_CODES (nano, error_common);
|
||||
REGISTER_ERROR_CODES (nano, error_blocks);
|
||||
REGISTER_ERROR_CODES (nano, error_rpc);
|
||||
REGISTER_ERROR_CODES (nano, error_process);
|
||||
|
|
|
@ -422,6 +422,13 @@ void rai::deterministic_key (rai::uint256_union const & seed_a, uint32_t index_a
|
|||
blake2b_final (&hash, prv_a.bytes.data (), prv_a.bytes.size ());
|
||||
}
|
||||
|
||||
rai::public_key rai::pub_key (rai::private_key const & privatekey_a)
|
||||
{
|
||||
rai::uint256_union result;
|
||||
ed25519_publickey (privatekey_a.bytes.data (), result.bytes.data ());
|
||||
return result;
|
||||
}
|
||||
|
||||
bool rai::validate_message (rai::public_key const & public_key, rai::uint256_union const & message, rai::uint512_union const & signature)
|
||||
{
|
||||
auto result (0 != ed25519_sign_open (message.bytes.data (), sizeof (message.bytes), public_key.bytes.data (), signature.bytes.data ()));
|
||||
|
|
|
@ -121,6 +121,7 @@ using signature = uint512_union;
|
|||
rai::uint512_union sign_message (rai::raw_key const &, rai::public_key const &, rai::uint256_union const &);
|
||||
bool validate_message (rai::public_key const &, rai::uint256_union const &, rai::uint512_union const &);
|
||||
void deterministic_key (rai::uint256_union const &, uint32_t, rai::uint256_union &);
|
||||
rai::public_key pub_key (rai::private_key const &);
|
||||
}
|
||||
|
||||
namespace std
|
||||
|
|
3582
rai/node/rpc.cpp
3582
rai/node/rpc.cpp
File diff suppressed because it is too large
Load diff
|
@ -144,7 +144,7 @@ public:
|
|||
void block_hash ();
|
||||
void bootstrap ();
|
||||
void bootstrap_any ();
|
||||
void chain ();
|
||||
void chain (bool = false);
|
||||
void confirmation_history ();
|
||||
void delegators ();
|
||||
void delegators_count ();
|
||||
|
@ -154,14 +154,12 @@ public:
|
|||
void keepalive ();
|
||||
void key_create ();
|
||||
void key_expand ();
|
||||
void krai_to_raw ();
|
||||
void krai_from_raw ();
|
||||
void ledger ();
|
||||
void mrai_to_raw ();
|
||||
void mrai_from_raw ();
|
||||
void mrai_to_raw (rai::uint128_t = rai::Mxrb_ratio);
|
||||
void mrai_from_raw (rai::uint128_t = rai::Mxrb_ratio);
|
||||
void password_change ();
|
||||
void password_enter ();
|
||||
void password_valid (bool wallet_locked);
|
||||
void password_valid (bool = false);
|
||||
void payment_begin ();
|
||||
void payment_init ();
|
||||
void payment_end ();
|
||||
|
@ -170,8 +168,6 @@ public:
|
|||
void pending ();
|
||||
void pending_exists ();
|
||||
void process ();
|
||||
void rai_to_raw ();
|
||||
void rai_from_raw ();
|
||||
void receive ();
|
||||
void receive_minimum ();
|
||||
void receive_minimum_set ();
|
||||
|
@ -183,7 +179,6 @@ public:
|
|||
void send ();
|
||||
void stats ();
|
||||
void stop ();
|
||||
void successors ();
|
||||
void unchecked ();
|
||||
void unchecked_clear ();
|
||||
void unchecked_get ();
|
||||
|
@ -222,6 +217,18 @@ public:
|
|||
rai::rpc & rpc;
|
||||
boost::property_tree::ptree request;
|
||||
std::function<void(boost::property_tree::ptree const &)> response;
|
||||
void response_errors ();
|
||||
std::error_code ec;
|
||||
boost::property_tree::ptree response_l;
|
||||
std::shared_ptr<rai::wallet> wallet_impl ();
|
||||
rai::account account_impl (std::string = "");
|
||||
rai::amount amount_impl ();
|
||||
rai::block_hash hash_impl (std::string = "hash");
|
||||
rai::amount threshold_optional_impl ();
|
||||
uint64_t work_optional_impl ();
|
||||
uint64_t count_impl ();
|
||||
uint64_t count_optional_impl (uint64_t = std::numeric_limits<uint64_t>::max ());
|
||||
bool rpc_control_impl ();
|
||||
};
|
||||
/** Returns the correct RPC implementation based on TLS configuration */
|
||||
std::unique_ptr<rai::rpc> get_rpc (boost::asio::io_service & service_a, rai::node & node_a, rai::rpc_config const & config_a);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue