-
Notifications
You must be signed in to change notification settings - Fork 23
Support to RGB Swaps #373
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
Support to RGB Swaps #373
Conversation
josediegorobles
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
Ok, All the sign operations must pass for bitmask-extension for the users, so in web.rs we need endpoints for that. For every of this actions:
And for the accept part it's simply accept the consignment isn't it? We can keep the current part |
|
Hey @josediegorobles and @cryptoquick Please, review my PR. I'm not very confirmable with some details of the solution, especially the public data part in carbonado. Could you please check? |
cryptoquick
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per our discussion yesterday:
We should use DHKE to create Carbonado files for bids and offers between peers.
The server should keep only a small centralized index of DHKE keys, bid/offer IDs, and timestamps (so we can expire old offers at a later date should they ever build up, but not necessarily automatically).
Also, let's be sure this passes tests. If we have flaky tests, we can skip them with a reason, "flaky test".
As for the workflow for how this will all happen, I'll get started on a Nostr relay and Nostr methods for listing and publishing offers and bids. We may not need to do this all with Carbonado, but it's good to have both approaches. And the Carbonado files are still needed to store the PSBTs and such for the swap, in a private manner, using keys only between both peers.
Does this all sound good?
sounds good to me |
Minnor correction: reponse to response
Okay, sure. I elaborated on the scenarios to check if we were on the same page. I will use three characters in my examples: Alice (seller), Bob, and Carol (latest both buyers) Scenario 1: Alice Bob published orders (offer and bid, respectively). The bitmask (wallet/server) will generate four Carbonado files:
After that, Alice chooses to swap with Bob, and the bitmask (wallet/server) executes the following steps:
Steps 4, 5, and 6 occur when we call the rgb::verify_transfer function. Scenario 2: Alice publish one offer, and Bob and Carol publish bids based in Alice's offer. The bitmask (wallet/server) will generate six carbonado files:
After that, Alice chooses to swap with Carol, and the bitmask (wallet/server) executes the following steps:
Steps 4, 5, and 6 occur when we call the rgb::verify_transfer function. @cryptoquick |
The rest looks fine. |
Will we use the same public key as nostr then? It's not a problem? Mainly that all users will have access to this orderbook index information? I thought about creating a key per offer/bid, never reusing the keys. |
|
The Nostr sk is used with ECDH to create a new key per peer pair... I'm not sure you call that key reuse |
I was referring to that today we use nostr sk in files, but we always produce the same public key for this, as we use the global context. For each offers/bids, I just don't use the global context. |
|
We can use the nostr sk generated by the wallet, yes |
|
I made the changes @cryptoquick and @josediegorobles Just confirmation, the chrono is the best package to working with timestamp? if yes, I found her terms confusing ("naive_date", etc.). Could you confirm if the way I am generating the date is Greenwich, please? Code example: if let Some(expire_at) = expire_at {
let utc = chrono::Local::now().naive_utc().timestamp();
if expire_at.sub(utc) <= 0 {
return Err(RgbSwapError::OfferExpired);
}
} |
josediegorobles
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK. Apparently chrono is ok and I only request a little and not problematic change, so when is done I see this for merge
| offer_id: String, | ||
| status: String, | ||
| /// Offer Status | ||
| bid_status: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the comment bad? Bid status // offer status
cryptoquick
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just reviewed all of the code, and I have to say, this is incredible work. I have have just a couple suggestions, and once they're addressed, I will approve.
|
Done. Just confirmation, is this correctly? |
|
Yes, Jose looked into it and he said your work on chrono appears to be okay. |
cryptoquick
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK
Everything looks good, let's get this merged.
Description
This PR allows us make RGB Swaps between two wallets.
How to works
Suppose we have two users, the seller and the buyer, and both would like to swap assets and bitcoins. The users need to follow the instructions below:
offerdefining the quantity of assets and price in satoshis.BMCregistry theofferin a public orderbook.public offersand creates abidbased onoffer.BMCregistry thebidin a public orderbook.offerreceiving abid. If yes, he creates theswap transfer.swap transfersand sends theconsig fileto buyer.New Concepts
Offersare a type of order from the user who wants to sell something. Whilebidsare orders from a user who wants to buy something.Progress
Create a rgb offer (wasm32 support).
offerofferofferoffersCreate a rgb bid (wasm32 support).
bidbidbidbidsPublish a public offer
public offerpublic offerspublic offerspublic offerPublish a public bid
public bidpublic bidspublic bidspublic bidCreate a swap transfer
Create a swap fee output
swap fee outputin PSBT Buyer step.Public Data (wasm32) [1]
Also, the RGB Swap supports the latest features like dustless transactions, fee rate, and RBF coming soon.
[1] Two methods need to be included to ensure compatibility.
Limitations
All current limitations are workable, I decided not to implement it now so you can start testing.
Closes #292