The Wallet HTLC approach is TRAIN’s solution for practical atomic swaps with recoverable secret generation. Instead of requiring users to manually manage secrets or complete multiple transactions per swap, secrets are derived from the user’s wallet signature. This enables N+1 interactions for N swaps — after an initial sign-in, users can perform unlimited swaps without additional signing steps.Documentation Index
Fetch the complete documentation index at: https://docs.train.tech/llms.txt
Use this file to discover all available pages before exploring further.
The Challenge
Traditional HTLC implementations face a key tradeoff: User-generated secrets. Private key/secret management burden on users; if the browser clears cache or the user loses access, the transaction cannot be recovered Wallet HTLC solves this by making secret derivation reproducible and recoverable from on-chain data, while delegating the management entirely to the dApp.Sign In
Cache Key
The dapp calls a HKDF to derive an initial key from the signature, and keeps the key in the cache.
Wallet HTLC Flow
Derive Secret
The dApp derives a secret from the user’s cached initial key, source chain, destination chain, and the timelock of the swap using HKDF.
User Locks Funds
User locks funds on the source chain using the hash of the derived secret as the hashlock.
Solver Locks Funds
Solver observes the source lock and creates a matching HTLC on the destination chain with the same hashlock.
User Transmits Signed Secret
The dApp signs a message containing the actual derived secret and transmits this signed secret to the Solver (or broadcasts it to any available actor).
Solver Releases Funds
The Solver reveals the secret on the destination chain to unlock the user’s funds (earning a designated reward for this action) and on the source chain to claim their primary fee. The Solver is economically incentivized to execute the destination redemption promptly—if they delay, any other actor can step in and claim the reward instead. Both user and Solver complete the swap.