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

remove null signatures #11335

Merged
merged 9 commits into from
Dec 13, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions ethcore/types/src/transaction/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,11 @@ impl Transaction {
}
}

#[cfg(any(test, feature = "test-helpers"))]
impl From<ethjson::transaction::Transaction> for SignedTransaction {
fn from(t: ethjson::transaction::Transaction) -> Self {
let to: Option<ethjson::hash::Address> = t.to.into();
let secret = Secret::from(t.secret.0);
let secret = t.secret.map(|s| Secret::from(s.0));
let tx = Transaction {
nonce: t.nonce.into(),
gas_price: t.gas_price.into(),
Expand All @@ -153,7 +154,10 @@ impl From<ethjson::transaction::Transaction> for SignedTransaction {
value: t.value.into(),
data: t.data.into(),
};
tx.sign(&secret, None)
match secret {
Some(s) => tx.sign(&s, None),
None => tx.null_sign(1),
}
}
}

Expand Down Expand Up @@ -235,7 +239,7 @@ impl Transaction {
}

/// Legacy EIP-86 compatible empty signature.
/// Used only for tests.
#[cfg(any(test, feature = "test-helpers"))]
pub fn null_sign(self, chain_id: u64) -> SignedTransaction {
ordian marked this conversation as resolved.
Show resolved Hide resolved
SignedTransaction {
transaction: UnverifiedTransaction {
Expand Down
2 changes: 1 addition & 1 deletion json/src/test_helpers/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub struct MultiTransaction {
pub nonce: Uint,
/// Secret key.
#[serde(rename = "secretKey")]
pub secret: H256,
pub secret: Option<H256>,
/// To.
pub to: MaybeEmpty<Address>,
/// Value set.
Expand Down
4 changes: 2 additions & 2 deletions json/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub struct Transaction {
pub v: MaybeEmpty<Uint>,
/// Secret
#[serde(rename = "secretKey")]
pub secret: H256,
pub secret: Option<H256>,
}

#[cfg(test)]
Expand Down Expand Up @@ -78,6 +78,6 @@ mod tests {
assert_eq!(tx.r, Uint(U256::zero()).into());
assert_eq!(tx.s, Uint(U256::one()).into());
assert_eq!(tx.v, Uint(U256::from(2)).into());
assert_eq!(tx.secret, H256(Eth256::zero()));
assert_eq!(tx.secret, Some(H256(Eth256::zero())));
}
}