-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Adds personal_signTransaction
RPC method
#6991
Conversation
rpc/src/v1/impls/personal.rs
Outdated
Ok(default) => default, | ||
Err(e) => return Box::new(future::err(e)), | ||
}; | ||
fn sign_transaction(&self, meta: Metadata, request: TransactionRequest, password: String) -> BoxFuture<RpcH256, Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to get whole RichRawTransaction
, just the hash is not useful at all. The whole point of this RPC method is to get signed RLP (raw transaction) that you will be able to propagate later.
The tests should go to |
d164f92
to
6b932d1
Compare
|
||
let response = r#"{"jsonrpc":"2.0","error":{"code":-32021,"message":"Account password is invalid or account does not exist.","data":"SStore(InvalidPassword)"},"id":1}"#; | ||
|
||
assert_eq!(tester.io.handle_request_sync(request.as_ref()), Some(response.into())); | ||
} | ||
|
||
#[test] | ||
fn sign_transaction_with_invalid_password() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to have a positive test case as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't sure how to check if the response is actually valid.
Is there a convenient way to validate the whole JSON response, knowing that it should describe a transaction? I.e. all fields should exist and types should be correct? Maybe I could try to deserialize it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, deserializing it makes sense.
6b932d1
to
c607a26
Compare
c607a26
to
b208a10
Compare
New RPC method
personal_signTransaction
is added. Existingsend_transaction
's impl is refactored to reuse the common logic.@tomusdrw, I believe I need to write some tests for this. Where should I host them?