Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

multisig-zec

2-of-3 multisig Zcash transparent wallet (t3… addresses), built on @bitgo/utxo-lib.

Three people each hold one key. Any two of them can move the funds; any single key alone cannot. A t3 address is a transparent P2SH wrapping the redeem script OP_2 <pk1> <pk2> <pk3> OP_3 OP_CHECKMULTISIG. This CLI derives the address, watches it through a free block explorer (Blockbook — no API key), and sweeps the funds out with a 2-of-3 signature.

Transparent multisig only. No shielded (z) support. Test with small amounts first.

Install

npm install

Commands run with tsx (no build needed). To compile to dist/: npm run build.

Full flow

1. Each of the 3 people makes a key

Every participant runs this on their own machine (offline is ideal):

npm run keygen

It prints a pubkey and a WIF.

  • Share the pubkey with the coordinator.
  • Keep the WIF secret. It is the private key. Never send it to anyone.

2. Coordinator writes the config

Collect the 3 pubkeys, then copy config.example.jsonconfig.json and fill in:

field meaning
pubkeys the 3 compressed pubkeys, in a fixed order — the order defines the address.
withdrawTo destination transparent address (t1…/t3…) for withdrawals.
signerWIFs any 2 of the 3 WIF private keys. Only needed to withdraw.
explorerUrl optional Blockbook URL (default https://blockbook.zec.zelcore.io; or EXPLORER_URL env).
feeZat optional fee override in zatoshis (default: ZIP-317 conventional fee).

Persist the pubkey order (or the printed redeemScript). Funds are unspendable without it.

config.json, secrets.json, .env are git-ignored — never commit real keys.

3. Get the address & deposit

npm run address -- config.json      # prints your t3… address

Send ZEC to that t3 address from any wallet — an ordinary transparent send. This tool never needs the depositing wallet's key.

4. Watch it arrive

npm run balance -- config.json      # confirmed / unconfirmed balance + UTXO count
npm run utxos   -- config.json      # list the confirmed UTXOs

Wait for confirmations before withdrawing.

5. Withdraw (sweep everything → withdrawTo)

Two steps for safety. First build + sign + review — this does not send:

npm run withdraw -- config.json

Prints from/to, amounts, fee, txid, a decoded summary, and the raw hex. Review it. Then send:

npm run withdraw -- config.json --broadcast

Confirm with npm run balance or the explorer. To push an already-reviewed hex separately:

npm run broadcast -- <hex> config.json

How it works

piece file what it does
Address src/address.ts deriveMultisig2of3 → P2SH scriptPubKey → t3 base58check.
Explorer src/explorer.ts Blockbook v2 REST (/utxo, /address, /tx, /sendtx). Free, no key.
Withdraw src/withdraw.ts Sweeps all confirmed UTXOs into one output, minus fee.
Sign src/spend.ts Builds a v5 tx, prevOutScriptType: 'p2sh-p2ms', signs with 2 of 3 keys.
Sighash src/zip244.ts ZIP-244 transparent sighash (v5 tx). Verified against reference test vectors.
Fee src/fee.ts ZIP-317 conventional fee (deterministic).

Run the sighash test vectors: npm run build && node test/zip244.vectors.js.

Notes / safety

  • Order matters. Pubkey order fixes the redeemScript and the address. Persist it.
  • Network upgrades. Tx version 5 is pinned to the mainnet upgrade active in the pinned @bitgo/utxo-lib. Keep the dependency current across future upgrades.
  • Broadcast errors from the node are surfaced verbatim. A script-verify error usually means wrong pubkey order / redeemScript or a fork mismatch. Rejected for low fee → raise feeZat.
  • Test small first. Testnet/regtest P2SH addresses start with t2 (not t3) and need a testnet explorer URL. Decode any hex with zcash-cli decoderawtransaction <hex> if you have a node.

License

MIT

About

2-of-3 multisig Zcash transparent (t3) wallet: address derivation, explorer watching, and NU5 v5 spend signing (ZIP-244) via @bitgo/utxo-lib

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages