Skip to main content

Module json

Module json 

Source
Expand description

JSON structs JSON conversion utilities for DLC contracts

This module provides functionality to convert Rust-DLC contract types into JSON representations, primarily for console output and API responses. The conversion is currently one-way (to JSON only) as the underlying Rust-DLC types don’t implement Serialize/Deserialize.

§Current Usage

  • Command line display of contract states
  • API responses for contract information
  • Debug output and logging

§TODO: Future Improvements

  • Create proper serializable/deserializable types that mirror Rust-DLC contracts
  • Implement bidirectional conversion between JSON and contract types
  • Add validation for contract state transitions
  • Support custom serialization formats
  • Add schema validation for JSON output

Structs§

OracleEvent
Represents an oracle event for JSON serialization. Used to track event IDs, oracle public keys, and event types.

Functions§

contract_to_value
Main conversion function that handles all contract states. Routes to the appropriate conversion function based on the contract’s state.
offered_contract_to_value
Converts an offered contract to a JSON value with basic contract information. Includes contract ID, party information, collateral, and associated oracle events.
preclosed_contract_to_value
Converts a pre-closed contract to a JSON value, including attestations and signed CET (Contract Execution Transaction) information.
signed_contract_to_value
Converts a signed contract to a JSON value, including funding transaction and contract state information.