An Algorithm for changing coins between BTC and Hive

Inspired by atomic swaps between Bitcoin like chains I came up with this adaptation for Hive.

User Alice has HBD and Bob has BTC. User Alice says, "you send first". Bob says, "no, you send first." To solve this trust issue we must have cross chain atomic swaps between Hive and BTC.


Alice and Bob must borrow a Hive account, Carmen, from the owner of Carmen, David. The account Carmen should have no HBD or Hive and no VESTS. It must have no owner authorities or keys.

David creates TX1 which sets the sole active key authority for the account Carmen to be David. The transaction will be valid between 48 hours + 2 minutes and 48 hours + 4 minutes into the future.

David sends TX1 to both Alice and Bob and both sign the transaction and return to him.

David creates TX2: So Alice and Bob can borrow a zero balance Hive account, Carmen loses all of its keys on the account and now there is only the active authority of Alice and Bob with weights of 1 each and threshold 2. Signs it for immediate broadcast.

  1. The transaction, TX2, is submitted to the network.

Alice creates TX3: "Pay w HBD to @Carmen"

Alice creates TX4: "Pay w HBD from @Carmen back to @Alice with the expiry time set to locked 48 hours + 2 minutes in the future, signed by Alice"

Alice creates TX5: "Pay w HBD from @Carmen to @Bob with a long salty memo and return the borrowed account to the lender with rental fee. The transaction itself is kept as a secret, x"

Alice sends TX4 to Bob

Bob signs TX4 and returns to Alice

  1. Alice sends H(TX5) and Alice's signature for TX5 to Bob but not TX5 and submits TX3 to the network.

Bob creates TX6: "Pay v BTC to <Alice's public-key> if (TX5 is known and this, TX6, signed by Alice) or (signed by Alice & Bob)"

Bob creates TX7: "Pay v BTC from TX6 to <Bob's public key>, locked 24 hours in the future, signed by Bob"

Bob sends TX7 to Alice

Alice signs TX7 and sends back to Bob

  1. Bob submits TX6 to the bitcoin network

  2. Alice spends TX6 on the bitcoin network, revealing TX5

  3. Bob broadcasts TX5 on the Hive network, moving HBD from Carmen to Bob.

This is atomic (with timeout). If the process is halted, it can be reversed no matter when it is stopped.


Before 1: Nothing happens. Nothing broadcasted.
Between 1 & 2: An account was borrowed and Carmen can be reclaimed by broadcasting it after the 48 hours and 2 minutes.
Between 2 & 3: Alice can use refund transaction after 48 hours to get his money back. David will get Carmen back.
Between 3 & 4: Bob can get refund after 24 hours. Alice has 24 more hours to get his refund. David will get Carmen back.
After 4: Transaction is completed with two operations:

  • Alice must spend his new BTC within 24 hours or Bob can claim the refund and keep his BTC
  • Bob must move his new HBD from Carmen between 48 hours and 48 hours and 2 minutes because of tight expiry date rules in Hive or Alice can claim the refund and keep his HBD

For safety, both should complete the process with lots of time until the deadlines.


Related articles to this.

Tools You Can Use to Do What is Described In the Article

Creating an account to lend out

3 columns
2 columns
1 column
Join the conversation now