Skip to content

Tolsi/bitcoinj-atomic-swap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bitcoinj-atomic-swap

Implementation of Coinswap in Scala using the AdamISZ's work and BitcoinJ library.

How it works

The application simulates the exchange of necessary data according to the protocol described in this document. As a result of the exchange, hex data of transactions are written to the console, which can be sent to the bitcoin testnet via the explorer.

To use the application, you must obtain 2 private keys and addresses for the testnet (you can use this site, single or batch wallet). Then you need to get some money for them to exchange using faucet.

You need replace the private keys (in WIF format) for alice and carol at CoinSwap:22-23 and then Bitcoin output info for a unspend output from faucet at CoinSwap:36-48. You can find that info in the explorer. You can see that I pass alice's keys as bob's keys so (that's more like atomic swap scheme), but you can create third account for bob and use it as intermediary (like CoinSwap scheme). Try it yourself!

After changing the initial data, you just need to start the application and it will generate all possible transactions. Try all cases: a simple successful exchange, a refund of money after the expiration of time or when disclosing a secret (bobX). Then just send transaction hex bytes through the explorer and look at the result!

How to run

You can run it using sbt from the project folder:

sbt run

or import the SBT project to IntelliJ IDEA and run ru.tolsi.CoinSwap class.

If you see some errors when importing or running in the IntelliJ IDEA, try run sbt clean compile from the project folder.

About

Scala Coinswap prototype

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages