Skip to main content

Crate winterwallet_client

Crate winterwallet_client 

Source
Expand description

Off-chain client for the WinterWallet program.

Provides instruction builders, PDA derivation, preimage construction, CPI payload encoding, and on-chain state deserialization.

§Example: Build an Advance(Withdraw) plan

use winterwallet_client::*;
use winterwallet_common::WINTERNITZ_SCALARS;

// 1. Build a plan. It owns the payload + account order.
let plan = AdvancePlan::withdraw(&wallet_pda, &receiver, lamports, &new_root)?;

// 2. Compute preimage and sign.
let preimage = plan.preimage(&id, current_root);
let sig = keypair.sign_and_increment::<WINTERNITZ_SCALARS>(&preimage);

// 3. Build the Advance instruction.
let ix = plan.instruction(sig.as_bytes().try_into().unwrap());

Re-exports§

pub use instruction::AdvancePayload;
pub use instruction::advance;
pub use instruction::close;
pub use instruction::encode_advance;
pub use instruction::initialize;
pub use instruction::withdraw;
pub use transaction::AccountEntry;
pub use transaction::DEFAULT_ADVANCE_COMPUTE_UNIT_LIMIT;
pub use transaction::LEGACY_TRANSACTION_SIZE_LIMIT;
pub use transaction::estimate_legacy_transaction_size;
pub use transaction::set_compute_unit_limit;
pub use transaction::set_compute_unit_price;
pub use transaction::upsert;
pub use transaction::validate_legacy_transaction_size;
pub use transaction::validate_payer_only_signers;
pub use transaction::with_compute_budget;

Modules§

discriminator
Instruction discriminator bytes matching the on-chain match arms.
instruction
transaction

Structs§

AdvancePlan
Fully assembled but unsigned Advance instruction plan.
PersistedAdvance
Advance whose consumed position has been durably recorded.
SignedAdvance
Advance after a Winternitz position has been consumed, before persistence.
SigningPosition
Current one-time-signature derivation position.
UnsignedAdvance
Fully constructed Advance that has not burned a Winternitz position yet.
WinterWallet
High-level view of a WinterWallet account plus local signer position.
WinterWalletAccount
Deserialized WinterWallet account state.

Enums§

Error
Errors returned by the WinterWallet client.

Constants§

ID
The const program ID.
MAX_CPI_INSTRUCTION_ACCOUNTS
Upper bound on account metas per inner CPI’d instruction inside Advance.
MAX_PASSTHROUGH_ACCOUNTS
Upper bound on trailing accounts an Advance instruction can commit to. Sizes the stack-allocated signature-preimage buffer used during recovery.
SIGNATURE_LEN
Signature byte length: (N + 2) * 32.
TOTAL_SCALARS
Total scalars including the two checksum scalars.
WALLET_ACCOUNT_LEN
On-chain WinterWallet account data length: id(32) + root(32) + bump(1).
WINTERNITZ_SCALARS
Number of Winternitz message scalars (N). Total scalars = N + 2.
WINTERWALLET_ADVANCE
Domain tag for the Advance preimage.
WINTERWALLET_INITIALIZE
Domain tag for the Initialize preimage.
WINTERWALLET_SEED
PDA seed prefix.

Traits§

AdvancePersistence
Persistence adapter for advancing local one-time-signature state.
AdvanceSender
Sender adapter for persisted advances.

Functions§

advance_preimage
Build the preimage parts for an Advance signature.
find_wallet_address
Derive the WinterWallet PDA from a wallet ID.
initialize_preimage
Build the preimage parts for an Initialize signature.
token_transfer
Build an SPL Token Transfer instruction for use inside Advance.
wallet_id_from_mnemonic
Derive the wallet ID from a mnemonic at wallet index 0.