Skip to content
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

[WIP] Atomic bsq trades #5729

Closed
wants to merge 160 commits into from
Closed

Conversation

sqrrm
Copy link
Member

@sqrrm sqrrm commented Sep 27, 2021

Replaces #5121, #5127

Major refactoring of OfferPayload to accommodate offers with no maker fee tx.

A lot of copy paste and remove extra stuff to place and take atomic offers.

Trade domain refactoring to allow for atomic trades.

sqrrm and others added 30 commits September 27, 2021 18:12
Broaden type requirement
Let Offer handle all OfferPayload data access.
An interface for OfferPayload currently only used by OfferPayload. Some
features won't be available for newer payload types but to fit this into
the Offer and Trade framework it's necessary to hack it a bit.
Offer protobuf has oneof FeeTxOfferPayload and AtomicOfferPayload. This is
backwards compatible since the wire format is the same for the old Offer
and the new one with offer_payload set since the index is the same.
Add a hidden account type that's automatically used for BSQ trades. This
means old orders not using AtomicAccount can still complete the trades
as per normal and new offers placed with AtomicAccount can be taken by
anyone with an upgraded client, but won't be possible to take by users
with older clients.

The atomic account is added on startup if not already added. There is no
data associated with the account, a new BSQ address will be chosen
automatically during the atomic trade process.
Copy paste of normal take offer code with extra steps removed

Added AtomicTxBuilder prototype as a way to build the atomic tx, verify
inputs and gather input requirements. Only the input requirement is used
during the take offer process.
This prepares for letting TradeManager handle AtomicTrade that is a Tradable
Add atomic trade tab under portfolio
Set txid when parsing AtomicTrade from protobuf
- Add offers service protos: GetAtomicOffer, GetMyAtomicOffer,
  GetAtomicOffers, GetMyAtomicOffers, CreateAtomicOffer.

- Add proto message AtomicOfferInfo.

- Add bool tradeAtomic field to CreateCryptoCurrencyPaymentAccountRequest.

- Add trades service protos: GetAtomicTrade, TakeAtomicOffer.

- Add proto message AtomicTradeInfo.
chimp1984 and others added 26 commits October 9, 2021 16:55
We will need that to know if its a segwit input or not.
Add constructors for converting a TransactionInput to
RawTransactionInput. Handle bitcoinSerialize according
to segwit flag.

This change should not break anything as we only add a
field to protobuf and RawTransactionInput is not used in
cases where we depend on the hash of the payload like in
offers.
Don't change old behaviour for normal trade protocol methods
where we use segwit=false for serialisation.
transactionInput.hasWitness would only work for signed
inputs but we need to do the fee calculation before the signing.

Adjust fee calculation values using vbytes
according to https://bitcoin.stackexchange.com/questions/87275/how-to-calculate-segwit-transaction-fee-in-bytes
This need to be tested further...
at process input task and reuse that value in next task
If available funds is < dust it will add the dust change to miner fee
If the If available funds is > dust but the additional change output
would produce another dust change it will also add it to miner fees.
In that case the added amount is > dust.
Cleanup, make constructors private and
add deprecated annotation
Verify also sum of input values from DAO state data
@ripcurlx ripcurlx added this to the v1.8.0 milestone Oct 19, 2021
@ripcurlx
Copy link
Contributor

ripcurlx commented Nov 4, 2021

Closing as superseded and merged by #5775

@ripcurlx ripcurlx closed this Nov 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants