Stacks
Overview
Liquidity stacks split the COMB sent to them between two addresses: target and change. Once the Stack has received sum NATs (smallest units of COMB), it will trigger, sending the specified amount to the destination, while any remaining or future COMB gets sent to the change address. Stacks are the most versatile construct in Haircomb, and serve multiple purposes:
- Stealth Addresses: Used to construct receiving stealth and super stealth addresses.
- Transaction Outputs: Stacks can be used as outputs in transactions, allowing for complex fund transfers.
- Scalability: Liquidity trees may be leveraged as outputs in future upgrades, offering scalable multi-payment capabilities.
- Fundraising and Deferred Payments: Stacks can be used for scenarios like deferred payments or to structure a fundraiser.
- Amount-Decided-Later: Stacks support use cases where the precise amount of funds transferred can be decided later.
Stacks do not store data on-chain, providing a significant scalability advantage over traditional Bitcoin transaction outputs.
Entry Address
The address of a liquidity stack (known as the "entry address") is calculated on the Haircomb mainnet using the following formula:
entry address = SHA256(change address || target address || big-endian uint64 amount)
This hash preimage is 72 bytes long and ensures that the stack is unique for each combination of change address, destination address, and amount.
Functionality and Usage
Functionality
- Definition: Stacks in Haircomb refer to constructs that control how COMB is split and distributed between a destination and change address. Once the sum of COMB is received by a stack, the destination is funded, and any excess is routed to the change address.
- Core Functions:
- Push: Adding COMB to a stack.
- Trigger: Activating the stack once the required amount of NATs has been collected.
- Redirect: Any future COMB after triggering will be redirected to the change address based on the stack’s rules.
- Operations: The key operations involve the management of stealth and multi-payment scenarios, deferred payments, and transactions across multiple addresses simultaneously.
Usage
- Implementation: Stacks are implemented off-chain and rely on SHA-256 for addressing. The stack schema allows for flexible transaction handling, creating a powerful framework for multi-recipient payments or stealth transactions.
- Interaction: Stacks work by creating a chain of destinations and change addresses. A single transaction can trigger a cascade of payments through a stack structure.
- Performance: Since stacks do not store any on-chain data, they significantly enhance system scalability, especially in scenarios involving multiple simultaneous payments. They outperform traditional BTC outputs by orders of magnitude in such cases.
Wallet Import Format
Mainnet
/stack/data/{uppercase hex change address}{uppercase hex target address}{uppercase hex big-endian uint64 amount}\r\n
Testnet
\stack\data{uppercase hex change address}{uppercase hex target address}{uppercase hex big-endian uint64 amount}\r\n
Example Use Cases
Use Case 1: Receiving Stealth Address
- Description: A stealth address allows for anonymous transactions. A stack is created where the destination is hidden, and COMB is automatically redirected to the change address, effectively concealing the receiver’s identity.
- Process:
- 1) User A creates a stealth stack by setting a garbage target (e.g., a small integer identifying the stealth address) and an own legitimate change address. The target amount is 0, making the stack pre-triggered.
- 2) User B sends or claims COMB to the stealth address.
- 3) The COMB is automatically forwarded to the hidden change address (User A's real address).
- Outcome: User A receives the funds without revealing their main address, enhancing privacy.
Use Case 2: Super Stealth Address
- Description: A super stealth address operates like a regular stealth address but adds extra layers of security by chaining stacks together.
- Process:
- 1) User A creates a stealth stack by setting a true random target address (which must be recorded), and an own legitimate change address. The target amount is 0, making the stack pre-triggered.
- 2) User B sends or claims COMB to the stealth address.
- 3) The COMB is automatically forwarded to the hidden change address (User A's real address).
- Outcome: Maximum anonymity for high-security transactions, as tracing the origin or destination becomes nearly impossible, even if knowing the backing address.
Summary
Stacks are a crucial part of Haircomb’s infrastructure, enabling flexible, scalable, and private transaction mechanisms. They allow users to split payments, create stealth addresses, conduct multi-payment transactions, and handle deferred payments, all while avoiding the need for on-chain data storage. By leveraging SHA-256 for address creation and a flexible transaction framework, stacks help enhance system performance, efficiency, and scalability, making them an integral component of Haircomb’s future growth.