# Sanario: multisig vaults for company Bitcoin & Ethereum [![License: MIT](https://img.shields.io/badge/license-MIT-34d399.svg)](LICENSE) **Open source.** Sanario is MIT-licensed so anyone can audit the code that guards their funds. Security reports: see [SECURITY.md](SECURITY.md). Non-custodial M-of-N treasury vaults. Sanario stores only public data (xpubs, addresses, unsigned/partially-signed transactions) in the browser; private keys stay on the signers' devices. There is no backend: the app talks directly to mempool.space (Bitcoin) and public RPCs (EVM). ## Run ```bash npm install npm run dev # http://localhost:3000 npm run build && npm start # production npm test # 18 tests: BTC vaults (all script types) + contract in an in-process EVM npm run compile:contracts # recompile contracts/SanarioMultisig.sol → lib/eth/artifact.json ``` Requires TypeScript 5.x (Next 15 cannot load TypeScript 7). ## Layout | Path | What | |---|---| | `app/page.tsx` | Landing page (how multisig secures funds) | | `app/app/btc/*` | Bitcoin vault: create/import, receive, send (PSBT), sign, broadcast, backup | | `app/app/eth/*` | Ethereum vault: deploy/add, proposals, signing link page (`/app/eth/sign#p=…`) | | `lib/btc/core.ts` | Keys, BIP48 paths, address derivation, descriptors (BIP380), config files | | `lib/btc/psbt.ts` | Coin selection, PSBT build / combine / finalize | | `lib/btc/import.ts` | Import Coldcard/Keystone/Jade JSON, `[fp/path]xpub`, descriptors, config files | | `lib/btc/esplora.ts` | Balance scan (gap limit 20), fees, broadcast | | `lib/hw/ledger.ts`, `lib/hw/trezor.ts` | Hardware wallets (BTC + ETH) | | `lib/eth/wallet.ts` | EIP-6963 wallets, deploy, EIP-712 proposals, execute | | `contracts/SanarioMultisig.sol` | The Ethereum multisig contract | ## Bitcoin script types | Type | Descriptor | Path | |---|---|---| | Taproot | `tr(H, sortedmulti_a(M,…))` (H = BIP341 NUMS point) | m/48'/c'/0'/3' | | Native SegWit | `wsh(sortedmulti(M,…))` | m/48'/c'/0'/2' | | Nested SegWit | `sh(wsh(sortedmulti(M,…)))` | m/48'/c'/0'/1' | | Legacy | `sh(sortedmulti(M,…))` | m/45' | ## Signer support | | Add key | Sign | |---|---|---| | Ledger (WebHID, Chrome/Edge/Brave) | ✓ | P2WSH, P2SH-P2WSH, P2SH (BIP-388 wallet registration); ETH EIP-712 | | Trezor (Trezor Connect) | ✓ | P2WSH, P2SH-P2WSH, P2SH; ETH EIP-712 | | Coldcard, Keystone, Passport, Jade, Sparrow, Electrum, Nunchuk, Specter, Core | key file / paste | PSBT file or base64 round-trip | | MetaMask, Rabby, Coinbase, Trust, OKX, Brave… | connected account | EIP-712 or on-chain `approveHash` | Taproot multisig: Ledger and Trezor cannot sign it yet (Ledger's BIP-388 has no fixed NUMS internal key). Sign Taproot vaults with a taproot-capable coordinator, e.g. Bitcoin Core. ## Before production - **Get SanarioMultisig independently audited** before it holds significant funds. The app shows this warning on the deploy screen. - Test Ledger and Trezor signing on testnet / Sepolia with real devices. The PSBT and contract logic is unit-tested, but the device drivers could not be exercised without hardware. - Set `NEXT_PUBLIC_TREZOR_MANIFEST_EMAIL` to a real contact address (Trezor Connect requires one). - Serve over HTTPS (WebHID and clipboard need a secure context). - Consider your own Esplora/mempool instance and RPC endpoints, both for privacy and to avoid public rate limits. ## Changing signers or threshold (e.g. 3-of-5 → 4-of-5) - **Ethereum:** vault page → *Signers & threshold*. Remove or add owners and pick the new M; Sanario plans the owner-management calls (`replaceOwner` / `addOwner` / `removeOwner` / `changeThreshold`, see `lib/eth/signers.ts`) and creates them as ordinary proposals. Each needs the quorum in force when it executes. Same address, no fund move. - **Bitcoin:** vault page → *Settings* → *Change signers or threshold*. M-of-N is part of every address, so this creates a new vault prefilled from the old one; the old vault then offers a one-click proposal moving its whole balance to the new vault (signed by the old quorum). ## Open source and verifying a deployment - License: [MIT](LICENSE). Security reports: [SECURITY.md](SECURITY.md). - `npm run build` first runs `scripts/pack-source.mjs` (the `prebuild` step), which publishes the exact source of the build at **`/source`**: a deterministic `sanario-source.tar.gz`, a `SHA256SUMS` list of every file, and a plain-text copy of each file for reading in the browser. - Check a checkout against a live site: `curl -s https:///source/SHA256SUMS | sha256sum -c` or `npm run verify-source -- https://`. - Rebuild the contract: `npm run compile:contracts` must reproduce `lib/eth/artifact.json` byte for byte. - Set `NEXT_PUBLIC_SOURCE_REPO=https://github.com//sanario` at build time to show a GitHub link on `/source`.