Commit Graph

5123 Commits

Author SHA1 Message Date
chimp1984
455c9b0ff3
Avoid logging warning at startup 2020-12-08 10:13:31 -05:00
Christoph Atteneder
d41692602a
Merge pull request #4903 from oscarguindzberg/bloomFilterFix
Upate bitcoinj to commit dcf8af0 - Bloom filter fix
2020-12-08 15:03:28 +01:00
Christoph Atteneder
89e55774c7
Merge pull request #4910 from chimp1984/remove-log-entry
Improve logs
2020-12-08 15:03:09 +01:00
sqrrm
2a2f05f408
Merge pull request #4912 from chimp1984/add-serialized-tx-as-hex-to-trade-details
Add "Raw deposit transaction as hex" to details window
2020-12-08 12:28:15 +01:00
chimp1984
25d227556b
Add "Raw deposit transaction as hex" to details window
Rename Contract as json button to detail data
2020-12-07 20:25:29 -05:00
chimp1984
d0005e45f4
Add logs of tx in case of exceptions 2020-12-07 19:47:44 -05:00
chimp1984
a3df372ecd
Apply project format rules (no code change) 2020-12-07 19:47:05 -05:00
chimp1984
b5e19312c5
Remove logs logging absolute path to data directory 2020-12-07 19:35:01 -05:00
chimp1984
38d52ff6f9
Add more logs to AddressEntry domain 2020-12-07 19:32:32 -05:00
chimp1984
f4fd286b86
Remove verbose log 2020-12-07 17:56:28 -05:00
chimp1984
30ff8c3853
Remove paymentAccount from log 2020-12-07 14:53:45 -05:00
chimp1984
e2f9009fce
Remove dev log, fix typo in log 2020-12-07 10:33:41 -05:00
Oscar Guindzberg
9ca20d8b3d
Use bitcoinj 0.15.8 (commit dcf8af0) 2020-12-07 11:39:58 -03:00
Christoph Atteneder
588623eb2d
Merge pull request #4885 from chimp1984/fix-bug-with-reapplying-past-trade-state
Avoid that buyer switches back to trade step 2 at startup after payment confirmed
2020-12-04 16:41:41 +01:00
chimp1984
c04b95b996
Remove checkNotNull for takerFeeTxId 2020-12-04 10:10:57 -05:00
sqrrm
57681245ff
Merge pull request #4889 from chimp1984/avoid-case-of-multi-trades-with-same-offer-id
Avoid case of multi trades with same offer
2020-12-04 00:48:45 +01:00
chimp1984
8f99ca0b63
Add uid to trade to make sure that look up for process model cannot
fail in case of multiple trades with the same offer id.
Use uid instead of the weaker offerId as key for the tradeProtocolByTradeId map
2020-12-03 14:43:35 -05:00
chimp1984
2d5fc33ba4
Move MakerRemovesOpenOffer to first task to avoid that if take offer
fails early that we get another trade with same id at maker in case another use takes the offer afterwards.
2020-12-03 14:19:24 -05:00
Christoph Atteneder
baa038aa39
Merge pull request #4886 from jmacxx/hotfix/v1.5.1
add logging of Tx hex
2020-12-03 19:18:50 +01:00
chimp1984
1fdc43e4d0
Increase timeout for trade protocol task runners from 30 to 60 sec 2020-12-03 11:53:35 -05:00
jmacxx
fa80553890
add logging of Tx hex 2020-12-03 10:22:07 -06:00
chimp1984
f843b5477b
Fixes https://github.com/bisq-network/bisq/issues/4864
When seller if offline we resend the CounterCurrencyTransferStartedMessage at startup.
That caused the trade state set to BUYER_SENT_FIAT_PAYMENT_INITIATED_MSG and then after
the msg was stored in mailbox to BUYER_STORED_IN_MAILBOX_FIAT_PAYMENT_INITIATED_MSG.
Those 2 msg trigger diff. UI states which led to the UI glitch that the UI moved to
step 2 and then to step 3 which was correct but confusing to the user.

Now we only apply BUYER_SENT_FIAT_PAYMENT_INITIATED_MSG is trade state ordinal is
smaller avoiding that UI glitch.
2020-12-03 11:19:18 -05:00
chimp1984
29d757b741
- revent that a wrong tx is set as deposit tx
We check if the txIds of the inputs matches our maker fee tx and taker fee tx and if the depositTxAddress we
use for the confidence lookup is use as an output address.
This prevents that past txs which have the our depositTxAddress as input or output (deposit or payout txs) could
be interpreted as our deposit tx. This happened because if a bug which caused re-use of the Multisig address
entries and if both traders use the same key for multiple trades the depositTxAddress would be the same.
We fix that bug as well but we also need to avoid that past already used addresses might be taken again
(the Multisig flag got reverted to available in the address entry).

- Add check to swapTradeEntryToAvailableEntry to not swap MULTI_SIG entries.

- Remove swap for MULTI_SIG entries at resetAddressEntriesForPendingTrade

- Add check to swapToAvailable to not swap MULTI_SIG entries.

