Skip to main content

Overview

Core Lane provides fundamental data structures for accounts, transactions, and receipts. These types form the foundation of state management and transaction processing.

CoreLaneAccount

Represents a Core Lane account with balance and nonce tracking. Location: src/account.rs:8

Structure

pub struct CoreLaneAccount {
    pub balance: U256,
    pub nonce: U256,
}

Methods

new
fn() -> Self
Creates a new account with zero balance and nonce.
with_balance
fn(balance: U256) -> Self
Creates a new account with the specified balance and zero nonce.Parameters:
  • balance: Initial balance for the account
increment_nonce
fn(&mut self) -> Result<()>
Increments the account nonce by 1. Returns an error if nonce would overflow.
add_balance
fn(&mut self, amount: U256) -> Result<()>
Adds the specified amount to the account balance.Parameters:
  • amount: Amount to add to the balance
Returns: Error if balance would overflow
sub_balance
fn(&mut self, amount: U256) -> Result<()>
Subtracts the specified amount from the account balance.Parameters:
  • amount: Amount to subtract from the balance
Returns: Error if insufficient balance or underflow would occur

Example

use core_lane::CoreLaneAccount;
use alloy_primitives::U256;

let mut account = CoreLaneAccount::new();
account.add_balance(U256::from(1000))?;
account.increment_nonce()?;

assert_eq!(account.balance, U256::from(1000));
assert_eq!(account.nonce, U256::from(1));

TransactionReceipt

Receipt generated after transaction execution. Location: src/state.rs:32

Structure

pub struct TransactionReceipt {
    pub transaction_hash: String,
    pub block_number: u64,
    pub transaction_index: u64,
    pub from: String,
    pub to: Option<String>,
    pub cumulative_gas_used: String,
    pub gas_used: String,
    pub contract_address: Option<String>,
    pub logs: Vec<Log>,
    pub status: String,
    pub effective_gas_price: String,
    pub tx_type: String,
    pub logs_bloom: String,
}

Fields

transaction_hash
String
Hash of the executed transaction
block_number
u64
Block number where transaction was included
from
String
Address that sent the transaction
to
Option<String>
Recipient address (None for contract creation)
status
String
Transaction execution status (“1” for success, “0” for failure)
logs
Vec<Log>
Event logs emitted during execution

Log

Event log emitted during transaction execution. Location: src/state.rs:14

Structure

pub struct Log {
    pub address: String,
    pub topics: Vec<String>,
    pub data: String,
    pub block_number: String,
    pub transaction_hash: String,
    pub transaction_index: String,
    pub block_hash: String,
    pub log_index: String,
    pub removed: bool,
}

StoredTransaction

Transaction stored in state with metadata. Location: src/state.rs:49

Structure

pub struct StoredTransaction {
    pub envelope: TxEnvelope,
    pub raw_data: Vec<u8>,
    pub block_number: u64,
}

Fields

envelope
TxEnvelope
Decoded transaction envelope (Legacy, EIP-1559, EIP-2930, or EIP-4844)
raw_data
Vec<u8>
Raw transaction bytes for hash calculation
block_number
u64
Block number where transaction was included

CoreLaneStateForLib

Simplified state context for external applications. Location: src/lib.rs:84

Structure

pub struct CoreLaneStateForLib {
    account_manager: StateManager,
    bitcoin_client_read: Arc<dyn BitcoinRpcReadClient>,
    bitcoin_client_write: Arc<BitcoinRpcClient>,
    bitcoin_network: bitcoin::Network,
}

Methods

new
fn
pub fn new(
    state_manager: StateManager,
    bitcoin_client_read: Arc<dyn BitcoinRpcReadClient>,
    bitcoin_client_write: Arc<BitcoinRpcClient>,
    network: bitcoin::Network,
) -> Self
Creates a new state context with Bitcoin RPC clients.
replace_state_manager
fn(&mut self, new_state: StateManager)
Replaces the internal state manager with a new one. Useful when applying changes to a StateManager.

Example

use core_lane::{CoreLaneStateForLib, StateManager};
use core_lane::{create_bitcoin_rpc_client, BitcoinRpcClient};
use std::sync::Arc;

let rpc_client = create_bitcoin_rpc_client(
    "http://127.0.0.1:18443",
    "user",
    "pass"
)?;

let mut state = CoreLaneStateForLib::new(
    StateManager::new(),
    rpc_client.clone(),
    rpc_client,
    bitcoin::Network::Regtest
);

Re-exported Types

The following types are re-exported from external crates for convenience:

From alloy_primitives

  • Address - Ethereum address (20 bytes)
  • Bytes - Dynamic byte array
  • B256 - 256-bit hash
  • U256 - 256-bit unsigned integer

From alloy_consensus

  • TxEnvelope - Transaction envelope supporting Legacy, EIP-1559, EIP-2930, and EIP-4844 transactions

Example

use core_lane::{Address, U256, B256, Bytes};

let address = Address::from([0x42; 20]);
let amount = U256::from(1_000_000);
let hash = B256::from([0xff; 32]);