Expose Message via the new default Transaction constructor
This commit is contained in:
@ -4,7 +4,7 @@ pub mod genesis_block;
|
|||||||
pub mod hash;
|
pub mod hash;
|
||||||
pub mod instruction;
|
pub mod instruction;
|
||||||
pub mod loader_instruction;
|
pub mod loader_instruction;
|
||||||
mod message;
|
pub mod message;
|
||||||
pub mod native_loader;
|
pub mod native_loader;
|
||||||
pub mod native_program;
|
pub mod native_program;
|
||||||
pub mod packet;
|
pub mod packet;
|
||||||
|
@ -88,16 +88,25 @@ impl Transaction {
|
|||||||
Self::new_unsigned_message(message)
|
Self::new_unsigned_message(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn new<T: KeypairUtil>(
|
||||||
|
from_keypairs: &[&T],
|
||||||
|
message: Message,
|
||||||
|
recent_blockhash: Hash,
|
||||||
|
) -> Transaction {
|
||||||
|
let mut tx = Self::new_unsigned_message(message);
|
||||||
|
tx.sign(from_keypairs, recent_blockhash);
|
||||||
|
tx
|
||||||
|
}
|
||||||
|
|
||||||
pub fn new_signed_instructions<T: KeypairUtil>(
|
pub fn new_signed_instructions<T: KeypairUtil>(
|
||||||
from_keypairs: &[&T],
|
from_keypairs: &[&T],
|
||||||
instructions: Vec<Instruction>,
|
instructions: Vec<Instruction>,
|
||||||
recent_blockhash: Hash,
|
recent_blockhash: Hash,
|
||||||
fee: u64,
|
fee: u64,
|
||||||
) -> Transaction {
|
) -> Transaction {
|
||||||
let mut tx = Self::new(instructions);
|
let mut message = Message::new(instructions);
|
||||||
tx.fee = fee;
|
message.fee = fee;
|
||||||
tx.sign(from_keypairs, recent_blockhash);
|
Self::new(from_keypairs, message, recent_blockhash)
|
||||||
tx
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_signed<S: Serialize, T: KeypairUtil>(
|
pub fn new_signed<S: Serialize, T: KeypairUtil>(
|
||||||
@ -113,11 +122,7 @@ impl Transaction {
|
|||||||
account_metas.push(AccountMeta::new(*pubkey, false));
|
account_metas.push(AccountMeta::new(*pubkey, false));
|
||||||
}
|
}
|
||||||
let instruction = Instruction::new(*program_id, data, account_metas);
|
let instruction = Instruction::new(*program_id, data, account_metas);
|
||||||
let mut transaction = Self::new(vec![instruction]);
|
Self::new_signed_instructions(&[from_keypair], vec![instruction], recent_blockhash, fee)
|
||||||
transaction.fee = fee;
|
|
||||||
transaction.recent_blockhash = recent_blockhash;
|
|
||||||
transaction.sign(&[from_keypair], recent_blockhash);
|
|
||||||
transaction
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a signed transaction
|
/// Create a signed transaction
|
||||||
|
Reference in New Issue
Block a user