Skip to main content

Crate ai_agent_bitcoin_escrow

Crate ai_agent_bitcoin_escrow 

Source
Expand description

§AI Agent Bitcoin Escrow Library

A Rust library that enables AI agents to create, manage, and execute Bitcoin escrow contracts using multisig. The library supports condition-based fund releases triggered by AI agent decisions or external oracles, with full audit logging for all actions.

§Features

  • Multisig Support: 2-of-3 (or n-of-m) multisig escrow contracts
  • Condition-Based Release: AI decisions, oracle triggers, timelocks
  • Audit Logging: Immutable, chained audit log for all operations
  • Oracle Integration: HTTP-based oracle support for real-world data
  • AI Agent Autonomy: Designed for autonomous AI agent economic activities

§Quick Start

use ai_agent_bitcoin_escrow::{
    escrow::{EscrowBuilder, EscrowManager},
    multisig::create_participant,
    conditions::ConditionBuilder,
    audit::AuditLogger,
    types::{EscrowConfig, EscrowRole},
};
use bitcoin::Network;

// Create an escrow manager with audit logging
let audit = AuditLogger::new("/tmp/audit.log").unwrap();
let mut manager = EscrowManager::new(audit);

// Create participants
let (buyer, _buyer_key) = create_participant(
    EscrowRole::Buyer, 
    "buyer-1".to_string(), 
    Network::Testnet
).unwrap();
let (seller, _seller_key) = create_participant(
    EscrowRole::Seller, 
    "seller-1".to_string(), 
    Network::Testnet
).unwrap();
let (arbiter, _arbiter_key) = create_participant(
    EscrowRole::Arbiter, 
    "arbiter-1".to_string(), 
    Network::Testnet
).unwrap();

// Build an escrow contract
let contract = EscrowBuilder::new()
    .network(Network::Testnet)
    .threshold(2)
    .participant(buyer)
    .participant(seller)
    .participant(arbiter)
    .description("AI agent bounty payment")
    .build()
    .unwrap();

println!("Escrow contract created: {}", contract.id);

§Architecture

The library is organized into several modules:

  • escrow - Main escrow contract management
  • multisig - Multisignature wallet operations
  • conditions - Release condition evaluation
  • audit - Immutable audit logging
  • oracle - External oracle integration
  • types - Common types and structures
  • error - Error handling

§AI Agent Integration

This library is designed to be used by AI agents for autonomous economic activities. Key features for AI agent autonomy:

  • Self-Custody: AI agents control their own keys
  • Verifiable Actions: All operations are logged in an immutable audit log
  • Conditional Releases: Funds can be released based on AI decisions
  • Oracle Integration: Real-world data can trigger releases

§Security Considerations

  • All private keys should be securely stored
  • The audit log provides a verifiable record of all actions
  • Multisig ensures no single party can unilaterally control funds
  • Timelocks provide a safety mechanism for dispute resolution

§License

Dual-licensed under MIT or Apache-2.0.

Re-exports§

pub use error::EscrowError;
pub use error::Result;
pub use escrow::EscrowBuilder;
pub use escrow::EscrowContract;
pub use escrow::EscrowManager;
pub use types::AgentId;
pub use types::ConditionResult;
pub use types::EscrowConfig;
pub use types::EscrowId;
pub use types::EscrowParticipant;
pub use types::EscrowRole;
pub use types::EscrowStatus;
pub use types::OracleId;
pub use types::ReleaseCondition;

Modules§

audit
Audit logging for escrow operations.
conditions
Release conditions for escrow contracts.
error
Error types for the AI Agent Bitcoin Escrow Library.
escrow
Escrow contract management for AI agents.
multisig
Multisig operations for escrow contracts.
oracle
External oracle integration for escrow conditions.
types
Common types for the AI Agent Bitcoin Escrow Library.

Constants§

NAME
Library name.
VERSION
Library version.