pub struct UnsignedTransaction { /* private fields */ }Expand description
An unsigned transaction with the chain hash baked in.
Created by [UnsignedTransaction::build]. Contains everything
needed to produce signable bytes without a client reference.
Implementations§
Source§impl UnsignedTransaction
impl UnsignedTransaction
Sourcepub fn to_bytes(&self) -> SDKResult<Vec<u8>>
pub fn to_bytes(&self) -> SDKResult<Vec<u8>>
Serialize into the bytes that must be signed.
Borsh-serializes the transaction and appends the chain hash (32 bytes) as a domain separator.
Sourcepub fn to_display_message(&self) -> SDKResult<String>
pub fn to_display_message(&self) -> SDKResult<String>
Render the unsigned transaction payload as a human-readable message.
This is useful when an external wallet can only show raw message bytes
during signing. The returned string is for display only; sign the bytes
from to_bytes.
Sourcepub fn to_ledger_signable_bytes(&self, pubkey: &[u8; 32]) -> SDKResult<Vec<u8>>
pub fn to_ledger_signable_bytes(&self, pubkey: &[u8; 32]) -> SDKResult<Vec<u8>>
Build the bytes a Ledger hardware wallet must sign.
Prepends the 85-byte Solana off-chain message preamble (using chain_hash
as the application domain) to the JSON message bytes. This is the spec-
compliant format required by Ledger firmware. Pass the resulting bytes to
wallet.signMessage; then assemble and submit with
SolanaLedgerTransaction::from_parts and Client::send_ledger_transaction.
Sourcepub fn to_message_bytes(&self) -> SDKResult<Vec<u8>>
pub fn to_message_bytes(&self) -> SDKResult<Vec<u8>>
Serialize into the human-readable JSON bytes for offchain signing.
This is the message external Solana wallets should sign when the backend
uses the solanaSimple authenticator. The resulting signature must be
wrapped with SolanaOffchainTransaction::from_parts and submitted via
Client::send_offchain_transaction.
Sourcepub fn builder<'f1>() -> UnsignedTransactionBuilder<'f1>
pub fn builder<'f1>() -> UnsignedTransactionBuilder<'f1>
Build an unsigned transaction.
The returned UnsignedTransaction contains the chain hash, so
to_bytes() produces signable bytes
without needing a client reference.
§Example
let unsigned = UnsignedTransaction::builder()
.call_message(call_msg)
.max_fee(10_000_000)
.client(&client)
.build()?;
let signable = unsigned.to_bytes()?;
let signature: [u8; 64] = external_signer.sign(&signable);
let pub_key: [u8; 32] = external_signer.public_key();
let signed = Transaction::from_parts(unsigned, signature, pub_key);