Make signing compatible with geth. (#4468)

This commit is contained in:
Gav Wood 2017-02-07 16:09:59 -05:00 committed by Arkadiy Paronyan
parent 428e8361ce
commit 810ec3558a
3 changed files with 8 additions and 4 deletions

View File

@ -109,8 +109,12 @@ pub fn execute<C, M>(client: &C, miner: &M, accounts: &AccountProvider, payload:
.map(ConfirmationResponse::SignTransaction) .map(ConfirmationResponse::SignTransaction)
) )
}, },
ConfirmationPayload::Signature(address, data) => { ConfirmationPayload::Signature(address, mut data) => {
signature(accounts, address, data.sha3(), pass) let mut message_data =
format!("\x19Ethereum Signed Message:\n{}", data.len())
.into_bytes();
message_data.append(&mut data);
signature(accounts, address, message_data.sha3(), pass)
.map(|result| result .map(|result| result
.map(|rsv| { .map(|rsv| {
let mut vrs = [0u8; 65]; let mut vrs = [0u8; 65];

View File

@ -310,7 +310,7 @@ fn rpc_eth_sign() {
], ],
"id": 1 "id": 1
}"#; }"#;
let res = r#"{"jsonrpc":"2.0","result":"0x1b5100b2be0aafd86271c8f49891262920bfbfeaeccb2ef1d0b2053aefc3ddb399483eb3c902ecf4add3156461a61f59e924a65eb5e6cdbab0a158d45db5f87cdf","id":1}"#; let res = r#"{"jsonrpc":"2.0","result":"0x1ba2870db1d0c26ef93c7b72d2a0830fa6b841e0593f7186bc6c7cc317af8cf3a42fda03bd589a49949aa05db83300cdb553116274518dbe9d90c65d0213f4af49","id":1}"#;
assert_eq!(tester.io.handle_request_sync(&req), Some(res.into())); assert_eq!(tester.io.handle_request_sync(&req), Some(res.into()));
} }

View File

@ -200,7 +200,7 @@ fn should_sign_if_account_is_unlocked() {
], ],
"id": 1 "id": 1
}"#; }"#;
let response = r#"{"jsonrpc":"2.0","result":"0x1bb3062482b0687e9c97c7609ea60c1649959dbb334f71b3d5cacd496e0848ba8137bc765756627722389c6c39bc77700ccdc8916916a0eb03bcf5191d4f74dc65","id":1}"#; let response = r#"{"jsonrpc":"2.0","result":"0x1bdb53b32e56cf3e9735377b7664d6de5a03e125b1bf8ec55715d253668b4238503b4ac931fe6af90add73e72a585e952665376b2b9afc5b6b239b7df74c734e12","id":1}"#;
assert_eq!(tester.io.handle_request_sync(&request), Some(response.to_owned())); assert_eq!(tester.io.handle_request_sync(&request), Some(response.to_owned()));
assert_eq!(tester.signer.requests().len(), 0); assert_eq!(tester.signer.requests().len(), 0);
} }