finalizing

This commit is contained in:
Nikolay Volf 2016-03-05 18:29:01 +03:00
parent 1aaae7b553
commit bb8a79f18c
3 changed files with 12 additions and 7 deletions

View File

@ -260,11 +260,15 @@ impl Eth for EthClient {
let client = take_weak!(self.client);
let store = client.secret_store().read().unwrap();
match store.account_secret(&transaction_request.from) {
Ok(_) => {
// todo: actually sign and push to queue transaction here
Ok(Value::Bool(true))
Ok(secret) => {
let sync = take_weak!(self.sync);
let (transaction, _) = transaction_request.to_eth();
let signed_transaction = transaction.sign(&secret);
let hash = signed_transaction.hash();
sync.insert_transaction(signed_transaction);
to_value(&hash)
},
Err(_) => { Ok(Value::Bool(false ))}
Err(_) => { to_value(&U256::zero()) }
}
})
}

View File

@ -28,6 +28,7 @@ impl Bytes {
pub fn new(bytes: Vec<u8>) -> Bytes {
Bytes(bytes)
}
pub fn to_vec(self) -> Vec<u8> { let Bytes(x) = self; x }
}
impl Default for Bytes {

View File

@ -19,7 +19,6 @@ use ethcore::transaction::{LocalizedTransaction, Action};
use v1::types::{Bytes, OptionalValue};
use serde::{Deserializer, Error};
use ethcore;
use util;
#[derive(Debug, Default, Serialize)]
pub struct Transaction {
@ -53,7 +52,8 @@ pub struct TransactionRequest {
}
impl TransactionRequest {
fn to_eth(self) -> (ethcore::transaction::Transaction, Address) {
/// maps transaction request to the transaction that can be signed and inserted
pub fn to_eth(self) -> (ethcore::transaction::Transaction, Address) {
(ethcore::transaction::Transaction {
nonce: self.nonce.unwrap_or(U256::zero()),
action: match self.to {
@ -63,7 +63,7 @@ impl TransactionRequest {
gas: self.gas.unwrap_or(U256::zero()),
gas_price: self.gas_price.unwrap_or(U256::zero()),
value: self.value.unwrap_or(U256::zero()),
data: { let (ref x) = self.data; x }
data: self.data.to_vec()
}, self.from)
}
}