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

catch exception/error if signature is invalid and return error messag… #3397

Closed
wants to merge 1 commit into from
Closed
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
11 changes: 8 additions & 3 deletions src/EOS/Entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,14 @@ void Entry::compile([[maybe_unused]] TWCoinType coin, const Data& txInputData, c
return;
}

auto chainId = Data(input.chain_id().begin(), input.chain_id().end());
auto signedTx = Signer(chainId).buildSignedTx(input, signatures[0]);
output.set_json_encoded(signedTx.data(), signedTx.size());
try {
auto chainId = Data(input.chain_id().begin(), input.chain_id().end());
auto signedTx = Signer(chainId).buildSignedTx(input, signatures[0]);
output.set_json_encoded(signedTx.data(), signedTx.size());
} catch (const std::exception& e) {
output.set_error(Common::Proto::Error_invalid_params);
output.set_error_message(Common::Proto::SigningError_Name(Common::Proto::Error_invalid_params));
}
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/EOS/Signer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Data Signer::buildUnsignedTx(const Proto::SigningInput& input) noexcept {
return serializeTx(tx);
}

std::string Signer::buildSignedTx(const Proto::SigningInput& input, const Data& signature) noexcept {
std::string Signer::buildSignedTx(const Proto::SigningInput& input, const Data& signature) {
auto tx = buildTx(input);

// get key type
Expand Down
2 changes: 1 addition & 1 deletion src/EOS/Signer.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Signer {

Transaction buildTx(const Proto::SigningInput& input) const;
Data buildUnsignedTx(const Proto::SigningInput& input) noexcept;
std::string buildSignedTx(const Proto::SigningInput& input, const Data& signature) noexcept;
std::string buildSignedTx(const Proto::SigningInput& input, const Data& signature);
};

} // namespace TW::EOS