The bisq-musig protocol describes the communication between the 2 traders conducting the trade. Each communication between the 2 parties will result in different state of the state maschine, and the traders have some predefined options of what they (or the bisq software) will so, also based on events resulting from the blockchain and time expiration. The graphics below shows the Overview of states. below it we will describe the states and substates of it. It is intended that this state maschine will be implemented in the Java part of Bisq2 using the FSM.
signing of Txs this is already implemented in rust, basically the running test link serves as a rust implementation of what needs to be implemented in Java with FSM. Please see the test-case here. It basically consists of 5 Rounds of communication where each rounds has a class Round1Request and Round1Response. The data in these classes need to be exchanged between the peers.
DepositTx broadcast -no substates-
Seller broadcasts SwapTx
Traders exchange secret keys for P’
Seller or Buyer broadcast WarningTx. Note that there are two (slightly) different WarningTxs for seller and buyer
No additional substates (will be one call to the rust code)
Traders exchange secret keys for Q’
+9. can be made into one state API-call for the java code. Something like checkWarningKeysExchanged(…) could be called and returns true iff keys were present and funds have been transafered to wallet.
t1 expired time trigger should go off if other trader broadcasted the WarningTx and t1 expired. no substates
If the other trader broadcasted the WarningTx , we need to send the RedirectTx to get into Arbitration. The trade ends in arbitration, some substate need to be added here, basically the same procedure as in bisq1.
time trigger if we posted the WarningTx and RedirectTx did not appear on chain yet.
Seller or Buyer broadcast ClaimTx. Workflow ends with ClaimTx.