Skip to content

Quick Start

This page shows the lifecycle of a Bitcoin escrow. EVM and Monero follow the same pattern with chain specific evidence and approval types.

The example assumes that terms, evidence, and utxo were built by your application. See Bitcoin for terms construction and funding evidence details.

Bitcoin release flow

from multisig_escrow import BitcoinEscrow, BroadcastEvidence, MemoryStore, SignerId
from multisig_escrow.bitcoin import BtcReleaseParams, PsbtApproval

store = MemoryStore()
escrow = BitcoinEscrow.create(terms, store=store)

target = escrow.funding_target()
print(target.address)
print(target.amount)
print(target.confirmations)

escrow.fund(evidence)
print(escrow.status)

proposal = escrow.propose_release(
    SignerId("buyer"),
    BtcReleaseParams((utxo,), 1500),
)
print(proposal.summary())

first = wallet_one.sign_psbt(proposal.plan.psbt_base64)
second = wallet_two.sign_psbt(proposal.plan.psbt_base64)

escrow.approve(PsbtApproval(first))
escrow.approve(PsbtApproval(second))
print(escrow.status)

final = escrow.finalize()
assert final.txid is not None
assert final.raw_tx is not None

escrow.mark_broadcast(
    BroadcastEvidence(final.txid, final.payload_hash, final.raw_tx)
)
escrow.confirm(final.txid, confirmations=1)
print(escrow.status)

Expected status progression:

draft
funded
release_pending
release_ready
release_broadcast
released

Each approve call applies the signatures present in the PSBT that belong to allowed signers. The escrow moves to release_ready when the approval policy is satisfied. finalize combines the approved PSBTs and returns the final raw transaction. It does not broadcast anything.

What is external

  • Key generation and custody
  • PSBT signing on a hardware wallet or signer
  • Chain reads for funding, confirmations, and tip freshness
  • Transaction broadcast
  • Address and amount verification on the signing device
  • Payout verification through an independent channel

EVM release flow

EVM funding requires fresh context. The tip must not be in the future and must not be older than one hour.

from multisig_escrow import ChainTip, EvidenceContext, SignerId
from multisig_escrow.evm import EvmReleaseParams, SafeApproval

context = EvidenceContext(
    now=now,
    tip=ChainTip(height, block_hash, tip_time),
)

escrow.fund(evidence, context)
proposal = escrow.propose_release(
    SignerId("buyer"),
    EvmReleaseParams(nonce=7),
)

digest = proposal.plan.signing_hash
signature = owner_key.sign_msg_hash(digest).to_bytes()
escrow.approve(SafeApproval(signature))

final = escrow.finalize()
print(final.outer_to)
print(final.calldata_hex)

The final EVM artifact is Safe execTransaction calldata. Your operator submits it from the Safe owner account. Read EVM for the full flow.

Monero release flow

Monero requires a funding verifier, a settlement verifier, and the native Monero Oxide verifier. Missing verifiers fail closed.

from multisig_escrow import SignerId
from multisig_escrow.monero import MoneroApproval, MoneroEscrow

escrow = MoneroEscrow.create(terms, store=store, clock=clock)
escrow.fund(evidence, context, verifier=funding_verifier)

plan = escrow.propose_release(SignerId("buyer"), release_params)

approval_context = escrow.approval_context(release_params.key_images[0].key_image)
signature = buyer_approval_private_key.sign(approval_context.digest())

escrow.approve(
    MoneroApproval(
        SignerId("buyer"),
        "buyer approval key",
        signature,
        release_params.key_images[0].key_image,
    )
)

token = escrow.verify_settlement(
    signed_tx_set,
    ring,
    verifier=native_verifier,
    settlement_verifier=settlement_verifier,
)
escrow.mark_broadcast(
    token,
    signed_tx_set,
    ring,
    verifier=native_verifier,
    settlement_verifier=settlement_verifier,
)

Monero is experimental. R24 remains Critical. Read Monero and the Operator Checklist before using it.

Store and reload

MemoryStore is for development and tests. For production, implement the Store protocol with durable storage and optimistic revision checks.

from multisig_escrow import BitcoinEscrow

escrow = BitcoinEscrow.load(
    escrow_id,
    store=store,
    clock=clock,
    trusted_terms_hash=trusted_terms_hash,
)

The trusted terms hash must come from outside the store. A loaded record without an external anchor is not trusted for production use.

Next