Skip to content

feat(wasm-solana): complete Jito stake/unstake and sign generated key…#160

Merged
lcovar merged 1 commit intomasterfrom
BTC-3025-sol-wasm-staking-fixes
Feb 13, 2026
Merged

feat(wasm-solana): complete Jito stake/unstake and sign generated key…#160
lcovar merged 1 commit intomasterfrom
BTC-3025-sol-wasm-staking-fixes

Conversation

@lcovar
Copy link
Contributor

@lcovar lcovar commented Feb 13, 2026

…pairs in Rust

Jito staking:

  • Add ATA creation support (createAssociatedTokenAccount field)
  • Derive withdraw authority PDA, destination/source pool accounts, and referral pool account when not explicitly provided
  • Use validatorAddress as fallback for stakePoolAddress

Jito unstaking:

  • Build full 4-instruction pattern: Approve, CreateAccount, WithdrawStake, Deactivate (matches legacy SDK behavior)
  • Build SPL Token Approve instruction manually to avoid spl-token v6/v3 type incompatibility

Generated keypair signing:

  • Sign generated keypairs (stake/unstake accounts) in Rust inside build_from_intent before returning to JS
  • Signatures survive the wasm-bindgen boundary because WasmTransaction is a heap-allocated Rust object that JS holds a handle to
  • Add sign_with_secret_key to WasmTransaction and sign to WasmKeypair for use by other callers

BTC-3025

…pairs in Rust

Jito staking:
- Add ATA creation support (createAssociatedTokenAccount field)
- Derive withdraw authority PDA, destination/source pool accounts, and
  referral pool account when not explicitly provided
- Use validatorAddress as fallback for stakePoolAddress

Jito unstaking:
- Build full 4-instruction pattern: Approve, CreateAccount, WithdrawStake,
  Deactivate (matches legacy SDK behavior)
- Build SPL Token Approve instruction manually to avoid spl-token v6/v3
  type incompatibility

Generated keypair signing:
- Sign generated keypairs (stake/unstake accounts) in Rust inside
  build_from_intent before returning to JS
- Signatures survive the wasm-bindgen boundary because WasmTransaction
  is a heap-allocated Rust object that JS holds a handle to
- Add sign_with_secret_key to WasmTransaction and sign to WasmKeypair
  for use by other callers

BTC-3025
@lcovar lcovar requested a review from a team as a code owner February 13, 2026 04:19
*
* @param secretKeyBase58 - The Ed25519 secret key (32-byte seed) as base58
*/
signWithSecretKey(secretKeyBase58: string): void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot explain how public keys are typed in wasm-utxo

Copy link

Copilot AI commented Feb 13, 2026

@OttoAllmendinger I've opened a new pull request, #161, to work on those changes. Once the pull request is ready, I'll request review from you.

Comment on lines +149 to +152
let secret_bytes: Vec<u8> = bs58::decode(secret_key_base58)
.into_vec()
.map_err(|e| WasmSolanaError::new(&format!("Failed to decode secret key: {}", e)))?;
let keypair = Keypair::from_secret_key_bytes(&secret_bytes)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the wasm interface is still pretty stringly typed

you could use the existing Keypair type instead here

  • more type safety at the callsite
  • no needless repeated decoding of the key here => faster tests

The callsite could still be backwards compatible and convert from string when necessary

Comment on lines +21 to +23
StakingType::Native => "NATIVE",
StakingType::Jito => "JITO",
StakingType::Marinade => "MARINADE",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uppercase here and regular case for the others? I'm guessing this is due to some external interface

* Get the Solana address (base58-encoded public key)
* @returns The address as a base58 string
*/
getAddress(): string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we actually need this anywhere?

* A keypair consists of a 32-byte secret key and a 32-byte public key.
* The public key (base58-encoded) is the Solana address.
*/
export class Keypair {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we already have one!

@lcovar lcovar merged commit af0c725 into master Feb 13, 2026
6 checks passed
@lcovar lcovar deleted the BTC-3025-sol-wasm-staking-fixes branch February 13, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants