signature agnostic transaction

This commit is contained in:
debris 2015-12-09 00:45:33 +01:00
parent a9099e8569
commit 421d2d1174
3 changed files with 48 additions and 0 deletions

View File

@ -64,3 +64,8 @@ impl Encodable for BlockHeader {
} }
} }
#[cfg(test)]
mod tests {
fn encoding_and_decoding() {
}
}

View File

@ -77,6 +77,7 @@ extern crate ethcore_util as util;
extern crate evmjit; extern crate evmjit;
pub mod blockheader; pub mod blockheader;
pub mod transaction;
#[test] #[test]
fn it_works() { fn it_works() {

42
src/transaction.rs Normal file
View File

@ -0,0 +1,42 @@
use util::hash::*;
use util::uint::*;
use util::rlp::*;
pub struct Transaction {
nonce: U256,
gas_price: U256,
gas: U256,
receive_address: Option<Address>,
value: U256,
data: Vec<u8>,
}
impl Encodable for Transaction {
fn encode<E>(&self, encoder: &mut E) where E: Encoder {
encoder.emit_list(| e | {
self.nonce.encode(e);
self.gas_price.encode(e);
self.gas.encode(e);
self.receive_address.encode(e);
self.value.encode(e);
self.data.encode(e);
})
}
}
impl Decodable for Transaction {
fn decode<D>(decoder: &D) -> Result<Self, DecoderError> where D: Decoder {
decoder.read_list(| d | {
let transaction = Transaction {
nonce: try!(Decodable::decode(&d[0])),
gas_price: try!(Decodable::decode(&d[1])),
gas: try!(Decodable::decode(&d[2])),
receive_address: try!(Decodable::decode(&d[3])),
value: try!(Decodable::decode(&d[4])),
data: try!(Decodable::decode(&d[5])),
};
Ok(transaction)
})
}
}