VTXO Transaction Flow
After a vault is funded, transfers between vault UTXOs are expressed as PSBTs spending the cooperative leaf, then wrapped in a Tachi wire envelope and submitted to the Tachi mempool.
Pipeline
1. Build
import { buildVtxoPsbt } from "@tachibtc/taurus-vault-core";
const built = buildVtxoPsbt({
vault,
inputs: [{ txid, vout, valueSats, scriptPubKey: vault.p2tr.output.toString("hex") }],
outputs: [
{ address: receiverAddr, valueSats: 40_00000000n },
{ address: vault.p2tr.address, valueSats: 59_00000000n }, // change
],
feeSats: 1_00000000n,
});
Creates a PSBT with the vault's NUMS internal key and cooperative tap leaf attached to each input.
2. Verify
import { verifyVtxoPsbt } from "@tachibtc/taurus-vault-core";
verifyVtxoPsbt(built.psbt, vault, { maxFeeSats: 2_00000000n });
Re-checks structure, witnessUtxo.script, internal key, leaf scripts, and enforces a fee ceiling.
Always pass maxFeeSats to prevent a malformed PSBT from silently draining value to miners. If you explicitly want no cap, pass allowUnboundedFee: true.
3. Sign
import { signVtxoPsbtAsUser } from "@tachibtc/taurus-vault-core";
await signVtxoPsbtAsUser(built.psbt, userSigner, vault, { maxFeeSats: 2_00000000n });
Attaches the user's Schnorr tapScriptSig. The 5-of-7 KDHT quorum contributes their signatures out-of-band.
4. Finalize
import { finalizeVtxoPsbt } from "@tachibtc/taurus-vault-core";
finalizeVtxoPsbt(built.psbt, vault, { maxFeeSats: 2_00000000n });
Assembles the witness from user + node signatures and the cooperative leaf control block.
5. Wrap in Tachi Envelope
import { buildTachiTxTransfer, signTachiTx } from "@tachibtc/taurus-vault-core";
const draft = buildTachiTxTransfer({
vault,
inputs: built.inputs,
outputs: built.outputs,
feeSats: 1_00000000n,
nonce: 0n,
psbt: built.psbt,
});
const tachi = await signTachiTx(draft, userSigner);
6. Broadcast
import { broadcastTachiTx, waitForVtxoCommit } from "@tachibtc/taurus-vault-core";
await broadcastTachiTx(tachi, {
url: "https://rpc-regtest.tachibtc.com/tachi_txBroadcastSync",
});
// Optionally wait for inclusion
await waitForVtxoCommit(/* ... */);
In production, always use https://. For local regtest, pass { allowInsecureHttp: true } to opt into plaintext HTTP — the library refuses to leak Schnorr signatures in the clear by default.
Deposits
For initial deposits (P2WPKH → vault), use buildTachiTxDeposit instead of buildTachiTxTransfer:
import { buildTachiTxDeposit, vtxoIdFromDeposit } from "@tachibtc/taurus-vault-core";
const depositTx = buildTachiTxDeposit({ vault, /* ... */ });
const vtxoId = vtxoIdFromDeposit(depositTx);
The 32-byte vtxoId is derived from the deposit envelope and used as input for subsequent transfers.
Ledger Transfers
vault-core 0.4.0. buildTachiTxLedgerTransfer moves sats between Tachi accounts with no Bitcoin-layer spend and no PSBT. It pays amountSats to to and returns exact change to the sender, so inputs = amount + fee + change. The daemon burns any excess, so the change must be right.
import { buildTachiTxLedgerTransfer, signTachiTx, broadcastTachiTx } from "@tachibtc/taurus-vault-core";
const draft = buildTachiTxLedgerTransfer({
senderXOnly: myXOnly,
inputs: [{ vtxoId, valueSats: 5_000n }], // amounts from /tachi_addressVtxos
to: recipientXOnly,
amountSats: 1_000n,
feeSats: 1n, // the daemon's minimum
nonce,
});
const signed = await signTachiTx(draft, userSigner);
await broadcastTachiTx(signed, { url: `${DAEMON_URL}/tachi_txBroadcastSync` });
The envelope's inputs carry no amounts. The daemon spends each VTXO's real ledger amount, and valueSats only sizes the change. If valueSats is too low, the change is too small and the difference is burned. Paying yourself throws.
Locking VTXOs into a Vault
vault-core 0.4.0. Lock consent is active on regtest from block 1,901,400 and on signet from 1,971,100.
buildTachiTxLockForVault locks VTXOs to a vault. Its PSBT pays the vault address, which is how the daemon learns the target. vaultPayload names the vault id. Anyone but the vault owner also needs the owner's consent signature. Without it, anyone could lock dust into someone else's vault and block its cooperative refund and transfer.
import {
buildTachiTxLockForVault,
lockConsentSigHash,
withLockConsent,
signTachiTx,
} from "@tachibtc/taurus-vault-core";
let draft = buildTachiTxLockForVault({
senderXOnly: myXOnly,
vaultId: Buffer.from(vault.vault_id, "hex"), // from /tachi_vault
vaultAddress: vault.address,
network: "regtest",
inputs: [{ vtxoId, valueSats: 5_000n }], // txid/vout optional for ledger-native VTXOs
feeSats: 1n,
nonce,
});
// Locking into someone else's vault: the owner signs lockConsentSigHash with their vault user key.
const ownerSig = await ownerSigner.signSchnorr(lockConsentSigHash(draft));
draft = withLockConsent(draft, ownerSig, ownerPubKey); // ownerPubKey optional: verifies ownerSig here
const signed = await signTachiTx(draft, userSigner); // the sender signs last
- Locking into your own vault needs no consent. Build and sign.
lockConsentSigHash(tx)is the lock's sighash withvaultPayloadcut to the vault id. It commits to the sender, inputs, fee, nonce and vault, so a consent can't be replayed onto another lock.withLockConsentthrows if the tx is already signed. Apply consent beforesignTachiTx.- A lock moves no value. The mirror output carries the full input total, and the fee only has to be at most the inputs.
- Before lock consent is active, the daemon rejects any lock that carries a payload.
Decoding a Transaction
decodeTachiTx(bytes) is the exact inverse of encodeTachiTx: re-encoding gives the same bytes, and non-canonical input throws. Use it to show a signer what a tx really does instead of trusting a summary sent alongside it. It handles transfer, deposit, withdraw, lock, vault open, vault close and the payment request types. EVM txs are not supported.
summarizeTachiTxValue(tx, inputTotalSats?) splits the outputs into payments and change back to the signer. Fetch inputTotalSats yourself from /tachi_vtxo for each input, never from whoever built the tx. A non-zero burnedSats should block approval.
import { decodeTachiTx, summarizeTachiTxValue } from "@tachibtc/taurus-vault-core";
const tx = decodeTachiTx(Buffer.from(hex, "hex"));
const { payments, changeSats, feeSats, burnedSats } = summarizeTachiTxValue(tx, inputTotal);
if (burnedSats !== 0n) throw new Error("tx burns value");
Tachi Transaction Helpers
| Function | Description |
|---|---|
buildTachiTxDeposit | Build a deposit envelope (P2WPKH → vault) |
buildTachiTxTransfer | Build a transfer envelope (vault → vault) |
encodeTachiTx | Encode a TachiTx to bytes |
encodeTachiTxBase64 | Encode a TachiTx to base64 |
signTachiTx | BIP-340 sign over tachiTxSigHash |
tachiTxSigHash | Compute the sighash for a TachiTx |
computeVtxoId | Compute a vtxoId from inputs |
vtxoIdFromDeposit | Derive vtxoId from a deposit envelope |
xOnlyFromAddress | Extract x-only pubkey from a P2TR address |
buildTachiTxLedgerTransfer | Ledger-only transfer with exact change (0.4.0) |
buildTachiTxLockForVault | Lock VTXOs into a vault (0.4.0) |
lockConsentSigHash / withLockConsent | Owner consent for someone else's lock (0.4.0) |
buildTachiTxVaultClose | Close a vault after its L1 coins move. See Closing a vault (0.4.0) |
buildTachiTxPaymentRequest / Pay / Cancel | On-chain payment requests. See Payment Requests (0.4.0) |
decodeTachiTx | Inverse of encodeTachiTx (0.4.0) |
summarizeTachiTxValue | Payments, change and burned sats of a decoded tx |
tachiTxHash | The hash the daemon names a signed tx by (0.4.0) |