Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Adds personal_signTransaction RPC method #6991

Merged
merged 4 commits into from
Dec 19, 2017
Merged

Conversation

0x7CFE
Copy link
Contributor

@0x7CFE 0x7CFE commented Nov 6, 2017

New RPC method personal_signTransaction is added. Existing send_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?

Ok(default) => default,
Err(e) => return Box::new(future::err(e)),
};
fn sign_transaction(&self, meta: Metadata, request: TransactionRequest, password: String) -> BoxFuture<RpcH256, Error> {
Copy link
Collaborator

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.

@tomusdrw tomusdrw added A4-gotissues 💥 Pull request is reviewed and has significant issues which must be addressed. M6-rpcapi 📣 RPC API. labels Nov 6, 2017
@tomusdrw
Copy link
Collaborator

tomusdrw commented Nov 6, 2017

The tests should go to tests/mocked/personal.rs

@0x7CFE 0x7CFE added A0-pleasereview 🤓 Pull request needs code review. and removed A4-gotissues 💥 Pull request is reviewed and has significant issues which must be addressed. labels Nov 6, 2017
@5chdn 5chdn added this to the 1.9 milestone Nov 6, 2017
@0x7CFE 0x7CFE force-pushed the personal_sign_transaction branch from d164f92 to 6b932d1 Compare November 10, 2017 05:47
@0x7CFE 0x7CFE requested a review from debris November 11, 2017 16:01
@debris debris added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Nov 12, 2017

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() {
Copy link
Collaborator

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.

Copy link
Contributor Author

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?

Copy link
Collaborator

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.

@debris debris added A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. and removed A8-looksgood 🦄 Pull request is reviewed well. labels Nov 13, 2017
@0x7CFE 0x7CFE force-pushed the personal_sign_transaction branch from 6b932d1 to c607a26 Compare November 16, 2017 09:49
@0x7CFE 0x7CFE force-pushed the personal_sign_transaction branch from c607a26 to b208a10 Compare November 17, 2017 03:00
@tomusdrw tomusdrw added A8-looksgood 🦄 Pull request is reviewed well. and removed A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. labels Dec 19, 2017
@tomusdrw tomusdrw merged commit 5f82f00 into master Dec 19, 2017
@tomusdrw tomusdrw deleted the personal_sign_transaction branch December 19, 2017 09:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well. M6-rpcapi 📣 RPC API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants