Replies: 4 comments 14 replies
-
I think we should develop sort of interactive protocol for this, like BIP78. Also, the same scheme can be re-utilized for RGB payjoins, i.e there is no on-chain difference between RGB atomic swap and RGB payjoin |
Beta Was this translation helpful? Give feedback.
-
Important that RGB state transitions prepared by Bob and Alice are not shared and prepared/kept independently (even though commitment to them goes into the same bitcoin transaction output). I made this possible with the introduction of RGB state transition bundles in RGB Core v0.7 (if you remember I was saying they are really important for multi-party transactions). With bundling, Alice and Bob put assets into different inputs, the state transitions are kept separately and they will operate two different & independent consignments for it. |
Beta Was this translation helpful? Give feedback.
-
Question that comes to mind with this approach is what happens if e.g. Alice produces a signature for her input, but Bob instead of producing his and creating a valid transaction just waits (maybe till an exchange rate is more favorable for him) and only after e.g. 1 day submits the transaction. This would put the first signer of the transaction in a tricky position where the other party can execute the swap at any time in the future (or till the input UTXO is spent). Is there some way we can make the transaction valid only if sent within e.g. 10 blocks, kinda like a reverse timelock? |
Beta Was this translation helpful? Give feedback.
-
I am not sure if this is obvious from this description, but with tapret commitments this can be made non-interactive for RGB -> BTC swaps (this might useful for NFT/UDA sale listings). Seller A of an RGB asset, can create 1-in (utxo with rgb asset) & 1-out (output to the seller with tapret commitment) transaction, which is unspendable by itself (spends more BTC on the output that it receives on the input), and contains a tapret1st commitment sending his RGB asset to ~:1 (2nd output of the witness transaction - which is yet undefined in the transaction). Seller signs that transaction with SIGHASH_SINGLE|ANYONECANPAY and publishes this pre-signed transaction along with the consignment. Buyer B takes the pre-signed transaction, verifies the consignment. He then adds another input to the transaction making the transaction valid now (enough BTC on the input), and also adds another output for him to receive the RGB asset to (remember the RGB asset is sent to ~:1), he signs the whole transaction with SIGHASH_ALL and publishes it concluding the swap. |
Beta Was this translation helpful? Give feedback.
-
Atomic swaps are a powerful tool to exchange assets without intermediaries and without counterparty risk in a blockchain or across blockchains. Atomic swaps typically require the two parties to fund HTLC outputs, from which the assets will be redeemed using a secret if the swap is successful, or using a timelock if the swap fails. In RGB, it is possible to have atomic swap without the need for any scripting mechanism, and without having to perform two rounds of transactions, achieving both efficiency and privacy benefits.
In an RGB swap, the two parties will create together a Bitcoin transaction spending as inputs their respecting colored UTXO containing the RGB assets, and having as outputs the two change addresses where both parties can send back the bitcoins contained in their UTXO (minus the network fee) and an output containing the commitment to both RGB state transitions, one for Alice to send her assets to Bob, and the other for Bob to send his assets to Alice.
N.B. the output used for the RGB state transition commitment can either be a dedicated OP_RETURN output as in the example below, or a Taproot output also used for the bitcoin change of one of the two parties.
The atomicity of the exchange is guaranteed by the fact that both RGB state transitions are committed to same Bitcoin transaction, so either both of them get finalised or both of them fail. Compared to traditional atomic swaps, with RGB there is the advantage that much less on-chain space is used, and a blockchain observer cannot distinguish the atomic swap from a generic Bitcoin transaction.
The same scheme can work also for swaps between RGB asset and bitcoin, with the only difference that only one RGB state transition will be committed in the Bitcoin transaction, and one of the Bitcoin outputs will be dedicated to send bitcoin to the party who is acquiring bitcoin in the swap.
Beta Was this translation helpful? Give feedback.
All reactions