From 761aae4bf8272667ba80c11a23659a275ee933b0 Mon Sep 17 00:00:00 2001 From: abitmore Date: Sun, 23 Oct 2022 21:49:21 +0000 Subject: [PATCH 01/13] Update default version of pts_address to constexpr --- libraries/app/database_api.cpp | 4 ++-- libraries/chain/balance_evaluator.cpp | 11 +++++++---- .../include/graphene/protocol/pts_address.hpp | 11 ++++++++--- libraries/protocol/transaction.cpp | 8 ++++---- libraries/wallet/wallet_account.cpp | 4 ++-- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index ddd96aace9..3e1bcfa1ca 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -411,8 +411,8 @@ vector> database_api_impl::get_key_references( vector< for( auto& key : keys ) { - address a1( pts_address(key, false, 56) ); - address a2( pts_address(key, true, 56) ); + address a1( pts_address(key, false) ); // version = 56 (default) + address a2( pts_address(key, true) ); // version = 56 (default) address a3( pts_address(key, false, 0) ); address a4( pts_address(key, true, 0) ); address a5( key ); diff --git a/libraries/chain/balance_evaluator.cpp b/libraries/chain/balance_evaluator.cpp index 7c8b8b3ff1..2d0c4810bf 100644 --- a/libraries/chain/balance_evaluator.cpp +++ b/libraries/chain/balance_evaluator.cpp @@ -31,12 +31,15 @@ void_result balance_claim_evaluator::do_evaluate(const balance_claim_operation& database& d = db(); balance = &op.balance_to_claim(d); - GRAPHENE_ASSERT( + bool is_balance_owner_match = ( op.balance_owner_key == balance->owner || - pts_address(op.balance_owner_key, false, 56) == balance->owner || - pts_address(op.balance_owner_key, true, 56) == balance->owner || + pts_address(op.balance_owner_key, false) == balance->owner || // version = 56 (default) + pts_address(op.balance_owner_key, true) == balance->owner ); // version = 56 (default) + is_balance_owner_match = ( + is_balance_owner_match || pts_address(op.balance_owner_key, false, 0) == balance->owner || - pts_address(op.balance_owner_key, true, 0) == balance->owner, + pts_address(op.balance_owner_key, true, 0) == balance->owner ); + GRAPHENE_ASSERT( is_balance_owner_match, balance_claim_owner_mismatch, "Balance owner key was specified as '${op}' but balance's actual owner is '${bal}'", ("op", op.balance_owner_key) diff --git a/libraries/protocol/include/graphene/protocol/pts_address.hpp b/libraries/protocol/include/graphene/protocol/pts_address.hpp index 0a6e4cccea..6806832fb8 100644 --- a/libraries/protocol/include/graphene/protocol/pts_address.hpp +++ b/libraries/protocol/include/graphene/protocol/pts_address.hpp @@ -40,14 +40,19 @@ namespace graphene { namespace protocol { */ struct pts_address { + static constexpr uint8_t default_version = 56; + pts_address(); ///< constructs empty / null address - pts_address( const std::string& base58str ); ///< converts to binary, validates checksum - pts_address( const fc::ecc::public_key& pub, bool compressed = true, uint8_t version=56 ); ///< converts to binary + explicit pts_address( const std::string& base58str ); ///< converts to binary, validates checksum + /// Constructs from a public key + explicit pts_address( const fc::ecc::public_key& pub, + bool compressed = true, + uint8_t version = default_version ); uint8_t version()const { return addr.at(0); } bool is_valid()const; - operator std::string()const; ///< converts to base58 + checksum + explicit operator std::string()const; ///< converts to base58 + checksum std::array addr{}; ///< binary representation of address, 0-initialized }; diff --git a/libraries/protocol/transaction.cpp b/libraries/protocol/transaction.cpp index 82f5111e5a..2f1120650c 100644 --- a/libraries/protocol/transaction.cpp +++ b/libraries/protocol/transaction.cpp @@ -140,15 +140,15 @@ struct sign_state available_address_sigs = std::map(); provided_address_sigs = std::map(); for( auto& item : available_keys ) { - (*available_address_sigs)[ address(pts_address(item, false, 56) ) ] = item; - (*available_address_sigs)[ address(pts_address(item, true, 56) ) ] = item; + (*available_address_sigs)[ address(pts_address(item, false) ) ] = item; // verison = 56 (default) + (*available_address_sigs)[ address(pts_address(item, true) ) ] = item; // verison = 56 (default) (*available_address_sigs)[ address(pts_address(item, false, 0) ) ] = item; (*available_address_sigs)[ address(pts_address(item, true, 0) ) ] = item; (*available_address_sigs)[ address(item) ] = item; } for( auto& item : provided_signatures ) { - (*provided_address_sigs)[ address(pts_address(item.first, false, 56) ) ] = item.first; - (*provided_address_sigs)[ address(pts_address(item.first, true, 56) ) ] = item.first; + (*provided_address_sigs)[ address(pts_address(item.first, false) ) ] = item.first; //verison 56 (default) + (*provided_address_sigs)[ address(pts_address(item.first, true) ) ] = item.first; // verison 56 (default) (*provided_address_sigs)[ address(pts_address(item.first, false, 0) ) ] = item.first; (*provided_address_sigs)[ address(pts_address(item.first, true, 0) ) ] = item.first; (*provided_address_sigs)[ address(item.first) ] = item.first; diff --git a/libraries/wallet/wallet_account.cpp b/libraries/wallet/wallet_account.cpp index 4b8f123f20..68631120ab 100644 --- a/libraries/wallet/wallet_account.cpp +++ b/libraries/wallet/wallet_account.cpp @@ -346,9 +346,9 @@ namespace graphene { namespace wallet { namespace detail { addrs.push_back( address(pk) ); keys[addrs.back()] = *key; // see chain/balance_evaluator.cpp - addrs.push_back( address( pts_address( pk, false, 56 ) ) ); + addrs.push_back( address( pts_address( pk, false ) ) ); // version = 56 (default) keys[addrs.back()] = *key; - addrs.push_back( address( pts_address( pk, true, 56 ) ) ); + addrs.push_back( address( pts_address( pk, true ) ) ); // version = 56 (default) keys[addrs.back()] = *key; addrs.push_back( address( pts_address( pk, false, 0 ) ) ); keys[addrs.back()] = *key; From 40cc62c9adf0a84cc994c015b0ba0a0bb825176b Mon Sep 17 00:00:00 2001 From: abitmore Date: Sun, 23 Oct 2022 22:28:25 +0000 Subject: [PATCH 02/13] Update most functions of wallet_api class to const --- .../wallet/include/graphene/wallet/wallet.hpp | 235 +++++++++--------- libraries/wallet/wallet.cpp | 212 ++++++++-------- 2 files changed, 225 insertions(+), 222 deletions(-) diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index 1cd1b1976d..657d06d9b4 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -50,10 +50,15 @@ object* create_object( const variant& v ); class wallet_api { public: + // Variables + fc::signal lock_changed; + std::shared_ptr my; + + // Methods wallet_api( const wallet_data& initial_data, fc::api rapi ); virtual ~wallet_api(); - bool copy_wallet_file( string destination_filename ); + bool copy_wallet_file( string destination_filename )const; fc::ecc::private_key derive_private_key(const std::string& prefix_string, int sequence_number) const; @@ -61,7 +66,7 @@ class wallet_api * committee members. * @returns runtime info about the blockchain */ - variant info(); + variant info()const; /** Returns info such as client version, git version of graphene/fc, version of boost, openssl. * @returns compile time info and client and dependencies versions */ @@ -70,7 +75,7 @@ class wallet_api * @param num height of the block to retrieve * @returns info about the block, or null if not found */ - optional get_block( uint32_t num ); + optional get_block( uint32_t num )const; /** Returns the number of accounts registered on the blockchain * @returns the number of registered accounts */ @@ -80,7 +85,7 @@ class wallet_api * we possess. * @returns a list of account objects */ - vector list_my_accounts(); + vector list_my_accounts()const; /** Lists all accounts registered in the blockchain. * This returns a list of all account names and their account ids, sorted by account name. * @@ -93,7 +98,7 @@ class wallet_api * @param limit the maximum number of accounts to return (max: 1000) * @returns a list of accounts mapping account names to account ids */ - map list_accounts(const string& lowerbound, uint32_t limit); + map list_accounts(const string& lowerbound, uint32_t limit)const; /** List the balances of an account. * Each account can have multiple balances, one for each type of asset owned by that * account. The returned list will only contain assets for which the account has a @@ -101,7 +106,7 @@ class wallet_api * @param account_name_or_id the name or id of the account whose balances you want * @returns a list of the given account's balances */ - vector list_account_balances(const string& account_name_or_id); + vector list_account_balances(const string& account_name_or_id)const; /** Lists all assets registered on the blockchain. * * To list all assets, pass the empty string \c "" for the lowerbound to start @@ -148,7 +153,7 @@ class wallet_api * of \c name_or_id cannot be tied to an account, that input will be ignored. * */ - full_account get_full_account( const string& name_or_id ); + full_account get_full_account( const string& name_or_id )const; /** * @brief Get OHLCV data of a trading pair in a time range @@ -176,7 +181,7 @@ class wallet_api * * @note * 1. if \c name_or_id cannot be tied to an account, empty result will be returned - * 2. \c ostart_id and \c ostart_price can be \c null, if so the api will return the "first page" of orders; + * 2. \c ostart_id and \c ostart_price can be \c null, if so the api will return the "first page" of orders. * if \c ostart_id is specified and valid, its price will be used to do page query preferentially, * otherwise the \c ostart_price will be used */ @@ -185,7 +190,7 @@ class wallet_api const string "e, uint32_t limit = 101, optional ostart_id = optional(), - optional ostart_price = optional()); + optional ostart_price = optional())const; /** * @brief Get limit orders in a given market @@ -243,7 +248,7 @@ class wallet_api */ account_history_operation_detail get_account_history_by_operations( const string& account_name_or_id, const flat_set& operation_types, - uint32_t start, uint32_t limit); + uint32_t start, uint32_t limit)const; /** Returns the block chain's rapidly-changing properties. * The returned object contains information that changes every block interval @@ -353,7 +358,7 @@ class wallet_api * Create a new transaction builder. * @return handle of the new transaction builder */ - transaction_handle_type begin_builder_transaction(); + transaction_handle_type begin_builder_transaction()const; /** * @ingroup Transaction Builder API * @@ -361,7 +366,7 @@ class wallet_api * @param transaction_handle handle of the transaction builder * @param op the operation in JSON format */ - void add_operation_to_builder_transaction(transaction_handle_type transaction_handle, const operation& op); + void add_operation_to_builder_transaction(transaction_handle_type transaction_handle, const operation& op)const; /** * @ingroup Transaction Builder API * @@ -372,7 +377,7 @@ class wallet_api */ void replace_operation_in_builder_transaction(transaction_handle_type handle, unsigned operation_index, - const operation& new_op); + const operation& new_op)const; /** * @ingroup Transaction Builder API * @@ -381,7 +386,7 @@ class wallet_api * @param fee_asset symbol or ID of an asset that to be used to pay fees * @return total fees */ - asset set_fees_on_builder_transaction(transaction_handle_type handle, string fee_asset = GRAPHENE_SYMBOL); + asset set_fees_on_builder_transaction(transaction_handle_type handle, string fee_asset = GRAPHENE_SYMBOL)const; /** * @ingroup Transaction Builder API * @@ -389,7 +394,7 @@ class wallet_api * @param handle handle of the transaction builder * @return a transaction */ - transaction preview_builder_transaction(transaction_handle_type handle); + transaction preview_builder_transaction(transaction_handle_type handle)const; /** * @ingroup Transaction Builder API * @@ -398,7 +403,8 @@ class wallet_api * @param broadcast whether to broadcast the signed transaction to the network * @return a signed transaction */ - signed_transaction sign_builder_transaction(transaction_handle_type transaction_handle, bool broadcast = true); + signed_transaction sign_builder_transaction(transaction_handle_type transaction_handle, + bool broadcast = true)const; /** * @ingroup Transaction Builder API @@ -410,14 +416,14 @@ class wallet_api * @return a signed transaction */ signed_transaction sign_builder_transaction2(transaction_handle_type transaction_handle, - const vector& signing_keys = vector(), - bool broadcast = true); + const vector& signing_keys = vector(), + bool broadcast = true)const; /** Broadcast signed transaction * @param tx signed transaction * @returns the transaction ID along with the signed transaction. */ - pair broadcast_transaction(signed_transaction tx); + pair broadcast_transaction(signed_transaction tx)const; /** * @ingroup Transaction Builder API @@ -440,7 +446,7 @@ class wallet_api time_point_sec expiration = time_point::now() + fc::minutes(1), uint32_t review_period_seconds = 0, bool broadcast = true - ); + )const; /** * @ingroup Transaction Builder API @@ -462,7 +468,7 @@ class wallet_api time_point_sec expiration = time_point::now() + fc::minutes(1), uint32_t review_period_seconds = 0, bool broadcast = true - ); + )const; /** * @ingroup Transaction Builder API @@ -470,7 +476,7 @@ class wallet_api * Destroy a transaction builder. * @param handle handle of the transaction builder */ - void remove_builder_transaction(transaction_handle_type handle); + void remove_builder_transaction(transaction_handle_type handle)const; /** Checks whether the wallet has just been created and has not yet had a password set. * @@ -491,7 +497,7 @@ class wallet_api /** Locks the wallet immediately. * @ingroup Wallet Management */ - void lock(); + void lock()const; /** Unlocks the wallet. * @@ -504,7 +510,7 @@ class wallet_api * @param password the password previously set with \c set_password() * @ingroup Wallet Management */ - void unlock(string password); + void unlock(string password)const; /** Sets a new password on the wallet. * @@ -517,7 +523,7 @@ class wallet_api * @param password a new password * @ingroup Wallet Management */ - void set_password(string password); + void set_password(string password)const; /** Dumps all private keys owned by the wallet. * @@ -525,7 +531,7 @@ class wallet_api * using \c import_key() * @returns a map containing the private keys, indexed by their public key */ - map dump_private_keys(); + map dump_private_keys()const; /** Returns a list of all commands supported by the wallet API. * @@ -555,13 +561,13 @@ class wallet_api * existing wallet file * @returns true if the specified wallet is loaded */ - bool load_wallet_file(string wallet_filename = ""); + bool load_wallet_file(string wallet_filename = "")const; /** Quit from the wallet. * * The current wallet will be closed and saved. */ - void quit(); + void quit()const; /** Saves the current wallet to the given filename. * @@ -573,7 +579,7 @@ class wallet_api * or overwrite. If \c wallet_filename is empty, * save to the current filename. */ - void save_wallet_file(string wallet_filename = ""); + void save_wallet_file(string wallet_filename = "")const; /** Sets the wallet filename used for future writes. * @@ -582,7 +588,7 @@ class wallet_api * * @param wallet_filename the new filename to use for future saves */ - void set_wallet_filename(string wallet_filename); + void set_wallet_filename(string wallet_filename)const; /** Suggests a safe brain key to use for creating your account. * \c create_account_with_brain_key() requires you to specify a 'brain key', @@ -636,7 +642,7 @@ class wallet_api * @param wif_key the private key in WIF format * @returns true if the key was imported */ - bool import_key(string account_name_or_id, string wif_key); + bool import_key(string account_name_or_id, string wif_key)const; /** Imports accounts from a BitShares 0.x wallet file. * Current wallet file must be unlocked to perform the import. @@ -645,7 +651,7 @@ class wallet_api * @param password the password to encrypt the BitShares 0.x wallet file * @returns a map containing the accounts found and whether imported */ - map import_accounts( string filename, string password ); + map import_accounts( string filename, string password )const; /** Imports from a BitShares 0.x wallet file, find keys that were bound to a given account name on the * BitShares 0.x chain, rebind them to an account name on the 2.0 chain. @@ -658,7 +664,8 @@ class wallet_api * can be same or different to \c src_account_name * @returns whether the import has succeeded */ - bool import_account_keys( string filename, string password, string src_account_name, string dest_account_name ); + bool import_account_keys( string filename, string password, + string src_account_name, string dest_account_name )const; /** * This call will construct transaction(s) that will claim all balances controled @@ -669,7 +676,7 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network */ vector< signed_transaction > import_balance( string account_name_or_id, const vector& wif_keys, - bool broadcast ); + bool broadcast )const; /** Transforms a brain key to reduce the chance of errors when re-entering the key from memory. * @@ -691,7 +698,7 @@ class wallet_api * @see create_account_with_brain_key() * * @param name the name of the account, must be unique on the blockchain. Shorter names - * are more expensive to register; the rules are still in flux, but in general + * are more expensive to register. The rules are still in flux, but in general * names of more than 8 characters with at least one digit will be cheap. * @param owner the owner key for the new account * @param active the active key for the new account @@ -701,7 +708,7 @@ class wallet_api * same as the registrar_account if there is no referrer. * @param referrer_percent the percentage (0 - 100) of the new user's transaction fees * not claimed by the blockchain that will be distributed to the - * referrer; the rest will be sent to the registrar. Will be + * referrer, the rest will be sent to the registrar. Will be * multiplied by GRAPHENE_1_PERCENT when constructing the transaction. * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction registering the account @@ -712,7 +719,7 @@ class wallet_api string registrar_account, string referrer_account, uint32_t referrer_percent, - bool broadcast = false); + bool broadcast = false)const; /** * Upgrades an account to prime status. @@ -722,7 +729,7 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction upgrading the account */ - signed_transaction upgrade_account(string account_name_or_id, bool broadcast); + signed_transaction upgrade_account(string account_name_or_id, bool broadcast)const; /** Creates a new account and registers it on the blockchain. * @@ -748,7 +755,7 @@ class wallet_api string account_name, string registrar_account, string referrer_account, - bool broadcast = false); + bool broadcast = false)const; /** Transfer an amount from one account to another. * @param from the name or id of the account sending the funds @@ -767,7 +774,7 @@ class wallet_api string amount, string asset_symbol_or_id, string memo, - bool broadcast = false); + bool broadcast = false)const; /** * This method works just like transfer, except it always broadcasts and @@ -786,7 +793,7 @@ class wallet_api const string& to, const string& amount, const string& asset_symbol_or_id, - const string& memo ) { + const string& memo ) const { auto trx = transfer( from, to, amount, asset_symbol_or_id, memo, true ); return std::make_pair(trx.id(),trx); } @@ -807,24 +814,24 @@ class wallet_api * @param memo text to sign * @return the signed memo data */ - memo_data sign_memo(string from, string to, string memo); + memo_data sign_memo(string from, string to, string memo)const; /** Read a memo. * * @param memo JSON-encoded memo. * @returns string with decrypted message. */ - string read_memo(const memo_data& memo); + string read_memo(const memo_data& memo)const; /** Sign a message using an account's memo key. The signature is generated as in - * in https://github.com/xeroc/python-graphenelib/blob/d9634d74273ebacc92555499eca7c444217ecba0/graphenecommon/message.py#L64 . + * https://github.com/xeroc/python-graphenelib/blob/d9634d74273ebacc92555499eca7c444217ecba0/graphenecommon/message.py#L64 . * * @param signer the name or id of signing account * @param message text to sign * @return the signed message in an abstract format */ - signed_message sign_message(string signer, string message); + signed_message sign_message(string signer, string message)const; /** Verify a message signed with sign_message using the given account's memo key. * @@ -836,21 +843,21 @@ class wallet_api * @return true if signature matches */ bool verify_message( const string& message, const string& account, int32_t block, const string& msg_time, - const fc::ecc::compact_signature& sig ); + const fc::ecc::compact_signature& sig )const; /** Verify a message signed with sign_message * * @param message the signed_message structure containing message, meta data and signature * @return true if signature matches */ - bool verify_signed_message( signed_message message ); + bool verify_signed_message( signed_message message )const; /** Verify a message signed with sign_message, in its encapsulated form. * * @param message the complete encapsulated message string including separators and line feeds * @return true if signature matches */ - bool verify_encapsulated_message( string message ); + bool verify_encapsulated_message( string message )const; /** These methods are used for stealth transfers */ ///@{ @@ -862,7 +869,7 @@ class wallet_api * @param label a user-defined string as label * @return true if the label was set, otherwise false */ - bool set_key_label( public_key_type key, string label ); + bool set_key_label( public_key_type key, string label )const; /** * Get label of a public key. @@ -877,7 +884,7 @@ class wallet_api * @param brain_key the brain key to be used to generate a new blind account * @return the public key of the new account */ - public_key_type create_blind_account( string label, string brain_key ); + public_key_type create_blind_account( string label, string brain_key )const; /** * Return the total balances of all blinded commitments that can be claimed by the @@ -886,7 +893,7 @@ class wallet_api * @return the total balances of all blinded commitments that can be claimed by the * given account key or label */ - vector get_blind_balances( string key_or_label ); + vector get_blind_balances( string key_or_label )const; /** * Get all blind accounts. * @return all blind accounts @@ -910,7 +917,7 @@ class wallet_api * @param key_or_account a public key in Base58 format or an account * @return all blind receipts to/form the account */ - vector blind_history( string key_or_account ); + vector blind_history( string key_or_account )const; /** * Given a confirmation receipt, this method will parse it for a blinded balance and confirm @@ -923,7 +930,7 @@ class wallet_api * @param opt_memo a self-defined label for this transfer to be saved in local wallet file * @return a blind receipt */ - blind_receipt receive_blind_transfer( string confirmation_receipt, string opt_from, string opt_memo ); + blind_receipt receive_blind_transfer( string confirmation_receipt, string opt_from, string opt_memo )const; /** * Transfers a public balance from \c from_account_name_or_id to one or more blinded balances using a @@ -937,7 +944,7 @@ class wallet_api blind_confirmation transfer_to_blind( string from_account_name_or_id, string asset_symbol_or_id, vector> to_amounts, - bool broadcast = false ); + bool broadcast = false )const; /** * Transfers funds from a set of blinded balances to a public account balance. @@ -953,7 +960,7 @@ class wallet_api string to_account_name_or_id, string amount, string asset_symbol_or_id, - bool broadcast = false ); + bool broadcast = false )const; /** * Transfer from one set of blinded balances to another. @@ -968,11 +975,11 @@ class wallet_api string to_key_or_label, string amount, string symbol_or_id, - bool broadcast = false ); + bool broadcast = false )const; /** Place a limit order attempting to sell one asset for another. * - * Buying and selling are the same operation on BitShares; if you want to buy BTS + * Buying and selling are the same operation on BitShares. If you want to buy BTS * with USD, you should sell USD for BTS. * * The blockchain will attempt to sell the \c symbol_or_id_to_sell for as @@ -1004,7 +1011,7 @@ class wallet_api * cancelled and the un-spent funds are returned to the seller's * account * @param fill_or_kill if true, the order will only be included in the blockchain - * if it is filled immediately; if false, an open order will be + * if it is filled immediately. if false, an open order will be * left on the books to fill any amount that cannot be filled * immediately. * @param broadcast true to broadcast the transaction on the network @@ -1017,7 +1024,7 @@ class wallet_api string symbol_or_id_to_receive, uint32_t timeout_sec = 0, bool fill_or_kill = false, - bool broadcast = false); + bool broadcast = false)const; /** Borrow an asset or update the debt/collateral ratio for the loan. * @@ -1034,7 +1041,7 @@ class wallet_api * @returns the signed transaction borrowing the asset */ signed_transaction borrow_asset(string borrower, string amount_to_borrow, string asset_symbol_or_id, - string amount_of_collateral, bool broadcast = false); + string amount_of_collateral, bool broadcast = false)const; /** Borrow an asset or update the debt/collateral ratio for the loan, with additional options. * @@ -1054,7 +1061,7 @@ class wallet_api signed_transaction borrow_asset_ext( string borrower, string amount_to_borrow, string asset_symbol_or_id, string amount_of_collateral, call_order_update_operation::extensions_type extensions, - bool broadcast = false ); + bool broadcast = false )const; /** Cancel an existing order * @@ -1091,7 +1098,7 @@ class wallet_api uint8_t precision, asset_options common, fc::optional bitasset_opts, - bool broadcast = false); + bool broadcast = false)const; /** Create the specified amount of the specified asset and credit into the specified account. * @@ -1105,7 +1112,7 @@ class wallet_api signed_transaction issue_asset(string to_account, string amount, string symbol_or_id, string memo, - bool broadcast = false); + bool broadcast = false)const; /** Update the core options on an asset. * There are a number of options which all assets in the network use. These options are @@ -1126,7 +1133,7 @@ class wallet_api signed_transaction update_asset(string symbol_or_id, optional new_issuer, asset_options new_options, - bool broadcast = false); + bool broadcast = false)const; /** Update the issuer of an asset * Since this call requires the owner authority of the current issuer to sign the transaction, @@ -1141,7 +1148,7 @@ class wallet_api */ signed_transaction update_asset_issuer(string symbol_or_id, string new_issuer, - bool broadcast = false); + bool broadcast = false)const; /** Update the options specific to a BitAsset. * @@ -1158,7 +1165,7 @@ class wallet_api */ signed_transaction update_bitasset(string symbol_or_id, bitasset_options new_options, - bool broadcast = false); + bool broadcast = false)const; /** Update the set of feed-producing accounts for a BitAsset. * @@ -1172,7 +1179,7 @@ class wallet_api */ signed_transaction update_asset_feed_producers(string symbol_or_id, flat_set new_feed_producers, - bool broadcast = false); + bool broadcast = false)const; /** Publishes a price feed for the named asset. * @@ -1197,7 +1204,7 @@ class wallet_api signed_transaction publish_asset_feed(string publishing_account, string symbol_or_id, price_feed feed, - bool broadcast = false); + bool broadcast = false)const; /** Pay into the fee pool for the given asset. * @@ -1216,7 +1223,7 @@ class wallet_api signed_transaction fund_asset_fee_pool(string from, string symbol_or_id, string amount, - bool broadcast = false); + bool broadcast = false)const; /** Claim funds from the fee pool for the given asset. * @@ -1233,7 +1240,7 @@ class wallet_api */ signed_transaction claim_asset_fee_pool(string symbol_or_id, string amount, - bool broadcast = false); + bool broadcast = false)const; /** Burns an amount of given asset to its reserve pool. * @@ -1248,7 +1255,7 @@ class wallet_api signed_transaction reserve_asset(string from, string amount, string symbol_or_id, - bool broadcast = false); + bool broadcast = false)const; /** Forces a global settling of the given asset (black swan or prediction markets). * @@ -1269,7 +1276,7 @@ class wallet_api */ signed_transaction global_settle_asset(string symbol_or_id, price settle_price, - bool broadcast = false); + bool broadcast = false)const; /** Schedules a market-issued asset for automatic settlement. * @@ -1292,7 +1299,7 @@ class wallet_api signed_transaction settle_asset(string account_to_settle, string amount_to_settle, string symbol_or_id, - bool broadcast = false); + bool broadcast = false)const; /** Creates or updates a bid on an MPA after global settlement. * @@ -1311,7 +1318,7 @@ class wallet_api * @returns the signed transaction creating/updating the bid */ signed_transaction bid_collateral(string bidder, string debt_amount, string debt_symbol_or_id, - string additional_collateral, bool broadcast = false); + string additional_collateral, bool broadcast = false)const; /** Whitelist and blacklist accounts, primarily for transacting in whitelisted assets. * @@ -1336,7 +1343,7 @@ class wallet_api signed_transaction whitelist_account(string authorizing_account, string account_to_list, account_whitelist_operation::account_listing new_listing_status, - bool broadcast = false); + bool broadcast = false)const; /** Creates a committee_member object owned by the given account. * @@ -1350,7 +1357,7 @@ class wallet_api */ signed_transaction create_committee_member(string owner_account, string url, - bool broadcast = false); + bool broadcast = false)const; /** Lists all witnesses registered in the blockchain. * This returns a list of all account names that own witnesses, and the associated witness id, @@ -1365,7 +1372,7 @@ class wallet_api * @param limit the maximum number of witnesss to return (max: 1000) * @returns a list of witnesss mapping witness names to witness ids */ - map list_witnesses(const string& lowerbound, uint32_t limit); + map list_witnesses(const string& lowerbound, uint32_t limit)const; /** Lists all committee_members registered in the blockchain. * This returns a list of all account names that own committee_members, and the associated committee_member id, @@ -1380,19 +1387,19 @@ class wallet_api * @param limit the maximum number of committee_members to return (max: 1000) * @returns a list of committee_members mapping committee_member names to committee_member ids */ - map list_committee_members(const string& lowerbound, uint32_t limit); + map list_committee_members(const string& lowerbound, uint32_t limit)const; /** Returns information about the given witness. * @param owner_account the name or id of the witness account owner, or the id of the witness * @returns the information about the witness stored in the block chain */ - witness_object get_witness(string owner_account); + witness_object get_witness(string owner_account)const; /** Returns information about the given committee_member. * @param owner_account the name or id of the committee_member account owner, or the id of the committee_member * @returns the information about the committee_member stored in the block chain */ - committee_member_object get_committee_member(string owner_account); + committee_member_object get_committee_member(string owner_account)const; /** Creates a witness object owned by the given account. * @@ -1406,7 +1413,7 @@ class wallet_api */ signed_transaction create_witness(string owner_account, string url, - bool broadcast = false); + bool broadcast = false)const; /** * Update a witness object owned by the given account. @@ -1421,7 +1428,7 @@ class wallet_api signed_transaction update_witness(string witness_name, string url, string block_signing_key, - bool broadcast = false); + bool broadcast = false)const; /** @@ -1446,7 +1453,7 @@ class wallet_api string url, variant worker_settings, bool broadcast = false - ); + )const; /** * Update your votes for workers @@ -1460,7 +1467,7 @@ class wallet_api string account, worker_vote_delta delta, bool broadcast = false - ); + )const; /** * Create a hashed time lock contract @@ -1511,7 +1518,7 @@ class wallet_api * @param account_name An account name, account ID, or vesting balance object ID. * @return a list of vesting balance objects with additional info */ - vector< vesting_balance_object_with_info > get_vesting_balances( string account_name ); + vector< vesting_balance_object_with_info > get_vesting_balances( string account_name )const; /** * Withdraw a vesting balance. @@ -1526,7 +1533,7 @@ class wallet_api string witness_name, string amount, string asset_symbol_or_id, - bool broadcast = false); + bool broadcast = false)const; /** Vote for a given committee_member. * @@ -1548,7 +1555,7 @@ class wallet_api signed_transaction vote_for_committee_member(string voting_account, string committee_member, bool approve, - bool broadcast = false); + bool broadcast = false)const; /** Vote for a given witness. * @@ -1570,7 +1577,7 @@ class wallet_api signed_transaction vote_for_witness(string voting_account, string witness, bool approve, - bool broadcast = false); + bool broadcast = false)const; /** Set the voting proxy for an account. * @@ -1592,7 +1599,7 @@ class wallet_api */ signed_transaction set_voting_proxy(string account_to_modify, optional voting_account, - bool broadcast = false); + bool broadcast = false)const; /** Set your vote for the number of witnesses and committee_members in the system. * @@ -1618,7 +1625,7 @@ class wallet_api signed_transaction set_desired_witness_and_committee_member_count(string account_to_modify, uint16_t desired_number_of_witnesses, uint16_t desired_number_of_committee_members, - bool broadcast = false); + bool broadcast = false)const; /** Signs a transaction. * @@ -1628,7 +1635,7 @@ class wallet_api * @param broadcast true if you wish to broadcast the transaction * @return the signed version of the transaction */ - signed_transaction sign_transaction(signed_transaction tx, bool broadcast = false); + signed_transaction sign_transaction(signed_transaction tx, bool broadcast = false)const; /** Signs a transaction. * @@ -1642,7 +1649,7 @@ class wallet_api */ signed_transaction sign_transaction2(signed_transaction tx, const vector& signing_keys = vector(), - bool broadcast = true); + bool broadcast = true)const; /** Get transaction signers. @@ -1664,7 +1671,7 @@ class wallet_api /** Returns an uninitialized object representing a given blockchain operation. * - * This returns a default-initialized object of the given type; it can be used + * This returns a default-initialized object of the given type. It can be used * during early development of the wallet when we don't yet have custom commands for * creating all of the operations the blockchain supports. * @@ -1678,7 +1685,7 @@ class wallet_api * (e.g., "global_parameters_update_operation") * @return a default-constructed operation of the given type */ - operation get_prototype_operation(string operation_type); + operation get_prototype_operation(string operation_type)const; /** Creates a transaction to propose a parameter change. * @@ -1687,7 +1694,7 @@ class wallet_api * * @param proposing_account The account paying the fee to propose the tx * @param expiration_time Timestamp specifying when the proposal will either take effect or expire. - * @param changed_values The values to change; all other chain parameters are filled in with default values + * @param changed_values The values to change. All other chain parameters are filled in with default values * @param broadcast true if you wish to broadcast the transaction * @return the signed version of the transaction */ @@ -1695,7 +1702,7 @@ class wallet_api const string& proposing_account, fc::time_point_sec expiration_time, const variant_object& changed_values, - bool broadcast = false); + bool broadcast = false)const; /** Propose a fee change. * @@ -1710,7 +1717,7 @@ class wallet_api const string& proposing_account, fc::time_point_sec expiration_time, const variant_object& changed_values, - bool broadcast = false); + bool broadcast = false)const; /** Approve or disapprove a proposal. * @@ -1725,7 +1732,7 @@ class wallet_api const string& proposal_id, const approval_delta& delta, bool broadcast /* = false */ - ); + )const; /** * Returns the order book for the market base:quote. @@ -1734,7 +1741,7 @@ class wallet_api * @param limit depth of the order book to retrieve, for bids and asks each, capped at 50 * @return Order book of the market */ - order_book get_order_book( const string& base, const string& quote, unsigned limit = 50); + order_book get_order_book( const string& base, const string& quote, unsigned limit = 50)const; /** Signs a transaction. * @@ -1748,19 +1755,19 @@ class wallet_api * @return the signed transaction */ signed_transaction add_transaction_signature( signed_transaction tx, - bool broadcast = false ); + bool broadcast = false )const; - void dbg_make_uia(string creator, string symbol); - void dbg_make_mia(string creator, string symbol); - void dbg_push_blocks( std::string src_filename, uint32_t count ); - void dbg_generate_blocks( std::string debug_wif_key, uint32_t count ); - void dbg_stream_json_objects( const std::string& filename ); - void dbg_update_object( fc::variant_object update ); + void dbg_make_uia(string creator, string symbol)const; + void dbg_make_mia(string creator, string symbol)const; + void dbg_push_blocks( std::string src_filename, uint32_t count )const; + void dbg_generate_blocks( std::string debug_wif_key, uint32_t count )const; + void dbg_stream_json_objects( const std::string& filename )const; + void dbg_update_object( fc::variant_object update )const; - void flood_network(string prefix, uint32_t number_of_transactions); + void flood_network(string prefix, uint32_t number_of_transactions)const; - void network_add_nodes( const vector& nodes ); - vector< variant > network_get_connected_peers(); + void network_add_nodes( const vector& nodes )const; + vector< variant > network_get_connected_peers()const; /** * Used to transfer from one set of blinded balances to another @@ -1770,14 +1777,12 @@ class wallet_api string amount, string symbol, bool broadcast = false, - bool to_temp = false ); + bool to_temp = false )const; std::map> get_result_formatters() const; - fc::signal lock_changed; - std::shared_ptr my; - void encrypt_keys(); + void encrypt_keys()const; /** * Manage account storage map(key->value) by using the custom operations plugin. @@ -1794,7 +1799,7 @@ class wallet_api * @return The signed transaction */ signed_transaction account_store_map(string account, string catalog, bool remove, - flat_map> key_values, bool broadcast); + flat_map> key_values, bool broadcast)const; /** * Get \c account_storage_object of an account by using the custom operations plugin. @@ -1806,7 +1811,7 @@ class wallet_api * * @return An \c account_storage_object or empty. */ - vector get_account_storage(string account, string catalog); + vector get_account_storage(string account, string catalog)const; }; diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 0067bae1be..f3fe362b05 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -155,16 +155,14 @@ wallet_api::wallet_api(const wallet_data& initial_data, fc::api rapi) { } -wallet_api::~wallet_api() -{ -} +wallet_api::~wallet_api() = default; -bool wallet_api::copy_wallet_file(string destination_filename) +bool wallet_api::copy_wallet_file(string destination_filename)const { return my->copy_wallet_file(destination_filename); } -optional wallet_api::get_block(uint32_t num) +optional wallet_api::get_block(uint32_t num)const { return my->_remote_db->get_block(num); } @@ -174,17 +172,17 @@ uint64_t wallet_api::get_account_count() const return my->_remote_db->get_account_count(); } -vector wallet_api::list_my_accounts() +vector wallet_api::list_my_accounts()const { return vector(my->_wallet.my_accounts.begin(), my->_wallet.my_accounts.end()); } -map wallet_api::list_accounts(const string& lowerbound, uint32_t limit) +map wallet_api::list_accounts(const string& lowerbound, uint32_t limit)const { return my->_remote_db->lookup_accounts(lowerbound, limit, {}); } -vector wallet_api::list_account_balances(const string& id) +vector wallet_api::list_account_balances(const string& id)const { return my->_remote_db->get_account_balances(id, flat_set()); } @@ -379,7 +377,7 @@ account_history_operation_detail wallet_api::get_account_history_by_operations( const string& name, const flat_set& operation_types, uint32_t start, - uint32_t limit) + uint32_t limit)const { account_history_operation_detail result; @@ -422,7 +420,7 @@ account_history_operation_detail wallet_api::get_account_history_by_operations( return result; } -full_account wallet_api::get_full_account( const string& name_or_id) +full_account wallet_api::get_full_account( const string& name_or_id)const { return my->_remote_db->get_full_accounts({name_or_id}, false)[name_or_id]; } @@ -443,7 +441,7 @@ vector wallet_api::get_account_limit_orders( const string "e, uint32_t limit, optional ostart_id, - optional ostart_price) + optional ostart_price)const { return my->_remote_db->get_account_limit_orders(name_or_id, base, quote, limit, ostart_id, ostart_price); } @@ -502,14 +500,14 @@ string wallet_api::get_wallet_filename() const return my->get_wallet_filename(); } -transaction_handle_type wallet_api::begin_builder_transaction() +transaction_handle_type wallet_api::begin_builder_transaction()const { return my->begin_builder_transaction(); } void wallet_api::add_operation_to_builder_transaction( transaction_handle_type transaction_handle, - const operation& op) + const operation& op)const { my->add_operation_to_builder_transaction(transaction_handle, op); } @@ -517,34 +515,35 @@ void wallet_api::add_operation_to_builder_transaction( void wallet_api::replace_operation_in_builder_transaction( transaction_handle_type handle, unsigned operation_index, - const operation& new_op) + const operation& new_op)const { my->replace_operation_in_builder_transaction(handle, operation_index, new_op); } -asset wallet_api::set_fees_on_builder_transaction(transaction_handle_type handle, string fee_asset) +asset wallet_api::set_fees_on_builder_transaction(transaction_handle_type handle, string fee_asset)const { return my->set_fees_on_builder_transaction(handle, fee_asset); } -transaction wallet_api::preview_builder_transaction(transaction_handle_type handle) +transaction wallet_api::preview_builder_transaction(transaction_handle_type handle)const { return my->preview_builder_transaction(handle); } -signed_transaction wallet_api::sign_builder_transaction(transaction_handle_type transaction_handle, bool broadcast) +signed_transaction wallet_api::sign_builder_transaction(transaction_handle_type transaction_handle, + bool broadcast)const { return my->sign_builder_transaction(transaction_handle, broadcast); } signed_transaction wallet_api::sign_builder_transaction2(transaction_handle_type transaction_handle, const vector& explicit_keys, - bool broadcast) + bool broadcast)const { return my->sign_builder_transaction2(transaction_handle, explicit_keys, broadcast); } -pair wallet_api::broadcast_transaction(signed_transaction tx) +pair wallet_api::broadcast_transaction(signed_transaction tx)const { return my->broadcast_transaction(tx); } @@ -553,7 +552,7 @@ signed_transaction wallet_api::propose_builder_transaction( transaction_handle_type handle, time_point_sec expiration, uint32_t review_period_seconds, - bool broadcast) + bool broadcast)const { return my->propose_builder_transaction(handle, expiration, review_period_seconds, broadcast); } @@ -563,12 +562,12 @@ signed_transaction wallet_api::propose_builder_transaction2( string account_name_or_id, time_point_sec expiration, uint32_t review_period_seconds, - bool broadcast) + bool broadcast)const { return my->propose_builder_transaction2(handle, account_name_or_id, expiration, review_period_seconds, broadcast); } -void wallet_api::remove_builder_transaction(transaction_handle_type handle) +void wallet_api::remove_builder_transaction(transaction_handle_type handle)const { return my->remove_builder_transaction(handle); } @@ -602,7 +601,7 @@ asset_id_type wallet_api::get_asset_id(const string& asset_symbol_or_id) const return my->get_asset_id(asset_symbol_or_id); } -bool wallet_api::import_key(string account_name_or_id, string wif_key) +bool wallet_api::import_key(string account_name_or_id, string wif_key)const { FC_ASSERT(!is_locked()); // backup wallet @@ -621,7 +620,7 @@ bool wallet_api::import_key(string account_name_or_id, string wif_key) return false; } -map wallet_api::import_accounts( string filename, string password ) +map wallet_api::import_accounts( string filename, string password )const { FC_ASSERT( !is_locked() ); FC_ASSERT( fc::exists( filename ) ); @@ -697,7 +696,7 @@ bool wallet_api::import_account_keys( string filename, string password, string src_account_name, - string dest_account_name ) + string dest_account_name )const { FC_ASSERT( !is_locked() ); FC_ASSERT( fc::exists( filename ) ); @@ -749,7 +748,7 @@ string wallet_api::normalize_brain_key(string s) const return detail::normalize_brain_key( s ); } -variant wallet_api::info() +variant wallet_api::info()const { return my->info(); } @@ -770,14 +769,14 @@ signed_transaction wallet_api::register_account(string name, string registrar_account, string referrer_account, uint32_t referrer_percent, - bool broadcast) + bool broadcast)const { return my->register_account( name, owner_pubkey, active_pubkey, registrar_account, referrer_account, referrer_percent, broadcast ); } signed_transaction wallet_api::create_account_with_brain_key(string brain_key, string account_name, string registrar_account, string referrer_account, - bool broadcast /* = false */) + bool broadcast /* = false */)const { return my->create_account_with_brain_key( brain_key, account_name, registrar_account, @@ -785,13 +784,13 @@ signed_transaction wallet_api::create_account_with_brain_key(string brain_key, s ); } signed_transaction wallet_api::issue_asset(string to_account, string amount, string symbol, - string memo, bool broadcast) + string memo, bool broadcast)const { return my->issue_asset(to_account, amount, symbol, memo, broadcast); } signed_transaction wallet_api::transfer(string from, string to, string amount, - string asset_symbol, string memo, bool broadcast /* = false */) + string asset_symbol, string memo, bool broadcast /* = false */)const { return my->transfer(from, to, amount, asset_symbol, memo, broadcast); } @@ -800,8 +799,7 @@ signed_transaction wallet_api::create_asset(string issuer, uint8_t precision, asset_options common, fc::optional bitasset_opts, - bool broadcast) - + bool broadcast)const { return my->create_asset(issuer, symbol, precision, common, bitasset_opts, broadcast); } @@ -809,28 +807,28 @@ signed_transaction wallet_api::create_asset(string issuer, signed_transaction wallet_api::update_asset(string symbol, optional new_issuer, asset_options new_options, - bool broadcast /* = false */) + bool broadcast /* = false */)const { return my->update_asset(symbol, new_issuer, new_options, broadcast); } signed_transaction wallet_api::update_asset_issuer(string symbol, string new_issuer, - bool broadcast /* = false */) + bool broadcast /* = false */)const { return my->update_asset_issuer(symbol, new_issuer, broadcast); } signed_transaction wallet_api::update_bitasset(string symbol, bitasset_options new_options, - bool broadcast /* = false */) + bool broadcast /* = false */)const { return my->update_bitasset(symbol, new_options, broadcast); } signed_transaction wallet_api::update_asset_feed_producers(string symbol, flat_set new_feed_producers, - bool broadcast /* = false */) + bool broadcast /* = false */)const { return my->update_asset_feed_producers(symbol, new_feed_producers, broadcast); } @@ -838,7 +836,7 @@ signed_transaction wallet_api::update_asset_feed_producers(string symbol, signed_transaction wallet_api::publish_asset_feed(string publishing_account, string symbol, price_feed feed, - bool broadcast /* = false */) + bool broadcast /* = false */)const { return my->publish_asset_feed(publishing_account, symbol, feed, broadcast); } @@ -846,14 +844,14 @@ signed_transaction wallet_api::publish_asset_feed(string publishing_account, signed_transaction wallet_api::fund_asset_fee_pool(string from, string symbol, string amount, - bool broadcast /* = false */) + bool broadcast /* = false */)const { return my->fund_asset_fee_pool(from, symbol, amount, broadcast); } signed_transaction wallet_api::claim_asset_fee_pool(string symbol, string amount, - bool broadcast /* = false */) + bool broadcast /* = false */)const { return my->claim_asset_fee_pool(symbol, amount, broadcast); } @@ -861,14 +859,14 @@ signed_transaction wallet_api::claim_asset_fee_pool(string symbol, signed_transaction wallet_api::reserve_asset(string from, string amount, string symbol, - bool broadcast /* = false */) + bool broadcast /* = false */)const { return my->reserve_asset(from, amount, symbol, broadcast); } signed_transaction wallet_api::global_settle_asset(string symbol, price settle_price, - bool broadcast /* = false */) + bool broadcast /* = false */)const { return my->global_settle_asset(symbol, settle_price, broadcast); } @@ -876,7 +874,7 @@ signed_transaction wallet_api::global_settle_asset(string symbol, signed_transaction wallet_api::settle_asset(string account_to_settle, string amount_to_settle, string symbol, - bool broadcast /* = false */) + bool broadcast /* = false */)const { return my->settle_asset(account_to_settle, amount_to_settle, symbol, broadcast); } @@ -884,7 +882,7 @@ signed_transaction wallet_api::settle_asset(string account_to_settle, signed_transaction wallet_api::bid_collateral(string bidder_name, string debt_amount, string debt_symbol, string additional_collateral, - bool broadcast ) + bool broadcast )const { return my->bid_collateral(bidder_name, debt_amount, debt_symbol, additional_collateral, broadcast); } @@ -892,40 +890,40 @@ signed_transaction wallet_api::bid_collateral(string bidder_name, signed_transaction wallet_api::whitelist_account(string authorizing_account, string account_to_list, account_whitelist_operation::account_listing new_listing_status, - bool broadcast /* = false */) + bool broadcast /* = false */)const { return my->whitelist_account(authorizing_account, account_to_list, new_listing_status, broadcast); } signed_transaction wallet_api::create_committee_member(string owner_account, string url, - bool broadcast /* = false */) + bool broadcast /* = false */)const { return my->create_committee_member(owner_account, url, broadcast); } -map wallet_api::list_witnesses(const string& lowerbound, uint32_t limit) +map wallet_api::list_witnesses(const string& lowerbound, uint32_t limit)const { return my->_remote_db->lookup_witness_accounts(lowerbound, limit); } -map wallet_api::list_committee_members(const string& lowerbound, uint32_t limit) +map wallet_api::list_committee_members(const string& lowerbound, uint32_t limit)const { return my->_remote_db->lookup_committee_member_accounts(lowerbound, limit); } -witness_object wallet_api::get_witness(string owner_account) +witness_object wallet_api::get_witness(string owner_account)const { return my->get_witness(owner_account); } -committee_member_object wallet_api::get_committee_member(string owner_account) +committee_member_object wallet_api::get_committee_member(string owner_account)const { return my->get_committee_member(owner_account); } signed_transaction wallet_api::create_witness(string owner_account, string url, - bool broadcast /* = false */) + bool broadcast /* = false */)const { return my->create_witness(owner_account, url, broadcast); } @@ -938,7 +936,7 @@ signed_transaction wallet_api::create_worker( string name, string url, variant worker_settings, - bool broadcast /* = false */) + bool broadcast /* = false */)const { return my->create_worker( owner_account, work_begin_date, work_end_date, daily_pay, name, url, worker_settings, broadcast ); @@ -947,7 +945,7 @@ signed_transaction wallet_api::create_worker( signed_transaction wallet_api::update_worker_votes( string owner_account, worker_vote_delta delta, - bool broadcast /* = false */) + bool broadcast /* = false */)const { return my->update_worker_votes( owner_account, delta, broadcast ); } @@ -956,12 +954,12 @@ signed_transaction wallet_api::update_witness( string witness_name, string url, string block_signing_key, - bool broadcast /* = false */) + bool broadcast /* = false */)const { return my->update_witness(witness_name, url, block_signing_key, broadcast); } -vector< vesting_balance_object_with_info > wallet_api::get_vesting_balances( string account_name ) +vector< vesting_balance_object_with_info > wallet_api::get_vesting_balances( string account_name )const { return my->get_vesting_balances( account_name ); } @@ -970,7 +968,7 @@ signed_transaction wallet_api::withdraw_vesting( string witness_name, string amount, string asset_symbol, - bool broadcast /* = false */) + bool broadcast /* = false */)const { return my->withdraw_vesting( witness_name, amount, asset_symbol, broadcast ); } @@ -978,7 +976,7 @@ signed_transaction wallet_api::withdraw_vesting( signed_transaction wallet_api::vote_for_committee_member(string voting_account, string witness, bool approve, - bool broadcast /* = false */) + bool broadcast /* = false */)const { return my->vote_for_committee_member(voting_account, witness, approve, broadcast); } @@ -986,14 +984,14 @@ signed_transaction wallet_api::vote_for_committee_member(string voting_account, signed_transaction wallet_api::vote_for_witness(string voting_account, string witness, bool approve, - bool broadcast /* = false */) + bool broadcast /* = false */)const { return my->vote_for_witness(voting_account, witness, approve, broadcast); } signed_transaction wallet_api::set_voting_proxy(string account_to_modify, optional voting_account, - bool broadcast /* = false */) + bool broadcast /* = false */)const { return my->set_voting_proxy(account_to_modify, voting_account, broadcast); } @@ -1001,24 +999,24 @@ signed_transaction wallet_api::set_voting_proxy(string account_to_modify, signed_transaction wallet_api::set_desired_witness_and_committee_member_count(string account_to_modify, uint16_t desired_number_of_witnesses, uint16_t desired_number_of_committee_members, - bool broadcast /* = false */) + bool broadcast /* = false */)const { return my->set_desired_witness_and_committee_member_count(account_to_modify, desired_number_of_witnesses, desired_number_of_committee_members, broadcast); } -void wallet_api::set_wallet_filename(string wallet_filename) +void wallet_api::set_wallet_filename(string wallet_filename)const { my->_wallet_filename = wallet_filename; } -signed_transaction wallet_api::sign_transaction(signed_transaction tx, bool broadcast /* = false */) +signed_transaction wallet_api::sign_transaction(signed_transaction tx, bool broadcast /* = false */)const { try { return my->sign_transaction( tx, broadcast); } FC_CAPTURE_AND_RETHROW( (tx) ) } signed_transaction wallet_api::sign_transaction2(signed_transaction tx, const vector& signing_keys, - bool broadcast /* = false */) + bool broadcast /* = false */)const { try { return my->sign_transaction2( tx, signing_keys, broadcast); } FC_CAPTURE_AND_RETHROW( (tx) ) } @@ -1033,54 +1031,54 @@ vector> wallet_api::get_key_references(const vectorget_key_references(keys); } FC_CAPTURE_AND_RETHROW( (keys) ) } -operation wallet_api::get_prototype_operation(string operation_name) +operation wallet_api::get_prototype_operation(string operation_name)const { return my->get_prototype_operation( operation_name ); } -void wallet_api::dbg_make_uia(string creator, string symbol) +void wallet_api::dbg_make_uia(string creator, string symbol)const { FC_ASSERT(!is_locked()); my->dbg_make_uia(creator, symbol); } -void wallet_api::dbg_make_mia(string creator, string symbol) +void wallet_api::dbg_make_mia(string creator, string symbol)const { FC_ASSERT(!is_locked()); my->dbg_make_mia(creator, symbol); } -void wallet_api::dbg_push_blocks( std::string src_filename, uint32_t count ) +void wallet_api::dbg_push_blocks( std::string src_filename, uint32_t count )const { my->dbg_push_blocks( src_filename, count ); } -void wallet_api::dbg_generate_blocks( std::string debug_wif_key, uint32_t count ) +void wallet_api::dbg_generate_blocks( std::string debug_wif_key, uint32_t count )const { my->dbg_generate_blocks( debug_wif_key, count ); } -void wallet_api::dbg_stream_json_objects( const std::string& filename ) +void wallet_api::dbg_stream_json_objects( const std::string& filename )const { my->dbg_stream_json_objects( filename ); } -void wallet_api::dbg_update_object( fc::variant_object update ) +void wallet_api::dbg_update_object( fc::variant_object update )const { my->dbg_update_object( update ); } -void wallet_api::network_add_nodes( const vector& nodes ) +void wallet_api::network_add_nodes( const vector& nodes )const { my->network_add_nodes( nodes ); } -vector< variant > wallet_api::network_get_connected_peers() +vector< variant > wallet_api::network_get_connected_peers()const { return my->network_get_connected_peers(); } -void wallet_api::flood_network(string prefix, uint32_t number_of_transactions) +void wallet_api::flood_network(string prefix, uint32_t number_of_transactions)const { FC_ASSERT(!is_locked()); my->flood_network(prefix, number_of_transactions); @@ -1091,7 +1089,7 @@ signed_transaction wallet_api::propose_parameter_change( fc::time_point_sec expiration_time, const variant_object& changed_values, bool broadcast /* = false */ - ) + )const { return my->propose_parameter_change( proposing_account, expiration_time, changed_values, broadcast ); } @@ -1101,7 +1099,7 @@ signed_transaction wallet_api::propose_fee_change( fc::time_point_sec expiration_time, const variant_object& changed_fees, bool broadcast /* = false */ - ) + )const { return my->propose_fee_change( proposing_account, expiration_time, changed_fees, broadcast ); } @@ -1111,7 +1109,7 @@ signed_transaction wallet_api::approve_proposal( const string& proposal_id, const approval_delta& delta, bool broadcast /* = false */ - ) + )const { return my->approve_proposal( fee_paying_account, proposal_id, delta, broadcast ); } @@ -1127,7 +1125,7 @@ dynamic_global_property_object wallet_api::get_dynamic_global_properties() const } signed_transaction wallet_api::add_transaction_signature( signed_transaction tx, - bool broadcast ) + bool broadcast )const { return my->add_transaction_signature( tx, broadcast ); } @@ -1213,17 +1211,17 @@ string wallet_api::gethelp(const string& method)const return ss.str(); } -bool wallet_api::load_wallet_file( string wallet_filename ) +bool wallet_api::load_wallet_file( string wallet_filename )const { return my->load_wallet_file( wallet_filename ); } -void wallet_api::quit() +void wallet_api::quit()const { my->quit(); } -void wallet_api::save_wallet_file( string wallet_filename ) +void wallet_api::save_wallet_file( string wallet_filename )const { my->save_wallet_file( wallet_filename ); } @@ -1243,12 +1241,12 @@ bool wallet_api::is_new()const return my->_wallet.cipher_keys.size() == 0; } -void wallet_api::encrypt_keys() +void wallet_api::encrypt_keys()const { my->encrypt_keys(); } -void wallet_api::lock() +void wallet_api::lock()const { try { FC_ASSERT( !is_locked() ); encrypt_keys(); @@ -1259,7 +1257,7 @@ void wallet_api::lock() my->self.lock_changed(true); } FC_CAPTURE_AND_RETHROW() } -void wallet_api::unlock(string password) +void wallet_api::unlock(string password)const { try { FC_ASSERT(password.size() > 0); auto pw = fc::sha512::hash(password.c_str(), password.size()); @@ -1271,7 +1269,7 @@ void wallet_api::unlock(string password) my->self.lock_changed(false); } FC_CAPTURE_AND_RETHROW() } -void wallet_api::set_password( string password ) +void wallet_api::set_password( string password )const { if( !is_new() ) FC_ASSERT( !is_locked(), "The wallet must be unlocked before the password can be set" ); @@ -1282,18 +1280,18 @@ void wallet_api::set_password( string password ) vector< signed_transaction > wallet_api::import_balance( string name_or_id, const vector& wif_keys, - bool broadcast ) + bool broadcast )const { return my->import_balance( name_or_id, wif_keys, broadcast ); } -map wallet_api::dump_private_keys() +map wallet_api::dump_private_keys()const { FC_ASSERT(!is_locked()); return my->_keys; } -signed_transaction wallet_api::upgrade_account( string name, bool broadcast ) +signed_transaction wallet_api::upgrade_account( string name, bool broadcast )const { return my->upgrade_account(name,broadcast); } @@ -1305,14 +1303,14 @@ signed_transaction wallet_api::sell_asset(string seller_account, string symbol_to_receive, uint32_t expiration, bool fill_or_kill, - bool broadcast) + bool broadcast)const { return my->sell_asset(seller_account, amount_to_sell, symbol_to_sell, min_to_receive, symbol_to_receive, expiration, fill_or_kill, broadcast); } signed_transaction wallet_api::borrow_asset(string seller_name, string amount_to_sell, - string asset_symbol, string amount_of_collateral, bool broadcast) + string asset_symbol, string amount_of_collateral, bool broadcast)const { FC_ASSERT(!is_locked()); return my->borrow_asset(seller_name, amount_to_sell, asset_symbol, amount_of_collateral, broadcast); @@ -1321,7 +1319,7 @@ signed_transaction wallet_api::borrow_asset(string seller_name, string amount_to signed_transaction wallet_api::borrow_asset_ext( string seller_name, string amount_to_sell, string asset_symbol, string amount_of_collateral, call_order_update_operation::extensions_type extensions, - bool broadcast) + bool broadcast)const { FC_ASSERT(!is_locked()); return my->borrow_asset_ext(seller_name, amount_to_sell, asset_symbol, @@ -1334,26 +1332,26 @@ signed_transaction wallet_api::cancel_order(const limit_order_id_type& order_id, return my->cancel_order(order_id, broadcast); } -memo_data wallet_api::sign_memo(string from, string to, string memo) +memo_data wallet_api::sign_memo(string from, string to, string memo)const { FC_ASSERT(!is_locked()); return my->sign_memo(from, to, memo); } -string wallet_api::read_memo(const memo_data& memo) +string wallet_api::read_memo(const memo_data& memo)const { FC_ASSERT(!is_locked()); return my->read_memo(memo); } -signed_message wallet_api::sign_message(string signer, string message) +signed_message wallet_api::sign_message(string signer, string message)const { FC_ASSERT(!is_locked()); return my->sign_message(signer, message); } bool wallet_api::verify_message( const string& message, const string& account, int32_t block, const string& msg_time, - const fc::ecc::compact_signature& sig ) + const fc::ecc::compact_signature& sig )const { return my->verify_message( message, account, block, msg_time, sig ); } @@ -1363,7 +1361,7 @@ bool wallet_api::verify_message( const string& message, const string& account, i * @param message the signed_message structure containing message, meta data and signature * @return true if signature matches */ -bool wallet_api::verify_signed_message( signed_message message ) +bool wallet_api::verify_signed_message( signed_message message )const { return my->verify_signed_message( message ); } @@ -1373,7 +1371,7 @@ bool wallet_api::verify_signed_message( signed_message message ) * @param message the complete encapsulated message string including separators and line feeds * @return true if signature matches */ -bool wallet_api::verify_encapsulated_message( string message ) +bool wallet_api::verify_encapsulated_message( string message )const { return my->verify_encapsulated_message( message ); } @@ -1402,7 +1400,7 @@ public_key_type wallet_api::get_public_key( string label )const return public_key_type(); } -bool wallet_api::set_key_label( public_key_type key, string label ) +bool wallet_api::set_key_label( public_key_type key, string label )const { auto result = my->_wallet.labeled_keys.insert( key_label{label,key} ); if( result.second ) return true; @@ -1435,7 +1433,7 @@ map wallet_api::get_my_blind_accounts()const return result; } -public_key_type wallet_api::create_blind_account( string label, string brain_key ) +public_key_type wallet_api::create_blind_account( string label, string brain_key )const { FC_ASSERT( !is_locked() ); @@ -1455,7 +1453,7 @@ public_key_type wallet_api::create_blind_account( string label, string brain_ return pub_key; } -vector wallet_api::get_blind_balances( string key_or_label ) +vector wallet_api::get_blind_balances( string key_or_label )const { vector result; map balances; @@ -1492,7 +1490,7 @@ blind_confirmation wallet_api::transfer_from_blind( string from_blind_account_ke string to_account_id_or_name, string amount_in, string symbol, - bool broadcast ) + bool broadcast )const { try { transfer_from_blind_operation from_blind; @@ -1553,7 +1551,7 @@ blind_confirmation wallet_api::blind_transfer( string from_key_or_label, string to_key_or_label, string amount_in, string symbol, - bool broadcast ) + bool broadcast )const { return blind_transfer_help( from_key_or_label, to_key_or_label, amount_in, symbol, broadcast, false ); } @@ -1562,7 +1560,7 @@ blind_confirmation wallet_api::blind_transfer_help( string from_key_or_label, string amount_in, string symbol, bool broadcast, - bool to_temp ) + bool to_temp )const { blind_confirmation confirm; try { @@ -1739,7 +1737,7 @@ blind_confirmation wallet_api::transfer_to_blind( string from_account_id_or_name string asset_symbol, /* map from key or label to amount */ vector> to_amounts, - bool broadcast ) + bool broadcast )const { try { FC_ASSERT( !is_locked() ); idump((to_amounts)); @@ -1822,7 +1820,7 @@ blind_confirmation wallet_api::transfer_to_blind( string from_account_id_or_name return confirm; } FC_CAPTURE_AND_RETHROW( (from_account_id_or_name)(asset_symbol)(to_amounts) ) } -blind_receipt wallet_api::receive_blind_transfer( string confirmation_receipt, string opt_from, string opt_memo ) +blind_receipt wallet_api::receive_blind_transfer( string confirmation_receipt, string opt_from, string opt_memo )const { FC_ASSERT( !is_locked() ); stealth_confirmation conf(confirmation_receipt); @@ -1899,7 +1897,7 @@ blind_receipt wallet_api::receive_blind_transfer( string confirmation_receipt, s return result; } -vector wallet_api::blind_history( string key_or_account ) +vector wallet_api::blind_history( string key_or_account )const { vector result; auto pub_key = get_public_key( key_or_account ); @@ -1917,19 +1915,19 @@ vector wallet_api::blind_history( string key_or_account ) return result; } -order_book wallet_api::get_order_book( const string& base, const string& quote, unsigned limit ) +order_book wallet_api::get_order_book( const string& base, const string& quote, unsigned limit )const { return( my->_remote_db->get_order_book( base, quote, limit ) ); } // custom operations signed_transaction wallet_api::account_store_map(string account, string catalog, bool remove, - flat_map> key_values, bool broadcast) + flat_map> key_values, bool broadcast)const { return my->account_store_map(account, catalog, remove, key_values, broadcast); } -vector wallet_api::get_account_storage(string account, string catalog) +vector wallet_api::get_account_storage(string account, string catalog)const { try { return my->_custom_operations->get_storage_info(account, catalog); } FC_CAPTURE_AND_RETHROW( (account)(catalog) ) } From 42c6afca019280fac35bbc1d03f22c96eef0ac32 Mon Sep 17 00:00:00 2001 From: abitmore Date: Tue, 25 Oct 2022 16:48:33 +0000 Subject: [PATCH 03/13] Add comparator "std::less<>" to "map" --- libraries/app/database_api.cpp | 10 +++++----- libraries/app/database_api_impl.hxx | 4 ++-- .../app/include/graphene/app/database_api.hpp | 20 +++++++++---------- .../wallet/include/graphene/wallet/wallet.hpp | 2 +- libraries/wallet/wallet.cpp | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 3e1bcfa1ca..a0dddc52b0 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -774,16 +774,16 @@ vector> database_api_impl::lookup_account_names(const v return get_accounts( account_names, false ); } -map database_api::lookup_accounts( const string& lower_bound_name, +map> database_api::lookup_accounts( const string& lower_bound_name, uint32_t limit, - optional subscribe )const + const optional& subscribe )const { return my->lookup_accounts( lower_bound_name, limit, subscribe ); } -map database_api_impl::lookup_accounts( const string& lower_bound_name, +map> database_api_impl::lookup_accounts( const string& lower_bound_name, uint32_t limit, - optional subscribe )const + const optional& subscribe )const { FC_ASSERT( _app_options, "Internal error" ); const auto configured_limit = _app_options->api_limit_lookup_accounts; @@ -792,7 +792,7 @@ map database_api_impl::lookup_accounts( const string& lo ("configured_limit", configured_limit) ); const auto& accounts_by_name = _db.get_index_type().indices().get(); - map result; + map> result; if( limit == 0 ) // shortcut to save a database query return result; diff --git a/libraries/app/database_api_impl.hxx b/libraries/app/database_api_impl.hxx index 04f9f92a24..240793f53b 100644 --- a/libraries/app/database_api_impl.hxx +++ b/libraries/app/database_api_impl.hxx @@ -77,9 +77,9 @@ class database_api_impl : public std::enable_shared_from_this optional get_account_by_name( string name )const; vector get_account_references( const std::string account_id_or_name )const; vector> lookup_account_names(const vector& account_names)const; - map lookup_accounts( const string& lower_bound_name, + map> lookup_accounts( const string& lower_bound_name, uint32_t limit, - optional subscribe )const; + const optional& subscribe )const; uint64_t get_account_count()const; // Balances diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 752fefc2b4..73e858878b 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -80,7 +80,7 @@ class database_api /** * @brief Get the objects corresponding to the provided IDs * @param ids IDs of the objects to retrieve - * @param subscribe @a true to subscribe to the queried objects; @a false to not subscribe; + * @param subscribe @a true to subscribe to the queried objects, @a false to not subscribe, * @a null to subscribe or not subscribe according to current auto-subscription setting * (see @ref set_auto_subscription) * @return The objects retrieved, in the order they are mentioned in ids @@ -277,7 +277,7 @@ class database_api /** * @brief Get a list of accounts by names or IDs * @param account_names_or_ids names or IDs of the accounts to retrieve - * @param subscribe @a true to subscribe to the queried account objects; @a false to not subscribe; + * @param subscribe @a true to subscribe to the queried account objects, @a false to not subscribe, * @a null to subscribe or not subscribe according to current auto-subscription setting * (see @ref set_auto_subscription) * @return The accounts corresponding to the provided names or IDs @@ -292,7 +292,7 @@ class database_api * @param names_or_ids Each item must be the name or ID of an account to retrieve, * the quantity should not be greater than the configured value of * @a api_limit_get_full_accounts - * @param subscribe @a true to subscribe to the queried full account objects; @a false to not subscribe; + * @param subscribe @a true to subscribe to the queried full account objects, @a false to not subscribe, * @a null to subscribe or not subscribe according to current auto-subscription setting * (see @ref set_auto_subscription) * @return Map of string from @p names_or_ids to the corresponding account @@ -345,7 +345,7 @@ class database_api * @param lower_bound_name Lower bound of the first name to return * @param limit Maximum number of results to return, must not exceed the configured value of * @a api_limit_lookup_accounts - * @param subscribe @a true to subscribe to the queried account objects; @a false to not subscribe; + * @param subscribe @a true to subscribe to the queried account objects, @a false to not subscribe, * @a null to subscribe or not subscribe according to current auto-subscription setting * (see @ref set_auto_subscription) * @return Map of account names to corresponding IDs @@ -353,9 +353,9 @@ class database_api * @note In addition to the common auto-subscription rules, * this API will subscribe to the returned account only if @p limit is 1. */ - map lookup_accounts( const string& lower_bound_name, + map> lookup_accounts( const string& lower_bound_name, uint32_t limit, - optional subscribe = optional() )const; + const optional& subscribe = optional() )const; ////////////// // Balances // @@ -414,7 +414,7 @@ class database_api /** * @brief Get a list of assets by symbol names or IDs * @param asset_symbols_or_ids symbol names or IDs of the assets to retrieve - * @param subscribe @a true to subscribe to the queried asset objects; @a false to not subscribe; + * @param subscribe @a true to subscribe to the queried asset objects, @a false to not subscribe, * @a null to subscribe or not subscribe according to current auto-subscription setting * (see @ref set_auto_subscription) * @return The assets corresponding to the provided symbol names or IDs @@ -802,7 +802,7 @@ class database_api * @param ids IDs of the liquidity pools, * the quantity should not be greater than the configured value of * @a api_limit_get_liquidity_pools - * @param subscribe @a true to subscribe to the queried objects; @a false to not subscribe; + * @param subscribe @a true to subscribe to the queried objects, @a false to not subscribe, * @a null to subscribe or not subscribe according to current auto-subscription setting * (see @ref set_auto_subscription) * @param with_statistics Whether to return statistics @@ -821,7 +821,7 @@ class database_api * @param asset_symbols_or_ids symbol names or IDs of the share assets, * the quantity should not be greater than the configured value of * @a api_limit_get_liquidity_pools - * @param subscribe @a true to subscribe to the queried objects; @a false to not subscribe; + * @param subscribe @a true to subscribe to the queried objects, @a false to not subscribe, * @a null to subscribe or not subscribe according to current auto-subscription setting * (see @ref set_auto_subscription) * @param with_statistics Whether to return statistics @@ -1370,7 +1370,7 @@ class database_api /** * @brief Get HTLC object * @param id HTLC contract id - * @param subscribe @a true to subscribe to the queried HTLC objects; @a false to not subscribe; + * @param subscribe @a true to subscribe to the queried HTLC objects, @a false to not subscribe, * @a null to subscribe or not subscribe according to current auto-subscription setting * (see @ref set_auto_subscription) * @return HTLC object for the id diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index 657d06d9b4..c7756e9c52 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -98,7 +98,7 @@ class wallet_api * @param limit the maximum number of accounts to return (max: 1000) * @returns a list of accounts mapping account names to account ids */ - map list_accounts(const string& lowerbound, uint32_t limit)const; + map> list_accounts(const string& lowerbound, uint32_t limit)const; /** List the balances of an account. * Each account can have multiple balances, one for each type of asset owned by that * account. The returned list will only contain assets for which the account has a diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index f3fe362b05..940e04d328 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -177,7 +177,7 @@ vector wallet_api::list_my_accounts()const return vector(my->_wallet.my_accounts.begin(), my->_wallet.my_accounts.end()); } -map wallet_api::list_accounts(const string& lowerbound, uint32_t limit)const +map> wallet_api::list_accounts(const string& lowerbound, uint32_t limit)const { return my->_remote_db->lookup_accounts(lowerbound, limit, {}); } From 7772d56d91ebaf33ea24aa531547ee3599fc7f09 Mon Sep 17 00:00:00 2001 From: abitmore Date: Wed, 26 Oct 2022 16:00:47 +0000 Subject: [PATCH 04/13] Bump FC for std::map serialization update --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index ad7b28bca8..41f31f8c60 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit ad7b28bca8eebe68a594ed06ce1993975101e408 +Subproject commit 41f31f8c60561ef8f885f326abc21210cdd7db40 From 0fd16c863e98ae238b3db5ea8e0e71a2c69fdb01 Mon Sep 17 00:00:00 2001 From: abitmore Date: Wed, 26 Oct 2022 18:08:36 +0000 Subject: [PATCH 05/13] Simplify help info in cli_wallet --- libraries/wallet/generate_api_documentation.pl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/wallet/generate_api_documentation.pl b/libraries/wallet/generate_api_documentation.pl index a3f333db82..a515582396 100755 --- a/libraries/wallet/generate_api_documentation.pl +++ b/libraries/wallet/generate_api_documentation.pl @@ -91,6 +91,10 @@ END sub cleanupDoxygenType { my($type) = @_; + $type =~ s/std:://g; + $type =~ s/, less<>//g; + $type =~ s/const //g; + $type =~ s/ &//g; $type =~ s/< //>/g; return $type; From d41793670b301e375987d7a3613f3ecdbfa3aea2 Mon Sep 17 00:00:00 2001 From: abitmore Date: Wed, 26 Oct 2022 19:13:41 +0000 Subject: [PATCH 06/13] Replace typedef with using --- .../wallet/include/graphene/wallet/api_documentation.hpp | 4 ++-- libraries/wallet/include/graphene/wallet/wallet_structs.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/wallet/include/graphene/wallet/api_documentation.hpp b/libraries/wallet/include/graphene/wallet/api_documentation.hpp index ab303ccaa1..42dbba2d3e 100644 --- a/libraries/wallet/include/graphene/wallet/api_documentation.hpp +++ b/libraries/wallet/include/graphene/wallet/api_documentation.hpp @@ -42,10 +42,10 @@ namespace graphene { namespace wallet { class api_documentation { - typedef boost::multi_index::multi_index_container > > > method_description_set; + boost::multi_index::member > > >; method_description_set method_descriptions; public: api_documentation(); diff --git a/libraries/wallet/include/graphene/wallet/wallet_structs.hpp b/libraries/wallet/include/graphene/wallet/wallet_structs.hpp index 7d5b33dff9..00dba9e19a 100644 --- a/libraries/wallet/include/graphene/wallet/wallet_structs.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet_structs.hpp @@ -34,7 +34,7 @@ using std::vector; namespace graphene { namespace wallet { -typedef uint16_t transaction_handle_type; +using transaction_handle_type = uint16_t; struct plain_keys { From 8fbc1cd5f51648108bda7eec78164573ccd1d3ff Mon Sep 17 00:00:00 2001 From: abitmore Date: Wed, 26 Oct 2022 19:18:43 +0000 Subject: [PATCH 07/13] Simplify wallet_api::borrow_asset() implementation --- libraries/wallet/wallet.cpp | 2 +- libraries/wallet/wallet_api_impl.hpp | 3 --- libraries/wallet/wallet_transfer.cpp | 7 ------- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 940e04d328..bbaeac3659 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -1313,7 +1313,7 @@ signed_transaction wallet_api::borrow_asset(string seller_name, string amount_to string asset_symbol, string amount_of_collateral, bool broadcast)const { FC_ASSERT(!is_locked()); - return my->borrow_asset(seller_name, amount_to_sell, asset_symbol, amount_of_collateral, broadcast); + return my->borrow_asset_ext(seller_name, amount_to_sell, asset_symbol, amount_of_collateral, {}, broadcast); } signed_transaction wallet_api::borrow_asset_ext( string seller_name, string amount_to_sell, diff --git a/libraries/wallet/wallet_api_impl.hpp b/libraries/wallet/wallet_api_impl.hpp index e9e5810361..3a498dfe46 100644 --- a/libraries/wallet/wallet_api_impl.hpp +++ b/libraries/wallet/wallet_api_impl.hpp @@ -355,9 +355,6 @@ class wallet_api_impl string min_to_receive, string symbol_to_receive, uint32_t timeout_sec = 0, bool fill_or_kill = false, bool broadcast = false); - signed_transaction borrow_asset(string seller_name, string amount_to_borrow, string asset_symbol, - string amount_of_collateral, bool broadcast = false); - signed_transaction borrow_asset_ext( string seller_name, string amount_to_borrow, string asset_symbol, string amount_of_collateral, call_order_update_operation::extensions_type extensions, bool broadcast = false); diff --git a/libraries/wallet/wallet_transfer.cpp b/libraries/wallet/wallet_transfer.cpp index a18890624c..3707b11707 100644 --- a/libraries/wallet/wallet_transfer.cpp +++ b/libraries/wallet/wallet_transfer.cpp @@ -205,13 +205,6 @@ namespace graphene { namespace wallet { namespace detail { return sign_transaction( tx, broadcast ); } - signed_transaction wallet_api_impl::borrow_asset(string seller_name, string amount_to_borrow, - string asset_symbol, string amount_of_collateral, bool broadcast ) - { - return borrow_asset_ext( seller_name, amount_to_borrow, asset_symbol, amount_of_collateral, - {}, broadcast ); - } - signed_transaction wallet_api_impl::borrow_asset_ext( string seller_name, string amount_to_borrow, string asset_symbol, string amount_of_collateral, call_order_update_operation::extensions_type extensions, bool broadcast ) From 2d2bf9cee662fa3d91a9be789e297e2519c7fe58 Mon Sep 17 00:00:00 2001 From: abitmore Date: Wed, 26 Oct 2022 21:32:10 +0000 Subject: [PATCH 08/13] Fix code smells --- libraries/app/database_api.cpp | 36 +- libraries/app/database_api_impl.hxx | 9 +- .../app/include/graphene/app/database_api.hpp | 13 +- .../wallet/include/graphene/wallet/wallet.hpp | 548 +++++++++--------- .../graphene/wallet/wallet_structs.hpp | 10 +- libraries/wallet/wallet.cpp | 513 ++++++++-------- libraries/wallet/wallet_api_impl.hpp | 3 +- libraries/wallet/wallet_results.cpp | 25 +- tests/tests/api_limit_tests.cpp | 6 +- 9 files changed, 592 insertions(+), 571 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index a0dddc52b0..dfb1bac079 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -513,19 +513,14 @@ vector> database_api_impl::get_accounts( const vector database_api::get_full_accounts( const vector& names_or_ids, - optional subscribe ) +std::map> database_api::get_full_accounts( const vector& names_or_ids, + const optional& subscribe ) { return my->get_full_accounts( names_or_ids, subscribe ); } -vector database_api::get_top_voters(uint32_t limit)const -{ - return my->get_top_voters( limit ); -} - -std::map database_api_impl::get_full_accounts( const vector& names_or_ids, - optional subscribe ) +std::map> database_api_impl::get_full_accounts( + const vector& names_or_ids, const optional& subscribe ) { FC_ASSERT( _app_options, "Internal error" ); const auto configured_limit = _app_options->api_limit_get_full_accounts; @@ -535,7 +530,7 @@ std::map database_api_impl::get_full_accounts( const bool to_subscribe = get_whether_to_subscribe( subscribe ); - std::map results; + std::map> results; for (const std::string& account_name_or_id : names_or_ids) { @@ -703,6 +698,11 @@ std::map database_api_impl::get_full_accounts( const return results; } +vector database_api::get_top_voters(uint32_t limit)const +{ + return my->get_top_voters( limit ); +} + vector database_api_impl::get_top_voters(uint32_t limit)const { FC_ASSERT( _app_options, "Internal error" ); @@ -2203,14 +2203,14 @@ fc::optional database_api_impl::get_witness_by_account(const std return {}; } -map database_api::lookup_witness_accounts( const string& lower_bound_name, - uint32_t limit )const +map> database_api::lookup_witness_accounts( const string& lower_bound_name, + uint32_t limit )const { return my->lookup_witness_accounts( lower_bound_name, limit ); } -map database_api_impl::lookup_witness_accounts( const string& lower_bound_name, - uint32_t limit )const +map> database_api_impl::lookup_witness_accounts( const string& lower_bound_name, + uint32_t limit )const { FC_ASSERT( _app_options, "Internal error" ); const auto configured_limit = _app_options->api_limit_lookup_witness_accounts; @@ -2226,7 +2226,7 @@ map database_api_impl::lookup_witness_accounts( const s // records to return. This could be optimized, but we expect the // number of witnesses to be few and the frequency of calls to be rare // TODO optimize - std::map witnesses_by_account_name; + std::map> witnesses_by_account_name; for (const witness_object& witness : witnesses_by_id) if (auto account_iter = _db.find(witness.witness_account)) if (account_iter->name >= lower_bound_name) // we can ignore anything below lower_bound_name @@ -2294,13 +2294,13 @@ fc::optional database_api_impl::get_committee_member_by return {}; } -map database_api::lookup_committee_member_accounts( +map> database_api::lookup_committee_member_accounts( const string& lower_bound_name, uint32_t limit )const { return my->lookup_committee_member_accounts( lower_bound_name, limit ); } -map database_api_impl::lookup_committee_member_accounts( +map> database_api_impl::lookup_committee_member_accounts( const string& lower_bound_name, uint32_t limit )const { FC_ASSERT( _app_options, "Internal error" ); @@ -2317,7 +2317,7 @@ map database_api_impl::lookup_committee_member // records to return. This could be optimized, but we expect the // number of committee_members to be few and the frequency of calls to be rare // TODO optimize - std::map committee_members_by_account_name; + std::map> committee_members_by_account_name; for (const committee_member_object& committee_member : committee_members_by_id) if (auto account_iter = _db.find(committee_member.committee_member_account)) if (account_iter->name >= lower_bound_name) // we can ignore anything below lower_bound_name diff --git a/libraries/app/database_api_impl.hxx b/libraries/app/database_api_impl.hxx index 240793f53b..37c358a2cc 100644 --- a/libraries/app/database_api_impl.hxx +++ b/libraries/app/database_api_impl.hxx @@ -71,8 +71,8 @@ class database_api_impl : public std::enable_shared_from_this // Accounts vector> get_accounts( const vector& account_names_or_ids, optional subscribe )const; - std::map get_full_accounts( const vector& names_or_ids, - optional subscribe ); + map> get_full_accounts( const vector& names_or_ids, + const optional& subscribe ); vector get_top_voters(uint32_t limit)const; optional get_account_by_name( string name )const; vector get_account_references( const std::string account_id_or_name )const; @@ -160,7 +160,8 @@ class database_api_impl : public std::enable_shared_from_this // Witnesses vector> get_witnesses(const vector& witness_ids)const; fc::optional get_witness_by_account(const std::string& account_id_or_name)const; - map lookup_witness_accounts(const string& lower_bound_name, uint32_t limit)const; + map> lookup_witness_accounts( + const string& lower_bound_name, uint32_t limit )const; uint64_t get_witness_count()const; // Committee members @@ -168,7 +169,7 @@ class database_api_impl : public std::enable_shared_from_this const vector& committee_member_ids )const; fc::optional get_committee_member_by_account( const std::string& account_id_or_name )const; - map lookup_committee_member_accounts( + map> lookup_committee_member_accounts( const string& lower_bound_name, uint32_t limit )const; uint64_t get_committee_count()const; diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 73e858878b..b101dc84f0 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -306,8 +306,9 @@ class database_api * @a api_limit_get_full_accounts_lists option. Exceeded objects need to be queried with other APIs. * */ - std::map get_full_accounts( const vector& names_or_ids, - optional subscribe = optional() ); + map> get_full_accounts( + const vector& names_or_ids, + const optional& subscribe = optional() ); /** * @brief Returns vector of voting power sorted by reverse vp_active @@ -1141,7 +1142,8 @@ class database_api * @a api_limit_lookup_witness_accounts * @return Map of witness names to corresponding IDs */ - map lookup_witness_accounts(const string& lower_bound_name, uint32_t limit)const; + map> lookup_witness_accounts( const string& lower_bound_name, + uint32_t limit )const; /** * @brief Get the total number of witnesses registered with the blockchain @@ -1176,8 +1178,9 @@ class database_api * @a api_limit_lookup_committee_member_accounts * @return Map of committee_member names to corresponding IDs */ - map lookup_committee_member_accounts( const string& lower_bound_name, - uint32_t limit )const; + map> lookup_committee_member_accounts( + const string& lower_bound_name, + uint32_t limit )const; /** * @brief Get the total number of committee registered with the blockchain diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index c7756e9c52..eaf740e9a7 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -55,12 +55,12 @@ class wallet_api std::shared_ptr my; // Methods - wallet_api( const wallet_data& initial_data, fc::api rapi ); + wallet_api( const wallet_data& initial_data, const fc::api& rapi ); virtual ~wallet_api(); - bool copy_wallet_file( string destination_filename )const; + bool copy_wallet_file( const string& destination_filename )const; - fc::ecc::private_key derive_private_key(const std::string& prefix_string, int sequence_number) const; + fc::ecc::private_key derive_private_key( const string& prefix_string, uint32_t sequence_number ) const; /** Returns info about head block, chain_id, maintenance, participation, current active witnesses and * committee members. @@ -98,7 +98,7 @@ class wallet_api * @param limit the maximum number of accounts to return (max: 1000) * @returns a list of accounts mapping account names to account ids */ - map> list_accounts(const string& lowerbound, uint32_t limit)const; + map> list_accounts( const string& lowerbound, uint32_t limit )const; /** List the balances of an account. * Each account can have multiple balances, one for each type of asset owned by that * account. The returned list will only contain assets for which the account has a @@ -106,7 +106,7 @@ class wallet_api * @param account_name_or_id the name or id of the account whose balances you want * @returns a list of the given account's balances */ - vector list_account_balances(const string& account_name_or_id)const; + vector list_account_balances( const string& account_name_or_id )const; /** Lists all assets registered on the blockchain. * * To list all assets, pass the empty string \c "" for the lowerbound to start @@ -116,7 +116,7 @@ class wallet_api * @param limit the maximum number of assets to return (max: 100) * @returns the list of asset objects, ordered by symbol */ - vector list_assets(const string& lowerbound, uint32_t limit)const; + vector list_assets( const string& lowerbound, uint32_t limit )const; /** Returns assets count registered on the blockchain. * * @returns assets count @@ -131,7 +131,7 @@ class wallet_api * @param limit the number of entries to return (starting from the most recent) * @returns a list of \c operation_history_objects */ - vector get_account_history(const string& account_name_or_id, uint32_t limit)const; + vector get_account_history( const string& account_name_or_id, uint32_t limit )const; /** Returns the relative operations on the named account from start number. * @@ -164,8 +164,8 @@ class wallet_api * @param end the end of the time range * @return A list of OHLCV data, in "least recent first" order. */ - vector get_market_history( string symbol, string symbol2, uint32_t bucket, - fc::time_point_sec start, fc::time_point_sec end )const; + vector get_market_history( const string& symbol, const string& symbol2, uint32_t bucket, + const time_point_sec& start, const time_point_sec& end )const; /** * @brief Fetch all orders relevant to the specified account sorted descendingly by price @@ -186,11 +186,11 @@ class wallet_api * otherwise the \c ostart_price will be used */ vector get_account_limit_orders( const string& name_or_id, - const string &base, - const string "e, + const string& base, + const string& quote, uint32_t limit = 101, - optional ostart_id = optional(), - optional ostart_price = optional())const; + const optional& ostart_id = {}, + const optional& ostart_price = optional() )const; /** * @brief Get limit orders in a given market @@ -199,7 +199,7 @@ class wallet_api * @param limit Maximum number of orders to retrieve * @return The limit orders, ordered from least price to greatest */ - vector get_limit_orders(string a, string b, uint32_t limit)const; + vector get_limit_orders( const string& a, const string& b, uint32_t limit )const; /** * @brief Get call orders (aka margin positions) for a given asset @@ -207,7 +207,7 @@ class wallet_api * @param limit Maximum number of orders to retrieve * @return The call orders, ordered from earliest to be called to latest */ - vector get_call_orders(string asset_symbol_or_id, uint32_t limit)const; + vector get_call_orders( const string& asset_symbol_or_id, uint32_t limit )const; /** * @brief Get forced settlement orders in a given asset @@ -215,7 +215,7 @@ class wallet_api * @param limit Maximum number of orders to retrieve * @return The settle orders, ordered from earliest settlement date to latest */ - vector get_settle_orders(string a, uint32_t limit)const; + vector get_settle_orders( const string& a, uint32_t limit )const; /** Returns the collateral_bid object for the given MPA * @@ -224,8 +224,8 @@ class wallet_api * @param start the sequence number where to start looping back throw the history * @returns a list of \c collateral_bid_objects */ - vector get_collateral_bids(string asset_symbol_or_id, uint32_t limit = 100, - uint32_t start = 0)const; + vector get_collateral_bids( const string& asset_symbol_or_id, uint32_t limit = 100, + uint32_t start = 0 )const; /** Returns the block chain's slowly-changing settings. * This object contains all of the properties of the blockchain that are fixed @@ -248,7 +248,7 @@ class wallet_api */ account_history_operation_detail get_account_history_by_operations( const string& account_name_or_id, const flat_set& operation_types, - uint32_t start, uint32_t limit)const; + uint32_t start, uint32_t limit )const; /** Returns the block chain's rapidly-changing properties. * The returned object contains information that changes every block interval @@ -263,13 +263,13 @@ class wallet_api * @param account_name_or_id the name or ID of the account to provide information about * @returns the public account data stored in the blockchain */ - account_object get_account(string account_name_or_id) const; + account_object get_account( const string& account_name_or_id ) const; /** Returns information about the given asset. * @param asset_symbol_or_id the symbol or id of the asset in question * @returns the information about the asset stored in the block chain */ - extended_asset_object get_asset(string asset_symbol_or_id) const; + extended_asset_object get_asset( const string& asset_symbol_or_id ) const; /** Returns the BitAsset-specific data for a given asset. * Market-issued assets's behavior are determined both by their "BitAsset Data" and @@ -277,26 +277,26 @@ class wallet_api * @param asset_symbol_or_id the symbol or id of the BitAsset in question * @returns the BitAsset-specific data for this asset */ - asset_bitasset_data_object get_bitasset_data(string asset_symbol_or_id)const; + asset_bitasset_data_object get_bitasset_data( const string& asset_symbol_or_id )const; /** * Returns information about the given HTLC object. * @param htlc_id the id of the HTLC object. * @returns the information about the HTLC object */ - fc::optional get_htlc(const htlc_id_type& htlc_id) const; + optional get_htlc( const htlc_id_type& htlc_id ) const; /** Lookup the id of a named account. * @param account_name_or_id the name or ID of the account to look up * @returns the id of the named account */ - account_id_type get_account_id(string account_name_or_id) const; + account_id_type get_account_id( const string& account_name_or_id ) const; /** Lookup the name of an account. * @param account_name_or_id the name or ID of the account to look up * @returns the name of the account */ - string get_account_name(const string& account_name_or_id) const + string get_account_name( const string& account_name_or_id ) const { return get_account( account_name_or_id ).name; } /** @@ -304,14 +304,14 @@ class wallet_api * @param asset_symbol_or_id the symbol or ID of an asset to look up * @returns the id of the given asset */ - asset_id_type get_asset_id(const string& asset_symbol_or_id) const; + asset_id_type get_asset_id( const string& asset_symbol_or_id ) const; /** * Lookup the symbol of an asset. * @param asset_symbol_or_id the symbol or ID of an asset to look up * @returns the symbol of the given asset */ - string get_asset_symbol(const string& asset_symbol_or_id) const + string get_asset_symbol( const string& asset_symbol_or_id ) const { return get_asset( asset_symbol_or_id ).symbol; } /** @@ -319,7 +319,7 @@ class wallet_api * @param asset_symbol_or_id the symbol or ID of an asset to look up * @returns the symbol of the given asset */ - string get_asset_name(const string& asset_symbol_or_id) const + string get_asset_name( const string& asset_symbol_or_id ) const { return get_asset_symbol( asset_symbol_or_id ); } /** @@ -333,7 +333,7 @@ class wallet_api * @param id the id of the object to return * @returns the requested object */ - variant get_object(object_id_type id) const; + variant get_object( const object_id_type& id ) const; /** Returns the current wallet filename. * @@ -350,7 +350,7 @@ class wallet_api * @param pubkey a public key in Base58 format * @return the WIF private key */ - string get_private_key( public_key_type pubkey )const; + string get_private_key( const public_key_type& pubkey )const; /** * @ingroup Transaction Builder API @@ -366,7 +366,8 @@ class wallet_api * @param transaction_handle handle of the transaction builder * @param op the operation in JSON format */ - void add_operation_to_builder_transaction(transaction_handle_type transaction_handle, const operation& op)const; + void add_operation_to_builder_transaction( transaction_handle_type transaction_handle, + const operation& op )const; /** * @ingroup Transaction Builder API * @@ -375,9 +376,9 @@ class wallet_api * @param operation_index the index of the old operation in the builder to be replaced * @param new_op the new operation in JSON format */ - void replace_operation_in_builder_transaction(transaction_handle_type handle, - unsigned operation_index, - const operation& new_op)const; + void replace_operation_in_builder_transaction( transaction_handle_type handle, + uint32_t operation_index, + const operation& new_op )const; /** * @ingroup Transaction Builder API * @@ -386,7 +387,8 @@ class wallet_api * @param fee_asset symbol or ID of an asset that to be used to pay fees * @return total fees */ - asset set_fees_on_builder_transaction(transaction_handle_type handle, string fee_asset = GRAPHENE_SYMBOL)const; + asset set_fees_on_builder_transaction( transaction_handle_type handle, + const string& fee_asset = GRAPHENE_SYMBOL )const; /** * @ingroup Transaction Builder API * @@ -394,7 +396,7 @@ class wallet_api * @param handle handle of the transaction builder * @return a transaction */ - transaction preview_builder_transaction(transaction_handle_type handle)const; + transaction preview_builder_transaction( transaction_handle_type handle )const; /** * @ingroup Transaction Builder API * @@ -403,8 +405,8 @@ class wallet_api * @param broadcast whether to broadcast the signed transaction to the network * @return a signed transaction */ - signed_transaction sign_builder_transaction(transaction_handle_type transaction_handle, - bool broadcast = true)const; + signed_transaction sign_builder_transaction( transaction_handle_type transaction_handle, + bool broadcast = true )const; /** * @ingroup Transaction Builder API @@ -415,15 +417,15 @@ class wallet_api * @param broadcast whether to broadcast the signed transaction to the network * @return a signed transaction */ - signed_transaction sign_builder_transaction2(transaction_handle_type transaction_handle, + signed_transaction sign_builder_transaction2( transaction_handle_type transaction_handle, const vector& signing_keys = vector(), - bool broadcast = true)const; + bool broadcast = true )const; /** Broadcast signed transaction * @param tx signed transaction * @returns the transaction ID along with the signed transaction. */ - pair broadcast_transaction(signed_transaction tx)const; + pair broadcast_transaction( const signed_transaction& tx )const; /** * @ingroup Transaction Builder API @@ -443,7 +445,7 @@ class wallet_api */ signed_transaction propose_builder_transaction( transaction_handle_type handle, - time_point_sec expiration = time_point::now() + fc::minutes(1), + const time_point_sec& expiration = time_point::now() + fc::minutes(1), uint32_t review_period_seconds = 0, bool broadcast = true )const; @@ -464,8 +466,8 @@ class wallet_api */ signed_transaction propose_builder_transaction2( transaction_handle_type handle, - string account_name_or_id, - time_point_sec expiration = time_point::now() + fc::minutes(1), + const string& account_name_or_id, + const time_point_sec& expiration = time_point::now() + fc::minutes(1), uint32_t review_period_seconds = 0, bool broadcast = true )const; @@ -510,7 +512,7 @@ class wallet_api * @param password the password previously set with \c set_password() * @ingroup Wallet Management */ - void unlock(string password)const; + void unlock( const string& password )const; /** Sets a new password on the wallet. * @@ -523,7 +525,7 @@ class wallet_api * @param password a new password * @ingroup Wallet Management */ - void set_password(string password)const; + void set_password( const string& password )const; /** Dumps all private keys owned by the wallet. * @@ -546,7 +548,7 @@ class wallet_api * @param method the name of the API command you want help with * @returns a multi-line string suitable for displaying on a terminal */ - string gethelp(const string& method)const; + string gethelp( const string& method )const; /** Loads a specified BitShares wallet. * @@ -561,7 +563,7 @@ class wallet_api * existing wallet file * @returns true if the specified wallet is loaded */ - bool load_wallet_file(string wallet_filename = "")const; + bool load_wallet_file( const string& wallet_filename = "" )const; /** Quit from the wallet. * @@ -579,7 +581,7 @@ class wallet_api * or overwrite. If \c wallet_filename is empty, * save to the current filename. */ - void save_wallet_file(string wallet_filename = "")const; + void save_wallet_file( const string& wallet_filename = "" )const; /** Sets the wallet filename used for future writes. * @@ -588,7 +590,7 @@ class wallet_api * * @param wallet_filename the new filename to use for future saves */ - void set_wallet_filename(string wallet_filename)const; + void set_wallet_filename( const string& wallet_filename )const; /** Suggests a safe brain key to use for creating your account. * \c create_account_with_brain_key() requires you to specify a 'brain key', @@ -611,7 +613,8 @@ class wallet_api * @param number_of_desired_keys Number of desired keys * @return A list of keys that are deterministically derived from the brainkey */ - vector derive_owner_keys_from_brain_key(string brain_key, int number_of_desired_keys = 1) const; + vector derive_owner_keys_from_brain_key( const string& brain_key, + uint32_t number_of_desired_keys = 1 ) const; /** * Determine whether a textual representation of a public key @@ -620,16 +623,14 @@ class wallet_api * @param public_key Public key * @return Whether a public key is known */ - bool is_public_key_registered(string public_key) const; + bool is_public_key_registered( const string& public_key ) const; /** Converts a signed_transaction in JSON form to its binary representation. * * @param tx the transaction to serialize - * @returns the binary form of the transaction. It will not be hex encoded, - * this returns a raw string that may have null characters embedded - * in it + * @returns the binary form of the transaction, hex encoded. */ - string serialize_transaction(signed_transaction tx) const; + string serialize_transaction( const signed_transaction& tx ) const; /** Imports the private key for an existing account. * @@ -642,7 +643,7 @@ class wallet_api * @param wif_key the private key in WIF format * @returns true if the key was imported */ - bool import_key(string account_name_or_id, string wif_key)const; + bool import_key( const string& account_name_or_id, const string& wif_key )const; /** Imports accounts from a BitShares 0.x wallet file. * Current wallet file must be unlocked to perform the import. @@ -651,7 +652,7 @@ class wallet_api * @param password the password to encrypt the BitShares 0.x wallet file * @returns a map containing the accounts found and whether imported */ - map import_accounts( string filename, string password )const; + map> import_accounts( const string& filename, const string& password )const; /** Imports from a BitShares 0.x wallet file, find keys that were bound to a given account name on the * BitShares 0.x chain, rebind them to an account name on the 2.0 chain. @@ -664,8 +665,8 @@ class wallet_api * can be same or different to \c src_account_name * @returns whether the import has succeeded */ - bool import_account_keys( string filename, string password, - string src_account_name, string dest_account_name )const; + bool import_account_keys( const string& filename, const string& password, + const string& src_account_name, const string& dest_account_name )const; /** * This call will construct transaction(s) that will claim all balances controled @@ -675,7 +676,7 @@ class wallet_api * @param wif_keys private WIF keys of balance objects to claim balances from * @param broadcast true to broadcast the transaction on the network */ - vector< signed_transaction > import_balance( string account_name_or_id, const vector& wif_keys, + vector< signed_transaction > import_balance( const string& account_name_or_id, const vector& wif_keys, bool broadcast )const; /** Transforms a brain key to reduce the chance of errors when re-entering the key from memory. @@ -686,7 +687,7 @@ class wallet_api * @param s the brain key as supplied by the user * @returns the brain key in its normalized form */ - string normalize_brain_key(string s) const; + string normalize_brain_key( const string& s ) const; /** Registers a third party's account on the blockckain. * @@ -713,13 +714,13 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction registering the account */ - signed_transaction register_account(string name, - public_key_type owner, - public_key_type active, - string registrar_account, - string referrer_account, - uint32_t referrer_percent, - bool broadcast = false)const; + signed_transaction register_account( const string& name, + const public_key_type& owner, + const public_key_type& active, + const string& registrar_account, + const string& referrer_account, + uint32_t referrer_percent, + bool broadcast = false )const; /** * Upgrades an account to prime status. @@ -729,7 +730,7 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction upgrading the account */ - signed_transaction upgrade_account(string account_name_or_id, bool broadcast)const; + signed_transaction upgrade_account( const string& account_name_or_id, bool broadcast )const; /** Creates a new account and registers it on the blockchain. * @@ -751,11 +752,11 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction registering the account */ - signed_transaction create_account_with_brain_key(string brain_key, - string account_name, - string registrar_account, - string referrer_account, - bool broadcast = false)const; + signed_transaction create_account_with_brain_key( const string& brain_key, + const string& account_name, + const string& registrar_account, + const string& referrer_account, + bool broadcast = false )const; /** Transfer an amount from one account to another. * @param from the name or id of the account sending the funds @@ -769,12 +770,12 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction transferring funds */ - signed_transaction transfer(string from, - string to, - string amount, - string asset_symbol_or_id, - string memo, - bool broadcast = false)const; + signed_transaction transfer( const string& from, + const string& to, + const string& amount, + const string& asset_symbol_or_id, + const string& memo, + bool broadcast = false )const; /** * This method works just like transfer, except it always broadcasts and @@ -789,11 +790,11 @@ class wallet_api * increase with transaction size * @returns the transaction ID (hash) along with the signed transaction transferring funds */ - pair transfer2(const string& from, - const string& to, - const string& amount, - const string& asset_symbol_or_id, - const string& memo ) const { + pair transfer2( const string& from, + const string& to, + const string& amount, + const string& asset_symbol_or_id, + const string& memo ) const { auto trx = transfer( from, to, amount, asset_symbol_or_id, memo, true ); return std::make_pair(trx.id(),trx); } @@ -814,14 +815,14 @@ class wallet_api * @param memo text to sign * @return the signed memo data */ - memo_data sign_memo(string from, string to, string memo)const; + memo_data sign_memo( const string& from, const string& to, const string& memo )const; /** Read a memo. * * @param memo JSON-encoded memo. * @returns string with decrypted message. */ - string read_memo(const memo_data& memo)const; + string read_memo( const memo_data& memo )const; /** Sign a message using an account's memo key. The signature is generated as in @@ -831,7 +832,7 @@ class wallet_api * @param message text to sign * @return the signed message in an abstract format */ - signed_message sign_message(string signer, string message)const; + signed_message sign_message( const string& signer, const string& message )const; /** Verify a message signed with sign_message using the given account's memo key. * @@ -850,14 +851,14 @@ class wallet_api * @param message the signed_message structure containing message, meta data and signature * @return true if signature matches */ - bool verify_signed_message( signed_message message )const; + bool verify_signed_message( const signed_message& message )const; /** Verify a message signed with sign_message, in its encapsulated form. * * @param message the complete encapsulated message string including separators and line feeds * @return true if signature matches */ - bool verify_encapsulated_message( string message )const; + bool verify_encapsulated_message( const string& message )const; /** These methods are used for stealth transfers */ ///@{ @@ -869,14 +870,14 @@ class wallet_api * @param label a user-defined string as label * @return true if the label was set, otherwise false */ - bool set_key_label( public_key_type key, string label )const; + bool set_key_label( const public_key_type& key, const string& label )const; /** * Get label of a public key. * @param key a public key * @return the label if already set by \c set_key_label(), or an empty string if not set */ - string get_key_label( public_key_type key )const; + string get_key_label( const public_key_type& key )const; /** * Generates a new blind account for the given brain key and assigns it the given label. @@ -884,7 +885,7 @@ class wallet_api * @param brain_key the brain key to be used to generate a new blind account * @return the public key of the new account */ - public_key_type create_blind_account( string label, string brain_key )const; + public_key_type create_blind_account( const string& label, const string& brain_key )const; /** * Return the total balances of all blinded commitments that can be claimed by the @@ -893,23 +894,23 @@ class wallet_api * @return the total balances of all blinded commitments that can be claimed by the * given account key or label */ - vector get_blind_balances( string key_or_label )const; + vector get_blind_balances( const string& key_or_label )const; /** * Get all blind accounts. * @return all blind accounts */ - map get_blind_accounts()const; + map> get_blind_accounts()const; /** * Get all blind accounts for which this wallet has the private key. * @return all blind accounts for which this wallet has the private key */ - map get_my_blind_accounts()const; + map> get_my_blind_accounts()const; /** * Get the public key associated with a given label. * @param label a label * @return the public key associated with the given label */ - public_key_type get_public_key( string label )const; + public_key_type get_public_key( const string& label )const; ///@} /** @@ -917,7 +918,7 @@ class wallet_api * @param key_or_account a public key in Base58 format or an account * @return all blind receipts to/form the account */ - vector blind_history( string key_or_account )const; + vector blind_history( const string& key_or_account )const; /** * Given a confirmation receipt, this method will parse it for a blinded balance and confirm @@ -930,7 +931,9 @@ class wallet_api * @param opt_memo a self-defined label for this transfer to be saved in local wallet file * @return a blind receipt */ - blind_receipt receive_blind_transfer( string confirmation_receipt, string opt_from, string opt_memo )const; + blind_receipt receive_blind_transfer( const string& confirmation_receipt, + const string& opt_from, + const string& opt_memo )const; /** * Transfers a public balance from \c from_account_name_or_id to one or more blinded balances using a @@ -941,9 +944,9 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @return a blind confirmation */ - blind_confirmation transfer_to_blind( string from_account_name_or_id, - string asset_symbol_or_id, - vector> to_amounts, + blind_confirmation transfer_to_blind( const string& from_account_name_or_id, + const string& asset_symbol_or_id, + const vector>& to_amounts, bool broadcast = false )const; /** @@ -955,12 +958,11 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @return a blind confirmation */ - blind_confirmation transfer_from_blind( - string from_blind_account_key_or_label, - string to_account_name_or_id, - string amount, - string asset_symbol_or_id, - bool broadcast = false )const; + blind_confirmation transfer_from_blind( const string& from_blind_account_key_or_label, + const string& to_account_name_or_id, + const string& amount, + const string& asset_symbol_or_id, + bool broadcast = false )const; /** * Transfer from one set of blinded balances to another. @@ -971,10 +973,10 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @return a blind confirmation */ - blind_confirmation blind_transfer( string from_key_or_label, - string to_key_or_label, - string amount, - string symbol_or_id, + blind_confirmation blind_transfer( const string& from_key_or_label, + const string& to_key_or_label, + const string& amount, + const string& symbol_or_id, bool broadcast = false )const; /** Place a limit order attempting to sell one asset for another. @@ -1017,14 +1019,14 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction selling the funds */ - signed_transaction sell_asset(string seller_account, - string amount_to_sell, - string symbol_or_id_to_sell, - string min_to_receive, - string symbol_or_id_to_receive, - uint32_t timeout_sec = 0, - bool fill_or_kill = false, - bool broadcast = false)const; + signed_transaction sell_asset( const string& seller_account, + const string& amount_to_sell, + const string& symbol_or_id_to_sell, + const string& min_to_receive, + const string& symbol_or_id_to_receive, + uint32_t timeout_sec = 0, + bool fill_or_kill = false, + bool broadcast = false )const; /** Borrow an asset or update the debt/collateral ratio for the loan. * @@ -1040,8 +1042,9 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction borrowing the asset */ - signed_transaction borrow_asset(string borrower, string amount_to_borrow, string asset_symbol_or_id, - string amount_of_collateral, bool broadcast = false)const; + signed_transaction borrow_asset( const string& borrower, const string& amount_to_borrow, + const string& asset_symbol_or_id, + const string& amount_of_collateral, bool broadcast = false )const; /** Borrow an asset or update the debt/collateral ratio for the loan, with additional options. * @@ -1058,9 +1061,10 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction borrowing the asset */ - signed_transaction borrow_asset_ext( string borrower, string amount_to_borrow, string asset_symbol_or_id, - string amount_of_collateral, - call_order_update_operation::extensions_type extensions, + signed_transaction borrow_asset_ext( const string& borrower, const string& amount_to_borrow, + const string& asset_symbol_or_id, + const string& amount_of_collateral, + const call_order_update_operation::extensions_type& extensions, bool broadcast = false )const; /** Cancel an existing order @@ -1069,7 +1073,7 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction canceling the order */ - signed_transaction cancel_order(const limit_order_id_type& order_id, bool broadcast = false) const; + signed_transaction cancel_order( const limit_order_id_type& order_id, bool broadcast = false ) const; /** Creates a new user-issued or market-issued asset. * @@ -1093,12 +1097,12 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction creating a new asset */ - signed_transaction create_asset(string issuer, - string symbol, - uint8_t precision, - asset_options common, - fc::optional bitasset_opts, - bool broadcast = false)const; + signed_transaction create_asset( const string& issuer, + const string& symbol, + uint8_t precision, + const asset_options& common, + const optional& bitasset_opts, + bool broadcast = false )const; /** Create the specified amount of the specified asset and credit into the specified account. * @@ -1109,10 +1113,10 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction issuing the new supply */ - signed_transaction issue_asset(string to_account, string amount, - string symbol_or_id, - string memo, - bool broadcast = false)const; + signed_transaction issue_asset( const string& to_account, const string& amount, + const string& symbol_or_id, + const string& memo, + bool broadcast = false )const; /** Update the core options on an asset. * There are a number of options which all assets in the network use. These options are @@ -1130,10 +1134,10 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction updating the asset */ - signed_transaction update_asset(string symbol_or_id, - optional new_issuer, - asset_options new_options, - bool broadcast = false)const; + signed_transaction update_asset( const string& symbol_or_id, + const optional& new_issuer, + const asset_options& new_options, + bool broadcast = false )const; /** Update the issuer of an asset * Since this call requires the owner authority of the current issuer to sign the transaction, @@ -1146,14 +1150,14 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction updating the asset */ - signed_transaction update_asset_issuer(string symbol_or_id, - string new_issuer, - bool broadcast = false)const; + signed_transaction update_asset_issuer( const string& symbol_or_id, + const string& new_issuer, + bool broadcast = false )const; /** Update the options specific to a BitAsset. * - * BitAssets have some options which are not relevant to other asset types. This operation is used to update those - * options an an existing BitAsset. + * BitAssets have some options which are not relevant to other asset types. + * This operation is used to update those options an an existing BitAsset. * * @see update_asset() * @@ -1163,13 +1167,14 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction updating the bitasset */ - signed_transaction update_bitasset(string symbol_or_id, - bitasset_options new_options, - bool broadcast = false)const; + signed_transaction update_bitasset( const string& symbol_or_id, + const bitasset_options& new_options, + bool broadcast = false )const; /** Update the set of feed-producing accounts for a BitAsset. * - * BitAssets have price feeds selected by taking the median values of recommendations from a set of feed producers. + * BitAssets have price feeds selected by taking the median values of recommendations from + * a set of feed producers. * This command is used to specify which accounts may produce feeds for a given BitAsset. * @param symbol_or_id the symbol or id of the asset to update * @param new_feed_producers a list of account names or ids which are authorized to produce feeds for the asset. @@ -1177,23 +1182,25 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction updating the bitasset's feed producers */ - signed_transaction update_asset_feed_producers(string symbol_or_id, - flat_set new_feed_producers, - bool broadcast = false)const; + signed_transaction update_asset_feed_producers( const string& symbol_or_id, + const flat_set& new_feed_producers, + bool broadcast = false )const; /** Publishes a price feed for the named asset. * * Price feed providers use this command to publish their price feeds for market-issued assets. A price feed is - * used to tune the market for a particular market-issued asset. For each value in the feed, the median across all - * committee_member feeds for that asset is calculated and the market for the asset is configured with the median of that - * value. - * - * The feed object in this command contains three prices: a call price limit, a short price limit, and a settlement price. - * The call limit price is structured as (collateral asset) / (debt asset) and the short limit price is structured - * as (asset for sale) / (collateral asset). Note that the asset IDs are opposite to eachother, so if we're - * publishing a feed for USD, the call limit price will be CORE/USD and the short limit price will be USD/CORE. The - * settlement price may be flipped either direction, as long as it is a ratio between the market-issued asset and - * its collateral. + * used to tune the market for a particular market-issued asset. For each value in the feed, the median across + * all committee_member feeds for that asset is calculated and the market for the asset is configured with the + * median of that value. + * + * The feed object in this command contains three prices: a call price limit, a short price limit, + * and a settlement price. + * The call limit price is structured as (collateral asset) / (debt asset) and the short limit price is + * structured as (asset for sale) / (collateral asset). + * Note that the asset IDs are opposite to eachother, so if we're + * publishing a feed for USD, the call limit price will be CORE/USD and the short limit price will be USD/CORE. + * The settlement price may be flipped either direction, as long as it is a ratio between the market-issued + * asset and its collateral. * * @param publishing_account the account publishing the price feed * @param symbol_or_id the symbol or id of the asset whose feed we're publishing @@ -1201,10 +1208,10 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction updating the price feed for the given asset */ - signed_transaction publish_asset_feed(string publishing_account, - string symbol_or_id, - price_feed feed, - bool broadcast = false)const; + signed_transaction publish_asset_feed( const string& publishing_account, + const string& symbol_or_id, + const price_feed& feed, + bool broadcast = false )const; /** Pay into the fee pool for the given asset. * @@ -1220,10 +1227,10 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction funding the fee pool */ - signed_transaction fund_asset_fee_pool(string from, - string symbol_or_id, - string amount, - bool broadcast = false)const; + signed_transaction fund_asset_fee_pool( const string& from, + const string& symbol_or_id, + const string& amount, + bool broadcast = false )const; /** Claim funds from the fee pool for the given asset. * @@ -1238,9 +1245,9 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction claiming from the fee pool */ - signed_transaction claim_asset_fee_pool(string symbol_or_id, - string amount, - bool broadcast = false)const; + signed_transaction claim_asset_fee_pool( const string& symbol_or_id, + const string& amount, + bool broadcast = false )const; /** Burns an amount of given asset to its reserve pool. * @@ -1252,10 +1259,10 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction burning the asset */ - signed_transaction reserve_asset(string from, - string amount, - string symbol_or_id, - bool broadcast = false)const; + signed_transaction reserve_asset( const string& from, + const string& amount, + const string& symbol_or_id, + bool broadcast = false )const; /** Forces a global settling of the given asset (black swan or prediction markets). * @@ -1274,9 +1281,9 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction settling the named asset */ - signed_transaction global_settle_asset(string symbol_or_id, - price settle_price, - bool broadcast = false)const; + signed_transaction global_settle_asset( const string& symbol_or_id, + const price& settle_price, + bool broadcast = false )const; /** Schedules a market-issued asset for automatic settlement. * @@ -1296,10 +1303,10 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction settling the named asset */ - signed_transaction settle_asset(string account_to_settle, - string amount_to_settle, - string symbol_or_id, - bool broadcast = false)const; + signed_transaction settle_asset( const string& account_to_settle, + const string& amount_to_settle, + const string& symbol_or_id, + bool broadcast = false )const; /** Creates or updates a bid on an MPA after global settlement. * @@ -1317,8 +1324,9 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction creating/updating the bid */ - signed_transaction bid_collateral(string bidder, string debt_amount, string debt_symbol_or_id, - string additional_collateral, bool broadcast = false)const; + signed_transaction bid_collateral( const string& bidder, const string& debt_amount, + const string& debt_symbol_or_id, + const string& additional_collateral, bool broadcast = false )const; /** Whitelist and blacklist accounts, primarily for transacting in whitelisted assets. * @@ -1340,10 +1348,10 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction changing the whitelisting status */ - signed_transaction whitelist_account(string authorizing_account, - string account_to_list, - account_whitelist_operation::account_listing new_listing_status, - bool broadcast = false)const; + signed_transaction whitelist_account( const string& authorizing_account, + const string& account_to_list, + account_whitelist_operation::account_listing new_listing_status, + bool broadcast = false )const; /** Creates a committee_member object owned by the given account. * @@ -1355,9 +1363,9 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction registering a committee_member */ - signed_transaction create_committee_member(string owner_account, - string url, - bool broadcast = false)const; + signed_transaction create_committee_member( const string& owner_account, + const string& url, + bool broadcast = false )const; /** Lists all witnesses registered in the blockchain. * This returns a list of all account names that own witnesses, and the associated witness id, @@ -1372,7 +1380,7 @@ class wallet_api * @param limit the maximum number of witnesss to return (max: 1000) * @returns a list of witnesss mapping witness names to witness ids */ - map list_witnesses(const string& lowerbound, uint32_t limit)const; + map> list_witnesses( const string& lowerbound, uint32_t limit )const; /** Lists all committee_members registered in the blockchain. * This returns a list of all account names that own committee_members, and the associated committee_member id, @@ -1387,19 +1395,20 @@ class wallet_api * @param limit the maximum number of committee_members to return (max: 1000) * @returns a list of committee_members mapping committee_member names to committee_member ids */ - map list_committee_members(const string& lowerbound, uint32_t limit)const; + map> list_committee_members( + const string& lowerbound, uint32_t limit )const; /** Returns information about the given witness. * @param owner_account the name or id of the witness account owner, or the id of the witness * @returns the information about the witness stored in the block chain */ - witness_object get_witness(string owner_account)const; + witness_object get_witness( const string& owner_account )const; /** Returns information about the given committee_member. * @param owner_account the name or id of the committee_member account owner, or the id of the committee_member * @returns the information about the committee_member stored in the block chain */ - committee_member_object get_committee_member(string owner_account)const; + committee_member_object get_committee_member( const string& owner_account )const; /** Creates a witness object owned by the given account. * @@ -1411,9 +1420,9 @@ class wallet_api * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction registering a witness */ - signed_transaction create_witness(string owner_account, - string url, - bool broadcast = false)const; + signed_transaction create_witness( const string& owner_account, + const string& url, + bool broadcast = false )const; /** * Update a witness object owned by the given account. @@ -1425,10 +1434,10 @@ class wallet_api * @param broadcast true if you wish to broadcast the transaction. * @return the signed transaction */ - signed_transaction update_witness(string witness_name, - string url, - string block_signing_key, - bool broadcast = false)const; + signed_transaction update_witness( const string& witness_name, + const string& url, + const string& block_signing_key, + bool broadcast = false )const; /** @@ -1445,13 +1454,13 @@ class wallet_api * @return the signed transaction */ signed_transaction create_worker( - string owner_account, - time_point_sec work_begin_date, - time_point_sec work_end_date, - share_type daily_pay, - string name, - string url, - variant worker_settings, + const string& owner_account, + const time_point_sec& work_begin_date, + const time_point_sec& work_end_date, + const share_type& daily_pay, + const string& name, + const string& url, + const variant& worker_settings, bool broadcast = false )const; @@ -1464,8 +1473,8 @@ class wallet_api * @return the signed transaction */ signed_transaction update_worker_votes( - string account, - worker_vote_delta delta, + const string& account, + const worker_vote_delta& delta, bool broadcast = false )const; @@ -1476,7 +1485,7 @@ class wallet_api * @param destination The account that will receive the funds if the preimage is presented * @param amount the amount of the asset that is to be traded * @param asset_symbol_or_id The asset that is to be traded - * @param hash_algorithm the algorithm used to generate the hash from the preimage. Can be RIPEMD160, SHA1 or SHA256. + * @param hash_algorithm the algorithm used to generate the hash from the preimage. Can be RIPEMD160 or SHA256. * @param preimage_hash the hash of the preimage * @param preimage_size the size of the preimage in bytes * @param claim_period_seconds how long after creation until the lock expires @@ -1487,7 +1496,7 @@ class wallet_api signed_transaction htlc_create( const string& source, const string& destination, const string& amount, const string& asset_symbol_or_id, const string& hash_algorithm, const string& preimage_hash, uint32_t preimage_size, - uint32_t claim_period_seconds, const string& memo, bool broadcast = false) const; + uint32_t claim_period_seconds, const string& memo, bool broadcast = false ) const; /**** * Update a hashed time lock contract @@ -1497,7 +1506,7 @@ class wallet_api * @param preimage the preimage that should evaluate to the preimage_hash * @return the signed transaction */ - signed_transaction htlc_redeem( const htlc_id_type& htlc_id, const string& issuer, const std::string& preimage, + signed_transaction htlc_redeem( const htlc_id_type& htlc_id, const string& issuer, const string& preimage, bool broadcast = false ) const; /***** @@ -1510,7 +1519,7 @@ class wallet_api * @return the signed transaction */ signed_transaction htlc_extend( const htlc_id_type& htlc_id, const string& issuer, uint32_t seconds_to_add, - bool broadcast = false) const; + bool broadcast = false ) const; /** * Get information about a vesting balance object or vesting balance objects owned by an account. @@ -1518,7 +1527,7 @@ class wallet_api * @param account_name An account name, account ID, or vesting balance object ID. * @return a list of vesting balance objects with additional info */ - vector< vesting_balance_object_with_info > get_vesting_balances( string account_name )const; + vector< vesting_balance_object_with_info > get_vesting_balances( const string& account_name )const; /** * Withdraw a vesting balance. @@ -1530,10 +1539,10 @@ class wallet_api * @return the signed transaction */ signed_transaction withdraw_vesting( - string witness_name, - string amount, - string asset_symbol_or_id, - bool broadcast = false)const; + const string& witness_name, + const string& amount, + const string& asset_symbol_or_id, + bool broadcast = false )const; /** Vote for a given committee_member. * @@ -1552,10 +1561,10 @@ class wallet_api * @param broadcast true if you wish to broadcast the transaction * @return the signed transaction changing your vote for the given committee_member */ - signed_transaction vote_for_committee_member(string voting_account, - string committee_member, - bool approve, - bool broadcast = false)const; + signed_transaction vote_for_committee_member( const string& voting_account, + const string& committee_member, + bool approve, + bool broadcast = false )const; /** Vote for a given witness. * @@ -1574,10 +1583,10 @@ class wallet_api * @param broadcast true if you wish to broadcast the transaction * @return the signed transaction changing your vote for the given witness */ - signed_transaction vote_for_witness(string voting_account, - string witness, - bool approve, - bool broadcast = false)const; + signed_transaction vote_for_witness( const string& voting_account, + const string& witness, + bool approve, + bool broadcast = false )const; /** Set the voting proxy for an account. * @@ -1597,9 +1606,9 @@ class wallet_api * @param broadcast true if you wish to broadcast the transaction * @return the signed transaction changing your vote proxy settings */ - signed_transaction set_voting_proxy(string account_to_modify, - optional voting_account, - bool broadcast = false)const; + signed_transaction set_voting_proxy( const string& account_to_modify, + const optional& voting_account, + bool broadcast = false )const; /** Set your vote for the number of witnesses and committee_members in the system. * @@ -1622,34 +1631,34 @@ class wallet_api * @param broadcast true if you wish to broadcast the transaction * @return the signed transaction changing your vote proxy settings */ - signed_transaction set_desired_witness_and_committee_member_count(string account_to_modify, + signed_transaction set_desired_witness_and_committee_member_count( const string& account_to_modify, uint16_t desired_number_of_witnesses, uint16_t desired_number_of_committee_members, - bool broadcast = false)const; + bool broadcast = false )const; /** Signs a transaction. * * Given a fully-formed transaction that is only lacking signatures, this signs * the transaction with the necessary keys and optionally broadcasts the transaction - * @param tx the unsigned transaction + * @param tx the transaction to be signed * @param broadcast true if you wish to broadcast the transaction * @return the signed version of the transaction */ - signed_transaction sign_transaction(signed_transaction tx, bool broadcast = false)const; + signed_transaction sign_transaction( const signed_transaction& tx, bool broadcast = false )const; /** Signs a transaction. * * Given a fully-formed transaction that is only lacking signatures, this signs * the transaction with the inferred necessary keys and the explicitly provided keys, * and optionally broadcasts the transaction - * @param tx the unsigned transaction + * @param tx the transaction to be signed * @param signing_keys Keys that must be used when signing the transaction * @param broadcast true if you wish to broadcast the transaction * @return the signed version of the transaction */ - signed_transaction sign_transaction2(signed_transaction tx, - const vector& signing_keys = vector(), - bool broadcast = true)const; + signed_transaction sign_transaction2( const signed_transaction& tx, + const vector& signing_keys = vector(), + bool broadcast = true )const; /** Get transaction signers. @@ -1659,7 +1668,7 @@ class wallet_api * @param tx the signed transaction * @return the set of public_keys */ - flat_set get_transaction_signers(const signed_transaction &tx) const; + flat_set get_transaction_signers( const signed_transaction& tx ) const; /** Get key references. * @@ -1667,7 +1676,7 @@ class wallet_api * @param keys public keys to search for related accounts * @return the set of related accounts */ - vector> get_key_references(const vector &keys) const; + vector> get_key_references( const vector& keys ) const; /** Returns an uninitialized object representing a given blockchain operation. * @@ -1685,7 +1694,7 @@ class wallet_api * (e.g., "global_parameters_update_operation") * @return a default-constructed operation of the given type */ - operation get_prototype_operation(string operation_type)const; + operation get_prototype_operation( const string& operation_type )const; /** Creates a transaction to propose a parameter change. * @@ -1700,9 +1709,9 @@ class wallet_api */ signed_transaction propose_parameter_change( const string& proposing_account, - fc::time_point_sec expiration_time, + const time_point_sec& expiration_time, const variant_object& changed_values, - bool broadcast = false)const; + bool broadcast = false )const; /** Propose a fee change. * @@ -1715,9 +1724,9 @@ class wallet_api */ signed_transaction propose_fee_change( const string& proposing_account, - fc::time_point_sec expiration_time, + const time_point_sec& expiration_time, const variant_object& changed_values, - bool broadcast = false)const; + bool broadcast = false )const; /** Approve or disapprove a proposal. * @@ -1741,7 +1750,7 @@ class wallet_api * @param limit depth of the order book to retrieve, for bids and asks each, capped at 50 * @return Order book of the market */ - order_book get_order_book( const string& base, const string& quote, unsigned limit = 50)const; + order_book get_order_book( const string& base, const string& quote, uint32_t limit = 50 )const; /** Signs a transaction. * @@ -1749,22 +1758,22 @@ class wallet_api * the transaction with the owned keys and optionally broadcasts the * transaction. * - * @param tx the unsigned transaction + * @param tx the transaction to add signature to * @param broadcast true if you wish to broadcast the transaction * * @return the signed transaction */ - signed_transaction add_transaction_signature( signed_transaction tx, + signed_transaction add_transaction_signature( const signed_transaction& tx, bool broadcast = false )const; - void dbg_make_uia(string creator, string symbol)const; - void dbg_make_mia(string creator, string symbol)const; - void dbg_push_blocks( std::string src_filename, uint32_t count )const; - void dbg_generate_blocks( std::string debug_wif_key, uint32_t count )const; - void dbg_stream_json_objects( const std::string& filename )const; - void dbg_update_object( fc::variant_object update )const; + void dbg_make_uia( const string& creator, const string& symbol )const; + void dbg_make_mia( const string& creator, const string& symbol )const; + void dbg_push_blocks( const string& src_filename, uint32_t count )const; + void dbg_generate_blocks( const string& debug_wif_key, uint32_t count )const; + void dbg_stream_json_objects( const string& filename )const; + void dbg_update_object( const variant_object& update )const; - void flood_network(string prefix, uint32_t number_of_transactions)const; + void flood_network( const string& prefix, uint32_t number_of_transactions )const; void network_add_nodes( const vector& nodes )const; vector< variant > network_get_connected_peers()const; @@ -1772,15 +1781,16 @@ class wallet_api /** * Used to transfer from one set of blinded balances to another */ - blind_confirmation blind_transfer_help( string from_key_or_label, - string to_key_or_label, - string amount, - string symbol, - bool broadcast = false, - bool to_temp = false )const; + blind_confirmation blind_transfer_help( const string& from_key_or_label, + const string& to_key_or_label, + const string& amount, + const string& symbol, + bool broadcast = false, + bool to_temp = false )const; - std::map> get_result_formatters() const; + std::map< string, std::function< string( const variant&, const fc::variants& ) >, std::less<> > + get_result_formatters() const; void encrypt_keys()const; @@ -1798,8 +1808,8 @@ class wallet_api * * @return The signed transaction */ - signed_transaction account_store_map(string account, string catalog, bool remove, - flat_map> key_values, bool broadcast)const; + signed_transaction account_store_map( const string& account, const string& catalog, bool remove, + const flat_map>& key_values, bool broadcast )const; /** * Get \c account_storage_object of an account by using the custom operations plugin. @@ -1811,7 +1821,7 @@ class wallet_api * * @return An \c account_storage_object or empty. */ - vector get_account_storage(string account, string catalog)const; + vector get_account_storage( const string& account, const string& catalog )const; }; diff --git a/libraries/wallet/include/graphene/wallet/wallet_structs.hpp b/libraries/wallet/include/graphene/wallet/wallet_structs.hpp index 00dba9e19a..b4a69306b2 100644 --- a/libraries/wallet/include/graphene/wallet/wallet_structs.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet_structs.hpp @@ -228,8 +228,7 @@ struct worker_vote_delta struct signed_block_with_info : public signed_block { - signed_block_with_info( const signed_block& block ); - signed_block_with_info( const signed_block_with_info& block ) = default; + explicit signed_block_with_info( const signed_block& block ); block_id_type block_id; public_key_type signing_key; @@ -238,8 +237,7 @@ struct signed_block_with_info : public signed_block struct vesting_balance_object_with_info : public vesting_balance_object { - vesting_balance_object_with_info( const vesting_balance_object& vbo, fc::time_point_sec now ); - vesting_balance_object_with_info( const vesting_balance_object_with_info& vbo ) = default; + vesting_balance_object_with_info( const vesting_balance_object& vbo, const fc::time_point_sec& now ); /** * How much is allowed to be withdrawn. @@ -289,8 +287,8 @@ class utility { * @param number_of_desired_keys Number of desired keys * @return A list of keys that are deterministically derived from the brainkey */ - static vector derive_owner_keys_from_brain_key( string brain_key, - int number_of_desired_keys = 1 ); + static vector derive_owner_keys_from_brain_key( const string& brain_key, + uint32_t number_of_desired_keys = 1 ); /** Suggests a safe brain key to use for creating your account. * \c create_account_with_brain_key() requires you to specify a 'brain key', diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index bbaeac3659..848e26c711 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -90,20 +90,22 @@ namespace graphene { namespace wallet { fc::stringstream to_sign; to_sign << message << '\n'; to_sign << "account=" << meta.account << '\n'; - to_sign << "memokey=" << std::string( meta.memo_key ) << '\n'; + to_sign << "memokey=" << string( meta.memo_key ) << '\n'; to_sign << "block=" << meta.block << '\n'; to_sign << "timestamp=" << meta.time; return fc::sha256::hash( to_sign.str() ); } - vector utility::derive_owner_keys_from_brain_key(string brain_key, int number_of_desired_keys) + vector utility::derive_owner_keys_from_brain_key( const string& brain_key, + uint32_t number_of_desired_keys ) { // Safety-check - FC_ASSERT( number_of_desired_keys >= 1 ); + FC_ASSERT( number_of_desired_keys >= 1, "number_of_desired_keys should be at least 1" ); // Create as many derived owner keys as requested vector results; - for (int i = 0; i < number_of_desired_keys; ++i) { + for( uint32_t i = 0; i < number_of_desired_keys; ++i ) + { fc::ecc::private_key priv_key = graphene::wallet::detail::derive_private_key( brain_key, i ); brain_key_info result; @@ -130,7 +132,7 @@ namespace graphene { namespace wallet { entropy += entropy2; string brain_key = ""; - for (int i = 0; i < BRAIN_KEY_WORD_COUNT; i++) + for( uint32_t i = 0; i < BRAIN_KEY_WORD_COUNT; ++i ) { fc::bigint choice = entropy % graphene::words::word_list_size; entropy /= graphene::words::word_list_size; @@ -150,14 +152,14 @@ namespace graphene { namespace wallet { namespace graphene { namespace wallet { -wallet_api::wallet_api(const wallet_data& initial_data, fc::api rapi) +wallet_api::wallet_api( const wallet_data& initial_data, const fc::api& rapi ) : my( std::make_unique(*this, initial_data, rapi) ) { } wallet_api::~wallet_api() = default; -bool wallet_api::copy_wallet_file(string destination_filename)const +bool wallet_api::copy_wallet_file( const string& destination_filename )const { return my->copy_wallet_file(destination_filename); } @@ -177,17 +179,17 @@ vector wallet_api::list_my_accounts()const return vector(my->_wallet.my_accounts.begin(), my->_wallet.my_accounts.end()); } -map> wallet_api::list_accounts(const string& lowerbound, uint32_t limit)const +map> wallet_api::list_accounts( const string& lowerbound, uint32_t limit )const { return my->_remote_db->lookup_accounts(lowerbound, limit, {}); } -vector wallet_api::list_account_balances(const string& id)const +vector wallet_api::list_account_balances( const string& id )const { return my->_remote_db->get_account_balances(id, flat_set()); } -vector wallet_api::list_assets(const string& lowerbound, uint32_t limit)const +vector wallet_api::list_assets( const string& lowerbound, uint32_t limit )const { return my->_remote_db->list_assets( lowerbound, limit ); } @@ -237,7 +239,7 @@ fc::optional wallet_api::get_htlc(const htlc_id_type& htlc_id) cons result_type operator()(const fc::hash160& obj)const { return convert("HASH160", obj.str()); } private: - result_type convert(const std::string& type, const std::string& hash)const + result_type convert(const string& type, const string& hash)const { fc::mutable_variant_object ret_val; ret_val["hash_algo"] = type; @@ -275,7 +277,7 @@ signed_transaction wallet_api::htlc_extend( const htlc_id_type& htlc_id, const s return my->htlc_extend(htlc_id, issuer, seconds_to_add, broadcast); } -vector wallet_api::get_account_history(const string& name, uint32_t limit)const +vector wallet_api::get_account_history( const string& name, uint32_t limit )const { vector result; @@ -337,7 +339,7 @@ vector wallet_api::get_relative_account_history( const string& name, uint32_t stop, uint32_t limit, - uint32_t start)const + uint32_t start )const { vector result; auto account_id = get_account(name).get_id(); @@ -377,7 +379,7 @@ account_history_operation_detail wallet_api::get_account_history_by_operations( const string& name, const flat_set& operation_types, uint32_t start, - uint32_t limit)const + uint32_t limit )const { account_history_operation_detail result; @@ -420,50 +422,50 @@ account_history_operation_detail wallet_api::get_account_history_by_operations( return result; } -full_account wallet_api::get_full_account( const string& name_or_id)const +full_account wallet_api::get_full_account( const string& name_or_id )const { return my->_remote_db->get_full_accounts({name_or_id}, false)[name_or_id]; } vector wallet_api::get_market_history( - string symbol1, - string symbol2, + const string& symbol1, + const string& symbol2, uint32_t bucket, - fc::time_point_sec start, - fc::time_point_sec end )const + const fc::time_point_sec& start, + const fc::time_point_sec& end )const { return my->_remote_hist->get_market_history( symbol1, symbol2, bucket, start, end ); } vector wallet_api::get_account_limit_orders( const string& name_or_id, - const string &base, - const string "e, + const string& base, + const string& quote, uint32_t limit, - optional ostart_id, - optional ostart_price)const + const optional& ostart_id, + const optional& ostart_price )const { return my->_remote_db->get_account_limit_orders(name_or_id, base, quote, limit, ostart_id, ostart_price); } -vector wallet_api::get_limit_orders(std::string a, std::string b, uint32_t limit)const +vector wallet_api::get_limit_orders( const string& a, const string& b, uint32_t limit )const { return my->_remote_db->get_limit_orders(a, b, limit); } -vector wallet_api::get_call_orders(std::string a, uint32_t limit)const +vector wallet_api::get_call_orders( const string& a, uint32_t limit )const { return my->_remote_db->get_call_orders(a, limit); } -vector wallet_api::get_settle_orders(std::string a, uint32_t limit)const +vector wallet_api::get_settle_orders( const string& a, uint32_t limit )const { return my->_remote_db->get_settle_orders(a, limit); } -vector wallet_api::get_collateral_bids(std::string asset, uint32_t limit, uint32_t start)const +vector wallet_api::get_collateral_bids( const string& a, uint32_t limit, uint32_t start )const { - return my->_remote_db->get_collateral_bids(asset, limit, start); + return my->_remote_db->get_collateral_bids(a, limit, start); } brain_key_info wallet_api::suggest_brain_key()const @@ -472,25 +474,25 @@ brain_key_info wallet_api::suggest_brain_key()const } vector wallet_api::derive_owner_keys_from_brain_key( - string brain_key, - int number_of_desired_keys) const + const string& brain_key, + uint32_t number_of_desired_keys ) const { return graphene::wallet::utility::derive_owner_keys_from_brain_key(brain_key, number_of_desired_keys); } -bool wallet_api::is_public_key_registered(string public_key) const +bool wallet_api::is_public_key_registered( const string& public_key ) const { bool is_known = my->_remote_db->is_public_key_registered(public_key); return is_known; } -string wallet_api::serialize_transaction( signed_transaction tx )const +string wallet_api::serialize_transaction( const signed_transaction& tx )const { return fc::to_hex(fc::raw::pack(tx)); } -variant wallet_api::get_object( object_id_type id ) const +variant wallet_api::get_object( const object_id_type& id ) const { return my->_remote_db->get_objects({id}, {}); } @@ -507,20 +509,20 @@ transaction_handle_type wallet_api::begin_builder_transaction()const void wallet_api::add_operation_to_builder_transaction( transaction_handle_type transaction_handle, - const operation& op)const + const operation& op )const { my->add_operation_to_builder_transaction(transaction_handle, op); } void wallet_api::replace_operation_in_builder_transaction( transaction_handle_type handle, - unsigned operation_index, - const operation& new_op)const + uint32_t operation_index, + const operation& new_op )const { my->replace_operation_in_builder_transaction(handle, operation_index, new_op); } -asset wallet_api::set_fees_on_builder_transaction(transaction_handle_type handle, string fee_asset)const +asset wallet_api::set_fees_on_builder_transaction( transaction_handle_type handle, const string& fee_asset )const { return my->set_fees_on_builder_transaction(handle, fee_asset); } @@ -543,26 +545,26 @@ signed_transaction wallet_api::sign_builder_transaction2(transaction_handle_type return my->sign_builder_transaction2(transaction_handle, explicit_keys, broadcast); } -pair wallet_api::broadcast_transaction(signed_transaction tx)const +pair wallet_api::broadcast_transaction( const signed_transaction& tx )const { return my->broadcast_transaction(tx); } signed_transaction wallet_api::propose_builder_transaction( transaction_handle_type handle, - time_point_sec expiration, + const time_point_sec& expiration, uint32_t review_period_seconds, - bool broadcast)const + bool broadcast )const { return my->propose_builder_transaction(handle, expiration, review_period_seconds, broadcast); } signed_transaction wallet_api::propose_builder_transaction2( transaction_handle_type handle, - string account_name_or_id, - time_point_sec expiration, + const string& account_name_or_id, + const time_point_sec& expiration, uint32_t review_period_seconds, - bool broadcast)const + bool broadcast )const { return my->propose_builder_transaction2(handle, account_name_or_id, expiration, review_period_seconds, broadcast); } @@ -572,36 +574,36 @@ void wallet_api::remove_builder_transaction(transaction_handle_type handle)const return my->remove_builder_transaction(handle); } -account_object wallet_api::get_account(string account_name_or_id) const +account_object wallet_api::get_account( const string& account_name_or_id ) const { return my->get_account(account_name_or_id); } -extended_asset_object wallet_api::get_asset(string asset_name_or_id) const +extended_asset_object wallet_api::get_asset( const string& asset_name_or_id ) const { auto found_asset = my->find_asset(asset_name_or_id); FC_ASSERT( found_asset, "Unable to find asset '${a}'", ("a",asset_name_or_id) ); return *found_asset; } -asset_bitasset_data_object wallet_api::get_bitasset_data(string asset_name_or_id) const +asset_bitasset_data_object wallet_api::get_bitasset_data( const string& asset_name_or_id ) const { auto asset = get_asset(asset_name_or_id); FC_ASSERT(asset.is_market_issued() && asset.bitasset_data_id); return my->get_object(*asset.bitasset_data_id); } -account_id_type wallet_api::get_account_id(string account_name_or_id) const +account_id_type wallet_api::get_account_id( const string& account_name_or_id ) const { return my->get_account_id(account_name_or_id); } -asset_id_type wallet_api::get_asset_id(const string& asset_symbol_or_id) const +asset_id_type wallet_api::get_asset_id( const string& asset_symbol_or_id ) const { return my->get_asset_id(asset_symbol_or_id); } -bool wallet_api::import_key(string account_name_or_id, string wif_key)const +bool wallet_api::import_key( const string& account_name_or_id, const string& wif_key )const { FC_ASSERT(!is_locked()); // backup wallet @@ -620,7 +622,7 @@ bool wallet_api::import_key(string account_name_or_id, string wif_key)const return false; } -map wallet_api::import_accounts( string filename, string password )const +map> wallet_api::import_accounts( const string& filename, const string& password )const { FC_ASSERT( !is_locked() ); FC_ASSERT( fc::exists( filename ) ); @@ -630,7 +632,7 @@ map wallet_api::import_accounts( string filename, string password const auto password_hash = fc::sha512::hash( password ); FC_ASSERT( fc::sha512::hash( password_hash ) == imported_keys.password_checksum ); - map result; + map> result; for( const auto& item : imported_keys.account_keys ) { const auto import_this_account = [ & ]() -> bool @@ -693,10 +695,10 @@ map wallet_api::import_accounts( string filename, string password } bool wallet_api::import_account_keys( - string filename, - string password, - string src_account_name, - string dest_account_name )const + const string& filename, + const string& password, + const string& src_account_name, + const string& dest_account_name )const { FC_ASSERT( !is_locked() ); FC_ASSERT( fc::exists( filename ) ); @@ -743,7 +745,7 @@ bool wallet_api::import_account_keys( return false; } -string wallet_api::normalize_brain_key(string s) const +string wallet_api::normalize_brain_key( const string& s ) const { return detail::normalize_brain_key( s ); } @@ -758,312 +760,315 @@ variant_object wallet_api::about() const return my->about(); } -fc::ecc::private_key wallet_api::derive_private_key(const std::string& prefix_string, int sequence_number) const +fc::ecc::private_key wallet_api::derive_private_key( const string& prefix_string, uint32_t sequence_number ) const { return detail::derive_private_key( prefix_string, sequence_number ); } -signed_transaction wallet_api::register_account(string name, - public_key_type owner_pubkey, - public_key_type active_pubkey, - string registrar_account, - string referrer_account, - uint32_t referrer_percent, - bool broadcast)const +signed_transaction wallet_api::register_account( const string& name, + const public_key_type& owner_pubkey, + const public_key_type& active_pubkey, + const string& registrar_account, + const string& referrer_account, + uint32_t referrer_percent, + bool broadcast )const { return my->register_account( name, owner_pubkey, active_pubkey, registrar_account, referrer_account, referrer_percent, broadcast ); } -signed_transaction wallet_api::create_account_with_brain_key(string brain_key, string account_name, - string registrar_account, string referrer_account, - bool broadcast /* = false */)const +signed_transaction wallet_api::create_account_with_brain_key( const string& brain_key, const string& account_name, + const string& registrar_account, const string& referrer_account, + bool broadcast /* = false */ )const { return my->create_account_with_brain_key( brain_key, account_name, registrar_account, referrer_account, broadcast ); } -signed_transaction wallet_api::issue_asset(string to_account, string amount, string symbol, - string memo, bool broadcast)const +signed_transaction wallet_api::issue_asset( const string& to_account, const string& amount, const string& symbol, + const string& memo, bool broadcast )const { return my->issue_asset(to_account, amount, symbol, memo, broadcast); } -signed_transaction wallet_api::transfer(string from, string to, string amount, - string asset_symbol, string memo, bool broadcast /* = false */)const +signed_transaction wallet_api::transfer( const string& from, const string& to, const string& amount, + const string& asset_symbol, const string& memo, + bool broadcast /* = false */ )const { return my->transfer(from, to, amount, asset_symbol, memo, broadcast); } -signed_transaction wallet_api::create_asset(string issuer, - string symbol, - uint8_t precision, - asset_options common, - fc::optional bitasset_opts, - bool broadcast)const +signed_transaction wallet_api::create_asset( const string& issuer, + const string& symbol, + uint8_t precision, + const asset_options& common, + const optional& bitasset_opts, + bool broadcast )const { return my->create_asset(issuer, symbol, precision, common, bitasset_opts, broadcast); } -signed_transaction wallet_api::update_asset(string symbol, - optional new_issuer, - asset_options new_options, - bool broadcast /* = false */)const +signed_transaction wallet_api::update_asset( const string& symbol, + const optional& new_issuer, + const asset_options& new_options, + bool broadcast /* = false */ )const { return my->update_asset(symbol, new_issuer, new_options, broadcast); } -signed_transaction wallet_api::update_asset_issuer(string symbol, - string new_issuer, - bool broadcast /* = false */)const +signed_transaction wallet_api::update_asset_issuer( const string& symbol, + const string& new_issuer, + bool broadcast /* = false */ )const { return my->update_asset_issuer(symbol, new_issuer, broadcast); } -signed_transaction wallet_api::update_bitasset(string symbol, - bitasset_options new_options, - bool broadcast /* = false */)const +signed_transaction wallet_api::update_bitasset( const string& symbol, + const bitasset_options& new_options, + bool broadcast /* = false */ )const { return my->update_bitasset(symbol, new_options, broadcast); } -signed_transaction wallet_api::update_asset_feed_producers(string symbol, - flat_set new_feed_producers, - bool broadcast /* = false */)const +signed_transaction wallet_api::update_asset_feed_producers( const string& symbol, + const flat_set& new_feed_producers, + bool broadcast /* = false */ )const { return my->update_asset_feed_producers(symbol, new_feed_producers, broadcast); } -signed_transaction wallet_api::publish_asset_feed(string publishing_account, - string symbol, - price_feed feed, - bool broadcast /* = false */)const +signed_transaction wallet_api::publish_asset_feed( const string& publishing_account, + const string& symbol, + const price_feed& feed, + bool broadcast /* = false */ )const { return my->publish_asset_feed(publishing_account, symbol, feed, broadcast); } -signed_transaction wallet_api::fund_asset_fee_pool(string from, - string symbol, - string amount, - bool broadcast /* = false */)const +signed_transaction wallet_api::fund_asset_fee_pool( const string& from, + const string& symbol, + const string& amount, + bool broadcast /* = false */ )const { return my->fund_asset_fee_pool(from, symbol, amount, broadcast); } -signed_transaction wallet_api::claim_asset_fee_pool(string symbol, - string amount, - bool broadcast /* = false */)const +signed_transaction wallet_api::claim_asset_fee_pool( const string& symbol, + const string& amount, + bool broadcast /* = false */ )const { return my->claim_asset_fee_pool(symbol, amount, broadcast); } -signed_transaction wallet_api::reserve_asset(string from, - string amount, - string symbol, - bool broadcast /* = false */)const +signed_transaction wallet_api::reserve_asset( const string& from, + const string& amount, + const string& symbol, + bool broadcast /* = false */ )const { return my->reserve_asset(from, amount, symbol, broadcast); } -signed_transaction wallet_api::global_settle_asset(string symbol, - price settle_price, - bool broadcast /* = false */)const +signed_transaction wallet_api::global_settle_asset( const string& symbol, + const price& settle_price, + bool broadcast /* = false */ )const { return my->global_settle_asset(symbol, settle_price, broadcast); } -signed_transaction wallet_api::settle_asset(string account_to_settle, - string amount_to_settle, - string symbol, - bool broadcast /* = false */)const +signed_transaction wallet_api::settle_asset( const string& account_to_settle, + const string& amount_to_settle, + const string& symbol, + bool broadcast /* = false */ )const { return my->settle_asset(account_to_settle, amount_to_settle, symbol, broadcast); } -signed_transaction wallet_api::bid_collateral(string bidder_name, - string debt_amount, string debt_symbol, - string additional_collateral, - bool broadcast )const +signed_transaction wallet_api::bid_collateral( const string& bidder_name, + const string& debt_amount, const string& debt_symbol, + const string& additional_collateral, + bool broadcast )const { return my->bid_collateral(bidder_name, debt_amount, debt_symbol, additional_collateral, broadcast); } -signed_transaction wallet_api::whitelist_account(string authorizing_account, - string account_to_list, - account_whitelist_operation::account_listing new_listing_status, - bool broadcast /* = false */)const +signed_transaction wallet_api::whitelist_account( const string& authorizing_account, + const string& account_to_list, + account_whitelist_operation::account_listing new_listing_status, + bool broadcast /* = false */ )const { return my->whitelist_account(authorizing_account, account_to_list, new_listing_status, broadcast); } -signed_transaction wallet_api::create_committee_member(string owner_account, string url, - bool broadcast /* = false */)const +signed_transaction wallet_api::create_committee_member( const string& owner_account, const string& url, + bool broadcast /* = false */ )const { return my->create_committee_member(owner_account, url, broadcast); } -map wallet_api::list_witnesses(const string& lowerbound, uint32_t limit)const +map> wallet_api::list_witnesses( const string& lowerbound, uint32_t limit )const { return my->_remote_db->lookup_witness_accounts(lowerbound, limit); } -map wallet_api::list_committee_members(const string& lowerbound, uint32_t limit)const +map> wallet_api::list_committee_members( + const string& lowerbound, uint32_t limit )const { return my->_remote_db->lookup_committee_member_accounts(lowerbound, limit); } -witness_object wallet_api::get_witness(string owner_account)const +witness_object wallet_api::get_witness( const string& owner_account )const { return my->get_witness(owner_account); } -committee_member_object wallet_api::get_committee_member(string owner_account)const +committee_member_object wallet_api::get_committee_member( const string& owner_account )const { return my->get_committee_member(owner_account); } -signed_transaction wallet_api::create_witness(string owner_account, - string url, - bool broadcast /* = false */)const +signed_transaction wallet_api::create_witness( const string& owner_account, + const string& url, + bool broadcast /* = false */ )const { return my->create_witness(owner_account, url, broadcast); } signed_transaction wallet_api::create_worker( - string owner_account, - time_point_sec work_begin_date, - time_point_sec work_end_date, - share_type daily_pay, - string name, - string url, - variant worker_settings, - bool broadcast /* = false */)const + const string& owner_account, + const time_point_sec& work_begin_date, + const time_point_sec& work_end_date, + const share_type& daily_pay, + const string& name, + const string& url, + const variant& worker_settings, + bool broadcast /* = false */ )const { return my->create_worker( owner_account, work_begin_date, work_end_date, daily_pay, name, url, worker_settings, broadcast ); } signed_transaction wallet_api::update_worker_votes( - string owner_account, - worker_vote_delta delta, - bool broadcast /* = false */)const + const string& owner_account, + const worker_vote_delta& delta, + bool broadcast /* = false */ )const { return my->update_worker_votes( owner_account, delta, broadcast ); } signed_transaction wallet_api::update_witness( - string witness_name, - string url, - string block_signing_key, - bool broadcast /* = false */)const + const string& witness_name, + const string& url, + const string& block_signing_key, + bool broadcast /* = false */ )const { return my->update_witness(witness_name, url, block_signing_key, broadcast); } -vector< vesting_balance_object_with_info > wallet_api::get_vesting_balances( string account_name )const +vector< vesting_balance_object_with_info > wallet_api::get_vesting_balances( const string& account_name )const { return my->get_vesting_balances( account_name ); } signed_transaction wallet_api::withdraw_vesting( - string witness_name, - string amount, - string asset_symbol, - bool broadcast /* = false */)const + const string& witness_name, + const string& amount, + const string& asset_symbol, + bool broadcast /* = false */ )const { return my->withdraw_vesting( witness_name, amount, asset_symbol, broadcast ); } -signed_transaction wallet_api::vote_for_committee_member(string voting_account, - string witness, - bool approve, - bool broadcast /* = false */)const +signed_transaction wallet_api::vote_for_committee_member( const string& voting_account, + const string& witness, + bool approve, + bool broadcast /* = false */ )const { return my->vote_for_committee_member(voting_account, witness, approve, broadcast); } -signed_transaction wallet_api::vote_for_witness(string voting_account, - string witness, - bool approve, - bool broadcast /* = false */)const +signed_transaction wallet_api::vote_for_witness( const string& voting_account, + const string& witness, + bool approve, + bool broadcast /* = false */ )const { return my->vote_for_witness(voting_account, witness, approve, broadcast); } -signed_transaction wallet_api::set_voting_proxy(string account_to_modify, - optional voting_account, - bool broadcast /* = false */)const +signed_transaction wallet_api::set_voting_proxy( const string& account_to_modify, + const optional& voting_account, + bool broadcast /* = false */ )const { return my->set_voting_proxy(account_to_modify, voting_account, broadcast); } -signed_transaction wallet_api::set_desired_witness_and_committee_member_count(string account_to_modify, +signed_transaction wallet_api::set_desired_witness_and_committee_member_count( const string& account_to_modify, uint16_t desired_number_of_witnesses, uint16_t desired_number_of_committee_members, - bool broadcast /* = false */)const + bool broadcast /* = false */ )const { return my->set_desired_witness_and_committee_member_count(account_to_modify, desired_number_of_witnesses, desired_number_of_committee_members, broadcast); } -void wallet_api::set_wallet_filename(string wallet_filename)const +void wallet_api::set_wallet_filename( const string& wallet_filename )const { my->_wallet_filename = wallet_filename; } -signed_transaction wallet_api::sign_transaction(signed_transaction tx, bool broadcast /* = false */)const +signed_transaction wallet_api::sign_transaction( const signed_transaction& tx, bool broadcast /* = false */ )const { try { return my->sign_transaction( tx, broadcast); } FC_CAPTURE_AND_RETHROW( (tx) ) } -signed_transaction wallet_api::sign_transaction2(signed_transaction tx, const vector& signing_keys, - bool broadcast /* = false */)const +signed_transaction wallet_api::sign_transaction2( const signed_transaction& tx, + const vector& signing_keys, + bool broadcast /* = false */ )const { try { return my->sign_transaction2( tx, signing_keys, broadcast); } FC_CAPTURE_AND_RETHROW( (tx) ) } -flat_set wallet_api::get_transaction_signers(const signed_transaction &tx) const +flat_set wallet_api::get_transaction_signers( const signed_transaction& tx ) const { try { return my->get_transaction_signers(tx); } FC_CAPTURE_AND_RETHROW( (tx) ) } -vector> wallet_api::get_key_references(const vector &keys) const +vector> wallet_api::get_key_references( const vector& keys ) const { try { return my->get_key_references(keys); } FC_CAPTURE_AND_RETHROW( (keys) ) } -operation wallet_api::get_prototype_operation(string operation_name)const +operation wallet_api::get_prototype_operation( const string& operation_name )const { return my->get_prototype_operation( operation_name ); } -void wallet_api::dbg_make_uia(string creator, string symbol)const +void wallet_api::dbg_make_uia( const string& creator, const string& symbol )const { FC_ASSERT(!is_locked()); my->dbg_make_uia(creator, symbol); } -void wallet_api::dbg_make_mia(string creator, string symbol)const +void wallet_api::dbg_make_mia( const string& creator, const string& symbol )const { FC_ASSERT(!is_locked()); my->dbg_make_mia(creator, symbol); } -void wallet_api::dbg_push_blocks( std::string src_filename, uint32_t count )const +void wallet_api::dbg_push_blocks( const string& src_filename, uint32_t count )const { my->dbg_push_blocks( src_filename, count ); } -void wallet_api::dbg_generate_blocks( std::string debug_wif_key, uint32_t count )const +void wallet_api::dbg_generate_blocks( const string& debug_wif_key, uint32_t count )const { my->dbg_generate_blocks( debug_wif_key, count ); } -void wallet_api::dbg_stream_json_objects( const std::string& filename )const +void wallet_api::dbg_stream_json_objects( const string& filename )const { my->dbg_stream_json_objects( filename ); } -void wallet_api::dbg_update_object( fc::variant_object update )const +void wallet_api::dbg_update_object( const fc::variant_object& update )const { my->dbg_update_object( update ); } @@ -1078,7 +1083,7 @@ vector< variant > wallet_api::network_get_connected_peers()const return my->network_get_connected_peers(); } -void wallet_api::flood_network(string prefix, uint32_t number_of_transactions)const +void wallet_api::flood_network( const string& prefix, uint32_t number_of_transactions )const { FC_ASSERT(!is_locked()); my->flood_network(prefix, number_of_transactions); @@ -1086,7 +1091,7 @@ void wallet_api::flood_network(string prefix, uint32_t number_of_transactions)co signed_transaction wallet_api::propose_parameter_change( const string& proposing_account, - fc::time_point_sec expiration_time, + const fc::time_point_sec& expiration_time, const variant_object& changed_values, bool broadcast /* = false */ )const @@ -1096,7 +1101,7 @@ signed_transaction wallet_api::propose_parameter_change( signed_transaction wallet_api::propose_fee_change( const string& proposing_account, - fc::time_point_sec expiration_time, + const fc::time_point_sec& expiration_time, const variant_object& changed_fees, bool broadcast /* = false */ )const @@ -1124,7 +1129,7 @@ dynamic_global_property_object wallet_api::get_dynamic_global_properties() const return my->get_dynamic_global_properties(); } -signed_transaction wallet_api::add_transaction_signature( signed_transaction tx, +signed_transaction wallet_api::add_transaction_signature( const signed_transaction& tx, bool broadcast )const { return my->add_transaction_signature( tx, broadcast ); @@ -1132,9 +1137,9 @@ signed_transaction wallet_api::add_transaction_signature( signed_transaction tx, string wallet_api::help()const { - std::vector method_names = my->method_documentation.get_method_names(); + std::vector method_names = my->method_documentation.get_method_names(); std::stringstream ss; - for (const std::string& method_name : method_names) + for (const string& method_name : method_names) { try { @@ -1148,13 +1153,13 @@ string wallet_api::help()const return ss.str(); } -string wallet_api::gethelp(const string& method)const +string wallet_api::gethelp( const string& method )const { fc::api tmp; std::stringstream ss; ss << "\n"; - std::string doxygenHelpString = my->method_documentation.get_detailed_description(method); + string doxygenHelpString = my->method_documentation.get_detailed_description(method); if (!doxygenHelpString.empty()) ss << doxygenHelpString << "\n"; @@ -1211,7 +1216,7 @@ string wallet_api::gethelp(const string& method)const return ss.str(); } -bool wallet_api::load_wallet_file( string wallet_filename )const +bool wallet_api::load_wallet_file( const string& wallet_filename )const { return my->load_wallet_file( wallet_filename ); } @@ -1221,13 +1226,13 @@ void wallet_api::quit()const my->quit(); } -void wallet_api::save_wallet_file( string wallet_filename )const +void wallet_api::save_wallet_file( const string& wallet_filename )const { my->save_wallet_file( wallet_filename ); } -std::map > -wallet_api::get_result_formatters() const +std::map< string, std::function< string( const fc::variant&, const fc::variants& ) >, std::less<> > + wallet_api::get_result_formatters() const { return my->get_result_formatters(); } @@ -1257,7 +1262,7 @@ void wallet_api::lock()const my->self.lock_changed(true); } FC_CAPTURE_AND_RETHROW() } -void wallet_api::unlock(string password)const +void wallet_api::unlock( const string& password )const { try { FC_ASSERT(password.size() > 0); auto pw = fc::sha512::hash(password.c_str(), password.size()); @@ -1269,7 +1274,7 @@ void wallet_api::unlock(string password)const my->self.lock_changed(false); } FC_CAPTURE_AND_RETHROW() } -void wallet_api::set_password( string password )const +void wallet_api::set_password( const string& password )const { if( !is_new() ) FC_ASSERT( !is_locked(), "The wallet must be unlocked before the password can be set" ); @@ -1278,7 +1283,7 @@ void wallet_api::set_password( string password )const } vector< signed_transaction > wallet_api::import_balance( - string name_or_id, + const string& name_or_id, const vector& wif_keys, bool broadcast )const { @@ -1291,60 +1296,61 @@ map wallet_api::dump_private_keys()const return my->_keys; } -signed_transaction wallet_api::upgrade_account( string name, bool broadcast )const +signed_transaction wallet_api::upgrade_account( const string& name, bool broadcast )const { return my->upgrade_account(name,broadcast); } -signed_transaction wallet_api::sell_asset(string seller_account, - string amount_to_sell, - string symbol_to_sell, - string min_to_receive, - string symbol_to_receive, - uint32_t expiration, - bool fill_or_kill, - bool broadcast)const +signed_transaction wallet_api::sell_asset( const string& seller_account, + const string& amount_to_sell, + const string& symbol_to_sell, + const string& min_to_receive, + const string& symbol_to_receive, + uint32_t expiration, + bool fill_or_kill, + bool broadcast )const { return my->sell_asset(seller_account, amount_to_sell, symbol_to_sell, min_to_receive, symbol_to_receive, expiration, fill_or_kill, broadcast); } -signed_transaction wallet_api::borrow_asset(string seller_name, string amount_to_sell, - string asset_symbol, string amount_of_collateral, bool broadcast)const +signed_transaction wallet_api::borrow_asset( const string& seller_name, const string& amount_to_sell, + const string& asset_symbol, const string& amount_of_collateral, + bool broadcast )const { FC_ASSERT(!is_locked()); - return my->borrow_asset_ext(seller_name, amount_to_sell, asset_symbol, amount_of_collateral, {}, broadcast); + return my->borrow_asset_ext( seller_name, amount_to_sell, asset_symbol, amount_of_collateral, {}, broadcast ); } -signed_transaction wallet_api::borrow_asset_ext( string seller_name, string amount_to_sell, - string asset_symbol, string amount_of_collateral, - call_order_update_operation::extensions_type extensions, - bool broadcast)const +signed_transaction wallet_api::borrow_asset_ext( const string& seller_name, const string& amount_to_sell, + const string& asset_symbol, const string& amount_of_collateral, + const call_order_update_operation::extensions_type& extensions, + bool broadcast )const { FC_ASSERT(!is_locked()); return my->borrow_asset_ext(seller_name, amount_to_sell, asset_symbol, amount_of_collateral, extensions, broadcast); } -signed_transaction wallet_api::cancel_order(const limit_order_id_type& order_id, bool broadcast) const +signed_transaction wallet_api::cancel_order( const limit_order_id_type& order_id, bool broadcast ) const { FC_ASSERT(!is_locked()); return my->cancel_order(order_id, broadcast); } -memo_data wallet_api::sign_memo(string from, string to, string memo)const +memo_data wallet_api::sign_memo( const string& from, const string& to, const string& memo )const { FC_ASSERT(!is_locked()); return my->sign_memo(from, to, memo); } -string wallet_api::read_memo(const memo_data& memo)const +string wallet_api::read_memo( const memo_data& memo )const { FC_ASSERT(!is_locked()); return my->read_memo(memo); } -signed_message wallet_api::sign_message(string signer, string message)const +signed_message wallet_api::sign_message( const string& signer, const string& message )const { FC_ASSERT(!is_locked()); return my->sign_message(signer, message); @@ -1361,7 +1367,7 @@ bool wallet_api::verify_message( const string& message, const string& account, i * @param message the signed_message structure containing message, meta data and signature * @return true if signature matches */ -bool wallet_api::verify_signed_message( signed_message message )const +bool wallet_api::verify_signed_message( const signed_message& message )const { return my->verify_signed_message( message ); } @@ -1371,13 +1377,13 @@ bool wallet_api::verify_signed_message( signed_message message )const * @param message the complete encapsulated message string including separators and line feeds * @return true if signature matches */ -bool wallet_api::verify_encapsulated_message( string message )const +bool wallet_api::verify_encapsulated_message( const string& message )const { return my->verify_encapsulated_message( message ); } -string wallet_api::get_key_label( public_key_type key )const +string wallet_api::get_key_label( const public_key_type& key )const { auto key_itr = my->_wallet.labeled_keys.get().find(key); if( key_itr != my->_wallet.labeled_keys.get().end() ) @@ -1385,12 +1391,12 @@ string wallet_api::get_key_label( public_key_type key )const return string(); } -string wallet_api::get_private_key( public_key_type pubkey )const +string wallet_api::get_private_key( const public_key_type& pubkey )const { return key_to_wif( my->get_private_key( pubkey ) ); } -public_key_type wallet_api::get_public_key( string label )const +public_key_type wallet_api::get_public_key( const string& label )const { try { return fc::variant(label, 1).as( 1 ); } catch ( ... ){} @@ -1400,7 +1406,7 @@ public_key_type wallet_api::get_public_key( string label )const return public_key_type(); } -bool wallet_api::set_key_label( public_key_type key, string label )const +bool wallet_api::set_key_label( const public_key_type& key, const string& label )const { auto result = my->_wallet.labeled_keys.insert( key_label{label,key} ); if( result.second ) return true; @@ -1414,17 +1420,17 @@ bool wallet_api::set_key_label( public_key_type key, string label } return false; } -map wallet_api::get_blind_accounts()const +map> wallet_api::get_blind_accounts()const { - map result; + map> result; for( const auto& item : my->_wallet.labeled_keys ) result[item.label] = item.key; return result; } -map wallet_api::get_my_blind_accounts()const +map> wallet_api::get_my_blind_accounts()const { FC_ASSERT( !is_locked() ); - map result; + map> result; for( const auto& item : my->_wallet.labeled_keys ) { if( my->_keys.find(item.key) != my->_keys.end() ) @@ -1433,14 +1439,14 @@ map wallet_api::get_my_blind_accounts()const return result; } -public_key_type wallet_api::create_blind_account( string label, string brain_key )const +public_key_type wallet_api::create_blind_account( const string& label, const string& p_brain_key )const { FC_ASSERT( !is_locked() ); auto label_itr = my->_wallet.labeled_keys.get().find(label); if( label_itr != my->_wallet.labeled_keys.get().end() ) FC_ASSERT( !"Key with label already exists" ); - brain_key = fc::trim_and_normalize_spaces( brain_key ); + auto brain_key = fc::trim_and_normalize_spaces( p_brain_key ); auto secret = fc::sha256::hash( brain_key.c_str(), brain_key.size() ); auto priv_key = fc::ecc::private_key::regenerate( secret ); public_key_type pub_key = priv_key.get_public_key(); @@ -1453,7 +1459,7 @@ public_key_type wallet_api::create_blind_account( string label, string brain_ return pub_key; } -vector wallet_api::get_blind_balances( string key_or_label )const +vector wallet_api::get_blind_balances( const string& key_or_label )const { vector result; map balances; @@ -1486,10 +1492,10 @@ vector wallet_api::get_blind_balances( string key_or_label )const return result; } -blind_confirmation wallet_api::transfer_from_blind( string from_blind_account_key_or_label, - string to_account_id_or_name, - string amount_in, - string symbol, +blind_confirmation wallet_api::transfer_from_blind( const string& from_blind_account_key_or_label, + const string& to_account_id_or_name, + const string& amount_in, + const string& symbol, bool broadcast )const { try { transfer_from_blind_operation from_blind; @@ -1547,20 +1553,20 @@ blind_confirmation wallet_api::transfer_from_blind( string from_blind_account_ke return conf; } FC_CAPTURE_AND_RETHROW( (from_blind_account_key_or_label)(to_account_id_or_name)(amount_in)(symbol) ) } -blind_confirmation wallet_api::blind_transfer( string from_key_or_label, - string to_key_or_label, - string amount_in, - string symbol, +blind_confirmation wallet_api::blind_transfer( const string& from_key_or_label, + const string& to_key_or_label, + const string& amount_in, + const string& symbol, bool broadcast )const { return blind_transfer_help( from_key_or_label, to_key_or_label, amount_in, symbol, broadcast, false ); } -blind_confirmation wallet_api::blind_transfer_help( string from_key_or_label, - string to_key_or_label, - string amount_in, - string symbol, - bool broadcast, - bool to_temp )const +blind_confirmation wallet_api::blind_transfer_help( const string& from_key_or_label, + const string& to_key_or_label, + const string& amount_in, + const string& symbol, + bool broadcast, + bool to_temp )const { blind_confirmation confirm; try { @@ -1733,10 +1739,10 @@ blind_confirmation wallet_api::blind_transfer_help( string from_key_or_label, * Transfers a public balance from @from to one or more blinded balances using a * stealth transfer. */ -blind_confirmation wallet_api::transfer_to_blind( string from_account_id_or_name, - string asset_symbol, +blind_confirmation wallet_api::transfer_to_blind( const string& from_account_id_or_name, + const string& asset_symbol, /* map from key or label to amount */ - vector> to_amounts, + const vector>& to_amounts, bool broadcast )const { try { FC_ASSERT( !is_locked() ); @@ -1820,7 +1826,8 @@ blind_confirmation wallet_api::transfer_to_blind( string from_account_id_or_name return confirm; } FC_CAPTURE_AND_RETHROW( (from_account_id_or_name)(asset_symbol)(to_amounts) ) } -blind_receipt wallet_api::receive_blind_transfer( string confirmation_receipt, string opt_from, string opt_memo )const +blind_receipt wallet_api::receive_blind_transfer( const string& confirmation_receipt, + const string& opt_from, const string& opt_memo )const { FC_ASSERT( !is_locked() ); stealth_confirmation conf(confirmation_receipt); @@ -1897,7 +1904,7 @@ blind_receipt wallet_api::receive_blind_transfer( string confirmation_receipt, s return result; } -vector wallet_api::blind_history( string key_or_account )const +vector wallet_api::blind_history( const string& key_or_account )const { vector result; auto pub_key = get_public_key( key_or_account ); @@ -1915,28 +1922,28 @@ vector wallet_api::blind_history( string key_or_account )const return result; } -order_book wallet_api::get_order_book( const string& base, const string& quote, unsigned limit )const +order_book wallet_api::get_order_book( const string& base, const string& quote, uint32_t limit )const { return( my->_remote_db->get_order_book( base, quote, limit ) ); } // custom operations -signed_transaction wallet_api::account_store_map(string account, string catalog, bool remove, - flat_map> key_values, bool broadcast)const +signed_transaction wallet_api::account_store_map( const string& account, const string& catalog, bool remove, + const flat_map>& key_values, bool broadcast )const { return my->account_store_map(account, catalog, remove, key_values, broadcast); } -vector wallet_api::get_account_storage(string account, string catalog)const +vector wallet_api::get_account_storage( const string& account, const string& catalog )const { try { return my->_custom_operations->get_storage_info(account, catalog); } FC_CAPTURE_AND_RETHROW( (account)(catalog) ) } signed_block_with_info::signed_block_with_info( const signed_block& block ) - : signed_block( block ) + : signed_block( block ), + block_id { id() }, + signing_key { signee() } { - block_id = id(); - signing_key = signee(); transaction_ids.reserve( transactions.size() ); for( const processed_transaction& tx : transactions ) transaction_ids.push_back( tx.id() ); @@ -1944,11 +1951,11 @@ signed_block_with_info::signed_block_with_info( const signed_block& block ) vesting_balance_object_with_info::vesting_balance_object_with_info( const vesting_balance_object& vbo, - fc::time_point_sec now ) - : vesting_balance_object( vbo ) + const fc::time_point_sec& now ) + : vesting_balance_object( vbo ), + allowed_withdraw { get_allowed_withdraw( now ) }, + allowed_withdraw_time { now } { - allowed_withdraw = get_allowed_withdraw( now ); - allowed_withdraw_time = now; } } } // graphene::wallet diff --git a/libraries/wallet/wallet_api_impl.hpp b/libraries/wallet/wallet_api_impl.hpp index 3a498dfe46..02994a0b86 100644 --- a/libraries/wallet/wallet_api_impl.hpp +++ b/libraries/wallet/wallet_api_impl.hpp @@ -367,7 +367,8 @@ class wallet_api_impl signed_transaction issue_asset(string to_account, string amount, string symbol, string memo, bool broadcast = false); - std::map> get_result_formatters() const; + std::map< string, std::function< string( const fc::variant&, const fc::variants& ) >, std::less<> > + get_result_formatters() const; signed_transaction propose_parameter_change( const string& proposing_account, fc::time_point_sec expiration_time, const variant_object& changed_values, bool broadcast = false); diff --git a/libraries/wallet/wallet_results.cpp b/libraries/wallet/wallet_results.cpp index 8bdefff6b7..a47e28476f 100644 --- a/libraries/wallet/wallet_results.cpp +++ b/libraries/wallet/wallet_results.cpp @@ -27,21 +27,22 @@ namespace graphene { namespace wallet { namespace detail { -std::map> wallet_api_impl::get_result_formatters() const + std::map< string, std::function< string( const fc::variant&, const fc::variants& ) >, std::less<> > + wallet_api_impl::get_result_formatters() const { - std::map > m; + std::map< string, std::function< string( const fc::variant&, const fc::variants& ) >, std::less<> > m; - m["help"] = [](variant result, const fc::variants&) + m["help"] = [](const variant& result, const fc::variants&) { return result.get_string(); }; - m["gethelp"] = [](variant result, const fc::variants&) + m["gethelp"] = [](const variant& result, const fc::variants&) { return result.get_string(); }; - auto format_account_history = [this](variant result, const fc::variants&) + auto format_account_history = [this](const variant& result, const fc::variants&) { auto r = result.as>( GRAPHENE_MAX_NESTED_OBJECTS ); std::stringstream ss; @@ -64,7 +65,7 @@ std::map> wallet_a m["get_account_history"] = format_account_history; m["get_relative_account_history"] = format_account_history; - m["get_account_history_by_operations"] = [this](variant result, const fc::variants&) { + m["get_account_history_by_operations"] = [this](const variant& result, const fc::variants&) { auto r = result.as( GRAPHENE_MAX_NESTED_OBJECTS ); std::stringstream ss; ss << "total_count : " << r.total_count << " \n"; @@ -85,7 +86,7 @@ std::map> wallet_a return ss.str(); }; - auto format_balances = [this](variant result, const fc::variants&) + auto format_balances = [this](const variant& result, const fc::variants&) { auto r = result.as>( GRAPHENE_MAX_NESTED_OBJECTS ); vector asset_recs; @@ -103,7 +104,7 @@ std::map> wallet_a m["list_account_balances"] = format_balances; m["get_blind_balances"] = format_balances; - auto format_blind_transfers = [this](variant result, const fc::variants&) + auto format_blind_transfers = [this](const variant& result, const fc::variants&) { auto r = result.as( GRAPHENE_MAX_NESTED_OBJECTS ); std::stringstream ss; @@ -121,7 +122,7 @@ std::map> wallet_a m["transfer_to_blind"] = format_blind_transfers; m["blind_transfer"] = format_blind_transfers; - m["receive_blind_transfer"] = [this](variant result, const fc::variants&) + m["receive_blind_transfer"] = [this](const variant& result, const fc::variants&) { auto r = result.as( GRAPHENE_MAX_NESTED_OBJECTS ); std::stringstream ss; @@ -131,7 +132,7 @@ std::map> wallet_a return ss.str(); }; - m["blind_history"] = [this](variant result, const fc::variants&) + m["blind_history"] = [this](const variant& result, const fc::variants&) { auto records = result.as>( GRAPHENE_MAX_NESTED_OBJECTS ); std::stringstream ss; @@ -148,7 +149,7 @@ std::map> wallet_a return ss.str(); }; - m["get_order_book"] = [](variant result, const fc::variants&) + m["get_order_book"] = [](const variant& result, const fc::variants&) { auto orders = result.as( GRAPHENE_MAX_NESTED_OBJECTS ); auto bids = orders.bids; @@ -236,7 +237,7 @@ std::map> wallet_a return ss.str(); }; - m["sign_message"] = [](variant result, const fc::variants&) + m["sign_message"] = [](const variant& result, const fc::variants&) { auto r = result.as( GRAPHENE_MAX_NESTED_OBJECTS ); diff --git a/tests/tests/api_limit_tests.cpp b/tests/tests/api_limit_tests.cpp index 40baf71808..18167074b4 100644 --- a/tests/tests/api_limit_tests.cpp +++ b/tests/tests/api_limit_tests.cpp @@ -250,7 +250,7 @@ BOOST_AUTO_TEST_CASE( api_limit_lookup_accounts ) { graphene::app::database_api db_api( db, &( app.get_options() )); ACTOR(bob); GRAPHENE_CHECK_THROW(db_api.lookup_accounts("bob",220), fc::exception); - map result =db_api.lookup_accounts("bob",190); + auto result =db_api.lookup_accounts("bob",190); BOOST_REQUIRE_EQUAL( result.size(), 17u); } catch (fc::exception& e) { @@ -264,7 +264,7 @@ BOOST_AUTO_TEST_CASE( api_limit_lookup_witness_accounts ) { graphene::app::database_api db_api( db, &( app.get_options() )); ACTORS((bob)) ; GRAPHENE_CHECK_THROW(db_api.lookup_witness_accounts("bob",220), fc::exception); - map result =db_api.lookup_witness_accounts("bob",190); + auto result =db_api.lookup_witness_accounts("bob",190); BOOST_REQUIRE_EQUAL( result.size(), 10u); } catch (fc::exception& e) { @@ -549,7 +549,7 @@ BOOST_AUTO_TEST_CASE( api_limit_lookup_committee_member_accounts ) { graphene::app::database_api db_api( db, &( app.get_options() )); ACTORS((bob)); GRAPHENE_CHECK_THROW(db_api.lookup_committee_member_accounts("bob",220), fc::exception); - std::map result =db_api.lookup_committee_member_accounts("bob",190); + auto result =db_api.lookup_committee_member_accounts("bob",190); BOOST_REQUIRE_EQUAL( result.size(), 10u); } catch (fc::exception& e) { From 5f803130b66ee52ae0e4fdbe67f54496aa7e6106 Mon Sep 17 00:00:00 2001 From: abitmore Date: Wed, 26 Oct 2022 22:02:54 +0000 Subject: [PATCH 09/13] Fix a long line --- libraries/wallet/include/graphene/wallet/wallet.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index eaf740e9a7..bc5d965650 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -826,7 +826,7 @@ class wallet_api /** Sign a message using an account's memo key. The signature is generated as in - * https://github.com/xeroc/python-graphenelib/blob/d9634d74273ebacc92555499eca7c444217ecba0/graphenecommon/message.py#L64 . + * https://github.com/xeroc/python-graphenelib/blob/d9634d74/graphenecommon/message.py#L64 . * * @param signer the name or id of signing account * @param message text to sign From 805e052f8c5dbdbe55332a6f5058d359893b141d Mon Sep 17 00:00:00 2001 From: abitmore Date: Thu, 27 Oct 2022 10:50:25 +0000 Subject: [PATCH 10/13] Bump FC for typename of map> --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index 41f31f8c60..4d024a83b7 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 41f31f8c60561ef8f885f326abc21210cdd7db40 +Subproject commit 4d024a83b774da0e186c0c6c070e695f563da373 From c44e91c4ea94a587a279e6f2de17ecc7196e7add Mon Sep 17 00:00:00 2001 From: abitmore Date: Thu, 27 Oct 2022 15:57:32 +0000 Subject: [PATCH 11/13] Avoid using reserved identifier "remove" --- libraries/wallet/include/graphene/wallet/wallet.hpp | 4 ++-- libraries/wallet/wallet.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index bc5d965650..d444e656b9 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -1802,13 +1802,13 @@ class wallet_api * * @param account The account name or ID that we are adding additional information to. * @param catalog The name of the catalog the operation will insert data to. - * @param remove true if you want to remove stuff from a catalog. + * @param is_to_remove true if you want to remove stuff from a catalog. * @param key_values The map to be inserted/removed to/from the catalog * @param broadcast true if you wish to broadcast the transaction * * @return The signed transaction */ - signed_transaction account_store_map( const string& account, const string& catalog, bool remove, + signed_transaction account_store_map( const string& account, const string& catalog, bool is_to_remove, const flat_map>& key_values, bool broadcast )const; /** diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 848e26c711..616ee54b64 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -1928,10 +1928,10 @@ order_book wallet_api::get_order_book( const string& base, const string& quote, } // custom operations -signed_transaction wallet_api::account_store_map( const string& account, const string& catalog, bool remove, +signed_transaction wallet_api::account_store_map( const string& account, const string& catalog, bool is_to_remove, const flat_map>& key_values, bool broadcast )const { - return my->account_store_map(account, catalog, remove, key_values, broadcast); + return my->account_store_map(account, catalog, is_to_remove, key_values, broadcast); } vector wallet_api::get_account_storage( const string& account, const string& catalog )const From d8090cae4cf418b57ab94053edffc2e8e29b6b82 Mon Sep 17 00:00:00 2001 From: abitmore Date: Thu, 27 Oct 2022 20:46:10 +0000 Subject: [PATCH 12/13] Rename a variable --- libraries/chain/balance_evaluator.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/chain/balance_evaluator.cpp b/libraries/chain/balance_evaluator.cpp index 2d0c4810bf..c91a2b892a 100644 --- a/libraries/chain/balance_evaluator.cpp +++ b/libraries/chain/balance_evaluator.cpp @@ -31,15 +31,15 @@ void_result balance_claim_evaluator::do_evaluate(const balance_claim_operation& database& d = db(); balance = &op.balance_to_claim(d); - bool is_balance_owner_match = ( + bool is_balance_owner = ( op.balance_owner_key == balance->owner || pts_address(op.balance_owner_key, false) == balance->owner || // version = 56 (default) pts_address(op.balance_owner_key, true) == balance->owner ); // version = 56 (default) - is_balance_owner_match = ( - is_balance_owner_match || + is_balance_owner = ( + is_balance_owner || pts_address(op.balance_owner_key, false, 0) == balance->owner || pts_address(op.balance_owner_key, true, 0) == balance->owner ); - GRAPHENE_ASSERT( is_balance_owner_match, + GRAPHENE_ASSERT( is_balance_owner, balance_claim_owner_mismatch, "Balance owner key was specified as '${op}' but balance's actual owner is '${bal}'", ("op", op.balance_owner_key) From 31932639e0d316c6b58f2078c533720eee1f94e6 Mon Sep 17 00:00:00 2001 From: abitmore Date: Thu, 27 Oct 2022 21:18:00 +0000 Subject: [PATCH 13/13] Extend transaction_handle_type to 32 bits and handle overflow --- libraries/wallet/include/graphene/wallet/wallet_structs.hpp | 2 +- libraries/wallet/wallet_builder.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/wallet/include/graphene/wallet/wallet_structs.hpp b/libraries/wallet/include/graphene/wallet/wallet_structs.hpp index b4a69306b2..c4007127f7 100644 --- a/libraries/wallet/include/graphene/wallet/wallet_structs.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet_structs.hpp @@ -34,7 +34,7 @@ using std::vector; namespace graphene { namespace wallet { -using transaction_handle_type = uint16_t; +using transaction_handle_type = uint32_t; struct plain_keys { diff --git a/libraries/wallet/wallet_builder.cpp b/libraries/wallet/wallet_builder.cpp index 864daf28f8..b7005fbbaf 100644 --- a/libraries/wallet/wallet_builder.cpp +++ b/libraries/wallet/wallet_builder.cpp @@ -27,9 +27,9 @@ namespace graphene { namespace wallet { namespace detail { transaction_handle_type wallet_api_impl::begin_builder_transaction() { - int trx_handle = _builder_transactions.empty()? 0 + transaction_handle_type trx_handle = _builder_transactions.empty() ? 0 : (--_builder_transactions.end())->first + 1; - _builder_transactions[trx_handle]; + _builder_transactions[trx_handle] = {}; // Reset if exists already return trx_handle; }