sigil-economics · escrow
Source declarations, signatures and documentation for escrow.
Source: sigil/node/sigil-economics/src/escrow.rs. SHA-256: e933bb2c512391ce8f712f08c0f5303bc6c535626f4a820ea6f392785a7f0ac8.
This reference follows declared source modules, retains conditional attributes, and includes public declarations and implementation methods. Private-module re-exports and trait resolution require the compiler; this is a source reference, not a claim that every listed item is a root import. Function bodies and constant values are omitted.
Module condition:
#[cfg(feature = "compute")]escrow::EscrowAccount
An escrow account for an organization's compute spending.
Funds flow: funded -> reserved -> spent. Un-used reservations can be
refunded back to the free balance.
#[cfg(feature = "compute")]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct EscrowAccount {
/// OAS DID of the organization that owns this escrow.
pub org_did: String,
/// Total micro-MINT deposited into this escrow (lifetime).
pub total_funded: u64,
/// micro-MINT currently reserved for active jobs.
pub total_reserved: u64,
/// micro-MINT already settled (paid to providers).
pub total_spent: u64,
/// Per-agent maximum budget (agent_did -> max micro-MINT).
pub per_agent_budgets: HashMap<String, u64>,
/// Reservations by job ID.
#[serde(default)]
pub reservations: HashMap<String, u64>
}Source line: 17.
escrow::EscrowAccount::new
Create a new, empty escrow account for the given organization.
#[cfg(feature = "compute")]
pub fn new(org_did: String) -> Self;Source line: 35.
escrow::EscrowAccount::available_balance
Available (unreserved, unspent) balance.
#[cfg(feature = "compute")]
pub fn available_balance(&self) -> u64;Source line: 47.
escrow::fund_escrow
Add funds to the escrow account.
#[cfg(feature = "compute")]
pub fn fund_escrow(account: &mut EscrowAccount, amount: u64) -> Result<(), EconomicsError>;Source line: 55.
escrow::reserve_for_job
Reserve funds for a compute job.
The reserved amount is subtracted from the available balance but not yet spent. It is held until the job settles or is refunded.
#[cfg(feature = "compute")]
pub fn reserve_for_job(
account: &mut EscrowAccount,
job_id: String,
amount: u64,
) -> Result<(), EconomicsError>;Source line: 72.
escrow::settle_job
Settle a completed job, debiting the actual cost from the reservation.
If actual_cost < reserved, the surplus is returned to the free balance
(by reducing total_reserved). total_spent increases by actual_cost.
#[cfg(feature = "compute")]
pub fn settle_job(
account: &mut EscrowAccount,
job_id: &str,
actual_cost: u64,
) -> Result<(), EconomicsError>;Source line: 101.
escrow::refund_job
Refund a job's reservation back to the free balance.
Used when a job is cancelled before completion.
#[cfg(feature = "compute")]
pub fn refund_job(account: &mut EscrowAccount, job_id: &str) -> Result<(), EconomicsError>;Source line: 133.
escrow::check_agent_budget
Check whether an agent's spending would stay within its budget.
Returns true if the agent's budget allows the given amount, or if no
per-agent budget is set (i.e., unlimited).
#[cfg(feature = "compute")]
pub fn check_agent_budget(account: &EscrowAccount, agent_did: &str, amount: u64) -> bool;Source line: 147.
escrow::PaymentChannelEscrow
A payment channel escrow for Lightning-style off-consensus micropayments.
Both parties fund the channel; updates are signed balance sheets exchanged off-chain. Disputes are resolved via the Tower coordination chain.
#[cfg(feature = "compute")]
#[cfg(feature = "czac")]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PaymentChannelEscrow {
/// Unique channel identifier.
pub channel_id: String,
/// OAS DID of the channel initiator.
pub party_a_did: String,
/// OAS DID of the channel counterparty.
pub party_b_did: String,
/// micro-MINT funded by party A.
pub party_a_deposit: u64,
/// micro-MINT funded by party B.
pub party_b_deposit: u64,
/// Current balance for party A (per latest signed state).
pub balance_a: u64,
/// Current balance for party B (per latest signed state).
pub balance_b: u64,
/// Monotonically increasing sequence number for the latest signed state.
pub sequence: u64,
/// Block height at which the channel was opened.
pub opened_at_height: u64,
/// Block height at which a dispute was filed (if any).
pub dispute_height: Option<u64>,
/// Channel status.
pub status: PaymentChannelStatus
}Source line: 164.
escrow::PaymentChannelStatus
Status of a CZAC payment channel.
#[cfg(feature = "compute")]
#[cfg(feature = "czac")]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum PaymentChannelStatus {
/// Channel is open and accepting off-chain balance updates.
Open,
/// A unilateral close has been initiated; in dispute window.
Disputed,
/// Channel is cooperatively or unilaterally closed and settled.
Settled,
}Source line: 192.
escrow::PaymentChannelEscrow::new
Create a new payment channel escrow.
#[cfg(feature = "compute")]
#[cfg(feature = "czac")]
pub fn new(
channel_id: String,
party_a_did: String,
party_b_did: String,
party_a_deposit: u64,
party_b_deposit: u64,
opened_at_height: u64,
) -> Self;Source line: 204.
escrow::PaymentChannelEscrow::total_capacity
Total channel capacity.
#[cfg(feature = "compute")]
#[cfg(feature = "czac")]
pub fn total_capacity(&self) -> u64;Source line: 228.
escrow::PaymentChannelEscrow::update_balance
Apply a signed balance update. The balances must sum to total capacity.
#[cfg(feature = "compute")]
#[cfg(feature = "czac")]
pub fn update_balance(
&mut self,
balance_a: u64,
balance_b: u64,
sequence: u64,
) -> Result<(), EconomicsError>;Source line: 233.
escrow::PaymentChannelEscrow::cooperative_close
Cooperatively close the channel. Returns (party_a_payout, party_b_payout).
#[cfg(feature = "compute")]
#[cfg(feature = "czac")]
pub fn cooperative_close(&mut self) -> Result<(u64, u64), EconomicsError>;Source line: 263.
escrow::PaymentChannelEscrow::initiate_dispute
Initiate a unilateral dispute at the given block height.
#[cfg(feature = "compute")]
#[cfg(feature = "czac")]
pub fn initiate_dispute(&mut self, height: u64) -> Result<(), EconomicsError>;Source line: 272.
escrow::LandAuctionEscrow
Escrow for a Nova land auction bid.
#[cfg(feature = "compute")]
#[cfg(feature = "nova")]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct LandAuctionEscrow {
/// Parcel ID being auctioned.
pub parcel_id: String,
/// OAS DID of the highest bidder.
pub bidder_did: String,
/// Current highest bid in micro-MINT.
pub bid_amount: u64,
/// Block height at which the auction started.
pub auction_start_height: u64,
/// Block height at which the auction ends.
pub auction_end_height: u64,
/// Whether the auction has been finalized.
pub finalized: bool
}Source line: 289.
escrow::LandAuctionEscrow::new
Create a new land auction escrow with the first bid.
#[cfg(feature = "compute")]
#[cfg(feature = "nova")]
pub fn new(
parcel_id: String,
bidder_did: String,
bid_amount: u64,
auction_start_height: u64,
auction_duration_blocks: u64,
) -> Self;Source line: 307.
escrow::LandAuctionEscrow::place_bid
Place a higher bid. Returns the previous bidder DID and amount for refund.
#[cfg(feature = "compute")]
#[cfg(feature = "nova")]
pub fn place_bid(
&mut self,
bidder_did: String,
amount: u64,
current_height: u64,
) -> Result<(String, u64), EconomicsError>;Source line: 325.
escrow::LandAuctionEscrow::finalize
Finalize the auction. Returns the winner DID and winning bid.
#[cfg(feature = "compute")]
#[cfg(feature = "nova")]
pub fn finalize(&mut self, current_height: u64) -> Result<(String, u64), EconomicsError>;Source line: 353.
escrow::RentEscrow
Escrow for recurring Nova property rent payments via CZAC payment channels.
#[cfg(feature = "compute")]
#[cfg(feature = "nova")]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct RentEscrow {
/// Parcel ID being rented.
pub parcel_id: String,
/// OAS DID of the tenant.
pub tenant_did: String,
/// OAS DID of the landlord (parcel owner).
pub landlord_did: String,
/// Rent amount per epoch in micro-MINT.
pub rent_per_epoch: u64,
/// Total micro-MINT deposited by the tenant.
pub total_deposited: u64,
/// Total micro-MINT paid to the landlord so far.
pub total_paid: u64,
/// Epoch at which the lease started.
pub lease_start_epoch: u64,
/// Number of epochs the lease is valid for.
pub lease_duration_epochs: u64
}Source line: 372.
escrow::RentEscrow::new
Create a new rent escrow.
#[cfg(feature = "compute")]
#[cfg(feature = "nova")]
pub fn new(
parcel_id: String,
tenant_did: String,
landlord_did: String,
rent_per_epoch: u64,
deposit: u64,
lease_start_epoch: u64,
lease_duration_epochs: u64,
) -> Self;Source line: 394.
escrow::RentEscrow::remaining_deposit
Remaining deposit available to cover rent.
#[cfg(feature = "compute")]
#[cfg(feature = "nova")]
pub fn remaining_deposit(&self) -> u64;Source line: 416.
escrow::RentEscrow::pay_epoch
Process rent payment for one epoch. Returns the amount paid.
#[cfg(feature = "compute")]
#[cfg(feature = "nova")]
pub fn pay_epoch(&mut self) -> Result<u64, EconomicsError>;Source line: 421.
escrow::RentEscrow::is_expired
Check if the lease has expired at the given epoch.
#[cfg(feature = "compute")]
#[cfg(feature = "nova")]
pub fn is_expired(&self, current_epoch: u64) -> bool;Source line: 437.