Remove signed_keys
Use first signatures.len() of account_keys for signing
This commit is contained in:
committed by
Michael Vines
parent
cda9ad8565
commit
e048116ab2
@ -265,7 +265,6 @@ mod tests {
|
|||||||
let instruction = Instruction::NewBudget(expr);
|
let instruction = Instruction::NewBudget(expr);
|
||||||
let instructions = vec![transaction::Instruction::new(0, &instruction, vec![])];
|
let instructions = vec![transaction::Instruction::new(0, &instruction, vec![])];
|
||||||
let claim0 = Transaction {
|
let claim0 = Transaction {
|
||||||
signed_keys: vec![],
|
|
||||||
account_keys: vec![],
|
account_keys: vec![],
|
||||||
last_id: Default::default(),
|
last_id: Default::default(),
|
||||||
signatures: vec![],
|
signatures: vec![],
|
||||||
|
@ -36,12 +36,10 @@ impl Instruction {
|
|||||||
/// An atomic transaction
|
/// An atomic transaction
|
||||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
|
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
|
||||||
pub struct Transaction {
|
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<Signature>,
|
pub signatures: Vec<Signature>,
|
||||||
|
|
||||||
/// The `Pubkeys` that correspond to signature in `signatures`
|
|
||||||
pub signed_keys: Vec<Pubkey>,
|
|
||||||
|
|
||||||
/// The `Pubkeys` that are executing this transaction userdata. The meaning of each key is
|
/// The `Pubkeys` that are executing this transaction userdata. The meaning of each key is
|
||||||
/// program-specific.
|
/// program-specific.
|
||||||
/// * account_keys[0] - Typically this is the `caller` public key. `signature` is verified with account_keys[0].
|
/// * 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<Pubkey>,
|
program_ids: Vec<Pubkey>,
|
||||||
instructions: Vec<Instruction>,
|
instructions: Vec<Instruction>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let from = from_keypairs[0].pubkey();
|
let mut account_keys: Vec<_> = from_keypairs
|
||||||
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
|
|
||||||
.iter()
|
.iter()
|
||||||
.map(|keypair| keypair.pubkey())
|
.map(|keypair| keypair.pubkey())
|
||||||
.collect();
|
.collect();
|
||||||
|
account_keys.extend_from_slice(keys);
|
||||||
let mut tx = Transaction {
|
let mut tx = Transaction {
|
||||||
signatures: vec![],
|
signatures: vec![],
|
||||||
signed_keys,
|
|
||||||
account_keys,
|
account_keys,
|
||||||
last_id: Hash::default(),
|
last_id: Hash::default(),
|
||||||
fee,
|
fee,
|
||||||
@ -145,10 +139,7 @@ impl Transaction {
|
|||||||
}
|
}
|
||||||
/// Get the transaction data to sign.
|
/// Get the transaction data to sign.
|
||||||
pub fn get_sign_data(&self) -> Vec<u8> {
|
pub fn get_sign_data(&self) -> Vec<u8> {
|
||||||
let mut data = serialize(&self.signed_keys).expect("serialize signed keys");
|
let mut data = serialize(&self.account_keys).expect("serialize account_keys");
|
||||||
|
|
||||||
let account_keys_data = serialize(&self.account_keys).expect("serialize account_keys");
|
|
||||||
data.extend_from_slice(&account_keys_data);
|
|
||||||
|
|
||||||
let last_id_data = serialize(&self.last_id).expect("serialize last_id");
|
let last_id_data = serialize(&self.last_id).expect("serialize last_id");
|
||||||
data.extend_from_slice(&last_id_data);
|
data.extend_from_slice(&last_id_data);
|
||||||
|
Reference in New Issue
Block a user