Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add broadcast_transaction method for broadcasting transaction signed by … #656

Merged
merged 3 commits into from
Feb 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions libraries/wallet/include/graphene/wallet/wallet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,13 @@ class wallet_api
* @ingroup Transaction Builder API
*/
signed_transaction sign_builder_transaction(transaction_handle_type transaction_handle, bool broadcast = true);

/** Broadcast signed transaction
* @param tx signed transaction
* @returns the transaction ID along with the signed transaction.
*/
pair<transaction_id_type,signed_transaction> broadcast_transaction(signed_transaction tx);

/**
* @ingroup Transaction Builder API
*/
Expand Down Expand Up @@ -660,8 +667,6 @@ class wallet_api
bool is_public_key_registered(string public_key) const;

/** Converts a signed_transaction in JSON form to its binary representation.
*
* TODO: I don't see a broadcast_transaction() function, do we need one?
*
* @param tx the transaction to serialize
* @returns the binary form of the transaction. It will not be hex encoded,
Expand Down Expand Up @@ -1628,6 +1633,7 @@ FC_API( graphene::wallet::wallet_api,
(set_fees_on_builder_transaction)
(preview_builder_transaction)
(sign_builder_transaction)
(broadcast_transaction)
(propose_builder_transaction)
(propose_builder_transaction2)
(remove_builder_transaction)
Expand Down
18 changes: 18 additions & 0 deletions libraries/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,19 @@ class wallet_api_impl

return _builder_transactions[transaction_handle] = sign_transaction(_builder_transactions[transaction_handle], broadcast);
}

pair<transaction_id_type,signed_transaction> broadcast_transaction(signed_transaction tx)
{
try {
_remote_net_broadcast->broadcast_transaction(tx);
}
catch (const fc::exception& e) {
elog("Caught exception while broadcasting tx ${id}: ${e}", ("id", tx.id().str())("e", e.to_detail_string()));
throw;
}
return std::make_pair(tx.id(),tx);
}

signed_transaction propose_builder_transaction(
transaction_handle_type handle,
time_point_sec expiration = time_point::now() + fc::minutes(1),
Expand Down Expand Up @@ -3028,6 +3041,11 @@ signed_transaction wallet_api::sign_builder_transaction(transaction_handle_type
return my->sign_builder_transaction(transaction_handle, broadcast);
}

pair<transaction_id_type,signed_transaction> wallet_api::broadcast_transaction(signed_transaction tx)
{
return my->broadcast_transaction(tx);
}

signed_transaction wallet_api::propose_builder_transaction(
transaction_handle_type handle,
time_point_sec expiration,
Expand Down