- Remove swaps for MULTI_SIG entries

- Add setCoinLockedInMultiSigAddressEntry method

- Make coinLockedInMultiSig final and remove setter but use it in constructor.

- Rename getCoinLockedInMultiSig to getCoinLockedInMultiSigAsCoin
We use an immutable list when operating on AddressEntry so changes on the
object would not be reflected in the list.
The only mutable field (beside non critical cache fields) is the keyPair.
Might be good to refactor that as well at some point.

- Add setCoinLockedInMultiSigAddressEntrymethods

- Apply API changes:
-- resetCoinLockedInMultiSigAddressEntry
-- setCoinLockedInMultiSigAddressEntry
-- renamed methods
2020-12-03 10:01:01 -05:00
chimp1984
a39f2e8fcb
Apply project format rules (no code change) 2020-12-03 09:54:43 -05:00
sqrrm
3a5fba8196
Merge pull request #4838 from ripcurlx/update-resources-for-v1.5.0
Update resources for v1.5.0
2020-11-24 10:27:53 +01:00
Christoph Atteneder
788e0259d8
Merge branch 'release/v1.5.0' of github.com:bisq-network/bisq into add-delay-to-exit
# Conflicts:
#	core/src/main/java/bisq/core/app/BisqExecutable.java
2020-11-24 09:23:16 +01:00
Christoph Atteneder
94453cf27c
Merge pull request #4829 from chimp1984/prevent-downgrade
Check if user has downgraded to an older version
2020-11-24 09:15:47 +01:00
chimp1984
6b3a002b1c
Add 1 sec delay before calling exit
To persist in the very last moment before exit might cause problems on some OS.
We do not have confirmed that this might be an issue but to be on the safe side
we add a 1 sec. delay between persistence completed and exit.
2020-11-23 18:22:44 -05:00
Oscar Guindzberg
e667f8fbad
Upgrade bitcoinj to commit 60b4f2f 2020-11-23 14:39:26 -03:00
Christoph Atteneder
06a7d6fb14
Update translations for v1.5.0 (update 2) 2020-11-23 11:23:25 +01:00
Christoph Atteneder
06c16a1734
Update bitcoinj checkpoints for v1.5.0 (update 2) 2020-11-23 11:23:04 +01:00
chimp1984
9360e89ae8
Check if user has downgraded to an older version. If so require shutdown
and do not read or write persisted data.

We had recently a case where a user downgraded from 1.4.2 to 1.3.9 and
this caused failed trades and the wallet funds have been missing due to
some complexities of the wallet wegwit upgrade. The fund could be recovered
but it took quite some effort.
As downgrade is never tested and can lead to all kind of weird bugs we
should prevent that users accidentally can do it.
If there is valid reason to downgrade they can remove the version file.
2020-11-20 15:27:50 -05:00
chimp1984
9da231ed8b
Fix typo 2020-11-20 10:28:59 -05:00
Steven Barclay
345426fb50
Add further validation checks for delayed payout tx
Do some extra sanity checks like tx.outputSum < tx.inputSum, to rule out
any edge cases where an invalid delayed payout tx might still arise.
2020-11-19 17:30:16 +00:00
Steven Barclay
3574204e7d
Fix faulty signature check in finalizeDelayedPayoutTx
Make sure to use the segwit version of Script.correctlySpends in
TradeWalletService.finalizeDelayedPayoutTx, which requires the input
value and witness to be passed explicitly (as the latter holds the
actual signature). This was causing BuyerFinalizesDelayedPayoutTx to
fail to do any kind of signature check.

Also refactor the method slightly and remove a redundant call to
WalletService.checkScriptSig (which does the same thing as
TransactionInput.verify) in the branch used by the seller.
2020-11-19 17:19:14 +00:00
Steven Barclay
69d1e16f5e
Prevent takers from using non-segwit deposit tx inputs
Disallow non-P2WH depositTx inputs from the taker, while continuing to
allow them from the maker, so that offers created pre-v1.5.0 can still
be taken. (After some time, those inputs could be disallowed too.)

This is mainly to prevent mass blackmail attacks, where more victims'
money could be locked up than the DAO could possibly compensate them all
for. (This is probably only an attractive attack for a buyer anyway, at
least with the earlier commits.)
2020-11-19 17:19:14 +00:00
Steven Barclay
5a3b072692
Withhold witnesses in buyer->seller depositTx data, until last step
Strip all input witnesses from the depositTx message fields sent from
the buyer, until the last (DelayedPayoutTxSignatureResponse) message is
sent, where they can be bundled in as an extra field. Since the witness
data doesn't affect the final deposit tx id, the seller does not need to
know it until actually publishing the tx.

In the (fully) segwit case, this allows the buyer to prevent the seller
from publishing the deposit tx until the buyer has a valid, fully signed
delayedPayoutTx. Provide the final witness data in an extra 'depositTx'
field in DelayedPayoutTxSignatureResponse, which the seller can merge
with his depositTx witness block (for his own input signatures).
2020-11-19 17:19:13 +00:00
Steven Barclay
803035bdbb
Add new BuyerFinalizesDelayedPayoutTx task
Improve validation of the buyer's delayed payout tx (both before & after
they get the final DepositTxAndDelayedPayoutTxMessage from the peer), by
finalising it independently of the seller. This is now possible since
their 2-of-2 signature is included in the DelayedPayoutSignatureRequest.
Check that the final delayedPayoutTx received from the seller matches it
byte-for-byte (which actually makes its receipt redundant now).

This also fixes an apparent security bug, where the final validation of
the delayedPayoutTx appears to skip any kind of signature check (only a
deposit tx hash check, which is still necessary).

Finally, optimistically check the deposit tx against the input of the
prepared delayedPayoutTx received from the seller, in the case that the
former is non-malleable (that is, the fully segwit case) and thus has a
stable ID given by the hash of the buyer's preparedDepositTx.
2020-11-19 17:19:13 +00:00
Steven Barclay
f02d5ee216
Send seller's delayedPayoutTx signature to peer ASAP
Include a new 'delayedPayoutTxSellerSignature' field with the prepared
delayed payout tx sent to the buyer, in DelayedPayoutTxSignatureRequest.
This will allow the buyer to compute the final, signed delayedPayoutTx
as early as possible and withhold their deposit tx witness from the
seller until they know they have a valid delayedPayoutTx, preventing its
premature publishing in the fully segwit case. (To be done in a later
commit - for now just save the seller's delayedPayoutTx signature.)

As part of this, run the SellerSignsDelayedPayoutTx trade task at an
earlier step (just after payout tx creation) to make its signature
available to the seller ASAP. Also rename 'delayedPayoutTxSignature' to
'delayedPayoutTxBuyerSignature' in DelayedPayoutTxSignatureResponse.
2020-11-19 17:19:12 +00:00
Steven Barclay
79fa219533
Fix missing segwit case when sanitising preparedDepositTx
Make sure witness data is stripped from the seller's prepared deposit
tx, in addition to ScriptSig data, to prevent the buyer from being able
to publish it prematurely (before having signed the delayed payout tx).
2020-11-19 17:19:07 +00:00
Steven Barclay
88d7d96427
Fix failing OpenOfferManagerTest & PeerManagerTest
These are failing on the tip of release/1.5.0 currently due to extra
validation added to PersistenceManager, causing the build to fail upon
merging upstream. Add missing PersistenceManager.shutDown calls to the
tearDown methods of the affected tests to fix.
2020-11-19 16:47:21 +01:00
Christoph Atteneder
ce265e48b7
Merge pull request #4816 from chimp1984/reduce-persistence-interval
Fix issues with missing persistence for trade state
2020-11-19 16:33:46 +01:00
chimp1984
a4db09fe1d
Move delay for applying mailbox messages inside onInitialized
We need to set addDecryptedDirectMessageListener without
delay as otherwise we could miss direct messages (detected
with localhost testing, with tor its likely slower and
would not have been triggered).
2020-11-19 10:19:48 -05:00
chimp1984
d6f4eed39e
Add requestPersistence call at TradeTask.complete call.
This is not really needed as we call it at each state change of the
trade but gives more redundancy in case we missed one or once
changes are applied and a dev forgets to call it.

Multiple repeated calls do have close to zero costs.
2020-11-19 09:51:06 -05:00
chimp1984
da9b42fb83
Handle potential deposit confirmed state issues
The deposit confirmed state is set after we applied the mailbox messages,
which led to a task failure due wrong phase and the message was not applied.
Further it can be that the wallet is still syncing and the deposit
confirmed state is set in any time in the future.

To fix the first problem we add a bit of delay so that the trade has
been updated when we apply the mailbox messages. A better fix would be to change
the order of the methods but that is a bit tricky to get right and I dont want to
risk that for that release.

The second problem would require a large change to trigger the mailbox
processing based on wallet state. We prefer to be more tolerant with
the expected phase instead so allow the mailbox message to be processed
also in the DEPOSIT_PUBLISHED state.
This has no risks as the payout tx would be invalid anyway if the
buyer has cheated and sent the msg in not confirmed deposit tx state (only
possible with code manipulation).

A better fix would to add a listener for the wallet and process
the mailbox msg once wallet is ready and trade state set, but I
leave that for another PR.
2020-11-19 00:34:40 -05:00
chimp1984
706ec5a2ed
Add null checks for tradeManager
We get called some setter methods from protobuf methods before tradeManager is set.
2020-11-19 00:07:34 -05:00
chimp1984
438a0d8217
Remove requestPersistence in constructor as TradeManager is not set at that moment. 2020-11-18 19:58:20 -05:00
Oscar Guindzberg
5906950e1f
Calculate witness sig with AES key 2020-11-18 18:28:06 -03:00
chimp1984
6fb36dcd41
Add more requestPersistence calls 2020-11-18 12:51:53 -05:00
chimp1984
255460e5d5
Add more requestPersistence for data changes in ProcessModel and TradingPeer 2020-11-18 12:38:39 -05:00