Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add atomic swap htlc sending and claiming #3552

Merged
merged 1 commit into from Nov 16, 2021

Conversation

SWvheerden
Copy link
Collaborator

Description

This Pr adds in the ability to send and claim HTLC transactions.
This is added to the console wallet UI and GRPC commands.

UI:
tari_console_wallet --command "init-sha-atomic-swap <Amount> <Bob pubkey> <Message>"
This is used to initialize an atomic swap for the XTR side
tari_console_wallet --command "finalise-sha-atomic-swap <Output hash> <pre_image hex>"
This is used to finalize and claim an HTLC transaction for the XTR side.

GRPC:
rpc SendShaAtomicSwapTransaction(SendShaAtomicSwapRequest) returns (SendShaAtomicSwapResponse);
This is used to initialize an atomic swap for the XTR side
rpc ClaimShaAtomicSwapTransaction(ClaimShaAtomicSwapRequest) returns (ClaimShaAtomicSwapResponse);
This is used to finalize and claim an HTLC transaction for the XTR side.

Motivation and Context

This is the first step in allowing Atomic swaps for Tari and coins that have SHA256 as a pre_image.
Currently, the available commands in this PR and tools available we can do the happy path of an atomic swap for:
Bitcoin
Bitcoin Cash (Bitcoin ABC, Bitcoin Unlimited, Bitcoin XT)
Decred
Litecoin
Monacoin
Particl
Qtum
Vertcoin
Viacoin
Zcoin

How Has This Been Tested?

Added unit and cucumber tests for the Tari side.
Did a manual XTR BTC atomic swap
XTR UTXO hash:
186a95239d16ebf800cb3b7991521585b569253255002b009b16f11faab8d115
BTC tx_ids:
1f770ce82aeb1f6c0d0345a6a88f1b3eb2e226595063491c93ad442625f678ae
2b6e2e2566577e8e52da685e2abb4252b98fc4a60dc9a1b09a56e6b003900bc9

@SWvheerden SWvheerden force-pushed the sw_xtr_btc_swap branch 2 times, most recently from e0a5b50 to 94ee0b5 Compare November 11, 2021 10:40
Copy link
Contributor

@philipr-za philipr-za left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking really good, a couple minor comments.

base_layer/wallet/src/output_manager_service/service.rs Outdated Show resolved Hide resolved
base_layer/wallet/src/transaction_service/service.rs Outdated Show resolved Hide resolved
base_layer/wallet/tests/transaction_service/service.rs Outdated Show resolved Hide resolved
base_layer/wallet/src/output_manager_service/handle.rs Outdated Show resolved Hide resolved
docs/src/btc_atomic_swap.md Outdated Show resolved Hide resolved
hansieodendaal
hansieodendaal previously approved these changes Nov 12, 2021
Copy link
Contributor

@hansieodendaal hansieodendaal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM from a code review and logic perspective - really nice.

@philipr-za
Copy link
Contributor

Changes look good, just needs a rebase. Quite a few conflicts.

@aviator-app aviator-app bot merged commit a185506 into tari-project:development Nov 16, 2021
@SWvheerden SWvheerden deleted the sw_xtr_btc_swap branch November 16, 2021 06:36
sdbondi added a commit to sdbondi/tari that referenced this pull request Nov 18, 2021
* development: (32 commits)
  feat: add atomic swap refund transaction handling (tari-project#3573)
  feat: improve wallet connectivity status for console wallet (tari-project#3577)
  v0.21.1
  feat: add error codes to LibWallet for CipherSeed errors (tari-project#3578)
  ci: split cucumber job into two (tari-project#3583)
  feat(wallet): import utxo’s as EncumberedToBeReceived rather than Unspent (tari-project#3575)
  docs: rfc 0250_Covenants (tari-project#3574)
  feat: get fee for transactions for stratum transcoder (tari-project#3571)
  test: make monerod stagenet usage resilient (tari-project#3572)
  feat: add atomic swap htlc sending and claiming (tari-project#3552)
  feat: implement prometheus metrics for base node (tari-project#3563)
  feat: implement multiple read single write for sqlite (tari-project#3568)
  feat: trigger time lock balance update when block received (tari-project#3567)
  test: reduce cucumber ci to critical only (tari-project#3566)
  test: fix cucumber console wallet startup (tari-project#3564)
  chore: add node id/public key to log mdc (tari-project#3559)
  fix: avoid implicit using of the time crate (tari-project#3562)
  feat: one-click installer - cli edition (tari-project#3534)
  ci: add workflow dispatch to libwallet build action (tari-project#3556)
  fix: stop leak of value of recovered output (tari-project#3558)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants