Skip to content

feat(wallet): use sigma-rust for local wallet and transaction signing (#42) - #68

Open
ocakciomursel-pixel wants to merge 1 commit into
BetterMoneyLabs:masterfrom
ocakciomursel-pixel:feat-sigma-wallet-42
Open

ocakciomursel-pixel wants to merge 1 commit into
BetterMoneyLabs:masterfrom
ocakciomursel-pixel:feat-sigma-wallet-42

Conversation

@ocakciomursel-pixel

Copy link
Copy Markdown

Closes #42

Summary

Adds sigma-rust (ergo-lib) local wallet support so that the chaincash server can derive keys, select unspent boxes, and sign transactions locally without requiring an unlocked node wallet:

  • LocalWallet & WalletConfig (crates/chaincash_services/src/wallet.rs):
    • Supports configuring a BIP-39 mnemonic (with optional mnemonic_password and derivation_paths, defaulting to m/44'/429'/0'/0/0) and/or raw base16 DlogProverInput secrets in [wallet].
    • Derives P2PK addresses and EcPoint public keys locally.
    • Fetches unspent boxes by address via the node's /blockchain/box/unspent/byAddress indexer endpoint (node.endpoints().blockchain()?.unspent_by_address(...)).
    • Builds ErgoStateContext from the latest 10 block headers via /blocks/chainSlice, signs UnsignedTransaction locally using ergo_lib::wallet::Wallet::sign_transaction + TransactionContext, and submits signed transactions via POST /transactions.
  • TransactionService & ServerState (crates/chaincash_services/src/{lib,transaction,scanner}.rs):
    • Uses LocalWallet for wallet_pubkeys, get_utxos, box_selection_with_amount, get_tx_ctx, get_private_key, and sign_and_submit across mint_reserve, top_up_reserve, mint_note, spend_note, and redeem_note when configured, while preserving full backward compatibility with the node wallet when [wallet] is not configured.
    • Updates wait_scan_block in scanner.rs to poll /blockchain/indexedHeight instead of /wallet/status when LocalWallet is active.
  • Tests:
    • Added unit tests for BIP-39 mnemonic + secret key derivation and local sigma-rust signing of reserve mint & top-up transactions.

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.

Use sigma-rust for wallet functionality

1 participant