CLI Atomic Swap with BTC and LTC

Beam Privacy
BEAM Privacy
Published in
3 min readJul 4, 2019

Team Beam is thrilled to announce the release of its designed for coherent and fully-automatic swaps between heterogeneous blockchains.

This feature offers the most reliable way to swap BTC or LTC directly from your CLI wallet, without any need for a trusted third party. Users save on exchange fees, but also they also fully remove counterparty, settlement, and custodial risks.

Trading of digital assets should be as disintermediated and seamless as possible — this vision guides Beam’s development since day one. By actively extending Bitcoin’s postulate of disintermediation, Beam now provides an alternative to centralized trading systems.

Today, we are proud to release our Atomic Swap functionality for secure exchange of digital assets in a peer-to-peer fashion.

Beam users can now perform cross-chain atomics swaps between Beam and BTC or LTC directly from their CLI wallets.

This is but the first step. After we did the heavy-lifting technological part, we plan to eventually make the feature much more user-friendly by adding it to the graphical user interface of our wallets on all platforms.

Below is a detailed guide on how to perform the Atomic Swap between Litecoin and Beam.

Creating an atomic swap transaction

To perform an atomic swap between Beam and LiteCoin, Alice (BEAM) and Bob (LTC) need to follow the steps below:

1. Alice and Bob need to start nodes for Beam and Litecoin blockchains. In order to run a Litecoin node Alice and Bob are using the following command.

For Alice:

$ ./litecoind -server -datadir=”Alice/path_to_litecoin_wallet_data” -port=10000

-rpcuser=Alice -rpcpassword=123 -printtoconsole

For Bob:

$ ./litecoind -server -datadir=”Bob/path_to_litecoin_wallet_data” -port=10005

-rpcuser=Bob -rpcpassword=123 -printtoconsole

In order to run Beam node please refer to “Run Beam Node

2. Now Alice and Bob need to check their Litecoin balance using the following commands.

For Alice:

$ ./litecoin-cli -rpcuser=Alice -rpcpassword=123 getbalance

For Bob:

$ ./litecoin-cli -rpcuser=Bob -rpcpassword=123 getbalance

3. It doesn’t matter who will trigger the swap first. In our current case, let’s say Bob starts:

$ ./beam-wallet swap_init — swap_coin=ltc -n 127.0.0.1:10005 — amount 50 -r <Alice_address> — swap_amount 100000000 — ltc_node_addr 127.0.0.1:9332 — ltc_user Bob — swap_feerate=90000

Alice will use the next command to “answer” to the swap:

$ ./beam-wallet swap-listen — swap_coin=ltc -n 127.0.0.1:10000 — amount 50 — swap_amount=50000 ltc_node_addr 127.0.0.1:9332 — ltc_pass 123 — ltc_user Alice — swap_beam_side — swap_feerate=90000 — swap_beam_side

4. If the swap conditions match each other, a swap transaction will be created, and a LTC UTXO will be locked on Bob’s blockchain.

5. Alice and Bob need to wait for 6 blocks confirmation (in each blockchain) till the coins will be unlocked.

6. Once the 6 blocks confirmation is received, Bob will redeem Alice’s Beams and the swap will be completed.

7. Now Alice and Bob can check their Litecoin and Beam wallets respectively to ensure the coins were transferred to them.

Conclusion

Atomic Swaps, allow Beam users to maintain full sovereignty over their cross-chain financial transactions by disintermediating the exchange and removing the counterparty risk. In other words, users can securely swap diverse kinds of value without requiring to trust third-parties. A fully user-friendly version of this feature will be released in the next couple of months for Beam GUI Wallets.

Stay tuned.

Come discover Beam and join our community!

Download Beam Android Wallet on Google Play

Download Beam iOS Wallet on App Store

Learn more about Beam on our website and blog

Telegram: t.me/BeamPrivacy

QQ Beam 中国官方社区: https://jq.qq.com/?_wv=1027&k=5Mbs8N4

Reddit: reddit.com/r/beamprivacy/

Twitter: twitter.com/beamprivacy

--

--