add_sidechain_address fixes for HIVE, wallet doc fixes

This commit is contained in:
serkixenos 2021-04-02 15:02:46 +02:00
parent 944fa3b072
commit 2c5e1c35a5
3 changed files with 46 additions and 19 deletions

View file

@ -9,7 +9,9 @@ namespace graphene { namespace chain {
void_result add_sidechain_address_evaluator::do_evaluate(const sidechain_address_add_operation& op) void_result add_sidechain_address_evaluator::do_evaluate(const sidechain_address_add_operation& op)
{ try{ { try{
FC_ASSERT( op.deposit_public_key.length() > 0 && op.deposit_address.length() == 0 && op.deposit_address_data.length() == 0, "User should add a valid deposit public key and a null deposit address"); if (op.sidechain == sidechain_type::bitcoin) {
FC_ASSERT( op.deposit_public_key.length() > 0 && op.deposit_address.length() == 0 && op.deposit_address_data.length() == 0, "ser should add a valid deposit public key and a null deposit address (Bitcoin only)");
}
const auto& sdpke_idx = db().get_index_type<sidechain_address_index>().indices().get<by_sidechain_and_deposit_public_key_and_expires>(); const auto& sdpke_idx = db().get_index_type<sidechain_address_index>().indices().get<by_sidechain_and_deposit_public_key_and_expires>();
FC_ASSERT( sdpke_idx.find(boost::make_tuple(op.sidechain, op.deposit_public_key, time_point_sec::maximum())) == sdpke_idx.end(), "An active deposit key already exists" ); FC_ASSERT( sdpke_idx.find(boost::make_tuple(op.sidechain, op.deposit_public_key, time_point_sec::maximum())) == sdpke_idx.end(), "An active deposit key already exists" );
return void_result(); return void_result();
@ -31,8 +33,8 @@ object_id_type add_sidechain_address_evaluator::do_apply(const sidechain_address
obj.sidechain_address_account = op.sidechain_address_account; obj.sidechain_address_account = op.sidechain_address_account;
obj.sidechain = op.sidechain; obj.sidechain = op.sidechain;
obj.deposit_public_key = op.deposit_public_key; obj.deposit_public_key = op.deposit_public_key;
obj.deposit_address = ""; obj.deposit_address = op.deposit_address;
obj.deposit_address_data = ""; obj.deposit_address_data = op.deposit_address_data;
obj.withdraw_public_key = op.withdraw_public_key; obj.withdraw_public_key = op.withdraw_public_key;
obj.withdraw_address = op.withdraw_address; obj.withdraw_address = op.withdraw_address;
obj.valid_from = db().head_block_time(); obj.valid_from = db().head_block_time();

View file

@ -651,7 +651,7 @@ class wallet_api
* @see suggest_brain_key() * @see suggest_brain_key()
* *
* @param brain_key Brain key * @param brain_key Brain key
* @param numberOfDesiredKeys Number of desired keys * @param number_of_desired_keys Number of desired keys
* @return A list of keys that are deterministically derived from the brainkey * @return A list of keys that are deterministically derived from the brainkey
*/ */
vector<brain_key_info> derive_owner_keys_from_brain_key(string brain_key, int number_of_desired_keys = 1) const; vector<brain_key_info> derive_owner_keys_from_brain_key(string brain_key, int number_of_desired_keys = 1) const;
@ -666,7 +666,12 @@ class wallet_api
bool is_public_key_registered(string public_key) const; bool is_public_key_registered(string public_key) const;
/** /**
* @param role - active | owner | memo * Gets private key from password
*
* @param account Account name
* @param role Account role - active | owner | memo
* @param password Account password
* @return public/private key pair
*/ */
pair<public_key_type,string> get_private_key_from_password( string account, string role, string password )const; pair<public_key_type,string> get_private_key_from_password( string account, string role, string password )const;
@ -894,18 +899,24 @@ class wallet_api
* that it exists in the blockchain. If it exists then it will report the amount received and * that it exists in the blockchain. If it exists then it will report the amount received and
* who sent it. * who sent it.
* *
* @param opt_from - if not empty and the sender is a unknown public key, then the unknown public key will be given the label opt_from
* @param confirmation_receipt - a base58 encoded stealth confirmation * @param confirmation_receipt - a base58 encoded stealth confirmation
* @param opt_from - if not empty and the sender is a unknown public key, then the unknown public key will be given the label opt_from
* @param opt_memo - optional memo
*/ */
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 );
/** /**
* Transfers a public balance from @from to one or more blinded balances using a * Transfers a public balance from from_account_id_or_name to one or more blinded balances using a
* stealth transfer. * stealth transfer.
*
* @param from_account_id_or_name account id or name
* @param asset_symbol asset symbol
* @param to_amounts map from key or label to amount
* @param broadcast true to broadcast the transaction on the network
* @returns blind confirmation structure
*/ */
blind_confirmation transfer_to_blind( string from_account_id_or_name, blind_confirmation transfer_to_blind( string from_account_id_or_name,
string asset_symbol, string asset_symbol,
/** map from key or label to amount */
vector<pair<string, string>> to_amounts, vector<pair<string, string>> to_amounts,
bool broadcast = false ); bool broadcast = false );
@ -1009,11 +1020,11 @@ class wallet_api
* *
* @param buyer_account The account buying the asset for another asset. * @param buyer_account The account buying the asset for another asset.
* @param base The name or id of the asset to buy. * @param base The name or id of the asset to buy.
* @param quote The name or id of the assest being offered as payment. * @param quote The name or id of the asset being offered as payment.
* @param rate The rate in base:quote at which you want to buy. * @param rate The rate in base:quote at which you want to buy.
* @param amount the amount of base you want to buy. * @param amount the amount of base you want to buy.
* @param broadcast true to broadcast the transaction on the network. * @param broadcast true to broadcast the transaction on the network.
* @param The signed transaction selling the funds. * @returns The signed transaction buying the funds.
*/ */
signed_transaction buy( string buyer_account, signed_transaction buy( string buyer_account,
string base, string base,
@ -1493,6 +1504,7 @@ class wallet_api
* @param account the name or id of the account who owns the address * @param account the name or id of the account who owns the address
* @param sidechain a sidechain to whom address belongs * @param sidechain a sidechain to whom address belongs
* @param deposit_public_key sidechain public key used for deposit address * @param deposit_public_key sidechain public key used for deposit address
* @param deposit_address sidechain address for deposits
* @param withdraw_public_key sidechain public key used for withdraw address * @param withdraw_public_key sidechain public key used for withdraw address
* @param withdraw_address sidechain address for withdrawals * @param withdraw_address sidechain address for withdrawals
* @param broadcast true to broadcast the transaction on the network * @param broadcast true to broadcast the transaction on the network
@ -1501,6 +1513,7 @@ class wallet_api
signed_transaction add_sidechain_address(string account, signed_transaction add_sidechain_address(string account,
sidechain_type sidechain, sidechain_type sidechain,
string deposit_public_key, string deposit_public_key,
string deposit_address,
string withdraw_public_key, string withdraw_public_key,
string withdraw_address, string withdraw_address,
bool broadcast = false); bool broadcast = false);
@ -1561,7 +1574,7 @@ class wallet_api
/** /**
* Update a witness object owned by the given account. * Update a witness object owned by the given account.
* *
* @param witness The name of the witness's owner account. Also accepts the ID of the owner account or the ID of the witness. * @param witness_name The name of the witness's owner account. Also accepts the ID of the owner account or the ID of the witness.
* @param url Same as for create_witness. The empty string makes it remain the same. * @param url Same as for create_witness. The empty string makes it remain the same.
* @param block_signing_key The new block signing public key. The empty string makes it remain the same. * @param block_signing_key The new block signing public key. The empty string makes it remain the same.
* @param broadcast true if you wish to broadcast the transaction. * @param broadcast true if you wish to broadcast the transaction.
@ -1599,7 +1612,7 @@ class wallet_api
* Update your votes for a worker * Update your votes for a worker
* *
* @param account The account which will pay the fee and update votes. * @param account The account which will pay the fee and update votes.
* @param worker_vote_delta {"vote_for" : [...], "vote_against" : [...], "vote_abstain" : [...]} * @param delta {"vote_for" : [...], "vote_against" : [...], "vote_abstain" : [...]}
* @param broadcast true if you wish to broadcast the transaction. * @param broadcast true if you wish to broadcast the transaction.
*/ */
signed_transaction update_worker_votes( signed_transaction update_worker_votes(
@ -1732,7 +1745,7 @@ class wallet_api
signed_transaction update_son_votes(string voting_account, signed_transaction update_son_votes(string voting_account,
std::vector<std::string> sons_to_approve, std::vector<std::string> sons_to_approve,
std::vector<std::string> sons_to_reject, std::vector<std::string> sons_to_reject,
uint16_t desired_number_of_son, uint16_t desired_number_of_sons,
bool broadcast = false); bool broadcast = false);
/** Vote for a given witness. /** Vote for a given witness.
@ -1826,8 +1839,8 @@ class wallet_api
* set, your preferences will be ignored. * set, your preferences will be ignored.
* *
* @param account_to_modify the name or id of the account to update * @param account_to_modify the name or id of the account to update
* @param number_of_committee_members the number * @param desired_number_of_witnesses desired number of witnesses
* * @param desired_number_of_committee_members desired number of committee members
* @param broadcast true if you wish to broadcast the transaction * @param broadcast true if you wish to broadcast the transaction
* @return the signed transaction changing your vote proxy settings * @return the signed transaction changing your vote proxy settings
*/ */
@ -1958,6 +1971,7 @@ class wallet_api
/** Get random numbers /** Get random numbers
* @brief Returns the random number * @brief Returns the random number
* @param account The account paying the fee to get a random number
* @param minimum Lower bound of segment containing random number * @param minimum Lower bound of segment containing random number
* @param maximum Upper bound of segment containing random number * @param maximum Upper bound of segment containing random number
* @param selections Number of random numbers to return * @param selections Number of random numbers to return
@ -1975,7 +1989,9 @@ class wallet_api
/** Get random number /** Get random number
* @brief Returns the random number * @brief Returns the random number
* @param account The account paying the fee to get a random number
* @param bound Upper bound of segment containing random number * @param bound Upper bound of segment containing random number
* @param broadcast true if you wish to broadcast the transaction
* @return Random number from segment [0, bound) * @return Random number from segment [0, bound)
*/ */
uint64_t get_random_number(string account, uint64_t get_random_number(string account,
@ -2155,6 +2171,7 @@ class wallet_api
/** Creates a new tournament /** Creates a new tournament
* @param creator the accout that is paying the fee to create the tournament * @param creator the accout that is paying the fee to create the tournament
* @param options the options detailing the specifics of the tournament * @param options the options detailing the specifics of the tournament
* @param broadcast true if you wish to broadcast the transaction
* @return the signed version of the transaction * @return the signed version of the transaction
*/ */
signed_transaction tournament_create( string creator, tournament_options options, bool broadcast = false ); signed_transaction tournament_create( string creator, tournament_options options, bool broadcast = false );
@ -2194,7 +2211,7 @@ class wallet_api
tournament_state state); tournament_state state);
/** Get specific information about a tournament /** Get specific information about a tournament
* @param tournament_id the ID of the tournament * @param id the ID of the tournament
*/ */
tournament_object get_tournament(tournament_id_type id); tournament_object get_tournament(tournament_id_type id);
@ -2202,6 +2219,7 @@ class wallet_api
* @param game_id the id of the game * @param game_id the id of the game
* @param player_account the name of the player * @param player_account the name of the player
* @param gesture rock, paper, or scissors * @param gesture rock, paper, or scissors
* @param broadcast true if you wish to broadcast the transaction
* @return the signed version of the transaction * @return the signed version of the transaction
*/ */
signed_transaction rps_throw(game_id_type game_id, signed_transaction rps_throw(game_id_type game_id,
@ -2254,6 +2272,9 @@ class wallet_api
* @param revenue_split revenue split for the sale * @param revenue_split revenue split for the sale
* @param is_transferable can transfer the NFT or not * @param is_transferable can transfer the NFT or not
* @param is_sellable can sell NFT or not * @param is_sellable can sell NFT or not
* @param role_id account role id
* @param max_supply max supply of NTFs
* @param lottery_options lottery options
* @param broadcast true to broadcast transaction to the network * @param broadcast true to broadcast transaction to the network
* @return Signed transaction transfering the funds * @return Signed transaction transfering the funds
*/ */
@ -2281,6 +2302,7 @@ class wallet_api
* @param revenue_split revenue split for the sale * @param revenue_split revenue split for the sale
* @param is_transferable can transfer the NFT or not * @param is_transferable can transfer the NFT or not
* @param is_sellable can sell NFT or not * @param is_sellable can sell NFT or not
* @param role_id account role id
* @param broadcast true to broadcast transaction to the network * @param broadcast true to broadcast transaction to the network
* @return Signed transaction transfering the funds * @return Signed transaction transfering the funds
*/ */
@ -2394,8 +2416,8 @@ class wallet_api
/** /**
* @brief Returns operator approved state for all NFT owned by owner * @brief Returns operator approved state for all NFT owned by owner
* @param owner NFT owner account ID * @param owner_account_id_or_name NFT owner account ID or name
* @param token_id NFT ID * @param operator_account_id_or_name NFT operator account ID or name
* @return True if operator is approved for all NFT owned by owner, else False * @return True if operator is approved for all NFT owned by owner, else False
*/ */
bool nft_is_approved_for_all(string owner_account_id_or_name, string operator_account_id_or_name) const; bool nft_is_approved_for_all(string owner_account_id_or_name, string operator_account_id_or_name) const;

View file

@ -2221,6 +2221,7 @@ public:
signed_transaction add_sidechain_address(string account, signed_transaction add_sidechain_address(string account,
sidechain_type sidechain, sidechain_type sidechain,
string deposit_public_key, string deposit_public_key,
string deposit_address,
string withdraw_public_key, string withdraw_public_key,
string withdraw_address, string withdraw_address,
bool broadcast /* = false */) bool broadcast /* = false */)
@ -2232,6 +2233,7 @@ public:
op.sidechain_address_account = sidechain_address_account_id; op.sidechain_address_account = sidechain_address_account_id;
op.sidechain = sidechain; op.sidechain = sidechain;
op.deposit_public_key = deposit_public_key; op.deposit_public_key = deposit_public_key;
op.deposit_address = deposit_address;
op.withdraw_public_key = withdraw_public_key; op.withdraw_public_key = withdraw_public_key;
op.withdraw_address = withdraw_address; op.withdraw_address = withdraw_address;
@ -5086,11 +5088,12 @@ vector<optional<son_wallet_object>> wallet_api::get_son_wallets(uint32_t limit)
signed_transaction wallet_api::add_sidechain_address(string account, signed_transaction wallet_api::add_sidechain_address(string account,
sidechain_type sidechain, sidechain_type sidechain,
string deposit_public_key, string deposit_public_key,
string deposit_address,
string withdraw_public_key, string withdraw_public_key,
string withdraw_address, string withdraw_address,
bool broadcast /* = false */) bool broadcast /* = false */)
{ {
return my->add_sidechain_address(account, sidechain, deposit_public_key, withdraw_public_key, withdraw_address, broadcast); return my->add_sidechain_address(account, sidechain, deposit_public_key, deposit_address, withdraw_public_key, withdraw_address, broadcast);
} }
signed_transaction wallet_api::delete_sidechain_address(string account, signed_transaction wallet_api::delete_sidechain_address(string account,