Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Document that Transaction::new can panic as well
Browse files Browse the repository at this point in the history
The direct callers of the Transaction::sign, which can panic, are
Transaction::new and related functions, which means these can panic as
well.
  • Loading branch information
ruuda committed May 4, 2021
1 parent 84c0d67 commit 489dd69
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions sdk/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ impl Transaction {
Self::new_unsigned(message)
}

/// Create a signed transaction with the given payer.
///
/// # Panics
///
/// Panics when signing fails.
pub fn new_signed_with_payer<T: Signers>(
instructions: &[Instruction],
payer: Option<&Pubkey>,
Expand All @@ -157,6 +162,11 @@ impl Transaction {
Self::new(signing_keypairs, message, recent_blockhash)
}

/// Create a signed transaction.
///
/// # Panics
///
/// Panics when signing fails.
pub fn new<T: Signers>(
from_keypairs: &T,
message: Message,
Expand All @@ -174,6 +184,10 @@ impl Transaction {
/// * `recent_blockhash` - The PoH hash.
/// * `program_ids` - The keys that identify programs used in the `instruction` vector.
/// * `instructions` - Instructions that will be executed atomically.
///
/// # Panics
///
/// Panics when signing fails.
pub fn new_with_compiled_instructions<T: Signers>(
from_keypairs: &T,
keys: &[Pubkey],
Expand Down

0 comments on commit 489dd69

Please sign in to comment.