Skip to content

Core Concepts

Network free construction

multisig is network free. It does not connect to Bitcoin, EVM, or Monero nodes. It builds and verifies artifacts locally. The chain and the signers remain the authority.

The library does not:

  • Generate or store private keys
  • Accept seed phrases, wallet files, or private view keys
  • Sign transactions or approval payloads
  • Scan wallets
  • Broadcast transactions
  • Prove that funding or confirmation evidence is true

Roles

There are three roles:

  • Buyer: the party that funds the escrow and receives a refund when the refund path applies.
  • Seller: the party that receives the release payout.
  • Arbiter: the party that can satisfy a dispute rule when the terms require it.

A buyer and seller are always required. An arbiter is required when the dispute policy enables an arbiter requirement. Monero requires one signer for each role.

Signers and keys

A Signer binds a SignerId, a Role, and a chain specific verification key.

  • Bitcoin uses BtcSigner, built from an extended public key, fingerprint, origin path, and derive path.
  • EVM uses EvmAddress, the Safe owner address.
  • Monero uses MoneroSigner, built from a public spend key and an Ed25519 approval key.

The library uses public keys and addresses only. A Signer is not a wallet and does not authorize signing.

Terms

Terms define the agreement:

  • Escrow identifier
  • Chain and asset
  • Amount
  • Signers and threshold
  • Release, refund, and dispute policies
  • Buyer and seller payouts
  • Funding and settlement deadlines
  • Confirmation policy
  • Fee policy
  • Optional timelock or metadata

EscrowTerms.create fills policy defaults and validates the complete agreement. Terms are immutable and canonical. terms_hash is a deterministic hash of the canonical terms.

Monero uses MoneroTerms, which is converted into core escrow terms internally. MoneroEscrow requires the original MoneroTerms on every load so the Monero specific policy can be revalidated.

Terms hash is not authentication

A stored record contains its own terms and its own terms_hash. The hash proves consistency, not authenticity. Anyone who can rewrite the store can rewrite both the terms and the hash.

Keep a trusted terms hash, or a signed terms manifest, outside the mutable store. Pass it to load with trusted_terms_hash or check it with require_trusted_terms. Read Terms and Evidence.

Escrow record and state machine

An escrow record contains the terms, current status, funding record, proposal, approvals, settlement, and revision.

The main statuses are:

  • draft
  • funded
  • disputed
  • release_pending
  • release_ready
  • release_broadcast
  • released
  • refund_pending
  • refund_ready
  • refund_broadcast
  • refunded
  • expired
  • cancelled

Transitions are checked against the current state, actor, proposal, and policies. Invalid transitions raise TransitionError or StateError.

Funding target

A funding target is the exact destination and amount that the escrow expects.

  • Bitcoin returns address, script pubkey, descriptor, amount, confirmation requirement, and overfunding tolerance.
  • EVM returns the Safe address, chain ID, asset, amount, and confirmation requirement.
  • Monero returns the multisig address, amount, confirmation requirement, and tolerance.

A funding target is not proof of funding. It is the expected shape that funding evidence must match.

Proposal

A proposal is a specific release or refund payload.

It binds:

  • Escrow ID
  • Terms hash
  • Action
  • Settlement path
  • Recipient and amount
  • Fee
  • Payload hash
  • Expected transaction ID when available
  • Required approvers and threshold

The payload hash covers the exact PSBT, Safe transaction digest, or Monero transaction set hash. Approvals are checked against that payload, not against a human readable summary.

Approval tokens

Approval tokens are internal state machine records. They bind the escrow ID, terms hash, proposal ID, signer, payload hash, signature hash, and chain evidence where applicable.

Tokens are not transferable bearer instruments. They are internal evidence that the state machine accepted a specific approval. Do not serialize them into a public API or treat them as a substitute for the original signed payload.

Settlement

The final settlement artifact depends on the chain.

  • Bitcoin: final raw transaction and transaction ID.
  • EVM: Safe execTransaction calldata, with the Safe address as the outer transaction target.
  • Monero: signed transaction set, transaction ID, key images, outputs, fee, and unlock time.

finalize verifies the artifact against the proposal and approval tokens. It does not broadcast. Broadcast evidence is verified separately with mark_broadcast.

Evidence

All chain evidence is caller supplied. The library verifies structure, signatures, payload binding, and declared freshness. It cannot query a chain.

Use a trusted node, independent verifier, or chain proof for:

  • Funding transaction inclusion
  • Confirmation depth
  • Chain tip height and timestamp
  • Mempool and broadcast status
  • Safe execution status
  • Monero transaction inclusion and key image status

EVM funding and Monero funding require an EvidenceContext. The context contains now and a ChainTip. Monero settlement requires a fresh MoneroRingContext with a recent tip. A future tip or a tip older than one hour is rejected.

Store and concurrency

The store contract has two operations:

record = store.load(escrow_id)
store.save(record, expected_revision)

Saves use optimistic revision checks. A concurrent writer can receive StoreConflictError. The library fails closed and does not merge state.

Use one writer per escrow, a per escrow lock or queue, or a retry loop after reloading the latest record. Do not share a mutable facade across threads without external serialization.

MemoryStore is for development and tests. It is not tamper evident and is not durable.

Errors

All library errors derive from EscrowError.

Common categories:

  • ValidationError: malformed input or terms
  • TermsError: terms policy or authenticity failure
  • FundingError: funding evidence mismatch
  • SignatureError: approval or signature failure
  • VerificationError: payload or proof verification failure
  • FreshnessError: stale or future context
  • StateError and TransitionError: invalid state transition
  • SettlementError: final settlement mismatch
  • StoreConflictError: optimistic concurrency conflict
  • DependencyError: missing optional dependency or external verifier

Catch the narrowest error you can handle. Do not convert a verification failure into a successful state transition.

Next