-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Offer PSBT design #2706
Comments
This sounds like a great model to me and is something that could be incorporated into the Node Monkeys bounty. I do think it would be good to create a standard design for how PSBTs could also be used for trxs that involve the creation of inscriptions. For example how an artist could create a PSBT where a buyer is providing BTC and in exchange the creator is inscribing and sending an Inscription to the buyer. This could also incorporate standards on how Parent Inscriptions could be involved. |
When it comes to atomic swaps for inscriptions, there are two patterns that are desired. One where you want to sell an inscription you own for a set price, and another where you may solicit offers for an inscription you own from many buyers and then accept the one you want. For the purposes of this explanation im going to call them Sell/Buysell
buy w/ 2 bump
buy w/ 2 bump and recycle
In the first pattern where you want to sell an inscription for a specific amount of sats, you create a psbt with one input and one output. The input is the current location/utxo of your inscription and the output is the amount of sats you want to receive. You sign the psbt SIGHASH_SINGLE|ANYONECANPAY. This will guarantee that the only way for a buyer to spend the inscription utxo is to fund a transaction that pays the seller the exact amount they signed for. Once a seller has signed, they can share the unbroadcasted psbt privately or publicly. To keep this design simple, we should not try to engineer how the psbts are shared, we can tackle that later. If you share your psbt publicly, but no longer wish for it to be purchased, you must transfer the inscription to yourself, which will spend the utxo and invalidate any signatures that may be floating around. The sell psbt is not broadcasted and is you dont need any cardinal utxos to create it. When the buyer want to purchase, they construct a transaction that uses ordinal theory to transfer the inscription into an output that the buyer controls. The buyer signs this transaction SIGHASH_ALL and then takes the signature from the sellers psbt and inserts it into their purchasing psbt. They then broadcast this transaction to the network, finalizing the swap. There are multiple methods to construct these purchase psbts and ill do my best to explain the tradeoff of each.
ThesIn this sell/buy pattern, selling is very straightforward to understand the security risks and implementation. Buying is where all the complexity comes in. The buy methods defined here transfer the entire postage of a utxo and do not attempt to try and split certain sats out a a utxo Offer/Accept Offer
This pattern is a little less complex as it requires no bump utxos. A buyer constructs a transaction to purchase an inscription and signs it SIGHASH_ALL. The first input is the inscription that a buyer wants to purchase, and the first output is the buyers address with postage the same exact size as the inscription currently contains. All other inputs of this transaction are the buyers used to fund the purchase. The 2nd output is the inscription owners address with the amount of sats the buyer decided on, 3rd output is buyers change address. After the buyer signs this transaction, they give it to the seller. The seller inspects the psbt and see what inscription is being purchased and for what amount. If a seller likes what they see, they can sign SIGHASH_ALL on the 1st input and then broadcast the transaction. This method is nice for running a trustless auction where after some set amount of time, the seller accepts the highest offer. Its also useful if you wanted to only sell an inscription to certain address/addresses, particularly if you wanted to run a trustless claim for a collection |
Great breakdown of how listings and offers can be done with PSBTs @utxo-detective Follow-up questions (from a non-dev):
Appreciate it! |
If you want to list at a lower price than originally, you can just create a psbt at a lower price, no need to transfer and create a new. If you want to increase the price, you should transfer the inscription to yourself and then create a new psbt at the higher amount
Unfortunately not. SIGHASH_SINGLE only makes a promise of some amount of satoshis, not some specfic sats. I beleive there is a proposed SIGHASH_ANYPREVOUT that is not yet added to bitcoincore but it may be able to accomplish this sort of thing, but i dont know much about it other than i saw it somewhere on twitter |
Is the only downside of the 0 bump utxo method that it requires the buyer to split the ordinal out in a separate transaction after purchase? If so, I think we should consider it. Needing to keep bump UTXOs around will add more complexity to the wallet's utxo management, which is already complex. Also, if you need bump UTXOs to buy, you're limited to one buy in-flight at a time, or having more bump utxos available to make multiple purchases at the same time. |
You don't need dummy/padding inputs, not sure why the community kept on building using this scheme Edit: one reason I can think of is that existing third-party wallets are reusing addresses, and that's really bad for hygiene. Transaction MappingAll Initial Asks are Submited as PSBTs with:
Signed and submitted to the order book by the maker The taker finalizes the PSBT based on available UTXOs and fee market conditions:
Credits: @p0stcapone |
If you only have one cardinal, this method does not work and you will still need to create a setup transaction. If you only have large cardinals then one will now be inscription postage. The ideal case for 0 bump is you have 1 small and 1 large cardinal, but this may not always be the case.
This is a fair assessment but you are trading off complexity in transaction construction for complexity in ux. It just kicking the can to users who will need to manage their cardinals. Also, i found that the utxo selection on 0 bump was more complex than just maintaining a few 600 sat utxos.
Primary reason is cheaper since you didnt need to split inscriptions out after each purchase and it also made bulk purchase easier. The 2 bump method is generalized as |
True, but the user is more likely to have multiple cardinal outputs vs having bump outputs of a specific size.
Is that an issue if you split afterwards? The transaction builder will strip postage over 20,000 sats automatically when sending inscriptions. |
My thinking was that if you may need to split anyway, that the logic would be simpler if they were fixed size
Its not an issue after you split, just means for most purchases youll have to do purchase tx + split tx and sometimes setup tx, purchase tx and then split tx |
In the ord wallet, I don't think you'll have to do the split tx manually. The inscription will be in your wallet with extra postage, and then when you send it, it'll be stripped automatically. However it will lock that postage up for other uses, and then you'll have to manually send the inscription back to yourself if you want to use it. I'm leaning towards two bump utxos, like you suggest. Could you make a diagram for the no-bump case? I just want to make sure I'm understanding the tradeoffs. And thanks for writing this up and providing the diagrams! It's super helpful. |
Will create them in a next day or so, need to dig into my old code and find the openordex version |
Why not split a utxo into more usable chunks? If you split into 2 x 600 sat utxos you'll end up with a 1200 sat UTXO which is basically dust with current fee rates. That's a big issue with market places, that they keep on adding dust utxos each time you purchase on top of creating new utxos worth 600 each for subsequent transactions and they never reuse those 1200 sat utxos. |
@utxo-detective Any update? No worries if not, just wanted to ping this issue, since this is a great feature. |
Actually most marketplace is now using a 600-600-1200 (or 300-300-600 if using taproot) 3 bump rotation scheme. Using this design you just do setup once and keep using 3 bump utxos forever. The downside is a bigger tx size tho. |
Another idea is that you can "mark" every utxos with 600x (600/1200/1800...) as bumps, then you can keep reusing those bumps since that even if they "grow" after each transaction, they are still 600x. You don't deem a 1200-sat UTXO as a waste, instead it's another bump that you can use for future transactions. |
Yeah, I'm thinking this will be best, then you can decrease the amount of dust you have and do "free" consolidation of your dust. |
Before adding commands to create and accept offers, we should design and agree on the right structure for offer PSBTs. There are a number of tricky issues that I don't fully understand. Namely, making sure everything works with the sighash flags, it isn't possible to accept an offer without providing the right amount of BTC, and the number and order of padding inputs. (Some PSBT implementations include extra padding inputs, I think for alignment, but I don't fully understand the tradeoffs there.)
This design will make it easier to review PRs adding the commands. As is, reading the code in #2697 to figure out the PSBT structure is pretty hard. It would be better to have a documented design first, and then review the code to make sure that it's doing what's in the design.
In order to close this issue:
docs/src/inscriptions/offers.md
Then we can move on to actually implementing and reviewing the sell and accept commands, updating the design if needed.
The text was updated successfully, but these errors were encountered: