From e048116ab2f0578719068a277ef8cdb4cb59c6d4 Mon Sep 17 00:00:00 2001 From: Stephen Akridge Date: Wed, 14 Nov 2018 21:15:53 -0800 Subject: [PATCH] Remove signed_keys Use first signatures.len() of account_keys for signing --- src/budget_transaction.rs | 1 - src/transaction.rs | 19 +++++-------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/budget_transaction.rs b/src/budget_transaction.rs index 09a925657a..6fa3ebb199 100644 --- a/src/budget_transaction.rs +++ b/src/budget_transaction.rs @@ -265,7 +265,6 @@ mod tests { let instruction = Instruction::NewBudget(expr); let instructions = vec![transaction::Instruction::new(0, &instruction, vec![])]; let claim0 = Transaction { - signed_keys: vec![], account_keys: vec![], last_id: Default::default(), signatures: vec![], diff --git a/src/transaction.rs b/src/transaction.rs index e15253aee9..3c2039ab08 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -36,12 +36,10 @@ impl Instruction { /// An atomic transaction #[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)] pub struct Transaction { - /// A set of digital signature of `account_keys`, `program_ids`, `last_id`, `fee` and `instructions`, signed by `signed_keys`. + /// A set of digital signature of `account_keys`, `program_ids`, `last_id`, `fee` and `instructions`, signed by the first + /// signatures.len() keys of account_keys pub signatures: Vec, - /// The `Pubkeys` that correspond to signature in `signatures` - pub signed_keys: Vec, - /// The `Pubkeys` that are executing this transaction userdata. The meaning of each key is /// program-specific. /// * account_keys[0] - Typically this is the `caller` public key. `signature` is verified with account_keys[0]. @@ -99,17 +97,13 @@ impl Transaction { program_ids: Vec, instructions: Vec, ) -> Self { - let from = from_keypairs[0].pubkey(); - let mut account_keys = Vec::with_capacity(keys.len() + 1); - account_keys.push(from); - account_keys.extend_from_slice(keys); - let signed_keys = from_keypairs + let mut account_keys: Vec<_> = from_keypairs .iter() .map(|keypair| keypair.pubkey()) .collect(); + account_keys.extend_from_slice(keys); let mut tx = Transaction { signatures: vec![], - signed_keys, account_keys, last_id: Hash::default(), fee, @@ -145,10 +139,7 @@ impl Transaction { } /// Get the transaction data to sign. pub fn get_sign_data(&self) -> Vec { - let mut data = serialize(&self.signed_keys).expect("serialize signed keys"); - - let account_keys_data = serialize(&self.account_keys).expect("serialize account_keys"); - data.extend_from_slice(&account_keys_data); + let mut data = serialize(&self.account_keys).expect("serialize account_keys"); let last_id_data = serialize(&self.last_id).expect("serialize last_id"); data.extend_from_slice(&last_id_data);