-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
V5 trade protocol #7105
base: master
Are you sure you want to change the base?
V5 trade protocol #7105
Commits on Sep 13, 2024
-
Implement WarningTransactionFactory
The factory can create, sign, and finalize the warning transaction.
Configuration menu - View commit details
-
Copy full SHA for bd94857 - Browse repository at this point
Copy the full SHA bd94857View commit details -
Implement RedirectionTransactionFactory
The factory can create, sign, and finalize the redirection transaction.
Configuration menu - View commit details
-
Copy full SHA for 6affded - Browse repository at this point
Copy the full SHA 6affdedView commit details -
Implement ClaimTransactionFactory
The factory creates, signs, and finalizes the claim transaction.
Configuration menu - View commit details
-
Copy full SHA for e314188 - Browse repository at this point
Copy the full SHA e314188View commit details -
Refactoring: Rename BuyerProtocol to BaseBuyerProtocol and SellerProt…
…ocol to BaseSellerProtocol Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 6eeb92b - Browse repository at this point
Copy the full SHA 6eeb92bView commit details -
Refactoring: Add BuyerProtocol and SellerProtocol interfaces
Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for bbdf1ac - Browse repository at this point
Copy the full SHA bbdf1acView commit details -
Refactoring: Use BuyerProtocol interfaces instead of BaseBuyerProtoco…
…l at client code Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 9292815 - Browse repository at this point
Copy the full SHA 9292815View commit details -
Refactoring: Use SellerProtocol interfaces instead of BaseSellerProto…
…col at client code Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for feca78b - Browse repository at this point
Copy the full SHA feca78bView commit details -
Refactoring: Make BaseBuyerProtocol and BaseSellerProtocol package pr…
…ivate and constructor protected Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for f7f3b37 - Browse repository at this point
Copy the full SHA f7f3b37View commit details -
Refactoring: Move protocol interfaces one level up
Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 65a140a - Browse repository at this point
Copy the full SHA 65a140aView commit details -
Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 3ac758d - Browse repository at this point
Copy the full SHA 3ac758dView commit details -
Refactoring: Add methods to implementation classes even they have not…
… custom code but only call super to make it more transparent which handler methods are in the protocol. Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 5d35a98 - Browse repository at this point
Copy the full SHA 5d35a98View commit details -
Refactoring: Use getTradeProtocolVersion getter instead of public TRA…
…DE_PROTOCOL_VERSION field. Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 7a8f5c2 - Browse repository at this point
Copy the full SHA 7a8f5c2View commit details -
Refactoring: Rename Protocol classes with
_v4
postfix and move to p……rotocol_v4 package
Configuration menu - View commit details
-
Copy full SHA for 83b1f22 - Browse repository at this point
Copy the full SHA 83b1f22View commit details -
Use new protocol version after activation date
Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 15d25d0 - Browse repository at this point
Copy the full SHA 15d25d0View commit details -
Add copies of protocol classes to bisq_v5 package. Those will serve a…
…s base for later implementing the new protocol. Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 8ed3f7a - Browse repository at this point
Copy the full SHA 8ed3f7aView commit details -
Use new protocol classes if version 5 is activated
Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 3393e48 - Browse repository at this point
Copy the full SHA 3393e48View commit details -
Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for c5a2137 - Browse repository at this point
Copy the full SHA c5a2137View commit details -
Set v5 activation date in past for dev testing
Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 29f6d8f - Browse repository at this point
Copy the full SHA 29f6d8fView commit details -
Pass depositTxOutput to make it more clear what is really used. Use long for claimDelay (to be consistent with lockTime and ScriptBuilder expected type). Do not pass aesKey in TradeWalletService.signWarningTx as its kept private in that service class. Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 96ee168 - Browse repository at this point
Copy the full SHA 96ee168View commit details -
Add util method for calculating fee rate which was used for the depos…
…it tx. Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 1f1753b - Browse repository at this point
Copy the full SHA 1f1753bView commit details -
Add StagedPayoutTxParameters class which holds relevant protocol para…
…meters Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 965764a - Browse repository at this point
Copy the full SHA 965764aView commit details -
Using a dedicated ProcessModel implementation would cause too much changes in client code. Maybe we still refactor that later, but for now it seems its less painful to add fields and use the same class at the old and new protocol. Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for d1bae86 - Browse repository at this point
Copy the full SHA d1bae86View commit details -
Add InputsForDepositTxResponse_v5 message
Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for e586b57 - Browse repository at this point
Copy the full SHA e586b57View commit details -
Add new tasks for BuyerAsMakerProtocol_v5. We might generalize later …
…to BuyerProtocol_v5, but for now we start with one variant (BuyerAsMakerProtocol_v5 and SellerAsTakerProtocol_v5) Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 76f7e28 - Browse repository at this point
Copy the full SHA 76f7e28View commit details -
Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 0971d9b - Browse repository at this point
Copy the full SHA 0971d9bView commit details -
Add InputsForDepositTxResponse_v5 message
Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 0380f2e - Browse repository at this point
Copy the full SHA 0380f2eView commit details -
Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for ed729f9 - Browse repository at this point
Copy the full SHA ed729f9View commit details -
Add BuyersRedirectSellerSignatureRequest
Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 2c3ca21 - Browse repository at this point
Copy the full SHA 2c3ca21View commit details -
Add tasks for 3rd phase at buyer
Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for c029b87 - Browse repository at this point
Copy the full SHA c029b87View commit details -
Add BuyersRedirectSellerSignatureResponse
Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for bf1e6de - Browse repository at this point
Copy the full SHA bf1e6deView commit details -
Add tasks for 4th phase at seller
Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for bf64b1e - Browse repository at this point
Copy the full SHA bf64b1eView commit details -
Comment out correctlySpends checks at claim and redirect txs.
TODO: check if that is expected when we do not have the full tx chain or if its caused by a bug. Signed-off-by: HenrikJannsen <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for fc7932e - Browse repository at this point
Copy the full SHA fc7932eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 20290f7 - Browse repository at this point
Copy the full SHA 20290f7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8e63921 - Browse repository at this point
Copy the full SHA 8e63921View commit details -
Configuration menu - View commit details
-
Copy full SHA for c257b70 - Browse repository at this point
Copy the full SHA c257b70View commit details -
More changes the get the trade start working
Also add trade tasks to publish the warning/redirect/claim txs.
Configuration menu - View commit details
-
Copy full SHA for 8de1468 - Browse repository at this point
Copy the full SHA 8de1468View commit details -
Fix warning/redirect/claim tx fee calculations
Also make claim delay 5 blocks on regtest, and add missing TradeMessage constructors to provide a default argument for the P2P message version, for consistency with the other trade messages.
Configuration menu - View commit details
-
Copy full SHA for f7dc741 - Browse repository at this point
Copy the full SHA f7dc741View commit details -
Make further improvements to the redirect tx fee precision
Add an extra flag to 'DelayedPayoutTxReceiverService.getReceivers(..)' to control the tx fee precision, and refactor to use an EnumSet of flags activated by particular date, instead of just passing boolean args. This new 'PRECISE_FEES' flag is currently set to activate at the same time as the v5 protocol upgrade (though it can be used independently). When present, the flag changes the receiver list calculation as follows: 1) Spendable amount depends on individual output ScriptPubKey sizes, instead of all outputs assumed to cost 32 bytes each (P2SH cost); 2) Base cost of DPT is that of the signed instead of unsigned tx (v4 protocol only - redirect tx base cost is always for the signed tx); 3) Increase in spendable amount from saved tx fees after filtering out the small outputs is taken into account; 4) Small outputs are filtered out pre-adjustment upwards, rather than post-adjustment, so that they don't get erroneously included; 5) The balance given to the LBM takes the tx fee cost of his output into account. Additionally, restrict the fee bump addresses of the peer's warning and redirect txs to be P2WPKH, for more predictable tx fee rates.
Configuration menu - View commit details
-
Copy full SHA for 8f72f91 - Browse repository at this point
Copy the full SHA 8f72f91View commit details -
Provide missing persistence for warning/redirect/claim txs
Make sure the 'signedClaimTx' & 'finalized(Warning|Redirect)Tx' fields of the 'ProcessModel' & 'TradingPeer' models are persisted properly in the respective proto objects. To this end, store them serialised as byte arrays instead of Transaction objects. (Also clean up the Lombok annotations slightly.)
Configuration menu - View commit details
-
Copy full SHA for 4c780aa - Browse repository at this point
Copy the full SHA 4c780aaView commit details -
Fix UI+log errors/warnings in happy path of v5 trade protocol
Add checks that we're not running the v5 protocol, everywhere a missing delayed payout tx would cause errors or warnings to appear in either the logs or the Pending Trades or Trade Details views, for a v5 trade that completes normally. Also add both the buyer's & seller's redirect & warning txs to the Trade Details view, in place of the missing DPT, as well as the claim tx if it's present. (The latter is created & signed at the point of use.) Add suitable 'get*(BtcWalletService)' methods to 'Trade' for that purpose.
Configuration menu - View commit details
-
Copy full SHA for 0c915e6 - Browse repository at this point
Copy the full SHA 0c915e6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8d0e8bd - Browse repository at this point
Copy the full SHA 8d0e8bdView commit details -
Ensure v5 staged txs are linked to trade in Transactions view
Make sure 'TransactionAwareTrade::isRelatedToTransaction' returns true for warning, redirect & claim txs belonging to the given trade. Also optimise the method somewhat by short circuiting on a wider class of txs than those with zero locktime, when ruling out that the tx is a delayed payout or warning tx. The previous short circuit test was inadequate due to the fact that a lot of wallets, such as Sparrow, set a nonzero locktime on all txs by default, to prevent fee sniping. Also modify 'TransactionAwareTradable::bucketIndex' to place the new staged txs in the (global) delayed payout tx bucket, so that they get past the related transactions filter, used to speed up the pairing of txs with tradables.
Configuration menu - View commit details
-
Copy full SHA for 2e86bdd - Browse repository at this point
Copy the full SHA 2e86bddView commit details -
Use watched scripts to pick up broadcast of staged txs
Since the multisig escrow outputs of the deposit & warning txs do not belong to the user, bitcoinj won't pick up any txs spending them unless a corresponding watched script (the ScriptPubKey) is added to the wallet. To this end, provide a trade task to add watched scripts for those three outputs, which runs just before the client or the peer might broadcast the deposit tx. Also remove them upon withdrawal of funds at the end of the trade (closed normally or through a dispute). We need to add watched scripts for the deposit tx output and both the user's and the peer's warning tx outputs, so that the peer's warning, redirect and claim txs are all picked up, regardless of any message sent to the client. TODO: Possibly find a way to clear out old watched scripts from failed trades, as they will otherwise remain in the user's wallet permanently, creating a growing burden for the wallet. Also, we should possibly re- add all the watched scripts if the wallet is restored from seed.
Configuration menu - View commit details
-
Copy full SHA for dfce59e - Browse repository at this point
Copy the full SHA dfce59eView commit details -
Make Transactions view display correct types & amounts for staged txs
Ensure 'TransactionsListItem' recognises warning, redirect & claim txs and displays appropriate details messages for them. Redirect txs are made to show the same "Refund collateral" details message as delayed payout txs and don't distinguish between the user's or peer's tx, whereas warning & claim tx details do distinguish between them. Also ensure the correct amounts are displayed in the Transaction view, when watched scripts are present in the wallet, by changing 'WalletService::getValueSent(To|From)MeForTransaction' not to include watched outputs or inputs in their respective sums. Ensure claim txs broadcast by the peer are correctly linked to the trade and display correctly in the Transactions view, by changing 'BisqRiskAnalysis' not to deem txs with a relative lock time as risky, as that interferes with the v5 trade protocol. Finally, make the Trade Details window resilient to missing peer's redirect & warning tx from old trades, which could be cleared out as sensitive data, and prevent it from incorrectly displaying the claim tx as the multisig payout tx (and similarly for the Transactions view).
Configuration menu - View commit details
-
Copy full SHA for 810fd34 - Browse repository at this point
Copy the full SHA 810fd34View commit details -
Use LowRSigningKey for warning, redirect & claim txs
Also update the expected signed tx sizes accordingly, and require that the peer provides a low-R signature for them, so that they're never bigger than expected. (No such requirement is made of any of the txs in the current v4 protocol, to ensure backwards compatibility.)
Configuration menu - View commit details
-
Copy full SHA for 370b855 - Browse repository at this point
Copy the full SHA 370b855View commit details
Commits on Sep 14, 2024
-
Add extra dispute states for v5 protocol
Add the 4 values 'WARNING_SENT(_BY_PEER)' & 'ESCROW_CLAIMED(_BY_PEER)' (all unused at present) to the 'Trade.DisputeState' enum, and update the proto. The new states are not classed as arbitrated, as arbitration is only deemed to occur once a redirect tx has been published (and that's intended to reuse the existing 'REFUND_REQUEST*' dispute states of the current v4 protocol). But they are an escalation beyond mediation, as they spend the escrow, and thus disable both the buyer and seller payment confirmation. Accordingly, add a 'DisputeState::isEscalated' predicate to include the new states in addition to the arbitrated ones.
Configuration menu - View commit details
-
Copy full SHA for cf4016e - Browse repository at this point
Copy the full SHA cf4016eView commit details -
Add preliminary code to publish warning tx if mediation fails
Adapt the existing workflow of starting a second-round arbitration process, upon mediation failure, to the v5 trade protocol, by giving the trader an option to broadcast his warning tx. This replaces the current (tertiary) action of broadcasting the (v4 protocol) delayed payout tx to start arbitration, on the mediation result popup. Instead, the trader must now wait for the peer to see the warning tx and actually start arbitration by broadcasting his redirect tx. (This second part is not yet implemented.) Also clean up 'DisputeValidation' slightly and prevent the errant display of a duplicate-DPT-detected message in the event that a dispute has a missing delayed payout txId (as is currently the case for v5 protocol trades). Fix the logic similarly for missing trade IDs & deposit txIds. TODO: Allow peer to start arbitration by broadcasting his redirect tx, upon detection (via a suitable listener) of a warning tx broadcast.
Configuration menu - View commit details
-
Copy full SHA for ce5087c - Browse repository at this point
Copy the full SHA ce5087cView commit details
Commits on Sep 22, 2024
-
Add listener to pick up warning tx broadcast
Provide a 'SetupWarningTxListener' trade task, which runs at the opening of the trade and upon initialisation of the trade manager at application startup. It adds a listener which picks up either warning tx and updates the dispute state to 'WARNING_SENT(_BY_PEER)', as appropriate. As the peer's warning tx may be unknown (at least in the unlikely event that sensitive data was cleared out of an unfailed trade), the listener detects any spend of the deposit tx escrow output. (This functionality will also be needed to pick up the peer's claim tx, which has a completely unknown txId.) To this end, provide a new listener type, 'OutputSpendConfidenceListener', which can be added to or removed from a 'WalletService' instance and detects change in the confidence of any tx spending the provided (non-detached) 'TranactionOutput' instance. (Also do some minor cleanup of the 'WalletService' class.)
Configuration menu - View commit details
-
Copy full SHA for 21b0c35 - Browse repository at this point
Copy the full SHA 21b0c35View commit details -
Pick up WARNING_SENT* dispute states in TradeStepView
When either of the trade peers publishes his warning tx, reflect that in the info panel of the trade step view, providing a red "Redirect to arbitration" or a (possibly greyed out) green "Claim trade collateral" button, in place of the usual get-help/open-dispute button. Add four new values to the 'TradeStepInfo.State' enum to distiguish whose warning tx was published and whether the corresponding claim tx is still locked. Provide (currently unimplemented) button action stubs to open a popup to claim/redirect. Also do some minor cleanup of 'TradeStepView' and make sure the method 'DisputeManager::checkForMediatedTradePayout' closes the mediation ticket upon publishing of either warning tx, not just upon starting arbitration or receiving a payout.
Configuration menu - View commit details
-
Copy full SHA for 463ab45 - Browse repository at this point
Copy the full SHA 463ab45View commit details
Commits on Sep 25, 2024
-
Add downstream listeners to SetupWarningTxListener & rename
Rename 'SetupWarningTxListener' to 'SetupStagedTxListeners' and add code to provide a second listener for the redirect or claim tx, upon firing of the first listener. Set the trade dispute state to one of the four states 'REFUND_REQUEST(_STARTED_BY_PEER)' or 'ESCROW_CLAIMED(_BY_PEER)', as appropriate, upon firing of the downstream listener. Also, restore the peer's redirect or warning tx in the unlikely event that they were cleared out as sensitive data, and fill in the peer's claim tx if it gets picked up. Add a proto field to persist the latter, in order to show it in the details window of a past trade. Make sure that the peer's staged txs don't get subsequently removed as sensitive data if the trade wound up in a dispute and any staged txs were broadcast. Similarly, suppress the removal of watched scripts in that case, to prevent staged txs disappearing if there's an SPV resync. Finally, add a missing 'SetupStagedTxListeners' trade task item to the 'PreparedTxBuyerSignaturesMessage' handler of the v5 seller-as-maker protocol (overriding super), as the listeners weren't being set up at the start of the trade in that case.
Configuration menu - View commit details
-
Copy full SHA for d5ce7bc - Browse repository at this point
Copy the full SHA d5ce7bcView commit details
Commits on Sep 28, 2024
-
Make Transactions view tolerate missing tx witness data
Make the filtering methods 'isPossible(RedirectOrClaimTx|EscrowSpend)', used to speed up the Transactions view, lenient towards segwit txs that have missing witness data. This appears to be the case for a lot of txs fetched from the network by bitcoinj, including all the segwit txs in the wallet after an SPV resync. Since the witness data of a peer's claim tx (picked up by bitcoinj) may in fact be missing, rename the field 'TradingPeer.signedClaimTx' to 'claimTx', along with corresponding proto field. Finally, make sure the correct details message is shown for refund agent payout txs, for v5 protocol trades in the Transactions view, by changing the order of some of the nested if-else branches, in order to avoid an unwanted '!trade.hasV5Protocol()' clause.
Configuration menu - View commit details
-
Copy full SHA for 97f761b - Browse repository at this point
Copy the full SHA 97f761bView commit details
Commits on Oct 1, 2024
-
Add code to redirect or claim after warning tx published
Implement the redirect-to-arbitration & claim buttons in the trade step view, allowing the warned peer to publish the redirect tx and open a refund dispute, or the user to close the trade by publishing the claim tx if an unresponsive peer. To this end, add '(warning|redirect)TxId' fields to the 'Dispute' DTO and corresponding proto, to use in place of the (now null) 'delayedPayoutTxId' field. The new fields allow the refund agent to validate the tx chain in the case of the v5 protocol (using the Mempool service to make sure the redirect tx is valid and published/confirmed -- not yet implemented) and guard against replay attacks. Update the validation logic accordingly (& add some TODOs). Additionally, tidy up 'DisputeSummaryWindow' a little and fix a bug in 'SetupStagedTxListeners' preventing the redirect/claim tx listener from firing after the warning tx appears, until an application restart. Also ensure that it closes the trade instead of merely updating the dispute state, when a claim tx is picked up. TODO: Improve popup messages & fix arbtrator tx chain validation logic.
Configuration menu - View commit details
-
Copy full SHA for 4230a38 - Browse repository at this point
Copy the full SHA 4230a38View commit details
Commits on Oct 3, 2024
-
Refactor replay detection logic in DisputeValidation
Replace the large tuple of 'Map<String, Set<String>>' objects, built by 'DisputeValidation.getTestReplayHashMaps' to detect triplicate trade & tx IDs across all the disputes, with a map from dispute field refs to multimaps of all the corresponding fieldValue-disputeUid mappings. This eliminates a lot of the repetition building the individual hash maps of the tuple and consuming them, as a map was needed for each ID field of 'Dispute' with triplicate detection, namely the five fields: tradeId, delayedPayoutTxId, warningTxId, redirectTxId, depositTxId. For this purpose, create a private 'DisputeIdField' enum of field refs encapsulating the field name (for log & error messages) and getter. (Triplicated rather than duplicated IDs are being detected because the dispute DTOs come in pairs: one for the buyer and one for the seller.)
Configuration menu - View commit details
-
Copy full SHA for 4b318a0 - Browse repository at this point
Copy the full SHA 4b318a0View commit details