Skip to content

Conversation

@esaminu
Copy link
Contributor

@esaminu esaminu commented Nov 25, 2025

feat: add Bitcoin vault integration with per-input PSBT signing

Description

Adds complete Bitcoin vault functionality with support for UTXO management, PSBT construction, per-input MPC signatures, and transaction monitoring on Bitcoin regtest.

New components:

  • Bitcoin vault pallet (pallet-btc-vault): Handles deposits, claims, and balance tracking
  • Bitcoin PSBT builder (pallet-build-btc-tx): Constructs PSBTs from UTXOs and outputs
  • Integration test (btc-vault.test.ts): Full deposit/claim flow with regtest
  • Server support: Bitcoin transaction monitoring and result reporting

Key features:

  • Derives Bitcoin addresses from Substrate accounts using MPC key derivation
  • Per-input signature requests with unique request IDs for each UTXO
  • Automatic UTXO discovery and coin selection
  • Transaction confirmation monitoring on Bitcoin network
  • Bidirectional result reporting from MPC to Substrate

Motivation and Context

Extends the Signet MPC framework to support Bitcoin transactions, enabling users to deposit BTC into a Substrate vault by:

  1. Deriving a Bitcoin address from their Substrate account
  2. Building a PSBT that spends to the vault
  3. Requesting MPC signatures for each input
  4. Broadcasting the signed transaction
  5. Claiming the deposited amount in Substrate after confirmation

This mirrors the existing ERC20 vault pattern but adapted for Bitcoin's UTXO model.

How Has This Been Tested?

  • Full integration test (btc-vault.test.ts) passes end-to-end
  • UTXO selection and PSBT construction verified
  • Per-input signature generation and verification
  • Transaction broadcast and confirmation on regtest
  • MPC monitoring and bidirectional result reporting
  • Deposit claim and balance tracking in vault

Test environment:

  • Bitcoin Core regtest (Docker)
  • Substrate node with btc-vault, build-btc-tx, and signet pallets
  • Mock MPC server (substrate-new branch)
  • Test demonstrates: fund address → build PSBT → sign → broadcast → confirm → claim

Checklist:

  • I have updated the documentation if necessary.
  • I have added tests to cover my changes, regression test if fixing an issue.
  • This is a breaking change.

@esaminu esaminu changed the title Btc vault pallet feat: Btc vault pallet Dec 3, 2025
@iamyxsh iamyxsh self-assigned this Dec 19, 2025
import { ec as EC } from "elliptic";

export class KeyDerivation {
private static readonly EPSILON_PREFIX = "sig.network v1.0.0 epsilon derivation";
Copy link

Choose a reason for hiding this comment

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

in the tests we are using key_version = 1, then this place should be sig.network v2.0.0 epsilon derivation

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.

4 participants