Skip to content

Instantly share code, notes, and snippets.

@tsjk
Created April 2, 2025 18:47
Show Gist options
  • Save tsjk/40e143b2d70b508d8328f2a715ca6e32 to your computer and use it in GitHub Desktop.
Save tsjk/40e143b2d70b508d8328f2a715ca6e32 to your computer and use it in GitHub Desktop.
Bisq Musig Protocol (simple state diagram)
stateDiagram-v2
    state BisqMusigProtocol {
        [*] --> SigningOfTxs
        SigningOfTxs --> [*]: Cancelled
        state "DepositTxBroadcast w/ Seller's deposit & trade amount [TR key spend: P'] and Buyer's deposit [TR key spend: Q']" as DepositTxBroadcast
        SigningOfTxs --> DepositTxBroadcast
        DepositTxBroadcast --> TradersExchangeSecretKeysForP'
        DepositTxBroadcast --> SellerBroadcastsSwapTx
        DepositTxBroadcast --> SellerOrBuyerBroadcastWarningTx
        state "Buyer reveal key spend P' from Seller's signature and import secret key for Output0 and DepositTx into wallet" as BuyerRevealKeySpendP'
        SellerBroadcastsSwapTx --> BuyerRevealKeySpendP'
        BuyerRevealKeySpendP' --> [*]
        TradersExchangeSecretKeysForP' --> SellerBroadcastsSwapTx
        TradersExchangeSecretKeysForP' --> TradersExchangeSecretKeysForQ'
        TradersExchangeSecretKeysForP' --> SellerOrBuyerBroadcastWarningTx
        TradersExchangeSecretKeysForQ' --> SellerBroadcastsSwapTx
        TradersExchangeSecretKeysForQ' --> SellerOrBuyerBroadcastWarningTx
        TradersExchangeSecretKeysForQ' --> [*]
        state kx <<choice>>
        SellerOrBuyerBroadcastWarningTx --> kx
        kx --> BuyerOrSellerCreatesTxWithTotalFundsToTheirWallet: Key already exchanged
        BuyerOrSellerCreatesTxWithTotalFundsToTheirWallet --> [*]: One of the traders tried to cheat the other and gets punished by losing the deposited funds
        state t <<choice>>
        kx --> t: Key not exchanged
        t --> BuyerOrSellerBroadcastRedirectTx: t1 expired, but not t2 > t1
        BuyerOrSellerBroadcastRedirectTx --> [*]: One of the traders has been inactive, therefore the other trader gets the funds
        t --> SellerOrBuyerBroadcastClaimTx: t2 expired
        SellerOrBuyerBroadcastClaimTx --> [*]: One of the traders has been inactive, therefore the other trader gets the funds
  }
Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment