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
matcharms. - instruction
- transaction
Structs§
- Advance
Plan - Fully assembled but unsigned Advance instruction plan.
- Persisted
Advance - Advance whose consumed position has been durably recorded.
- Signed
Advance - Advance after a Winternitz position has been consumed, before persistence.
- Signing
Position - Current one-time-signature derivation position.
- Unsigned
Advance - Fully constructed Advance that has not burned a Winternitz position yet.
- Winter
Wallet - High-level view of a WinterWallet account plus local signer position.
- Winter
Wallet Account - 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§
- Advance
Persistence - Persistence adapter for advancing local one-time-signature state.
- Advance
Sender - 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
Transferinstruction for use inside Advance. - wallet_
id_ from_ mnemonic - Derive the wallet ID from a mnemonic at wallet index 0.